mirror of
https://github.com/golang/go
synced 2024-11-05 15:46:11 -07:00
7523baed09
The iOS test harness was recently changed in response to lldb bugs to replace breakpoints with the SIGUSR2 signal (CL 34926), and to pass the current directory in the test binary arguments (CL 35152). Both the signal sending and working directory setup is done from the go test driver. However, the new method doesn't work with tests where a C program is the test driver instead of go test: the current working directory will not be changed and SIGUSR2 is not raised. Instead of copying that logic into any C test program, rework the test harness (again) to move the setup logic to the early runtime cgo setup code. That way, the harness will run even in the library build modes. Then, use the app Info.plist file to pass the working directory, removing the need to alter the arguments after running. Finally, use the SIGINT signal instead of SIGUSR2 to avoid manipulating the signal masks or handlers. Fixes the testcarchive tests on iOS. With this CL, both darwin/arm and darwin/arm64 passes all.bash. This CL replaces CL 34926, CL 35152 as well as the fixup CL 35123 and CL 35255. They are reverted in CLs earlier in the relation chain. Change-Id: I8485c7db1404fbd8daa261efd1ea89e905121a3e Reviewed-on: https://go-review.googlesource.com/36090 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org> |
||
---|---|---|
.. | ||
clangwrap.sh | ||
detect.go | ||
go_darwin_arm_exec.go | ||
README |
Go on iOS ========= To build a cross compiling toolchain for iOS on OS X, first modify clangwrap.sh in misc/ios to match your setup. And then run: GOARM=7 CGO_ENABLED=1 GOARCH=arm CC_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh \ CXX_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh ./make.bash To build a program, use the normal go build command: CGO_ENABLED=1 GOARCH=arm go build import/path To run a program on an iDevice, first make sure you have a valid developer certificate and have setup your iDevice properly to run apps signed by your developer certificate. Then install https://github.com/phonegap/ios-deploy. At a first step, you can try building the famous hello world program to run on your test device. (The needed files are provided at https://github.com/minux/go-ios-examples.) # assume your program binary is helloworld.go, build it into the # example hello.app bundle. CGO_ENABLED=1 GOARCH=arm go build -o hello.app/hello helloworld.go # sign the executable using your developer certificate codesign -f -s "iPhone Developer" --entitlements hello.app/Entitlements.plist hello.app/hello # run the program inside lldb on iDevice, run `ios-deploy` for more # command options ios-deploy --debug --uninstall --bundle hello.app # Depending on your ios-deploy version, you might need to enter "run" # into lldb to run your program, and its output will be shown by lldb. Notes: - A dummy hello.app bundle is provided in this directory to help you get started. - Running the program on an iDevice requires code sign and thus external linking, if your program uses cgo, then it will automatically use external linking. However, if your program does not use cgo, please make sure to add import _ "runtime/cgo" so that external linking will be used. Known issues ============ - crypto/x509 won't build, I don't yet know how to get system root on iOS. - Because I still want to be able to do native build, CGO_ENABLED=1 is not the default, yet.