diff --git a/.gitignore b/.gitignore index d215838836..d96b8ed5e2 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ target /build/bin/* !/build/bin/geth.aar /geth*.zip +ndk_bundle # travis profile.tmp diff --git a/CeloBlockchain.podspec b/CeloBlockchain.podspec new file mode 100644 index 0000000000..9f9660d9c6 --- /dev/null +++ b/CeloBlockchain.podspec @@ -0,0 +1,16 @@ +require 'json' + +package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) + +Pod::Spec.new do |s| + s.name = 'CeloBlockchain' + s.version = package['version'] + s.license = package['license'] + s.homepage = package['homepage'] + s.authors = { 'Connor McEwen' => 'c@celo.org' } + s.summary = package['description'] + s.source = { :git => package['repository']['url'], :tag => s.version } + s.source_files = 'build/bin/Geth.framework/**/*.h', 'Empty.m' + s.vendored_libraries = 'libGeth.a', 'vendor/github.com/celo-org/bls-zexe/bls/target/universal/release/libbls_zexe.a' + s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-ObjC' } +end diff --git a/Makefile b/Makefile index 78f454df6b..2f8fe77418 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ GO ?= latest CARGO_exists := $(shell command -v cargo 2> /dev/null) RUSTUP_exists := $(shell command -v rustup 2> /dev/null) +CARGO_LIPO_exists := $(shell command -v cargo-lipo 2> /dev/null) LSB_exists := $(shell command -v lsb_release 2> /dev/null) OS := @@ -86,6 +87,17 @@ else cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --release --target=x86_64-linux-android --lib endif +bls-zexe-ios: +ifeq ("$(RUSTUP_exists)","") + $(error "No rustup in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md") +else +ifeq ("$(CARGO_LIPO_exists)","") + cargo install cargo-lipo +endif + rustup target add aarch64-apple-ios armv7-apple-ios x86_64-apple-ios i386-apple-ios + cd vendor/github.com/celo-org/bls-zexe/bls && cargo lipo --release --targets=aarch64-apple-ios,armv7-apple-ios,x86_64-apple-ios,i386-apple-ios +endif + vendor/github.com/celo-org/bls-zexe/bls/target/release/libbls_zexe.a: ifeq ("$(CARGO_exists)","") $(error "No cargo in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md") @@ -106,8 +118,9 @@ android: bls-zexe-android @echo "Done building." @echo "Import \"$(GOBIN)/geth.aar\" to use the library." -ios: +ios: bls-zexe-ios build/env.sh go run build/ci.go xcode --local + pushd "$(GOBIN)"; rm -rf Geth.framework.zip; zip -r9y Geth.framework.zip Geth.framework; popd @echo "Done building." @echo "Import \"$(GOBIN)/Geth.framework\" to use the library." diff --git a/build/ci.go b/build/ci.go index f440d2d7ee..7c82477e23 100644 --- a/build/ci.go +++ b/build/ci.go @@ -942,6 +942,8 @@ func doXCodeFramework(cmdline []string) { // Build the iOS XCode framework build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind")) + // Patch gomobile to disable bitcode for now (rust generated bls lib output is not compatible) + build.MustRunCommand("sed", "-i", "", `/^[[:space:]]*cflags += \" -fembed-bitcode\"$/s/^/\/\//`, filepath.Join(build.GOPATH(), "src/golang.org/x/mobile/cmd/gomobile/env.go")) bind := gomobileTool("bind", "-ldflags", "-s -w", "--target", "ios", "--tags", "ios", "-v", "github.com/ethereum/go-ethereum/mobile") if *local { diff --git a/mobile/geth.go b/mobile/geth.go index e0b10ce923..6026d746a9 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -98,6 +98,12 @@ type NodeConfig struct { // scrypt KDF at the expense of security. // See https://geth.ethereum.org/doc/Mobile_Account-management for reference UseLightweightKDF bool + + // IPCPath is the requested location to place the IPC endpoint. If the path is + // a simple file name, it is placed inside the data directory (or on the root + // pipe path on Windows), whereas if it's a resolvable path name (absolute or + // relative), then that specific path is enforced. An empty path disables IPC. + IPCPath string } // defaultNodeConfig contains the default node configuration values to use if all @@ -145,7 +151,7 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) { DataDir: datadir, KeyStoreDir: filepath.Join(datadir, "keystore"), // Mobile should never use internal keystores! UseLightweightKDF: config.UseLightweightKDF, - IPCPath: "geth.ipc", + IPCPath: config.IPCPath, P2P: p2p.Config{ NoDiscovery: true, DiscoveryV5: false, diff --git a/package.json b/package.json index d0a31e4eab..e458bd2b46 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,19 @@ "name": "@celo/client", "version": "0.0.1", "description": "Celo client for mobile", + "homepage": "https://celo.org", + "repository": { + "type": "git", + "url": "https://github.com/celo-org/celo-blockchain.git" + }, + "license": "LGPL-3.0", "files": [ - "build/bin/geth.aar" - ] + "build/bin/geth.aar", + "build/bin/Geth.framework.zip", + "CeloBlockchain.podspec", + "vendor/github.com/celo-org/bls-zexe/bls/target/universal/release/libbls_zexe.a" + ], + "scripts": { + "postinstall": "rm -rf build/bin/Geth.framework && unzip build/bin/Geth.framework.zip -d build/bin && touch Empty.m && ln -sf build/bin/Geth.framework/Versions/A/Geth libGeth.a" + } } diff --git a/vendor/github.com/celo-org/bls-zexe/go/bls_ios.go b/vendor/github.com/celo-org/bls-zexe/go/bls_ios.go new file mode 100644 index 0000000000..0e477047c4 --- /dev/null +++ b/vendor/github.com/celo-org/bls-zexe/go/bls_ios.go @@ -0,0 +1,8 @@ +// +build ios + +package bls + +/* +#cgo LDFLAGS: -L../bls/target/universal/release -lbls_zexe -ldl -lm -framework Security -framework Foundation +*/ +import "C"