Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8 from vgorloff/develop
Browse files Browse the repository at this point in the history
v1.0.6
  • Loading branch information
vgorloff authored Jan 2, 2019
2 parents 8524729 + 574a972 commit 8764e75
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions Patches/swift/stdlib-private-CMakeLists.txt.patch
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 13 additions & 0 deletions Patches/swift/stdlib-public-stubs-CMakeLists.txt.patch
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions Projects/Hello/hello.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ~~~~~~~~~~~~~~ CORE
print("SA - SwiftCore: Works!")


#if true
// ~~~~~~~~~~~~~~ DISPATCH
import Dispatch
let sema = DispatchSemaphore(value: 0)
Expand All @@ -15,8 +15,10 @@ queue.async {
if sema.wait(timeout: .now() + 10) == .timedOut {
print("SA - DispatchQueue: Timeout.")
}
#endif


#if true
// ~~~~~~~~~~~~~~ FOUNDATION
import Foundation

Expand All @@ -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: [])
Expand All @@ -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.")
Expand Down Expand Up @@ -72,3 +79,4 @@ print("SA - URLSession: Currently disabled. Will fail with `Segmentation fault`.
// } else {
// print("bad url")
// }
#endif
5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}\".")
Expand Down
28 changes: 26 additions & 2 deletions Scripts/Builders/FoundationBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion Scripts/Builders/HelloProjectBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 8764e75

Please sign in to comment.