diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 318b51678c..8d29795f1e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,10 +1,8 @@ -# Performs code quality checks +# Performs miscellaneous quick checks name: checks on: pull_request: push: - branches: - - "master" jobs: perform_code_quality_checks: @@ -14,4 +12,11 @@ jobs: os: [ "ubuntu-22.04" ] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: ./MOBILE/ios/createpodspecs_test + - run: ./script/nocopyreadall.bash + + - run: ./script/ghpublish_test.bash diff --git a/.github/workflows/ghpublish.yml b/.github/workflows/ghpublish.yml deleted file mode 100644 index a1229cff90..0000000000 --- a/.github/workflows/ghpublish.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Verifies that `./script/ghpublish.bash` is WAI -name: ghpublish -on: - push: - branches: - - "release/**" - - "fullbuild" - - "ghpublishbuild" - -jobs: - test_ghpublish_bash: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - run: ./script/ghpublish_test.bash diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 6ab92595e2..d4962a7263 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -38,7 +38,57 @@ jobs: # ./internal/cmd/buildtool needs coreutils for sha256 plus GNU build tools - run: brew install autoconf automake coreutils libtool - - run: make EXPECTED_XCODE_VERSION=14.2 MOBILE/ios + - run: make EXPECTED_XCODE_VERSION=14.2 ios + + - uses: actions/upload-artifact@v3 + with: + name: libcrypto.xcframework.zip + path: ./MOBILE/ios/libcrypto.xcframework.zip + + - uses: actions/upload-artifact@v3 + with: + name: libcrypto.podspec + path: ./MOBILE/ios/libcrypto.podspec + + - uses: actions/upload-artifact@v3 + with: + name: libevent.xcframework.zip + path: ./MOBILE/ios/libevent.xcframework.zip + + - uses: actions/upload-artifact@v3 + with: + name: libevent.podspec + path: ./MOBILE/ios/libevent.podspec + + - uses: actions/upload-artifact@v3 + with: + name: libssl.xcframework.zip + path: ./MOBILE/ios/libssl.xcframework.zip + + - uses: actions/upload-artifact@v3 + with: + name: libssl.podspec + path: ./MOBILE/ios/libssl.podspec + + - uses: actions/upload-artifact@v3 + with: + name: libtor.xcframework.zip + path: ./MOBILE/ios/libtor.xcframework.zip + + - uses: actions/upload-artifact@v3 + with: + name: libtor.podspec + path: ./MOBILE/ios/libtor.podspec + + - uses: actions/upload-artifact@v3 + with: + name: libz.xcframework.zip + path: ./MOBILE/ios/libz.xcframework.zip + + - uses: actions/upload-artifact@v3 + with: + name: libz.podspec + path: ./MOBILE/ios/libz.podspec - uses: actions/upload-artifact@v3 with: @@ -60,6 +110,46 @@ jobs: with: fetch-depth: 0 + - uses: actions/download-artifact@v3 + with: + name: libcrypto.xcframework.zip + + - uses: actions/download-artifact@v3 + with: + name: libcrypto.podspec + + - uses: actions/download-artifact@v3 + with: + name: libevent.xcframework.zip + + - uses: actions/download-artifact@v3 + with: + name: libevent.podspec + + - uses: actions/download-artifact@v3 + with: + name: libssl.xcframework.zip + + - uses: actions/download-artifact@v3 + with: + name: libssl.podspec + + - uses: actions/download-artifact@v3 + with: + name: libtor.xcframework.zip + + - uses: actions/download-artifact@v3 + with: + name: libtor.podspec + + - uses: actions/download-artifact@v3 + with: + name: libz.xcframework.zip + + - uses: actions/download-artifact@v3 + with: + name: libz.podspec + - uses: actions/download-artifact@v3 with: name: oonimkall.xcframework.zip @@ -68,7 +158,7 @@ jobs: with: name: oonimkall.podspec - - run: ./script/ghpublish.bash oonimkall.xcframework.zip oonimkall.podspec + - run: ./script/ghpublish.bash libcrypto.xcframework.zip libcrypto.podspec libevent.xcframework.zip libevent.podspec libssl.xcframework.zip libssl.podspec libtor.xcframework.zip libtor.podspec libz.xcframework.zip libz.podspec oonimkall.xcframework.zip oonimkall.podspec env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/MOBILE/ios/.gitignore b/MOBILE/ios/.gitignore index a98bc5c41d..e92bf14119 100644 --- a/MOBILE/ios/.gitignore +++ b/MOBILE/ios/.gitignore @@ -1,2 +1,3 @@ -/oonimkall.framework/ -/oonimkall.* +/*.xcframework/ +/*.zip +/*.podspec diff --git a/MOBILE/ios/check-xcode-version b/MOBILE/ios/check-xcode-version index 346e264fd3..e4f7b9a94d 100755 --- a/MOBILE/ios/check-xcode-version +++ b/MOBILE/ios/check-xcode-version @@ -2,7 +2,7 @@ set -euo pipefail -EXPECTED_XCODE_VERSION=${EXPECTED_XCODE_VERSION:-14.2} +EXPECTED_XCODE_VERSION=${EXPECTED_XCODE_VERSION:-15.0} printf "checking for xcodebuild... " command -v xcodebuild || { diff --git a/MOBILE/ios/createpodspec b/MOBILE/ios/createpodspec deleted file mode 100755 index b756259c67..0000000000 --- a/MOBILE/ios/createpodspec +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -set -euo pipefail -__version=$(date -u +%Y.%m.%d-%H%M%S) -__release=$(git describe --tags || echo '0.0.0-dev') -cat ./MOBILE/ios/template.podspec | sed -e "s/@VERSION@/$__version/g" \ - -e "s/@RELEASE@/$__release/g" >./MOBILE/ios/oonimkall.podspec diff --git a/MOBILE/ios/createpodspecs b/MOBILE/ios/createpodspecs new file mode 100755 index 0000000000..fbfb04a829 --- /dev/null +++ b/MOBILE/ios/createpodspecs @@ -0,0 +1,25 @@ +#!/bin/bash +set -euo pipefail +__version=$(date -u +%Y.%m.%d-%H%M%S) +__release="${1:-$(git describe --tags || echo '0.0.0-dev')}" + +# Save original variable before substitution so we can unit test it +__orig=${__release} + +# determine whether we're publishing to a release or to rolling +# +# when publishing to rolling the __release variable is like: 'v3.19.0-alpha-27-g4678578b' +# otherwise it's like `v3.19.0`, `v3.19.0-alpha`, or `v3.19.0-beta.555`. +if ! [[ $__release =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9]+)?)?$ ]]; then + __release=rolling +fi + +if [[ ${CREATE_POD_SPECS_DEBUG:-0} == 1 ]]; then + echo "$__orig -> $__release" + exit 0 +fi + +for name in libcrypto libevent libssl libtor libz oonimkall; do + cat ./MOBILE/ios/${name}-template.podspec | sed -e "s/@VERSION@/$__version/g" \ + -e "s/@RELEASE@/$__release/g" >./MOBILE/ios/${name}.podspec +done diff --git a/MOBILE/ios/createpodspecs_test b/MOBILE/ios/createpodspecs_test new file mode 100755 index 0000000000..f78c24d03c --- /dev/null +++ b/MOBILE/ios/createpodspecs_test @@ -0,0 +1,32 @@ +#!/bin/bash +set -euo pipefail + +export CREATE_POD_SPECS_DEBUG=1 + +function check() { + local expect=$1 + local got=$2 + echo -n "checking whether '$expect' equals '$got'... " 1>&2 + if [[ "$got" != "$expect" ]]; then + echo "NO" 1>&2 + exit 1 + fi + echo "yes" +} + +expect="v3.10.9-beta.116-44-g1777474 -> rolling" +got=$(./MOBILE/ios/createpodspecs v3.10.9-beta.116-44-g1777474) +check "$expect" "$got" + +expect="v3.10.0 -> v3.10.0" +got=$(./MOBILE/ios/createpodspecs v3.10.0) +check "$expect" "$got" + +expect="v3.10.0-alpha -> v3.10.0-alpha" +got=$(./MOBILE/ios/createpodspecs v3.10.0-alpha) +check "$expect" "$got" + +expect="v3.10.0-alpha.1 -> v3.10.0-alpha.1" +got=$(./MOBILE/ios/createpodspecs v3.10.0-alpha.1) +check "$expect" "$got" + diff --git a/MOBILE/ios/libcrypto-template.podspec b/MOBILE/ios/libcrypto-template.podspec new file mode 100644 index 0000000000..15b75148f0 --- /dev/null +++ b/MOBILE/ios/libcrypto-template.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = "libcrypto" + s.version = "@VERSION@" + s.summary = "OpenSSL libcrypto compiled for OONI Probe iOS" + s.author = "Simone Basso" + s.homepage = "https://github.com/ooni/probe-cli" + s.license = { :type => "Apache" } + s.source = { + :http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libcrypto.xcframework.zip" + } + s.platform = :ios, "9.0" + s.ios.vendored_frameworks = "libcrypto.xcframework" +end diff --git a/MOBILE/ios/libevent-template.podspec b/MOBILE/ios/libevent-template.podspec new file mode 100644 index 0000000000..ce480c0e0a --- /dev/null +++ b/MOBILE/ios/libevent-template.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = "libevent" + s.version = "@VERSION@" + s.summary = "Libevent compiled for OONI Probe iOS" + s.author = "Simone Basso" + s.homepage = "https://github.com/ooni/probe-cli" + s.license = { :type => "BSD" } + s.source = { + :http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libevent.xcframework.zip" + } + s.platform = :ios, "9.0" + s.ios.vendored_frameworks = "libevent.xcframework" +end diff --git a/MOBILE/ios/libssl-template.podspec b/MOBILE/ios/libssl-template.podspec new file mode 100644 index 0000000000..0d08ef8f98 --- /dev/null +++ b/MOBILE/ios/libssl-template.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = "libssl" + s.version = "@VERSION@" + s.summary = "OpenSSL libssl compiled for OONI Probe iOS" + s.author = "Simone Basso" + s.homepage = "https://github.com/ooni/probe-cli" + s.license = { :type => "Apache" } + s.source = { + :http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libssl.xcframework.zip" + } + s.platform = :ios, "9.0" + s.ios.vendored_frameworks = "libssl.xcframework" +end diff --git a/MOBILE/ios/libtor-template.podspec b/MOBILE/ios/libtor-template.podspec new file mode 100644 index 0000000000..6d33c298d5 --- /dev/null +++ b/MOBILE/ios/libtor-template.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = "libtor" + s.version = "@VERSION@" + s.summary = "tor compiled for OONI Probe iOS" + s.author = "Simone Basso" + s.homepage = "https://github.com/ooni/probe-cli" + s.license = { :type => "BSD" } + s.source = { + :http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libtor.xcframework.zip" + } + s.platform = :ios, "9.0" + s.ios.vendored_frameworks = "libtor.xcframework" +end diff --git a/MOBILE/ios/libz-template.podspec b/MOBILE/ios/libz-template.podspec new file mode 100644 index 0000000000..dcb33108e1 --- /dev/null +++ b/MOBILE/ios/libz-template.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = "libz" + s.version = "@VERSION@" + s.summary = "zlib compiled for OONI Probe iOS" + s.author = "Simone Basso" + s.homepage = "https://github.com/ooni/probe-cli" + s.license = { :type => "zlib" } + s.source = { + :http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libz.xcframework.zip" + } + s.platform = :ios, "9.0" + s.ios.vendored_frameworks = "libz.xcframework" +end diff --git a/MOBILE/ios/make-extra-frameworks b/MOBILE/ios/make-extra-frameworks new file mode 100755 index 0000000000..2ba7225e5a --- /dev/null +++ b/MOBILE/ios/make-extra-frameworks @@ -0,0 +1,48 @@ +#!/bin/bash +set -euxo pipefail + +TOPDIR=$(dirname $(dirname $(dirname $(realpath $0)))) +WORK=$(mktemp -d) + +# make_framework constructs a framework. +# +# This function does not bother itself with installing headers because we have +# already used the relevant headers when invoking `gomobile bind`. +# +# Arguments: +# +# - $1 is the name of the framework to create. +function make_framework() { + local name=$1 + shift + + # Start afresh. + rm -rf MOBILE/ios/${name}.xcframework + + # Create iphoneos/arm64 framework. + mkdir -p $WORK/iphoneos/${name}.framework/Versions/A/Headers + ln -s A $WORK/iphoneos/${name}.framework/Versions/Current + ln -s Versions/Current/Headers $WORK/iphoneos/${name}.framework/Headers + ln -s Versions/Current/${name} $WORK/iphoneos/${name}.framework/${name} + xcrun lipo $TOPDIR/internal/libtor/iphoneos/arm64/lib/${name}.a -create \ + -o $WORK/iphoneos/${name}.framework/Versions/A/${name} + + # Create iphonesimulator/{amd,arm}64 framework. + mkdir -p $WORK/iphonesimulator/${name}.framework/Versions/A/Headers + ln -s A $WORK/iphonesimulator/${name}.framework/Versions/Current + ln -s Versions/Current/Headers $WORK/iphonesimulator/${name}.framework/Headers + ln -s Versions/Current/${name} $WORK/iphonesimulator/${name}.framework/${name} + xcrun lipo $TOPDIR/internal/libtor/iphonesimulator/amd64/lib/${name}.a \ + $TOPDIR/internal/libtor/iphonesimulator/arm64/lib/${name}.a \ + -create -output $WORK/iphonesimulator/${name}.framework/Versions/A/${name} + + # Create a .xcframework. + xcodebuild -create-xcframework -framework /private$WORK/iphoneos/${name}.framework \ + -framework /private$WORK/iphonesimulator/${name}.framework -output MOBILE/ios/${name}.xcframework +} + +make_framework libz +make_framework libcrypto +make_framework libssl +make_framework libevent +make_framework libtor diff --git a/MOBILE/ios/template.podspec b/MOBILE/ios/oonimkall-template.podspec similarity index 92% rename from MOBILE/ios/template.podspec rename to MOBILE/ios/oonimkall-template.podspec index a7b6474d81..23a01de707 100644 --- a/MOBILE/ios/template.podspec +++ b/MOBILE/ios/oonimkall-template.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.summary = "OONI Probe Library for iOS" s.author = "Simone Basso" s.homepage = "https://github.com/ooni/probe-cli" - s.license = { :type => "BSD" } + s.license = { :type => "GPL" } s.source = { :http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/oonimkall.xcframework.zip" } diff --git a/MOBILE/ios/zipframework b/MOBILE/ios/zipframework deleted file mode 100755 index b03601f740..0000000000 --- a/MOBILE/ios/zipframework +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -euxo pipefail -( - cd ./MOBILE/ios - rm -rf oonimkall.xcframework.zip - zip -yr oonimkall.xcframework.zip oonimkall.xcframework -) diff --git a/MOBILE/ios/zipframeworks b/MOBILE/ios/zipframeworks new file mode 100755 index 0000000000..d32b11772d --- /dev/null +++ b/MOBILE/ios/zipframeworks @@ -0,0 +1,9 @@ +#!/bin/bash +set -euxo pipefail +( + cd ./MOBILE/ios + for name in libcrypto libevent libssl libtor libz oonimkall; do + rm -rf ${name}.xcframework.zip + zip -yr ${name}.xcframework.zip ${name}.xcframework + done +) diff --git a/Makefile b/Makefile index 43ddb7b580..026a7adc8e 100644 --- a/Makefile +++ b/Makefile @@ -95,13 +95,14 @@ android: search/for/java ./MOBILE/android/createpom #help: -#help: The `make MOBILE/ios` command builds the oonimkall library for iOS. -.PHONY: MOBILE/ios -MOBILE/ios: search/for/zip search/for/xcode +#help: The `make ios` command builds the oonimkall library for iOS. +.PHONY: ios +ios: search/for/zip search/for/xcode go run ./internal/cmd/buildtool ios cdeps zlib openssl libevent tor go run ./internal/cmd/buildtool ios gomobile - ./MOBILE/ios/zipframework - ./MOBILE/ios/createpodspec + ./MOBILE/ios/make-extra-frameworks + ./MOBILE/ios/zipframeworks + ./MOBILE/ios/createpodspecs .PHONY: search/for/java search/for/java: diff --git a/internal/cmd/buildtool/ios.go b/internal/cmd/buildtool/ios.go index 44af8b54a2..49cb8cbb54 100644 --- a/internal/cmd/buildtool/ios.go +++ b/internal/cmd/buildtool/ios.go @@ -72,16 +72,9 @@ func iosCdepsBuildMain(name string, deps buildtoolmodel.Dependencies) { // The ooni/probe-ios app explicitly only targets amd64 and arm64. It also targets // as the minimum version iOS 12, while one cannot target a version of iOS > 10 when // building for 32-bit targets. Hence, using only 64 bit archs here is fine. - archs := []string{"arm64", "amd64"} - for _, arch := range archs { - iosCdepsBuildArch(deps, arch, name) - } -} - -// iosPlatformForOONIArch maps the ooniArch to the iOS platform -var iosPlatformForOONIArch = map[string]string{ - "amd64": "iphonesimulator", - "arm64": "iphoneos", + iosCdepsBuildArch(deps, name, "iphoneos", "arm64") + iosCdepsBuildArch(deps, name, "iphonesimulator", "arm64") + iosCdepsBuildArch(deps, name, "iphonesimulator", "amd64") } // iosAppleArchForOONIArch maps the ooniArch to the corresponding apple arch @@ -90,22 +83,9 @@ var iosAppleArchForOONIArch = map[string]string{ "arm64": "arm64", } -// iosMinVersionFlagForOONIArch maps the ooniArch to the corresponding compiler flag -// to set the minimum version of either iphoneos or iphonesimulator. -// -// Note: the documentation of clang fetched on 2023-10-12 explicitly mentions that -// ios-version-min is an alias for iphoneos-version-min. Likewise, ios-simulator-version-min -// aliaes iphonesimulator-version-min. -// -// See https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mios-simulator-version-min -var iosMinVersionFlagForOONIArch = map[string]string{ - "amd64": "-miphonesimulator-version-min=", - "arm64": "-miphoneos-version-min=", -} - // iosCdepsBuildArch builds the given dependency for the given arch -func iosCdepsBuildArch(deps buildtoolmodel.Dependencies, ooniArch string, name string) { - cdenv := iosNewCBuildEnv(deps, ooniArch) +func iosCdepsBuildArch(deps buildtoolmodel.Dependencies, name, platform, ooniArch string) { + cdenv := iosNewCBuildEnv(deps, platform, ooniArch) switch name { case "libevent": cdepsLibeventBuildMain(cdenv, deps) @@ -125,19 +105,26 @@ func iosCdepsBuildArch(deps buildtoolmodel.Dependencies, ooniArch string, name s const iosMinVersion = "12.0" // iosNewCBuildEnv creates a new [cBuildEnv] for the given ooniArch ("arm64" or "amd64"). -func iosNewCBuildEnv(deps buildtoolmodel.Dependencies, ooniArch string) *cBuildEnv { +func iosNewCBuildEnv(deps buildtoolmodel.Dependencies, platform, ooniArch string) *cBuildEnv { destdir := runtimex.Try1(filepath.Abs(filepath.Join( // must be absolute - "internal", "libtor", "ios", ooniArch, + "internal", "libtor", platform, ooniArch, ))) var ( - appleArch = iosAppleArchForOONIArch[ooniArch] - minVersionFlag = iosMinVersionFlagForOONIArch[ooniArch] - platform = iosPlatformForOONIArch[ooniArch] + appleArch = iosAppleArchForOONIArch[ooniArch] + + // minVersionFlag sets the correct flag for the compiler depending on whether + // we're using the iphoneos or iphonesimulator platform. + // + // Note: the documentation of clang fetched on 2023-10-12 explicitly mentions that + // ios-version-min is an alias for iphoneos-version-min. Likewise, ios-simulator-version-min + // aliaes iphonesimulator-version-min. + // + // See https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mios-simulator-version-min + minVersionFlag = fmt.Sprintf("-m%s-version-min=", platform) ) runtimex.Assert(appleArch != "", "empty appleArch") runtimex.Assert(minVersionFlag != "", "empty minVersionFlag") - runtimex.Assert(platform != "", "empty platform") isysroot := deps.XCRun("-sdk", platform, "--show-sdk-path") @@ -185,6 +172,8 @@ func iosNewCBuildEnv(deps buildtoolmodel.Dependencies, ooniArch string) *cBuildE switch ooniArch { case "arm64": + // TODO(https://github.com/ooni/probe/issues/2570): using ios64-xcrun here is wrong and + // we should instead use the simulator as discussed in the issue. out.CONFIGURE_HOST = "arm-apple-darwin" out.OPENSSL_COMPILER = "ios64-xcrun" case "amd64": diff --git a/internal/cmd/buildtool/ios_test.go b/internal/cmd/buildtool/ios_test.go index 7f622a0d7b..13cc46bc88 100644 --- a/internal/cmd/buildtool/ios_test.go +++ b/internal/cmd/buildtool/ios_test.go @@ -178,18 +178,72 @@ func TestIOSBuildCdepsZlib(t *testing.T) { Env: []string{}, Argv: []string{ "make", - "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64", + "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64", "install", }, }, { Env: []string{}, Argv: []string{ - "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/pkgconfig", + "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/pkgconfig", }, }, { Env: []string{}, Argv: []string{ - "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/share", + "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/share", + }, + }, { + Env: []string{}, + Argv: []string{ + "curl", "-fsSLO", "https://zlib.net/zlib-1.3.tar.gz", + }, + }, { + Env: []string{}, + Argv: []string{ + "tar", "-xf", "zlib-1.3.tar.gz", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/zlib/000.patch", + }, + }, { + Env: []string{ + "AR=/Developer/SDKs/iphonesimulator/bin/ar", + "AS=/Developer/SDKs/iphonesimulator/bin/as", + "CC=/Developer/SDKs/iphonesimulator/bin/cc", + "CFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2", + "CXX=/Developer/SDKs/iphonesimulator/bin/c++", + "CXXFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2", + "LD=/Developer/SDKs/iphonesimulator/bin/ld", + "LDFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode", + "RANLIB=/Developer/SDKs/iphonesimulator/bin/ranlib", + "STRIP=/Developer/SDKs/iphonesimulator/bin/strip", + "CHOST=arm-apple-darwin", + }, + Argv: []string{ + "./configure", "--prefix=/", "--static", + }, + }, { + Env: []string{}, + Argv: []string{ + "make", "-j", strconv.Itoa(runtime.NumCPU()), + }, + }, { + Env: []string{}, + Argv: []string{ + "make", + "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64", + "install", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/pkgconfig", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/share", }, }, { Env: []string{}, @@ -232,18 +286,18 @@ func TestIOSBuildCdepsZlib(t *testing.T) { Env: []string{}, Argv: []string{ "make", - "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64", + "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64", "install", }, }, { Env: []string{}, Argv: []string{ - "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/pkgconfig", + "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/pkgconfig", }, }, { Env: []string{}, Argv: []string{ - "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/share", + "rm", "-rf", faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/share", }, }}, }} @@ -262,9 +316,9 @@ func TestIOSBuildCdepsZlib(t *testing.T) { }) expectCalls := map[string]int{ - buildtooltest.TagAbsoluteCurDir: 2, - buildtooltest.TagMustChdir: 2, - buildtooltest.TagVerifySHA256: 2, + buildtooltest.TagAbsoluteCurDir: 3, + buildtooltest.TagMustChdir: 3, + buildtooltest.TagVerifySHA256: 3, } if diff := cmp.Diff(expectCalls, deps.Counter); diff != "" { @@ -339,7 +393,57 @@ func TestIOSBuildCdepsOpenSSL(t *testing.T) { Env: []string{}, Argv: []string{ "make", - "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64", + "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64", + "install_dev", + }, + }, { + Env: []string{}, + Argv: []string{ + "curl", "-fsSLO", "https://www.openssl.org/source/openssl-3.1.3.tar.gz", + }, + }, { + Env: []string{}, + Argv: []string{ + "tar", "-xf", "openssl-3.1.3.tar.gz", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/openssl/000.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/openssl/001.patch", + }, + }, { + Env: []string{ + "CFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2 -Wno-macro-redefined", + "LDFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode", + "CXXFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2 -Wno-macro-redefined", + }, + Argv: []string{ + "./Configure", "no-comp", "no-dtls", "no-ec2m", "no-psk", "no-srp", + "no-ssl3", "no-camellia", "no-idea", "no-md2", "no-md4", "no-mdc2", + "no-rc2", "no-rc4", "no-rc5", "no-rmd160", "no-whirlpool", "no-dso", + "no-ui-console", "no-shared", "no-unit-test", "ios64-xcrun", + "-miphonesimulator-version-min=12.0", "-fembed-bitcode", + "--libdir=lib", "--prefix=/", "--openssldir=/", + }, + }, { + Env: []string{ + "CFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2 -Wno-macro-redefined", + "LDFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode", + "CXXFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2 -Wno-macro-redefined", + }, + Argv: []string{ + "make", "-j", strconv.Itoa(runtime.NumCPU()), + }, + }, { + Env: []string{}, + Argv: []string{ + "make", + "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64", "install_dev", }, }, { @@ -389,7 +493,7 @@ func TestIOSBuildCdepsOpenSSL(t *testing.T) { Env: []string{}, Argv: []string{ "make", - "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64", + "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64", "install_dev", }, }}, @@ -409,9 +513,9 @@ func TestIOSBuildCdepsOpenSSL(t *testing.T) { }) expectCalls := map[string]int{ - buildtooltest.TagAbsoluteCurDir: 2, - buildtooltest.TagMustChdir: 2, - buildtooltest.TagVerifySHA256: 2, + buildtooltest.TagAbsoluteCurDir: 3, + buildtooltest.TagMustChdir: 3, + buildtooltest.TagVerifySHA256: 3, } if diff := cmp.Diff(expectCalls, deps.Counter); diff != "" { @@ -483,19 +587,19 @@ func TestIOSBuildCdepsLibevent(t *testing.T) { fmt.Sprintf( "%s %s", "LDFLAGS=-isysroot /Developer/SDKs/iphoneos -miphoneos-version-min=12.0 -arch arm64 -fembed-bitcode", - "-L"+faketopdir+"/internal/cmd/buildtool/internal/libtor/ios/arm64/lib", + "-L"+faketopdir+"/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib", ), fmt.Sprintf( "%s %s", "CFLAGS=-isysroot /Developer/SDKs/iphoneos -miphoneos-version-min=12.0 -arch arm64 -fembed-bitcode -O2", - "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/ios/arm64/include", + "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/include", ), fmt.Sprintf( "%s %s", "CXXFLAGS=-isysroot /Developer/SDKs/iphoneos -miphoneos-version-min=12.0 -arch arm64 -fembed-bitcode -O2", - "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/ios/arm64/include", + "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/include", ), - "PKG_CONFIG_PATH=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/pkgconfig", + "PKG_CONFIG_PATH=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/pkgconfig", }, Argv: []string{ "./configure", @@ -514,7 +618,7 @@ func TestIOSBuildCdepsLibevent(t *testing.T) { Env: []string{}, Argv: []string{ "make", - "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64", + "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64", "install", }, }, { @@ -522,105 +626,288 @@ func TestIOSBuildCdepsLibevent(t *testing.T) { Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/bin", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/bin", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/pkgconfig/libevent.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/pkgconfig/libevent.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/pkgconfig/libevent_core.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/pkgconfig/libevent_core.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/pkgconfig/libevent_extra.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/pkgconfig/libevent_extra.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/pkgconfig/libevent_openssl.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/pkgconfig/libevent_openssl.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/pkgconfig/libevent_pthreads.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/pkgconfig/libevent_pthreads.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/libevent.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/libevent.la", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/libevent_core.a", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/libevent_core.a", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/libevent_core.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/libevent_core.la", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/libevent_extra.a", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/libevent_extra.a", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/libevent_extra.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/libevent_extra.la", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/libevent_openssl.a", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/libevent_openssl.a", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/libevent_openssl.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/libevent_openssl.la", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/libevent_pthreads.a", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/libevent_pthreads.a", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib/libevent_pthreads.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib/libevent_pthreads.la", + }, + }, { + Env: []string{}, + Argv: []string{ + "curl", + "-fsSLO", + "https://github.com/libevent/libevent/archive/release-2.1.12-stable.tar.gz", + }, + }, { + Env: []string{}, + Argv: []string{ + "tar", "-xf", "release-2.1.12-stable.tar.gz", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/libevent/000.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/libevent/001.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/libevent/002.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "./autogen.sh", + }, + }, { + Env: []string{ + "AS=/Developer/SDKs/iphonesimulator/bin/as", + "LD=/Developer/SDKs/iphonesimulator/bin/ld", + "CXX=/Developer/SDKs/iphonesimulator/bin/c++", + "CC=/Developer/SDKs/iphonesimulator/bin/cc", + "AR=/Developer/SDKs/iphonesimulator/bin/ar", + "RANLIB=/Developer/SDKs/iphonesimulator/bin/ranlib", + "STRIP=/Developer/SDKs/iphonesimulator/bin/strip", + fmt.Sprintf( + "%s %s", + "LDFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode", + "-L"+faketopdir+"/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib", + ), + fmt.Sprintf( + "%s %s", + "CFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2", + "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/include", + ), + fmt.Sprintf( + "%s %s", + "CXXFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2", + "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/include", + ), + "PKG_CONFIG_PATH=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/pkgconfig", + }, + Argv: []string{ + "./configure", + "--host=arm-apple-darwin", + "--disable-libevent-regress", + "--disable-samples", + "--disable-shared", + "--prefix=/", + }, + }, { + Env: []string{}, + Argv: []string{ + "make", "V=1", "-j", strconv.Itoa(runtime.NumCPU()), + }, + }, { + Env: []string{}, + Argv: []string{ + "make", + "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64", + "install", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/bin", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/pkgconfig/libevent.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/pkgconfig/libevent_core.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/pkgconfig/libevent_extra.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/pkgconfig/libevent_openssl.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-f", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/pkgconfig/libevent_pthreads.pc", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/libevent.la", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/libevent_core.a", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/libevent_core.la", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/libevent_extra.a", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/libevent_extra.la", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/libevent_openssl.a", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/libevent_openssl.la", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/libevent_pthreads.a", + }, + }, { + Env: []string{}, + Argv: []string{ + "rm", + "-rf", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib/libevent_pthreads.la", }, }, { Env: []string{}, @@ -666,19 +953,19 @@ func TestIOSBuildCdepsLibevent(t *testing.T) { fmt.Sprintf( "%s %s", "LDFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch x86_64 -fembed-bitcode", - "-L"+faketopdir+"/internal/cmd/buildtool/internal/libtor/ios/amd64/lib", + "-L"+faketopdir+"/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib", ), fmt.Sprintf( "%s %s", "CFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch x86_64 -fembed-bitcode -O2", - "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/ios/amd64/include", + "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/include", ), fmt.Sprintf( "%s %s", "CXXFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch x86_64 -fembed-bitcode -O2", - "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/ios/amd64/include", + "-I"+faketopdir+"/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/include", ), - "PKG_CONFIG_PATH=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/pkgconfig", + "PKG_CONFIG_PATH=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/pkgconfig", }, Argv: []string{ "./configure", @@ -697,7 +984,7 @@ func TestIOSBuildCdepsLibevent(t *testing.T) { Env: []string{}, Argv: []string{ "make", - "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64", + "DESTDIR=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64", "install", }, }, { @@ -705,105 +992,105 @@ func TestIOSBuildCdepsLibevent(t *testing.T) { Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/bin", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/bin", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/pkgconfig/libevent.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/pkgconfig/libevent.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/pkgconfig/libevent_core.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/pkgconfig/libevent_core.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/pkgconfig/libevent_extra.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/pkgconfig/libevent_extra.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/pkgconfig/libevent_openssl.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/pkgconfig/libevent_openssl.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-f", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/pkgconfig/libevent_pthreads.pc", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/pkgconfig/libevent_pthreads.pc", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/libevent.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/libevent.la", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/libevent_core.a", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/libevent_core.a", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/libevent_core.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/libevent_core.la", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/libevent_extra.a", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/libevent_extra.a", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/libevent_extra.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/libevent_extra.la", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/libevent_openssl.a", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/libevent_openssl.a", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/libevent_openssl.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/libevent_openssl.la", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/libevent_pthreads.a", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/libevent_pthreads.a", }, }, { Env: []string{}, Argv: []string{ "rm", "-rf", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib/libevent_pthreads.la", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib/libevent_pthreads.la", }, }}, }} @@ -822,9 +1109,9 @@ func TestIOSBuildCdepsLibevent(t *testing.T) { }) expectCalls := map[string]int{ - buildtooltest.TagAbsoluteCurDir: 2, - buildtooltest.TagMustChdir: 2, - buildtooltest.TagVerifySHA256: 2, + buildtooltest.TagAbsoluteCurDir: 3, + buildtooltest.TagMustChdir: 3, + buildtooltest.TagVerifySHA256: 3, } if diff := cmp.Diff(expectCalls, deps.Counter); diff != "" { @@ -900,11 +1187,89 @@ func TestIOSBuildCdepsTor(t *testing.T) { "--host=arm-apple-darwin", "--enable-pic", "--enable-static-libevent", - "--with-libevent-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64", + "--with-libevent-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64", + "--enable-static-openssl", + "--with-openssl-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64", + "--enable-static-zlib", + "--with-zlib-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64", + "--disable-module-dirauth", + "--disable-zstd", + "--disable-lzma", + "--disable-tool-name-check", + "--disable-systemd", + "--prefix=/", + "--disable-unittests", + }, + }, { + Env: []string{}, + Argv: []string{ + "make", "V=1", "-j", strconv.Itoa(runtime.NumCPU()), + }, + }, { + Env: []string{}, + Argv: []string{ + "install", "-m644", "src/feature/api/tor_api.h", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/include", + }, + }, { + Env: []string{}, + Argv: []string{ + "install", "-m644", "libtor.a", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphoneos/arm64/lib", + }, + }, { + Env: []string{}, + Argv: []string{ + "curl", "-fsSLO", "https://www.torproject.org/dist/tor-0.4.8.7.tar.gz", + }, + }, { + Env: []string{}, + Argv: []string{ + "tar", "-xf", "tor-0.4.8.7.tar.gz", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/000.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/001.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/002.patch", + }, + }, { + Env: []string{}, + Argv: []string{ + "git", "apply", faketopdir + "/CDEPS/tor/003.patch", + }, + }, { + Env: []string{ + "AS=/Developer/SDKs/iphonesimulator/bin/as", + "CC=/Developer/SDKs/iphonesimulator/bin/cc", + "RANLIB=/Developer/SDKs/iphonesimulator/bin/ranlib", + "STRIP=/Developer/SDKs/iphonesimulator/bin/strip", + "CXXFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2", + "CFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode -O2", + "LDFLAGS=-isysroot /Developer/SDKs/iphonesimulator -miphonesimulator-version-min=12.0 -arch arm64 -fembed-bitcode", + "CXX=/Developer/SDKs/iphonesimulator/bin/c++", + "LD=/Developer/SDKs/iphonesimulator/bin/ld", + "AR=/Developer/SDKs/iphonesimulator/bin/ar", + }, + Argv: []string{ + "./configure", + "--host=arm-apple-darwin", + "--enable-pic", + "--enable-static-libevent", + "--with-libevent-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64", "--enable-static-openssl", - "--with-openssl-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64", + "--with-openssl-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64", "--enable-static-zlib", - "--with-zlib-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64", + "--with-zlib-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64", "--disable-module-dirauth", "--disable-zstd", "--disable-lzma", @@ -922,13 +1287,13 @@ func TestIOSBuildCdepsTor(t *testing.T) { Env: []string{}, Argv: []string{ "install", "-m644", "src/feature/api/tor_api.h", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/include", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/include", }, }, { Env: []string{}, Argv: []string{ "install", "-m644", "libtor.a", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/arm64/lib", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/arm64/lib", }, }, { Env: []string{}, @@ -978,11 +1343,11 @@ func TestIOSBuildCdepsTor(t *testing.T) { "--host=x86_64-apple-darwin", "--enable-pic", "--enable-static-libevent", - "--with-libevent-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64", + "--with-libevent-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64", "--enable-static-openssl", - "--with-openssl-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64", + "--with-openssl-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64", "--enable-static-zlib", - "--with-zlib-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64", + "--with-zlib-dir=" + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64", "--disable-module-dirauth", "--disable-zstd", "--disable-lzma", @@ -1000,13 +1365,13 @@ func TestIOSBuildCdepsTor(t *testing.T) { Env: []string{}, Argv: []string{ "install", "-m644", "src/feature/api/tor_api.h", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/include", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/include", }, }, { Env: []string{}, Argv: []string{ "install", "-m644", "libtor.a", - faketopdir + "/internal/cmd/buildtool/internal/libtor/ios/amd64/lib", + faketopdir + "/internal/cmd/buildtool/internal/libtor/iphonesimulator/amd64/lib", }, }}, }} @@ -1025,9 +1390,9 @@ func TestIOSBuildCdepsTor(t *testing.T) { }) expectCalls := map[string]int{ - buildtooltest.TagAbsoluteCurDir: 2, - buildtooltest.TagMustChdir: 2, - buildtooltest.TagVerifySHA256: 2, + buildtooltest.TagAbsoluteCurDir: 3, + buildtooltest.TagMustChdir: 3, + buildtooltest.TagVerifySHA256: 3, } if diff := cmp.Diff(expectCalls, deps.Counter); diff != "" { diff --git a/internal/cmd/ghgen/ios.go b/internal/cmd/ghgen/ios.go index 08a359a3ad..2a0068419a 100644 --- a/internal/cmd/ghgen/ios.go +++ b/internal/cmd/ghgen/ios.go @@ -15,6 +15,16 @@ func buildAndPublishMobileIOS(w io.Writer, job *Job) { buildJob := "build_ios_mobile" artifacts := []string{ + "./MOBILE/ios/libcrypto.xcframework.zip", + "./MOBILE/ios/libcrypto.podspec", + "./MOBILE/ios/libevent.xcframework.zip", + "./MOBILE/ios/libevent.podspec", + "./MOBILE/ios/libssl.xcframework.zip", + "./MOBILE/ios/libssl.podspec", + "./MOBILE/ios/libtor.xcframework.zip", + "./MOBILE/ios/libtor.podspec", + "./MOBILE/ios/libz.xcframework.zip", + "./MOBILE/ios/libz.podspec", "./MOBILE/ios/oonimkall.xcframework.zip", "./MOBILE/ios/oonimkall.podspec", } @@ -24,7 +34,8 @@ func buildAndPublishMobileIOS(w io.Writer, job *Job) { newStepCheckout(w) newStepSetupGo(w, "ios") newStepSetupPsiphon(w) - newStepMake(w, "EXPECTED_XCODE_VERSION=14.2 MOBILE/ios") + iosNewStepBrewInstall(w) + newStepMake(w, "EXPECTED_XCODE_VERSION=14.2 ios") newStepUploadArtifacts(w, artifacts) newJob(w, publishJob, runsOnUbuntu, buildJob, contentsWritePermissions) @@ -32,3 +43,9 @@ func buildAndPublishMobileIOS(w io.Writer, job *Job) { newStepDownloadArtifacts(w, artifacts) newStepGHPublish(w, artifacts) } + +func iosNewStepBrewInstall(w io.Writer) { + mustFprintf(w, " # ./internal/cmd/buildtool needs coreutils for sha256 plus GNU build tools\n") + mustFprintf(w, " - run: brew install autoconf automake coreutils libtool\n") + mustFprintf(w, "\n") +} diff --git a/internal/libtor/enabled.go b/internal/libtor/enabled.go index f29619fd20..89298fcd9c 100644 --- a/internal/libtor/enabled.go +++ b/internal/libtor/enabled.go @@ -18,16 +18,36 @@ package libtor // #cgo android,amd64 CFLAGS: -I${SRCDIR}/android/amd64/include // #cgo android,amd64 LDFLAGS: -L${SRCDIR}/android/amd64/lib -ltor -levent -lssl -lcrypto -lz -lm // -// #cgo ios,arm64 CFLAGS: -I${SRCDIR}/ios/arm64/include -// #cgo ios,arm64 LDFLAGS: -L${SRCDIR}/ios/arm64/lib -ltor -levent -lssl -lcrypto -lz -lm -// #cgo ios,amd64 CFLAGS: -I${SRCDIR}/ios/amd64/include -// #cgo ios,amd64 LDFLAGS: -L${SRCDIR}/ios/amd64/lib -ltor -levent -lssl -lcrypto -lz -lm +// #cgo ios CFLAGS: -I${SRCDIR} // // #include // #include // #include // -// #include +// /* Select the correct header depending on the Apple's platform and architecture, otherwise, for +// other operating systems just use the header in the include path defined above. +// +// See https://stackoverflow.com/a/18729350 for details. */ +// #if defined(__APPLE__) && defined(__MACH__) +// #include +// #if TARGET_OS_IPHONE && TARGET_OS_SIMULATOR +// #if TARGET_CPU_X86_64 +// #include +// #elif TARGET_CPU_ARM64 +// #include +// #else +// #error "internal/libtor/enabled.go: unhandled Apple architecture" +// #endif +// #elif TARGET_OS_IPHONE && TARGET_OS_MACCATALYST +// #error "internal/libtor/enabled.go: unhandled Apple platform" +// #elif TARGET_OS_IPHONE +// #include +// #else +// #error "internal/libtor/enabled.go: unhandled Apple platform" +// #endif +// #else +// #include +// #endif // // /* Note: we need to define inline helpers because we cannot index C arrays in Go. */ // diff --git a/internal/libtor/ios/amd64/.gitignore b/internal/libtor/iphoneos/arm64/.gitignore similarity index 100% rename from internal/libtor/ios/amd64/.gitignore rename to internal/libtor/iphoneos/arm64/.gitignore diff --git a/internal/libtor/ios/arm64/.gitignore b/internal/libtor/iphonesimulator/amd64/.gitignore similarity index 100% rename from internal/libtor/ios/arm64/.gitignore rename to internal/libtor/iphonesimulator/amd64/.gitignore diff --git a/internal/libtor/iphonesimulator/arm64/.gitignore b/internal/libtor/iphonesimulator/arm64/.gitignore new file mode 100644 index 0000000000..f32e7dc720 --- /dev/null +++ b/internal/libtor/iphonesimulator/arm64/.gitignore @@ -0,0 +1,2 @@ +/include +/lib