Skip to content

Commit

Permalink
[ci skip] x
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Oct 12, 2023
1 parent c841657 commit b332665
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
PSIPHON_CONFIG_KEY: ${{ secrets.PSIPHON_CONFIG_KEY }}
PSIPHON_CONFIG_JSON_AGE_BASE64: ${{ secrets.PSIPHON_CONFIG_JSON_AGE_BASE64 }}
# we need coreutils for sha256 plus a bunch of GNU build tools
# ./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
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/buildtool/builddeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (*buildDeps) VerifySHA256(expectedSHA256 string, tarball string) {
cdepsMustVerifySHA256(expectedSHA256, tarball)
}

// XCRun implements buildtoolmodel.Dependencies
func (*buildDeps) XCRun(args ...string) string {
return iosXCRun(args...)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ type Dependencies interface {
// WindowsMingwCheck makes sure we're using the
// expected version of mingw-w64.
WindowsMingwCheck()

// XCRun executes Xcode's xcrun tool with the given arguments and returns
// the output emitted by xcrun or panics on failure.
XCRun(args ...string) string
}
16 changes: 15 additions & 1 deletion internal/cmd/buildtool/internal/buildtooltest/buildtooltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,19 @@ func (cc *DependenciesCallCounter) increment(name string) {

// XCRun implements buildtoolmodel.Dependencies.
func (*DependenciesCallCounter) XCRun(args ...string) string {
panic("unimplemented") // TODO(bassosimone): implement this function
runtimex.Assert(len(args) >= 1, "expected at least one argument")
switch args[0] {
case "-sdk":
runtimex.Assert(len(args) == 3, "expected three arguments")
runtimex.Assert(args[2] == "--show-sdk-path", "the third argument must be --show-sdk-path")
return filepath.Join("Developer", "SDKs", args[1])

case "-find":
runtimex.Assert(len(args) == 4, "expected four arguments")
runtimex.Assert(args[1] == "-sdk", "the second argument must be -sdk")
return filepath.Join("Developer", "SDKs", args[2], "bin", args[3])

default:
panic(errors.New("the first argument must be -sdk or -find"))
}
}
39 changes: 12 additions & 27 deletions internal/cmd/buildtool/ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ func iosCdepsBuildMain(name string, deps buildtoolmodel.Dependencies) {
"this command requires darwin or linux",
)

// The assembly of the arm version is broken for unknown reasons
//archs := []string{"arm", "arm64", "386", "amd64"}
// It seems there's no support for 386?
//archs := []string{"arm64", "386", "amd64"}
// 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)
Expand All @@ -83,29 +82,26 @@ func iosCdepsBuildMain(name string, deps buildtoolmodel.Dependencies) {

// iosPlatformForOONIArch maps the ooniArch to the iOS platform
var iosPlatformForOONIArch = map[string]string{
"386": "iphonesimulator",
"amd64": "iphonesimulator",
"arm": "iphoneos",
"arm64": "iphoneos",
}

// iosAppleArchForOONIArch maps the ooniArch to the corresponding apple arch
var iosAppleArchForOONIArch = map[string]string{
"386": "i386",
"amd64": "x86_64",
"arm": "armv7s",
"arm64": "arm64",
}

// iosMinVersionFlagForOONIArch maps the ooniArch to the corresponding compiler flag
// to set the minimum version of either iphoneos or iphonesimulator.
//
// TODO(bassosimone): the OpenSSL build sets -mios-version-min to a very low value
// and I *think* (but I don't *know* whether) these two flags are aliasing each other.
// 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{
"386": "-mios-simulator-version-min=",
"amd64": "-mios-simulator-version-min=",
"arm": "-miphoneos-version-min=",
"amd64": "-miphonesimulator-version-min=",
"arm64": "-miphoneos-version-min=",
}

Expand All @@ -126,12 +122,9 @@ func iosCdepsBuildArch(deps buildtoolmodel.Dependencies, ooniArch string, name s
}
}

// iosMinVersion is the minimum version that we support.
//
// Note: "iOS 10 is the maximum deployment target for 32-bit targets".
//
// See https://stackoverflow.com/questions/47772435.
const iosMinVersion = "10.0"
// iosMinVersion is the minimum version that we support. We're using the
// same value used by the ooni/probe-ios app as of 2023-10.12.
const iosMinVersion = "12.0"

// iosNewCBuildEnv creates a new [cBuildEnv] for the given ooniArch ("arm", "arm64", "386", "amd64").
func iosNewCBuildEnv(deps buildtoolmodel.Dependencies, ooniArch string) *cBuildEnv {
Expand Down Expand Up @@ -193,18 +186,10 @@ func iosNewCBuildEnv(deps buildtoolmodel.Dependencies, ooniArch string) *cBuildE
}

switch ooniArch {
case "arm":
out.CONFIGURE_HOST = "arm-apple-darwin"
out.GOARM = "7"
out.OPENSSL_COMPILER = "ios-xcrun"
case "arm64":
out.CONFIGURE_HOST = "arm-apple-darwin"
out.GOARM = ""
out.OPENSSL_COMPILER = "ios64-xcrun"
case "386":
out.CONFIGURE_HOST = "i386-apple-darwin"
out.GOARM = ""
out.OPENSSL_COMPILER = "iossimulator-i386-xcrun"
case "amd64":
out.CONFIGURE_HOST = "x86_64-apple-darwin"
out.GOARM = ""
Expand Down

0 comments on commit b332665

Please sign in to comment.