Skip to content
This repository was archived by the owner on Oct 25, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/curl_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module CurlBuilder
debug_symbols: false,
curldebug: false,
sdk_version: "9.0",
tvos_sdk_version: "none",
osx_sdk_version: "10.10",
libcurl_version: "7.38.0",
architectures: %w(i386 armv7 armv7s arm64 x86_64),
Expand All @@ -73,7 +74,10 @@ module CurlBuilder
cleanup: true,
}

VALID_ARGS = {architectures: %w(i386 armv7 armv7s arm64 x86_64)}
VALID_ARGS = {
architectures: %w(i386 armv7 armv7s arm64 x86_64),
architectures_64_bit: %w(arm64 x86_64)
}


attr_accessor :logger
Expand All @@ -94,7 +98,7 @@ def build_flags(flags)
flags.collect { |flag, enabled| enabled ? "--with-#{flag}" : "--without-#{flag}" }
end

def filter_valid_archs(archs)
VALID_ARGS[:architectures] & archs
def filter_valid_archs(archs, only_64_bit = false)
VALID_ARGS[(!only_64_bit ? :architectures : :architectures_64_bit)] & archs
end
end
22 changes: 12 additions & 10 deletions lib/curl_builder/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ def compile_for(architecture)
def platform_for(architecture)
case architecture
when "x86_64"
setup(:osx_sdk_version) == "none" ? "iPhoneSimulator" : "MacOSX"
setup(:osx_sdk_version) == "none" ? (setup(:tvos_sdk_version) == "none" ? "iPhoneSimulator" : "AppleTVSimulator") : "MacOSX"
when "i386"
"iPhoneSimulator"
setup(:tvos_sdk_version) == "none" ? "iPhoneSimulator" : "AppleTVSimulator"
else
"iPhoneOS"
setup(:tvos_sdk_version) == "none" ? "iPhoneOS" : "AppleTVOS"
end
end

Expand All @@ -86,18 +86,18 @@ def find_tool(tool_name, platform)
def sdk_version_for(platform)
if platform == "iPhoneOS" || platform == "iPhoneSimulator"
setup(:sdk_version)
elsif platform == "AppleTVOS" || platform == "AppleTVSimulator"
setup(:tvos_sdk_version)
else
setup(:osx_sdk_version)
end
end

def compilation_flags_for(platform, architecture)
if platform == "iPhoneSimulator"
version = "6.0"
min_version = "-miphoneos-version-min=#{version}"
elsif platform == "iPhoneOS"
version = architecture == "arm64" ? "6.0" : "5.0"
min_version = "-miphoneos-version-min=#{version}"
if platform == "iPhoneOS" || platform == "iPhoneSimulator"
min_version = "-miphoneos-version-min=6.0"
elsif platform == "AppleTVOS" || platform == "AppleTVSimulator"
min_version = "-mtvos-version-min=9.0"
else
min_version = "-mmacosx-version-min=10.7"
end
Expand All @@ -107,7 +107,7 @@ def compilation_flags_for(platform, architecture)

{
ldflags: "-arch #{architecture} -pipe -isysroot #{sdk}",
cflags: "-arch #{architecture} -pipe -isysroot #{sdk} #{min_version}"
cflags: "-arch #{architecture} -pipe -isysroot #{sdk} #{min_version} -Werror=partial-availability"
}
end

Expand Down Expand Up @@ -141,6 +141,8 @@ def configure(architecture, tools, compilation_flags)
--host=#{host}
--disable-shared
--enable-static
--enable-ipv6
--disable-ntlm-wb
#{flags.join(" ")}
--prefix="#{output_dir_for architecture}"
}
Expand Down
2 changes: 1 addition & 1 deletion lib/curl_builder/packer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def pack(compiled_architectures)
def copy_include_dir(architecture, name)
target_dir = result_include_dir(name)
FileUtils.mkdir_p target_dir
files_to_copy = File.join output_dir_for(architecture), "include", "curl", "*"
files_to_copy = File.join output_dir_for(architecture), "include", "curl"

copy_command = "cp -R #{files_to_copy} #{target_dir}"
setup(:verbose) ? system(copy_command) : `#{copy_command} &>/dev/null`
Expand Down
14 changes: 14 additions & 0 deletions lib/curl_builder/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ def parse(args)
setup[:sdk_version] = sdk
end

parser.on("--tvos-sdk-version SDK",
"Use specific SDK version",
" Defaults to #{param(setup[:tvos_sdk_version])}") do |sdk|
setup[:tvos_sdk_version] = sdk
end

parser.on("--osx-sdk-version SDK",
"Use specific SDK version",
" Defaults to #{param(setup[:osx_sdk_version])}") do |sdk|
Expand Down Expand Up @@ -150,6 +156,14 @@ def parse(args)

parser.parse(args)

if setup[:sdk_version] != "none" && setup[:tvos_sdk_version] != "none"
raise Errors::TaskError, "Builds with both iOS and tvOS SDKs active are unsupported. Please set either --sdk-version or --tvos-sdk-version to none."
end

if setup[:tvos_sdk_version] != "none"
setup[:architectures] = CurlBuilder.filter_valid_archs(setup[:architectures], true)
end

{setup: setup, protocols: protocols, flags: flags}
end
end
Expand Down