diff --git a/Patches/swift-corelibs-foundation/CompileOptions.patch b/Patches/swift-corelibs-foundation/CoreFoundation-CMakeLists.txt.patch similarity index 57% rename from Patches/swift-corelibs-foundation/CompileOptions.patch rename to Patches/swift-corelibs-foundation/CoreFoundation-CMakeLists.txt.patch index 784fd9ce..7cbfc110 100644 --- a/Patches/swift-corelibs-foundation/CompileOptions.patch +++ b/Patches/swift-corelibs-foundation/CoreFoundation-CMakeLists.txt.patch @@ -1,5 +1,5 @@ diff --git a/CoreFoundation/CMakeLists.txt b/CoreFoundation/CMakeLists.txt -index 0aa9565e3c3930e7375cc548870003c1b8432653..643e53a03e36477d71e3b0339f337a01e868c72b 100644 +index 0aa9565e3c3930e7375cc548870003c1b8432653..ce74ea3eb2cf06f6ad0a6f3e2d1b5d45b8d70b9e 100644 --- a/CoreFoundation/CMakeLists.txt +++ b/CoreFoundation/CMakeLists.txt @@ -194,6 +194,7 @@ add_framework(CoreFoundation @@ -10,6 +10,20 @@ index 0aa9565e3c3930e7375cc548870003c1b8432653..643e53a03e36477d71e3b0339f337a01 # Base Base.subproj/CFBase.c Base.subproj/CFFileUtilities.c +@@ -368,11 +369,11 @@ if(CF_ENABLE_LIBDISPATCH) + PRIVATE + ${CF_PATH_TO_LIBDISPATCH_SOURCE} + ${CF_PATH_TO_LIBDISPATCH_BUILD}/tests) +- if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) ++# if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) + target_include_directories(CoreFoundation + SYSTEM PRIVATE + ${CF_PATH_TO_LIBDISPATCH_SOURCE}/src/BlocksRuntime) +- endif() ++# endif() + endif() + + if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") @@ -405,9 +406,9 @@ if(CF_DEPLOYMENT_SWIFT) PRIVATE /clang:-fcf-runtime-abi=swift) diff --git a/Patches/swift/stdlib-private-CMakeLists.txt.patch b/Patches/swift/stdlib-private-CMakeLists.txt.patch new file mode 100644 index 00000000..cdb474f4 --- /dev/null +++ b/Patches/swift/stdlib-private-CMakeLists.txt.patch @@ -0,0 +1,13 @@ +diff --git a/stdlib/private/CMakeLists.txt b/stdlib/private/CMakeLists.txt +index d03a0ad1737b408700d5595498b2934c3b065b40..e1f20ba818dba29dc6e34737b7e93ba192cc1ab9 100644 +--- a/stdlib/private/CMakeLists.txt ++++ b/stdlib/private/CMakeLists.txt +@@ -2,7 +2,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY) + add_subdirectory(SwiftPrivate) + endif() + +-if(SWIFT_BUILD_SDK_OVERLAY) ++if(SWIFT_BUILD_SDK_OVERLAY AND NOT SWIFT_OVERLAY_TARGETS STREQUAL "") + # SwiftPrivateThreadExtras makes use of Darwin/Glibc, which is part of the + # SDK overlay. It can't be built separately from the SDK overlay. + add_subdirectory(RuntimeUnittest) diff --git a/Patches/swift/stdlib-public-stubs-CMakeLists.txt.patch b/Patches/swift/stdlib-public-stubs-CMakeLists.txt.patch new file mode 100644 index 00000000..922fda84 --- /dev/null +++ b/Patches/swift/stdlib-public-stubs-CMakeLists.txt.patch @@ -0,0 +1,13 @@ +diff --git a/stdlib/public/stubs/CMakeLists.txt b/stdlib/public/stubs/CMakeLists.txt +index 2196d456e791feacf2d5ec6f92d615f5a0ee2bbf..fa00c05f415b55e8e2e30ac6423e6016861ca18f 100644 +--- a/stdlib/public/stubs/CMakeLists.txt ++++ b/stdlib/public/stubs/CMakeLists.txt +@@ -37,7 +37,7 @@ add_swift_target_library(swiftStdlibStubs + INSTALL_IN_COMPONENT + stdlib) + +-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") ++if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT SWIFT_OVERLAY_TARGETS STREQUAL "") + set_property(SOURCE + SwiftNativeNSXXXBaseARC.m + APPEND_STRING PROPERTY COMPILE_FLAGS diff --git a/Projects/Hello/hello.swift b/Projects/Hello/hello.swift index 4c0bd1c9..6b697cc2 100755 --- a/Projects/Hello/hello.swift +++ b/Projects/Hello/hello.swift @@ -1,7 +1,7 @@ // ~~~~~~~~~~~~~~ CORE print("SA - SwiftCore: Works!") - +#if true // ~~~~~~~~~~~~~~ DISPATCH import Dispatch let sema = DispatchSemaphore(value: 0) @@ -15,8 +15,10 @@ queue.async { if sema.wait(timeout: .now() + 10) == .timedOut { print("SA - DispatchQueue: Timeout.") } +#endif +#if true // ~~~~~~~~~~~~~~ FOUNDATION import Foundation @@ -25,9 +27,11 @@ let op = BlockOperation { } let opQueue = OperationQueue() opQueue.addOperations([op], waitUntilFinished: true) +#endif -// ~~~~~~~~~~~~~~~~ Serialization +#if true +// ~~~~~~~~~~~~~~~~ Serialization let json = ["name": "SA - JSONSerialization/JSONDecoder: Works!"] do { let data = try JSONSerialization.data(withJSONObject: json, options: []) @@ -41,7 +45,10 @@ do { } catch { print(error) } +#endif + +#if true // ~~~~~~~~~~ Networking print("SA - URLSession: Currently disabled. Will fail with `Segmentation fault`. Seems something in Foundation classes needs to be fixed.") @@ -72,3 +79,4 @@ print("SA - URLSession: Currently disabled. Will fail with `Segmentation fault`. // } else { // print("bad url") // } +#endif diff --git a/Rakefile b/Rakefile index 30fa25ed..7943bbe9 100755 --- a/Rakefile +++ b/Rakefile @@ -74,7 +74,10 @@ namespace :armv7a do LLVMBuilder.new(Arch.armv7a).make swift.make DispatchBuilder.new(Arch.armv7a).make - FoundationBuilder.new(Arch.armv7a).make + if !tool.isMacOS? + # Foundation build on macOS host still broken. + FoundationBuilder.new(Arch.armv7a).make + end puts "" tool.print("\"Swift Toolchain for Android\" build is completed.") tool.print("It can be found in \"#{swift.installs}\".") diff --git a/Scripts/Builders/FoundationBuilder.rb b/Scripts/Builders/FoundationBuilder.rb index c090f8a5..296a39f4 100644 --- a/Scripts/Builders/FoundationBuilder.rb +++ b/Scripts/Builders/FoundationBuilder.rb @@ -61,10 +61,15 @@ def configure end cmd << "-DCMAKE_SWIFT_COMPILER=\"#{@swift.builds}/bin/swiftc\"" + # if isMacOS? + # cmd << "-DCMAKE_AR=#{@ndk.bin}/arm-linux-androideabi-ar" + # end + cmd << @sources execute cmd.join(" ") fixNinjaBuild() - execute "cd #{@builds} && CFLAGS='-DDEPLOYMENT_TARGET_ANDROID -I#{@sources}' ninja CoreFoundation-prefix/src/CoreFoundation-stamp/CoreFoundation-configure" + execute "cd #{@builds} && CFLAGS='-DDEPLOYMENT_TARGET_ANDROID -I#{@icu.include} -I#{@xml.include}/libxml2 -I#{@curl.include} -I#{@sources}' ninja CoreFoundation-prefix/src/CoreFoundation-stamp/CoreFoundation-configure" + fixCoreFoundationNinjaBuild() logConfigureCompleted end @@ -103,6 +108,25 @@ def checkout checkoutIfNeeded(@sources, "https://github.com/apple/swift-corelibs-foundation", "a7f12d0851780b2c196733b2710a8ff2ae56bdcd") end + def fixCoreFoundationNinjaBuild + if !isMacOS? + return + end + ndk = AndroidBuilder.new(@arch) + file = "#{@builds}/CoreFoundation-prefix/src/CoreFoundation-build/build.ninja" + message "Applying fix for #{file}" + contents = File.readlines(file).join() + contents = contents.gsub('-DDEPLOYMENT_TARGET_MACOSX', "-DDEPLOYMENT_TARGET_LINUX") + File.write(file, contents) + + file = "#{@builds}/CoreFoundation-prefix/src/CoreFoundation-build/rules.ninja" + message "Applying fix for #{file}" + contents = File.readlines(file).join() + contents = contents.gsub('/usr/bin/ar', "#{ndk.bin}/arm-linux-androideabi-ar") + contents = contents.gsub('/usr/bin/ranlib', "#{ndk.bin}/arm-linux-androideabi-ranlib") + File.write(file, contents) + end + def fixNinjaBuild if @arch == Arch.host return @@ -131,7 +155,7 @@ def configurePatches(shouldEnable = true) return end configurePatch("#{@sources}/cmake/modules/SwiftSupport.cmake", "#{@patches}/CmakeSystemProcessor.patch", shouldEnable) - configurePatch("#{@sources}/CoreFoundation/CMakeLists.txt", "#{@patches}/CompileOptions.patch", shouldEnable) + configurePatch("#{@sources}/CoreFoundation/CMakeLists.txt", "#{@patches}/CoreFoundation-CMakeLists.txt.patch", shouldEnable) configurePatch("#{@sources}/CMakeLists.txt", "#{@patches}/CMakeLists.patch", shouldEnable) configurePatch("#{@sources}/Foundation/NSGeometry.swift", "#{@patches}/NSGeometry.patch", shouldEnable) configurePatch("#{@sources}/Tools/plutil/main.swift", "#{@patches}/plutil.patch", shouldEnable) diff --git a/Scripts/Builders/HelloProjectBuilder.rb b/Scripts/Builders/HelloProjectBuilder.rb index 7e0b7338..061e98ae 100755 --- a/Scripts/Builders/HelloProjectBuilder.rb +++ b/Scripts/Builders/HelloProjectBuilder.rb @@ -20,13 +20,14 @@ def build ndk = AndroidBuilder.new(@arch) cmd = ["cd #{@builds} &&"] cmd << "PATH=#{swift.installs}/usr/bin:$PATH" - cmd << "swiftc" + cmd << "swiftc -v" if @arch != Arch.host cmd << "-tools-directory #{ndk.installs}/bin" cmd << "-target armv7-none-linux-androideabi" # Targeting android-armv7. cmd << "-Xcc -I#{ndk.installs}/sysroot/usr/include" cmd << "-Xcc -DDEPLOYMENT_TARGET_ANDROID" cmd << "-Xcc -DDEPLOYMENT_RUNTIME_SWIFT" + cmd << "-Xlinker -v" # Below seems not needed. # cmd << "-sdk #{ndk.sources}/platforms/android-#{ndk.api}/arch-arm" # Use the same NDK path and API version as you used to build the stdlib in the previous step. diff --git a/Scripts/Builders/SwiftBuilder.rb b/Scripts/Builders/SwiftBuilder.rb index afcb1aa5..56a60384 100755 --- a/Scripts/Builders/SwiftBuilder.rb +++ b/Scripts/Builders/SwiftBuilder.rb @@ -43,6 +43,8 @@ def initialize(arch = Arch.default) def configure logConfigureStarted prepare + configurePatches(false) + configurePatches dispatch = DispatchBuilder.new(@arch) llvm = LLVMBuilder.new(@arch) @@ -69,16 +71,16 @@ def configure cmd << "-DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING=FALSE" if @arch != Arch.host - cmd << "-DSWIFT_ANDROID_NDK_PATH:STRING=#{ndk.sources}" - cmd << "-DSWIFT_ANDROID_NDK_GCC_VERSION:STRING=#{ndk.gcc}" - cmd << "-DSWIFT_ANDROID_API_LEVEL:STRING=#{ndk.api}" - cmd << "-DSWIFT_ANDROID_armv7_ICU_UC:STRING=#{icu.lib}/libicuucswift.so" - cmd << "-DSWIFT_ANDROID_armv7_ICU_UC_INCLUDE:STRING=#{icu.sources}/source/common" - cmd << "-DSWIFT_ANDROID_armv7_ICU_I18N:STRING=#{icu.lib}/libicui18nswift.so" - cmd << "-DSWIFT_ANDROID_armv7_ICU_I18N_INCLUDE:STRING=#{icu.sources}/source/i18n" - cmd << "-DSWIFT_ANDROID_armv7_ICU_DATA:STRING=#{icu.lib}/libicudataswift.so" - cmd << "-DSWIFT_ANDROID_DEPLOY_DEVICE_PATH:STRING=/data/local/tmp" - cmd << "-DSWIFT_SDK_ANDROID_ARCHITECTURES:STRING=armv7" + cmd << "-DSWIFT_ANDROID_NDK_PATH=#{ndk.sources}" + cmd << "-DSWIFT_ANDROID_NDK_GCC_VERSION=#{ndk.gcc}" + cmd << "-DSWIFT_ANDROID_API_LEVEL=#{ndk.api}" + cmd << "-DSWIFT_ANDROID_armv7_ICU_UC=#{icu.lib}/libicuucswift.so" + cmd << "-DSWIFT_ANDROID_armv7_ICU_UC_INCLUDE=#{icu.sources}/source/common" + cmd << "-DSWIFT_ANDROID_armv7_ICU_I18N=#{icu.lib}/libicui18nswift.so" + cmd << "-DSWIFT_ANDROID_armv7_ICU_I18N_INCLUDE=#{icu.sources}/source/i18n" + cmd << "-DSWIFT_ANDROID_armv7_ICU_DATA=#{icu.lib}/libicudataswift.so" + cmd << "-DSWIFT_ANDROID_DEPLOY_DEVICE_PATH=/data/local/tmp" + cmd << "-DSWIFT_SDK_ANDROID_ARCHITECTURES=armv7" end cFlags = "-Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector" cmd << "-DCMAKE_C_FLAGS='#{cFlags}'" @@ -90,42 +92,50 @@ def configure cmd << "-DSWIFT_INCLUDE_TOOLS=TRUE" cmd << "-DSWIFT_BUILD_REMOTE_MIRROR=TRUE" cmd << "-DSWIFT_STDLIB_SIL_DEBUGGING=FALSE" - cmd << "-DSWIFT_BUILD_DYNAMIC_STDLIB:BOOL=TRUE" - cmd << "-DSWIFT_BUILD_STATIC_STDLIB:BOOL=FALSE" + cmd << "-DSWIFT_BUILD_DYNAMIC_STDLIB=TRUE" + cmd << "-DSWIFT_BUILD_STATIC_STDLIB=FALSE" + cmd << "-DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=TRUE" cmd << "-DSWIFT_BUILD_STATIC_SDK_OVERLAY=FALSE" + + # Disable Benchmarks cmd << "-DSWIFT_BUILD_PERF_TESTSUITE=FALSE" cmd << "-DSWIFT_BUILD_EXTERNAL_PERF_TESTSUITE=FALSE" + cmd << "-DSWIFT_BUILD_EXAMPLES=FALSE" cmd << "-DSWIFT_INCLUDE_TESTS=FALSE" cmd << "-DSWIFT_INCLUDE_DOCS=FALSE" cmd << "-DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE" - cmd << "-DSWIFT_INSTALL_COMPONENTS:STRING='autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license'" - cmd << "-DLIBDISPATCH_CMAKE_BUILD_TYPE:STRING=Release" + cmd << "-DSWIFT_INSTALL_COMPONENTS='autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license'" + cmd << "-DLIBDISPATCH_CMAKE_BUILD_TYPE=Release" + if isMacOS? + cmd << "-DSWIFT_OVERLAY_TARGETS=''" # Disabling builds of Darwin Overlays. cmd << "-DSWIFT_HOST_VARIANT=macosx" cmd << "-DSWIFT_HOST_VARIANT_SDK=OSX" + cmd << "-DSWIFT_ENABLE_IOS32=false" + cmd << "-DSWIFT_SDK_OSX_PATH=#{macOSSDK}" if @arch == Arch.host - cmd << "-DSWIFT_SDKS:STRING='OSX'" + cmd << "-DSWIFT_SDKS='OSX'" else - cmd << "-DSWIFT_SDKS:STRING='ANDROID;OSX'" - cmd << "-DSWIFT_HOST_TRIPLE:STRING=x86_64-apple-macosx10.9" + cmd << "-DSWIFT_SDKS='ANDROID;OSX'" + cmd << "-DSWIFT_HOST_TRIPLE=x86_64-apple-macosx10.9" end else cmd << "-DSWIFT_HOST_VARIANT=linux" cmd << "-DSWIFT_HOST_VARIANT_SDK=LINUX" if @arch == Arch.host - cmd << "-DSWIFT_SDKS:STRING='LINUX'" + cmd << "-DSWIFT_SDKS='LINUX'" else - cmd << "-DSWIFT_SDKS:STRING='ANDROID;LINUX'" + cmd << "-DSWIFT_SDKS='ANDROID;LINUX'" end end cmd << "-DSWIFT_HOST_VARIANT_ARCH=x86_64" cmd << "-DLLVM_LIT_ARGS=-sv" cmd << "-DCOVERAGE_DB=" - cmd << "-DSWIFT_SOURCEKIT_USE_INPROC_LIBRARY:BOOL=TRUE" + cmd << "-DSWIFT_SOURCEKIT_USE_INPROC_LIBRARY=TRUE" cmd << "-DSWIFT_AST_VERIFIER=FALSE" - cmd << "-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER:BOOL=FALSE" + cmd << "-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER=FALSE" cmd << "-DCMAKE_INSTALL_PREFIX=/usr" cmd << "-DSWIFT_PATH_TO_CLANG_SOURCE=#{llvm.sources}/tools/clang" cmd << "-DSWIFT_PATH_TO_CLANG_BUILD=#{llvm.builds}" @@ -135,25 +145,32 @@ def configure cmd << "-DSWIFT_PATH_TO_CMARK_BUILD=#{cmark.builds}" cmd << "-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=#{dispatch.sources}" cmd << "-DSWIFT_CMARK_LIBRARY_DIR=#{cmark.builds}/src" - cmd << "-DSWIFT_EXEC:STRING=#{@builds}/bin/swiftc" + cmd << "-DSWIFT_EXEC=#{@builds}/bin/swiftc" # See: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/Graphviz # cmd << "--graphviz=#{@builds}/graph.dot" cmd << @sources execute cmd.join(" ") + fixNinjaBuild() + fixNinjaRules() logConfigureCompleted end def build logBuildStarted + execute "cd #{@builds} && ninja" if isMacOS? - if @arch == Arch.host - execute "cd #{@builds} && ninja all" - else - execute "cd #{@builds} && ninja all swift-test-stdlib-macosx-x86_64 swift-test-stdlib-android-armv7" + if @arch != Arch.host + # Workaround: Should be `swift-stdlib-android-armv7` only. + targets = "swiftGlibc-android swiftCore-android swiftSIMDOperators-android swiftSwiftOnoneSupport-android swiftRemoteMirror-android" + execute "cd #{@builds} && ninja #{targets}" end + message "Copying Shared objects" + Dir["#{@builds}/lib/swift/android/armv7/*.so"].each { |so| + execute "cp -vfr \"#{so}\" \"#{@builds}/lib/swift/android/\"" + } else - execute "cd #{@builds} && ninja all swift-test-stdlib-linux-x86_64 swift-test-stdlib-android-armv7" + execute "cd #{@builds} && ninja swift-stdlib-linux-x86_64 swift-stdlib-android-armv7" end logBuildCompleted() end @@ -168,11 +185,13 @@ def make configure build install + configurePatches(false) end def install logInstallStarted() removeInstalls() + fixInstallScript() execute "env DESTDIR=#{@installs} cmake --build #{@builds} -- install" logInstallCompleted end @@ -182,9 +201,125 @@ def checkout end def clean + configurePatches(false) removeBuilds() removeInstalls() cleanGitRepo() end + def fixNinjaBuild + if @arch == Arch.host + return + end + file = "#{@builds}/build.ninja" + message "Applying fix for #{file}" + lines = File.readlines(file) + if isMacOS? + result = [] + # >> Fixes non NDK Linker options. + shouldFixLinker = false + lines.each { |line| + if line.start_with?("build") && line.include?('CXX_SHARED_LIBRARY_LINKER') && line.include?("android") + shouldFixLinker = true + elsif line.strip() == "" + shouldFixLinker = false + elsif shouldFixLinker && line.include?('LINK_LIBRARIES') + # See also: Build/armv7a-macos/swift/lib/cmake/swift/SwiftExports.cmake and Build/armv7a-macos/swift/lib/cmake/swift/SwiftConfig.cmake + line = line.gsub('-framework Foundation', '') + line = line.gsub('-framework CoreFoundation', '') + line = line.gsub('-licucore', '') + elsif shouldFixLinker && line.include?('LINK_FLAGS') + line = line.gsub('-all_load', '') + end + result << line + } + # << + lines = result + end + contents = lines.join() + if isMacOS? + contents = contents.gsub('-D__ANDROID_API__=21 -fobjc-arc', '-D__ANDROID_API__=21') + end + File.write(file, contents) + end + + def fixNinjaRules + if @arch == Arch.host || !isMacOS? + return + end + ndk = AndroidBuilder.new(@arch) + file = "#{@builds}/rules.ninja" + message "Applying fix for #{file}" + lines = File.readlines(file) + result = [] + # >> Fixes non NDK Dynamic Linker options. + shouldFixLinker = false + lines.each { |line| + if line.start_with?("rule") && line.include?('CXX_SHARED_LIBRARY_LINKER') && line.include?("android") + shouldFixLinker = true + elsif line.strip() == "" + shouldFixLinker = false + elsif shouldFixLinker && line.include?('command') + line = line.gsub('-dynamiclib', '-shared') + line = line.gsub('$SONAME_FLAG $INSTALLNAME_DIR$SONAME', '') + end + result << line + } + lines = result + # << + # >> Fixes non NDK Static Linker options. + shouldFixLinker = false + result = [] + lines.each { |line| + if line.start_with?("rule") && line.include?('CXX_STATIC_LIBRARY_LINKER') && line.include?("android") + shouldFixLinker = true + elsif line.strip() == "" + shouldFixLinker = false + elsif shouldFixLinker && line.include?('command') + line = line.gsub('/usr/bin/ar', "#{ndk.bin}/arm-linux-androideabi-ar") + end + result << line + } + lines = result + # << + File.write(file, lines.join() + "\n") + end + + def fixInstallScript + if !isMacOS? + return + end + file = "#{@builds}/cmake_install.cmake" + message "Applying fix for #{file}" + lines = File.readlines(file) + contents = lines.join + if contents.include?("libswiftGlibc.so") + message "Seems you already applied fix for #{file}" + return + end + result = [] + # >> Fixes non NDK Dynamic Linker options. + filesToInstall = Dir["#{builds}/lib/swift/android/armv7/*.so"].map { |so| " \"#{so}\"" }.join("\n") + commands = 'if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)' + "\n" + commands += ' file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/swift/android" TYPE FILE FILES' + "\n" + commands += filesToInstall + commands += ")\nendif()\n" + lines.each { |line| + if line.include?('if(CMAKE_INSTALL_COMPONENT)') + line = commands + "\n" + line + end + result << line + } + lines = result + File.write(file, lines.join() + "\n") + end + + def configurePatches(shouldEnable = true) + if @arch == Arch.host && shouldEnable + return + end + configurePatch("#{@sources}/stdlib/private/CMakeLists.txt", "#{@patches}/stdlib-private-CMakeLists.txt.patch", shouldEnable) + configurePatch("#{@sources}/stdlib/public/stubs/CMakeLists.txt", "#{@patches}/stdlib-public-stubs-CMakeLists.txt.patch", shouldEnable) + end + end diff --git a/Scripts/Common/Builder.rb b/Scripts/Common/Builder.rb index 09b02b3e..b80f7bdc 100755 --- a/Scripts/Common/Builder.rb +++ b/Scripts/Common/Builder.rb @@ -130,20 +130,24 @@ def setupSymLink(from, to, shouldCreate = true) end def setupLinkerSymLink(shouldCreate = true) + ndk = AndroidBuilder.new(@arch) + llvm = LLVMBuilder.new(@arch) if isMacOS? - return + targetFile = "#{llvm.builds}/bin/ld.gold" + sourceFile = "#{ndk.sources}/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/arm-linux-androideabi/bin/ld.gold" + else + targetFile = "/usr/bin/armv7-none-linux-androideabi-ld.gold" + sourceFile = "#{ndk.sources}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.gold" end - ndk = AndroidBuilder.new(@arch) if @arch == Arch.armv7a - targetFile = "/usr/bin/armv7-none-linux-androideabi-ld.gold" + sudo = isMacOS? ? "" : "sudo " if shouldCreate message "Making symbolic link to \"#{targetFile}\"..." - execute "sudo ln -svf #{ndk.sources}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.gold #{targetFile}" + execute "#{sudo}ln -svf #{sourceFile} #{targetFile}" else message "Removing previously created symlink: \"#{targetFile}\"..." - execute "sudo rm -fv #{targetFile}" + execute "#{sudo}rm -fv #{targetFile}" end - execute "ls -al /usr/bin/*ld.gold || true" end end diff --git a/VERSION b/VERSION index 90a27f9c..af0b7ddb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.5 +1.0.6