Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Oct 12, 2023
1 parent c3308c2 commit e69ae11
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 215 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ 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
- run: brew install autoconf automake coreutils libtool

- run: make EXPECTED_XCODE_VERSION=14.2 MOBILE/ios

- uses: actions/upload-artifact@v3
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ android: search/for/java
#help: The `make MOBILE/ios` command builds the oonimkall library for iOS.
.PHONY: MOBILE/ios
MOBILE/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
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/miekg/dns v1.1.56
github.com/mitchellh/go-wordwrap v1.0.1
github.com/montanaflynn/stats v0.7.1
github.com/ooni/go-libtor v1.1.8
github.com/ooni/netem v0.0.0-20230920215742-15f3ffec0107
github.com/ooni/oocrypto v0.5.5
github.com/ooni/oohttp v0.6.5
Expand Down Expand Up @@ -144,9 +145,9 @@ require (
github.com/xtaci/kcp-go/v5 v5.6.2 // indirect
github.com/xtaci/smux v1.5.24 // indirect
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
14 changes: 9 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/cretz/bine v0.1.0/go.mod h1:6PF6fWAvYtwjRGkAuDEJeWNOv3a2hUouSP/yRYXmvHw=
github.com/cretz/bine v0.2.0 h1:8GiDRGlTgz+o8H9DSnsl+5MeBK4HsExxgl6WgzOCuZo=
github.com/cretz/bine v0.2.0/go.mod h1:WU4o9QR9wWp8AVKtTM1XD5vUHkEqnf2vVSo6dBqbetI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -321,6 +322,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
github.com/ooni/go-libtor v1.1.8 h1:Wo3V3DVTxl5vZdxtQakqYP+DAHx7pPtAFSl1bnAa08w=
github.com/ooni/go-libtor v1.1.8/go.mod h1:q1YyLwRD9GeMyeerVvwc0vJ2YgwDLTp2bdVcrh/JXyI=
github.com/ooni/netem v0.0.0-20230920215742-15f3ffec0107 h1:PktaCPQ1NYZOaK+J8pQGYiPCYFkGR5H3ZURg9zPkQsI=
github.com/ooni/netem v0.0.0-20230920215742-15f3ffec0107/go.mod h1:5X3Lk4+cnrwrQiYgRlCWXgV33IMDgLaO5s1x0DD/fO0=
github.com/ooni/oocrypto v0.5.5 h1:x0wIgtBfghVu8Ok0tR/xVyfHlo646hN1LB/5bzuXcIg=
Expand Down Expand Up @@ -547,6 +550,7 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down Expand Up @@ -584,8 +588,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -622,7 +626,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -714,8 +718,8 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
4 changes: 0 additions & 4 deletions internal/cmd/buildtool/builddeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,3 @@ func (*buildDeps) GOOS() string {
func (*buildDeps) VerifySHA256(expectedSHA256 string, tarball string) {
cdepsMustVerifySHA256(expectedSHA256, tarball)
}

func (*buildDeps) XCRun(args ...string) string {
return iosXCRun(args...)
}
4 changes: 0 additions & 4 deletions internal/cmd/buildtool/cdepslibevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ func cdepsLibeventBuildMain(globalEnv *cBuildEnv, deps buildtoolmodel.Dependenci
}
envp := cBuildExportAutotools(cBuildMerge(globalEnv, localEnv))

// On iOS, we need PKG_CONFIG_PATH to convince libevent to use the OpenSSL we built but]
// always letting libevent's configure be pkgconfig aware would probably be fine
envp.Append("PKG_CONFIG_PATH", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig"))

argv := runtimex.Try1(shellx.NewArgv("./configure"))
if globalEnv.CONFIGURE_HOST != "" {
argv.Append("--host=" + globalEnv.CONFIGURE_HOST)
Expand Down
4 changes: 1 addition & 3 deletions internal/cmd/buildtool/cdepsopenssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,5 @@ func cdepsOpenSSLBuildMain(globalEnv *cBuildEnv, deps buildtoolmodel.Dependencie
))

must.Run(log.Log, "make", "DESTDIR="+globalEnv.DESTDIR, "install_dev")

// FIXME: we need to explain this change
//must.Run(log.Log, "rm", "-rf", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig"))
must.Run(log.Log, "rm", "-rf", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,3 @@ func (cc *DependenciesCallCounter) increment(name string) {
}
cc.Counter[name]++
}

// XCRun implements buildtoolmodel.Dependencies.
func (*DependenciesCallCounter) XCRun(args ...string) string {
panic("unimplemented") // TODO(bassosimone): implement this function
}
177 changes: 0 additions & 177 deletions internal/cmd/buildtool/ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ package main
//

import (
"errors"
"fmt"
"path/filepath"
"runtime"

"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/cmd/buildtool/internal/buildtoolmodel"
"github.com/ooni/probe-cli/v3/internal/must"
"github.com/ooni/probe-cli/v3/internal/runtimex"
"github.com/ooni/probe-cli/v3/internal/shellx"
"github.com/spf13/cobra"
)
Expand All @@ -24,26 +19,13 @@ func iosSubcommand() *cobra.Command {
Use: "ios",
Short: "Builds oonimkall and its dependencies for iOS",
}

cmd.AddCommand(&cobra.Command{
Use: "gomobile",
Short: "Builds oonimkall for iOS using gomobile",
Run: func(cmd *cobra.Command, args []string) {
iosBuildGomobile(&buildDeps{})
},
})

cmd.AddCommand(&cobra.Command{
Use: "cdeps {zlib|openssl|libevent|tor} [zlib|openssl|libevent|tor...]",
Short: "Cross compiles C dependencies for iOS",
Run: func(cmd *cobra.Command, args []string) {
for _, arg := range args {
iosCdepsBuildMain(arg, &buildDeps{})
}
},
Args: cobra.MinimumNArgs(1),
})

return cmd
}

Expand All @@ -59,165 +41,6 @@ func iosBuildGomobile(deps buildtoolmodel.Dependencies) {
output: filepath.Join("MOBILE", "ios", "oonimkall.xcframework"),
target: "ios",
}

log.Info("building the mobile library using gomobile")
gomobileBuild(config)
}

// iosCdepsBuildMain builds C dependencies for ios.
func iosCdepsBuildMain(name string, deps buildtoolmodel.Dependencies) {
runtimex.Assert(
runtime.GOOS == "darwin",
"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"}
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{
"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.
var iosMinVersionFlagForOONIArch = map[string]string{
"386": "-mios-simulator-version-min=",
"amd64": "-mios-simulator-version-min=",
"arm": "-miphoneos-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)
switch name {
case "libevent":
cdepsLibeventBuildMain(cdenv, deps)
case "openssl":
cdepsOpenSSLBuildMain(cdenv, deps)
case "tor":
cdepsTorBuildMain(cdenv, deps)
case "zlib":
cdepsZlibBuildMain(cdenv, deps)
default:
panic(fmt.Errorf("unknown dependency: %s", name))
}
}

// 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"

// iosNewCBuildEnv creates a new [cBuildEnv] for the given ooniArch ("arm", "arm64", "386", "amd64").
func iosNewCBuildEnv(deps buildtoolmodel.Dependencies, ooniArch string) *cBuildEnv {
destdir := runtimex.Try1(filepath.Abs(filepath.Join( // must be absolute
"internal", "libtor", "ios", ooniArch,
)))

var (
appleArch = iosAppleArchForOONIArch[ooniArch]
minVersionFlag = iosMinVersionFlagForOONIArch[ooniArch]
platform = iosPlatformForOONIArch[ooniArch]
)
runtimex.Assert(appleArch != "", "empty appleArch")
runtimex.Assert(minVersionFlag != "", "empty minVersionFlag")
runtimex.Assert(platform != "", "empty platform")

isysroot := deps.XCRun("-sdk", platform, "--show-sdk-path")

out := &cBuildEnv{
ANDROID_HOME: "", // not needed
ANDROID_NDK_ROOT: "", // not needed
AS: deps.XCRun("-find", "-sdk", platform, "as"),
AR: deps.XCRun("-find", "-sdk", platform, "ar"),
BINPATH: "", // not needed
CC: deps.XCRun("-find", "-sdk", platform, "cc"),
CFLAGS: []string{
"-isysroot", isysroot,
minVersionFlag + iosMinVersion, // tricky: they must be concatenated
"-O2",
"-arch", appleArch,
"-fembed-bitcode",
},
CONFIGURE_HOST: "", // later
DESTDIR: destdir,
CXX: deps.XCRun("-find", "-sdk", platform, "c++"),
CXXFLAGS: []string{
"-isysroot", isysroot,
minVersionFlag + iosMinVersion, // tricky: they must be concatenated
"-arch", appleArch,
"-fembed-bitcode",
"-O2",
},
GOARCH: ooniArch,
GOARM: "", // maybe later
LD: deps.XCRun("-find", "-sdk", platform, "ld"),
LDFLAGS: []string{
"-isysroot", isysroot,
minVersionFlag + iosMinVersion, // tricky: they must be concatenated
"-arch", appleArch,
"-fembed-bitcode",
},
OPENSSL_COMPILER: "", // later
OPENSSL_POST_COMPILER_FLAGS: []string{
minVersionFlag + iosMinVersion, // tricky: they must be concatenated
"-fembed-bitcode",
},
RANLIB: deps.XCRun("-find", "-sdk", platform, "ranlib"),
STRIP: deps.XCRun("-find", "-sdk", platform, "strip"),
}

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 = ""
out.OPENSSL_COMPILER = "iossimulator-xcrun"
default:
panic(errors.New("unsupported ooniArch"))
}

return out
}

// iosXCRun invokes `xcrun [args]` and returns its result of panics. This function
// is called indirectly by the iOS build through [buildtoolmodel.Dependencies].
func iosXCRun(args ...string) string {
return string(must.FirstLineBytes(must.RunOutput(log.Log, "xcrun", args...)))
}
5 changes: 0 additions & 5 deletions internal/libtor/enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ 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
//
// #include <limits.h>
// #include <stdbool.h>
// #include <stdlib.h>
Expand Down
2 changes: 0 additions & 2 deletions internal/libtor/ios/amd64/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions internal/libtor/ios/arm64/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion internal/tunnel/tordesktop.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ooni_libtor
//go:build !android && !ios && !ooni_libtor

package tunnel

Expand Down
2 changes: 1 addition & 1 deletion internal/tunnel/torembed.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build ooni_libtor
//go:build ooni_libtor && android

package tunnel

Expand Down
Loading

0 comments on commit e69ae11

Please sign in to comment.