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 #6 from vgorloff/develop
Browse files Browse the repository at this point in the history
Release 1.0.4
  • Loading branch information
vgorloff authored Dec 29, 2018
2 parents d1a80d6 + 72b2a5f commit 0b4dd34
Show file tree
Hide file tree
Showing 18 changed files with 293 additions and 193 deletions.
31 changes: 25 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ namespace :armv7a do
# UUIDBuilder.new().make
OpenSSLBuilder.new(Arch.armv7a).make
CurlBuilder.new(Arch.armv7a).make
CMarkBuilder.new(Arch.armv7a).make
LLVMBuilder.new(Arch.armv7a).make
swift.make
DispatchBuilder.new(Arch.armv7a).make
FoundationBuilder.new(Arch.armv7a).make
Expand All @@ -96,6 +98,7 @@ namespace :armv7a do

end

# Pass `SA_DRY_RUN=1 rake ...` for Dry run mode.
namespace :develop do
namespace :host do
namespace :make do
Expand All @@ -111,7 +114,18 @@ namespace :develop do
desc "Configure, Build and Install - UUID"
task :uuid do UUIDBuilder.new(Arch.host).make end
end
namespace :configure do
desc "Configure - ICU"
task :icu do ICUBuilder.new(Arch.host).configure end
end
namespace :build do
desc "Build - ICU"
task :icu do ICUBuilder.new(Arch.host).build end
end
namespace :install do
desc "Install - ICU"
task :icu do ICUBuilder.new(Arch.host).install end

desc "Install - libDispatch"
task :dispatch do DispatchBuilder.new(Arch.host).install end

Expand Down Expand Up @@ -226,11 +240,7 @@ namespace :develop do
task :curl do CurlBuilder.new(Arch.armv7a).install end

desc "Install - Hello project on Android"
task :project do
helper = ADBHelper.new()
helper.deployLibs
helper.deployProducts([HelloProjectBuilder.new(Arch.armv7a).executable])
end
task :project do ADBHelper.new().deploy(HelloProjectBuilder.new(Arch.armv7a).builds) end
end

namespace :make do
Expand Down Expand Up @@ -286,11 +296,20 @@ namespace :develop do

desc "Clean - UUID"
task :uuid do UUIDBuilder.new(Arch.armv7a).clean end

desc "Clean - libXML"
task :xml do XMLBuilder.new(Arch.armv7a).clean end

desc "Clean - OpenSSL"
task :ssl do OpenSSLBuilder.new(Arch.armv7a).clean end

desc "Clean - curl"
task :curl do CurlBuilder.new(Arch.armv7a).clean end
end

namespace :run do
desc "Run - Hello project on Android"
task :project do ADBHelper.new().run(HelloProjectBuilder.new(Arch.armv7a).executableName) end
task :project do ADBHelper.new().run(HelloProjectBuilder.new(Arch.armv7a).executable) end
end
end
end
Expand Down
9 changes: 8 additions & 1 deletion Scripts/Builders/AndroidBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ def api
return "21"
end

def gcc
return "4.9"
end

def initialize(arch = Arch.default)
super(Lib.ndk, arch)
@sources = "#{Config.sources}/#{@component}" + suffix
end

def download()
downloader = Downloader.new(Config.downloads, @sources, "https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip", 'android-ndk-*')
fileName = Tool.isMacOS? ? "android-ndk-r18b-darwin-x86_64.zip" : "android-ndk-r18b-linux-x86_64.zip"
url = "https://dl.google.com/android/repository/#{fileName}"
downloader = Downloader.new(Config.downloads, @sources, url, 'android-ndk-*')
downloader.bootstrap()
end

Expand Down
5 changes: 4 additions & 1 deletion Scripts/Builders/CMarkBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ def configure
cmd = []
cmd << "cd #{@builds} &&"
cmd << "cmake -G Ninja"
cmd << "-DCMAKE_C_COMPILER:PATH=/usr/bin/clang"
cmd << "-DCMAKE_CXX_COMPILER:PATH=/usr/bin/clang++"
cmd << "-DCMAKE_INSTALL_PREFIX=#{@installs}"
cmd << "-DCMAKE_BUILD_TYPE=Release"
cmd << "-DCMAKE_BUILD_TYPE:STRING=Release"
cmd << "-DCMARK_TESTS=false"
cmd << @sources
execute cmd.join(" ")
logConfigureCompleted
Expand Down
5 changes: 5 additions & 0 deletions Scripts/Builders/CurlBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,9 @@ def make
install
end

def clean
removeBuilds()
cleanGitRepo()
end

end
8 changes: 5 additions & 3 deletions Scripts/Builders/DispatchBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def prepare
def configure
logConfigureStarted
swift = SwiftBuilder.new(@arch)
llvm = LLVMBuilder.new(@arch)
ndk = AndroidBuilder.new(@arch)
# See: /swift/swift-corelibs-libdispatch/INSTALL.md
prepare
Expand All @@ -27,7 +28,7 @@ def configure
cmd << "cmake -G Ninja"
if @arch == Arch.host
cmd << "-DCMAKE_INSTALL_PREFIX=#{@installs}"
cmd << "-DCMAKE_C_COMPILER=\"#{swift.llvm}/bin/clang\""
cmd << "-DCMAKE_C_COMPILER=\"#{llvm.builds}/bin/clang\""
else
cmd << "-DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a"
cmd << "-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang"
Expand All @@ -40,8 +41,8 @@ def configure
cmd << "-DCMAKE_BUILD_TYPE=Release"
cmd << "-DENABLE_SWIFT=true"
cmd << "-DENABLE_TESTING=false"
cmd << "-DCMAKE_SWIFT_COMPILER=\"#{swift.swift}/bin/swiftc\""
cmd << "-DCMAKE_PREFIX_PATH=\"#{swift.swift}/lib/cmake/swift\""
cmd << "-DCMAKE_SWIFT_COMPILER=\"#{swift.builds}/bin/swiftc\""
cmd << "-DCMAKE_PREFIX_PATH=\"#{swift.builds}/lib/cmake/swift\""
cmd << @sources
execute cmd.join(" ")
fixNinjaBuild
Expand Down Expand Up @@ -98,6 +99,7 @@ def make
def clean
configurePatches(false)
removeBuilds()
cleanGitRepo()
end

def checkout
Expand Down
6 changes: 4 additions & 2 deletions Scripts/Builders/FoundationBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def initialize(arch = Arch.default)
@ndk = AndroidBuilder.new(arch)
@dispatch = DispatchBuilder.new(arch)
@swift = SwiftBuilder.new(arch)
@llvm = LLVMBuilder.new(arch)
@curl = CurlBuilder.new(arch)
@icu = ICUBuilder.new(arch)
@xml = XMLBuilder.new(arch)
Expand All @@ -30,7 +31,7 @@ def configure
cmd << "-DFOUNDATION_PATH_TO_LIBDISPATCH_BUILD=#{@dispatch.builds}" # Check later if we can use `@installs`
cmd << "-DCMAKE_BUILD_TYPE=Release"
if @arch == Arch.host
cmd << "-DCMAKE_C_COMPILER=\"#{@swift.llvm}/bin/clang\""
cmd << "-DCMAKE_C_COMPILER=\"#{@llvm.builds}/bin/clang\""
cmd << "-DCMAKE_INSTALL_PREFIX=#{@installs}"
else
cmd << "-DCMAKE_SYSROOT=#{@ndk.installs}/sysroot"
Expand Down Expand Up @@ -58,7 +59,7 @@ def configure

cmd << "-DCMAKE_INSTALL_PREFIX=#{@swift.installs}/usr" # Applying Foundation over existing file structure.
end
cmd << "-DCMAKE_SWIFT_COMPILER=\"#{@swift.swift}/bin/swiftc\""
cmd << "-DCMAKE_SWIFT_COMPILER=\"#{@swift.builds}/bin/swiftc\""

cmd << @sources
execute cmd.join(" ")
Expand Down Expand Up @@ -95,6 +96,7 @@ def make
def clean
configurePatches(false)
removeBuilds()
cleanGitRepo()
end

def checkout
Expand Down
39 changes: 35 additions & 4 deletions Scripts/Builders/HelloProjectBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# - Build error: No such module "SwiftGlibc" – https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20160919/002955.html
class HelloProjectBuilder < Builder

attr_reader :executable, :executableName
attr_reader :executable

def initialize(arch = Arch.default)
super("Hello", arch)
@executableName = "hello"
@executable = @builds + "/" + @executableName
@builds = "#{Config.build}/#{arch}/#{@component}"
@executable = "hello"
@projectRoot = "#{Config.projects}/Hello"
end

Expand All @@ -35,10 +35,41 @@ def build
end
cmd << "#{@projectRoot}/hello.swift"
execute cmd.join(" ")
execute "readelf -h #{@executable}"
copyLibs
execute "readelf -h #{@builds}/#{@executable}"
logBuildCompleted
end

def copyLibs()
swift = SwiftBuilder.new()
ndk = AndroidBuilder.new()
icu = ICUBuilder.new()
curl = CurlBuilder.new()
ssl = OpenSSLBuilder.new()
xml = XMLBuilder.new()
message "Copying Shared Objects started."
Dir["#{swift.installs}/usr/lib/swift/android" + "/*.so"].each { |lib|
execute "cp -vf #{lib} #{@builds}"
}
Dir[icu.lib + "/*.so*"].select { |lib| !File.symlink?(lib) }.each { |lib|
destName = File.basename(lib)
destName = destName.sub("63.1", "63") # Fix for error: CANNOT LINK EXECUTABLE ... library "libicudataswift.so.63" not found
execute "cp -vf #{lib} #{@builds}/#{destName}"
}
Dir[curl.lib + "/*.so"].each { |lib|
execute "cp -vf #{lib} #{@builds}"
}
Dir[xml.lib + "/*.so"].each { |lib|
execute "cp -vf #{lib} #{@builds}"
}
Dir[ssl.lib + "/*.so*"].select { |lib| !File.symlink?(lib) }.each { |lib|
execute "cp -vf #{lib} #{@builds}"
}
cxxLibPath = "#{ndk.sources}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so"
execute "cp -vf #{cxxLibPath} #{@builds}"
message "Copying Shared Objects completed."
end

def prepare()
prepareBuilds()
end
Expand Down
1 change: 1 addition & 0 deletions Scripts/Builders/ICUBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def clean
configurePatches(false)
end
removeBuilds()
cleanGitRepo()
end

end
55 changes: 42 additions & 13 deletions Scripts/Builders/LLVMBuilder.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
require_relative "../Common/Builder.rb"

# See:
# - https://stackoverflow.com/questions/40122657/build-llvm-clang4-0-for-android-armeabi
# - LLVM Getting Started: https://llvm.org/docs/GettingStarted.html#requirements
# - CLANG Getting Started: http://clang.llvm.org/get_started.html

class LLVMBuilder < Builder

def initialize(arch = Arch.default)
Expand All @@ -8,19 +13,38 @@ def initialize(arch = Arch.default)

def configure
logConfigureStarted
setupSymLinks
prepare
# See:
# - LLVM Getting Started: https://llvm.org/docs/GettingStarted.html#requirements
# - CLANG Getting Started: http://clang.llvm.org/get_started.html
cmd = []
cmd << "cd #{@builds} &&"
cmd << "cmake -G Ninja"
cmd << "-DCMAKE_INSTALL_PREFIX=#{@installs}"
cmd << "-DCMAKE_BUILD_TYPE=Release"
# See: https://stackoverflow.com/questions/40122657/build-llvm-clang4-0-for-android-armeabi
# Line below still cause build failure.
cmd << "-DLLVM_INCLUDE_EXAMPLES=false"
cmd << "-DLLVM_INCLUDE_TESTS=false"
cmd << "-DLLVM_INCLUDE_DOCS=false"
cmd << "-DLLVM_TARGETS_TO_BUILD=\"ARM;AArch64;X86\""
# cmd << "-DLLVM_DEFAULT_TARGET_TRIPLE=\"arm-linux-androideabi\""

cmd << "-DCMAKE_C_COMPILER:PATH=/usr/bin/clang"
cmd << "-DCMAKE_CXX_COMPILER:PATH=/usr/bin/clang++"
cmd << "-DCMAKE_LIBTOOL:PATH="
cmd << "-DLLVM_VERSION_MAJOR:STRING=7"
cmd << "-DLLVM_VERSION_MINOR:STRING=0"
cmd << "-DLLVM_VERSION_PATCH:STRING=0"
cmd << "-DCLANG_VERSION_MAJOR:STRING=7"
cmd << "-DCLANG_VERSION_MINOR:STRING=0"
cmd << "-DCLANG_VERSION_PATCH:STRING=0"
cmd << "-DLLVM_ENABLE_ASSERTIONS=TRUE"
cmd << "-DCMAKE_C_FLAGS=' -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector'"
cmd << "-DCMAKE_CXX_FLAGS=' -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector'"
cmd << "-DLLVM_TOOL_SWIFT_BUILD:BOOL=NO"
cmd << "-DLLVM_ENABLE_LTO:STRING="
cmd << "-DLLVM_TOOL_COMPILER_RT_BUILD:BOOL=TRUE"
cmd << "-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=TRUE"
cmd << "-DLLVM_LIT_ARGS=-sv"
cmd << "-DCMAKE_INSTALL_PREFIX=#{@installs}"
# cmd << "-DCMAKE_INSTALL_PREFIX:PATH=/usr/"
cmd << "-DINTERNAL_INSTALL_PREFIX=local"

cmd << @sources
execute cmd.join(" ")
logConfigureCompleted()
Expand All @@ -36,7 +60,8 @@ def build
def install
logInstallStarted
removeInstalls()
execute "cd #{@builds} && ninja install"
swift = SwiftBuilder.new()
execute "env DESTDIR=#{swift.installs} cmake --build #{@builds} -- install-llvm-cov install-llvm-profdata install-IndexStore"
logInstallCompleted()
end

Expand All @@ -52,17 +77,21 @@ def checkout

def prepare()
prepareBuilds()
end

def setupSymLinks
# Making needed SymLinks. See: https://llvm.org/docs/GettingStarted.html#git-mirror
message "Making symbolic links..."
@clang = ClangBuilder.new()
@crt = CompilerRTBuilder.new()
execute "ln -svf \"#{@clang.sources}\" \"#{@sources}/tools/clang\""
execute "ln -svf \"#{@crt.sources}\" \"#{@sources}/projects/compiler-rt\""
message "LLVM Prepare is Done!"
clang = ClangBuilder.new()
crt = CompilerRTBuilder.new()
setupSymLink(clang.sources, "#{@sources}/tools/clang")
setupSymLink(crt.sources, "#{@sources}/projects/compiler-rt")
setupSymLink("/usr/include/c++", "#{@builds}/include/c++")
end

def clean
removeBuilds()
cleanGitRepo()
end

end
5 changes: 5 additions & 0 deletions Scripts/Builders/OpenSSLBuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@ def make
install
end

def clean
removeBuilds()
cleanGitRepo()
end

end
Loading

0 comments on commit 0b4dd34

Please sign in to comment.