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 #25 from vgorloff/develop
Browse files Browse the repository at this point in the history
RC 1.0.13
  • Loading branch information
vgorloff authored May 7, 2019
2 parents e81bcd3 + 7775ff9 commit 7c8badf
Show file tree
Hide file tree
Showing 30 changed files with 552 additions and 143 deletions.
90 changes: 54 additions & 36 deletions Automation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,13 @@
class Automation

def perform()
helloExe = HelloExeBuilder.new(Arch.armv7a)
helloLib = HelloLibBuilder.new(Arch.armv7a)

action = ARGV.first
if action.nil? then usage()
elsif action.start_with?("build:") then build(action.sub("build:", '')) # Pass `SA_DRY_RUN=1 rake ...` for Dry run mode.
elsif action.start_with?("clean:") then clean(action.sub("clean:", ''))
elsif action.start_with?("build-project:") then buildProject(action.sub("build-project:", ''))
elsif action.start_with?("deploy:projects:") then deploy(action.sub("deploy:projects:", ''))
elsif action == "checkout" then checkout()
elsif action == "verify" then ADB.verify()
elsif action == "clean-armv7a:exe" then ADB.new(helloExe.libs, helloExe.binary).clean
elsif action == "clean-armv7a:lib" then ADB.new(helloLib.libs, helloLib.binary).clean
elsif action == "deploy-armv7a:exe"
helloExe.copyLibs()
adb = ADB.new(helloExe.libs, helloExe.binary)
adb.deploy()
adb.run()
elsif action == "deploy-armv7a:lib"
helloLib.copyLibs()
adb = ADB.new(helloLib.libs, helloLib.binary)
adb.deploy()
adb.run()
else usage()
end
end
Expand All @@ -58,6 +43,8 @@ def build(component)
elsif component == "swift" then SwiftBuilder.new().make
elsif component == "dispatch" then buildDispatch()
elsif component == "foundation" then buildFoundation()
elsif component == "llvm" then buildLLVM()
elsif component == "projects" then buildProjects()
else
puts "! Unknown component \"#{component}\"."
usage()
Expand All @@ -68,17 +55,52 @@ def clean(component)
if component == "curl" then cleanCURL()
elsif component == "xml" then cleanXML()
elsif component == "deps" then cleanDeps()
elsif component == "dispatch" then cleanDispatch()
elsif component == "foundation" then cleanFoundation()
elsif component == "llvm" then cleanLLVM()
elsif component == "libs" then cleanLibs()
elsif component == "swift" then SwiftBuilder.new().clean
elsif component.start_with?("projects:") then cleanProjects(component.sub("projects:", ''))
else
puts "! Unknown component \"#{component}\"."
usage()
end
end

def deploy(arch)
helloExe = HelloExeBuilder.new(arch)
helloLib = HelloLibBuilder.new(arch)
helloExe.copyLibs()
helloLib.copyLibs()
adb1 = ADB.new(helloExe.libs, helloExe.binary)
adb1.deploy()
adb2 = ADB.new(helloLib.libs, helloLib.binary)
adb2.deploy()
adb1.run()
adb2.run()
end

def cleanProjects(arch)
helloExe = HelloExeBuilder.new(arch)
helloLib = HelloLibBuilder.new(arch)
ADB.new(helloExe.libs, helloExe.binary).clean
ADB.new(helloLib.libs, helloLib.binary).clean
end

def buildProjects()
buildProject("exe")
buildProject("lib")
end

def buildProject(project)
if project == "exe" then buildProjectExe()
elsif project == "lib" then buildProjectLib()
if project == "exe"
HelloExeBuilder.new(Arch.armv7a).build
HelloExeBuilder.new(Arch.aarch64).build
HelloExeBuilder.new(Arch.x86).build
elsif project == "lib"
HelloLibBuilder.new(Arch.armv7a).build
HelloLibBuilder.new(Arch.aarch64).build
HelloLibBuilder.new(Arch.x86).build
else
puts "! Unknown project \"#{project}\"."
usage()
Expand Down Expand Up @@ -107,12 +129,9 @@ def buildLLVM()
CMarkBuilder.new().make
end

def buildProjectExe()
HelloExeBuilder.new(Arch.armv7a).build
end

def buildProjectLib()
HelloLibBuilder.new(Arch.armv7a).build
def cleanLLVM()
LLVMBuilder.new().clean
CMarkBuilder.new().clean
end

def cleanICU()
Expand Down Expand Up @@ -192,26 +211,26 @@ def buildLibs()

def cleanDispatch()
DispatchBuilder.new(Arch.armv7a).clean
# DispatchBuilder.new(Arch.aarch64).clean
# DispatchBuilder.new(Arch.x86).clean
DispatchBuilder.new(Arch.aarch64).clean
DispatchBuilder.new(Arch.x86).clean
end

def buildDispatch()
DispatchBuilder.new(Arch.armv7a).make
# DispatchBuilder.new(Arch.aarch64).make
# DispatchBuilder.new(Arch.x86).make
DispatchBuilder.new(Arch.aarch64).make
DispatchBuilder.new(Arch.x86).make
end

def cleanFoundation()
FoundationBuilder.new(Arch.armv7a).clean
# FoundationBuilder.new(Arch.aarch64).clean
# FoundationBuilder.new(Arch.x86).clean
FoundationBuilder.new(Arch.aarch64).clean
FoundationBuilder.new(Arch.x86).clean
end

def buildFoundation()
FoundationBuilder.new(Arch.armv7a).make
# FoundationBuilder.new(Arch.aarch64).make
# FoundationBuilder.new(Arch.x86).make
FoundationBuilder.new(Arch.aarch64).make
FoundationBuilder.new(Arch.x86).make
end

def usage()
Expand All @@ -228,8 +247,7 @@ def usage()
tool.print("2. Build all Swift components and Sample projects for armv7a.", 32)
help = <<EOM
$ make build:toolchain
$ make build-project:exe
$ make build-project:lib
$ make build:projects
EOM
tool.print(help, 36)

Expand All @@ -245,8 +263,8 @@ def usage()

tool.print("4. Deploy and run Demo projects to Android Device.", 32)
help = <<EOM
$ make deploy-armv7a:exe
$ make deploy-armv7a:lib
$ make deploy:projects:armv7a
$ make deploy:projects:x86
EOM

tool.print(help, 36)
Expand Down
19 changes: 11 additions & 8 deletions Patches/swift-corelibs-foundation/CMakeLists.txt.diff
Original file line number Diff line number Diff line change
@@ -1,56 +1,59 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index caa241e1..ed58c7ae 100644
index efe6aac25c59c9de17a56b58d7a7ab4fa39e1047..a3adaf02a3761bf58b9463d0dd256968743621aa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,7 @@ ExternalProject_Add(CoreFoundation
@@ -54,6 +54,10 @@ ExternalProject_Add(CoreFoundation
CMAKE_COMMAND
${CMAKE_COMMAND}
CMAKE_ARGS
+ -DANDROID_PLATFORM=${ANDROID_PLATFORM}
+ -DANDROID_ABI=${ANDROID_ABI}
+ -DANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN}
+ -DANDROID_STL=${ANDROID_STL}
-DBUILD_SHARED_LIBS=NO
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
@@ -287,6 +288,7 @@ add_swift_library(Foundation
@@ -308,6 +312,7 @@ add_swift_library(Foundation
${deployment_enable_libdispatch}
-F${install_dir}/System/Library/Frameworks
-D_DLL
+ ${ADDITIONAL_SWIFT_CFLAGS}
LINK_FLAGS
-L${install_dir}/usr/lib
-lCoreFoundation
@@ -297,6 +299,7 @@ add_swift_library(Foundation
@@ -318,6 +323,7 @@ add_swift_library(Foundation
-L${CMAKE_CURRENT_BINARY_DIR}
-luuid
${Foundation_rpath_flags}
+ ${ADDITIONAL_SWIFT_LINK_FLAGS}
SWIFT_FLAGS
-DDEPLOYMENT_RUNTIME_SWIFT
${deployment_enable_libdispatch}
@@ -304,6 +307,7 @@ add_swift_library(Foundation
@@ -325,6 +331,7 @@ add_swift_library(Foundation
${libdispatch_cflags}
${swift_enable_testing}
${swift_optimization_flags}
+ ${ADDITIONAL_SWIFT_FLAGS}
DEPENDS
CoreFoundation)

@@ -319,6 +323,7 @@ if(NOT BUILD_SHARED_LIBS)
@@ -340,6 +347,7 @@ if(NOT BUILD_SHARED_LIBS)
${LIBXML2_LIBRARIES})
endif()

+if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
add_swift_executable(plutil
SOURCES
Tools/plutil/main.swift
@@ -344,6 +349,7 @@ add_swift_executable(plutil
@@ -365,6 +373,7 @@ add_swift_executable(plutil
uuid
Foundation
CoreFoundation)
+endif()

if(ENABLE_TESTING)
add_swift_executable(xdgTestHelper
@@ -554,7 +560,9 @@ install(FILES
@@ -575,7 +584,9 @@ install(FILES
CoreFoundation/Base.subproj/module.map
DESTINATION
lib/swift/CoreFoundation)
Expand Down
13 changes: 13 additions & 0 deletions Patches/swift-corelibs-foundation/Foundation/CGFloat.swift.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/Foundation/CGFloat.swift b/Foundation/CGFloat.swift
index 1bb768df2982ea692bee7a6c0cc62f1c7327f293..5f33c061dcfc6f6b3e4972af3dce20311b4b3488 100644
--- a/Foundation/CGFloat.swift
+++ b/Foundation/CGFloat.swift
@@ -31,7 +31,7 @@ public struct CGFloat {
self.native = NativeType(value)
}

-#if !os(Windows) && (arch(i386) || arch(x86_64))
+#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
@_transparent public init(_ value: Float80) {
self.native = NativeType(value)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
diff --git a/Foundation/FileManager.swift b/Foundation/FileManager.swift
index c51536246fc92efd82115c2217b256466b234712..a537ae8e676f4e5326d8cd4aae38a2e312b42faf 100644
index 527e3fcb7a0405bf42583f9d6fc98dcf8d134c16..a08ee1f863296c0e06edf62f7346947a2e7de7d8 100644
--- a/Foundation/FileManager.swift
+++ b/Foundation/FileManager.swift
@@ -15,7 +15,7 @@
import Glibc
#endif

-#if os(Android) // struct stat.st_mode is UInt32
+#if os(Android) && (arch(i386) || arch(arm)) // struct stat.st_mode is UInt32
internal func &(left: UInt32, right: mode_t) -> mode_t {
return mode_t(left) & right
}
@@ -91,7 +91,10 @@ open class FileManager : NSObject {
urls = mountPoints(statBuf, Int(fsCount))
}
Expand Down Expand Up @@ -46,23 +55,23 @@ index c51536246fc92efd82115c2217b256466b234712..a537ae8e676f4e5326d8cd4aae38a2e3
}

/* attributesOfFileSystemForPath:error: returns an NSDictionary of key/value pairs containing the attributes of the filesystem containing the provided path. If this method returns 'nil', an NSError will be returned by reference in the 'error' parameter. This method does not traverse a terminal symlink.
@@ -880,6 +888,7 @@ open class FileManager : NSObject {
@@ -889,6 +897,7 @@ open class FileManager : NSObject {
return
}

+ /* FIXME: Android compile Workaround.
let fileType = FileAttributeType(statMode: stat.st_mode)
if fileType == .typeDirectory {
try createDirectory(atPath: dstPath, withIntermediateDirectories: false, attributes: nil)
@@ -903,6 +912,7 @@ open class FileManager : NSObject {
@@ -912,6 +921,7 @@ open class FileManager : NSObject {
} else {
try body(srcPath, dstPath, fileType)
}
+ */
}

private func shouldProceedAfterError(_ error: Error, copyingItemAtPath path: String, toPath: String, isURL: Bool) -> Bool {
@@ -1413,8 +1423,10 @@ open class FileManager : NSObject {
@@ -1422,8 +1432,10 @@ open class FileManager : NSObject {

if file1Type == S_IFCHR || file1Type == S_IFBLK {
// For character devices, just check the major/minor pair is the same.
Expand Down
13 changes: 13 additions & 0 deletions Patches/swift/cmake/modules/AddSwift.cmake.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake
index 5a7e220c6b04dbbef3288f996c4922ea539aac76..02e51b5f069ad8d5649c28d21ddf5351973482e6 100644
--- a/cmake/modules/AddSwift.cmake
+++ b/cmake/modules/AddSwift.cmake
@@ -435,6 +435,8 @@ function(_add_variant_link_flags)
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a")
elseif("${LFLAGS_ARCH}" MATCHES aarch64)
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a")
+ elseif("${LFLAGS_ARCH}" MATCHES i686)
+ set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/x86")
else()
message(SEND_ERROR "unknown architecture (${LFLAGS_ARCH}) for android")
endif()
13 changes: 13 additions & 0 deletions Patches/swift/cmake/modules/SwiftAndroidSupport.cmake.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/cmake/modules/SwiftAndroidSupport.cmake b/cmake/modules/SwiftAndroidSupport.cmake
index c6dcc783c68091927edc1cc065d0bbb8c435501d..2bd1a068c5c2f92268fa50f59a009d6e58a984bc 100644
--- a/cmake/modules/SwiftAndroidSupport.cmake
+++ b/cmake/modules/SwiftAndroidSupport.cmake
@@ -23,6 +23,8 @@ function(swift_android_lib_for_arch arch var)
list(APPEND paths "${_prebuilt}/${_host}/lib/armv7-a")
elseif(arch STREQUAL aarch64)
list(APPEND paths "${_prebuilt}/${_host}/lib64")
+ elseif(arch STREQUAL i686)
+ list(APPEND paths "${_prebuilt}/${_host}/lib")
else()
message(SEND_ERROR "unknown architecture (${arch}) for android")
endif()
32 changes: 32 additions & 0 deletions Patches/swift/cmake/modules/SwiftConfigureSDK.cmake.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/cmake/modules/SwiftConfigureSDK.cmake b/cmake/modules/SwiftConfigureSDK.cmake
index 21e47a6e6382cc19ea192d388677ec3e6276bc86..5c68072a79588f4217a29608da78403a2b2e9284 100644
--- a/cmake/modules/SwiftConfigureSDK.cmake
+++ b/cmake/modules/SwiftConfigureSDK.cmake
@@ -186,6 +186,11 @@ macro(configure_sdk_unix name architectures)
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "aarch64")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-arm64")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "aarch64-unknown-linux-android")
+ elseif("${arch}" STREQUAL "i686")
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "i686-linux-android")
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "i686")
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-x86")
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "i686-unknown-linux-android")
else()
message(FATAL_ERROR "unknown arch for android SDK: ${arch}")
endif()
@@ -196,8 +201,13 @@ macro(configure_sdk_unix name architectures)
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
set(_swift_android_prebuilt_build "linux-x86_64")
endif()
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
- "${SWIFT_ANDROID_NDK_PATH}/toolchains/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
+ if("${arch}" STREQUAL "i686")
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
+ "${SWIFT_ANDROID_NDK_PATH}/toolchains/x86-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
+ else()
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
+ "${SWIFT_ANDROID_NDK_PATH}/toolchains/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
+ endif()
else()
if(NOT SWIFT_SDK_${prefix}_ARCH_${arch}_PATH)
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "/")
15 changes: 15 additions & 0 deletions Patches/swift/include/swift/Runtime/SwiftDtoa.h.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/include/swift/Runtime/SwiftDtoa.h b/include/swift/Runtime/SwiftDtoa.h
index c309d2e97985ef70d6c714ca802e00831f113fe9..41a892eaaab662d640588c6a274a569545b5a7b7 100644
--- a/include/swift/Runtime/SwiftDtoa.h
+++ b/include/swift/Runtime/SwiftDtoa.h
@@ -37,6 +37,10 @@
#endif
#endif

+#if defined(__ANDROID__) && defined(__i386)
+ #undef SWIFT_DTOA_FLOAT80_SUPPORT
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
13 changes: 13 additions & 0 deletions Patches/swift/stdlib/public/Platform/Glibc.swift.gyb.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/stdlib/public/Platform/Glibc.swift.gyb b/stdlib/public/Platform/Glibc.swift.gyb
index 4c011570295f58d717387bc686e878df853de74d..2de990adfffaf01e077c2fc84059b44d0fc8359d 100644
--- a/stdlib/public/Platform/Glibc.swift.gyb
+++ b/stdlib/public/Platform/Glibc.swift.gyb
@@ -36,7 +36,7 @@ public let FLT_RADIX = Double.radix

%for type, prefix in [('Float', 'FLT'), ('Double', 'DBL'), ('Float80', 'LDBL')]:
% if type == "Float80":
-#if arch(i386) || arch(x86_64)
+#if !os(Android) && (arch(i386) || arch(x86_64))
% end
// Where does the 1 come from? C counts the usually-implicit leading
// significand bit, but Swift does not. Neither is really right or wrong.
Loading

0 comments on commit 7c8badf

Please sign in to comment.