Skip to content

Commit ba18576

Browse files
jeanregissertkporter
authored andcommitted
Add iOS build with bls (#528)
1 parent 25523c1 commit ba18576

File tree

7 files changed

+62
-4
lines changed

7 files changed

+62
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ target
2929
/build/bin/*
3030
!/build/bin/geth.aar
3131
/geth*.zip
32+
ndk_bundle
3233

3334
# travis
3435
profile.tmp

CeloBlockchain.podspec

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'json'
2+
3+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4+
5+
Pod::Spec.new do |s|
6+
s.name = 'CeloBlockchain'
7+
s.version = package['version']
8+
s.license = package['license']
9+
s.homepage = package['homepage']
10+
s.authors = { 'Connor McEwen' => '[email protected]' }
11+
s.summary = package['description']
12+
s.source = { :git => package['repository']['url'], :tag => s.version }
13+
s.source_files = 'build/bin/Geth.framework/**/*.h', 'Empty.m'
14+
s.vendored_libraries = 'libGeth.a', 'vendor/github.com/celo-org/bls-zexe/bls/target/universal/release/libbls_zexe.a'
15+
s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-ObjC' }
16+
end

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ GO ?= latest
1313

1414
CARGO_exists := $(shell command -v cargo 2> /dev/null)
1515
RUSTUP_exists := $(shell command -v rustup 2> /dev/null)
16+
CARGO_LIPO_exists := $(shell command -v cargo-lipo 2> /dev/null)
1617
LSB_exists := $(shell command -v lsb_release 2> /dev/null)
1718

1819
OS :=
@@ -86,6 +87,17 @@ else
8687
cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --release --target=x86_64-linux-android --lib
8788
endif
8889

90+
bls-zexe-ios:
91+
ifeq ("$(RUSTUP_exists)","")
92+
$(error "No rustup in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md")
93+
else
94+
ifeq ("$(CARGO_LIPO_exists)","")
95+
cargo install cargo-lipo
96+
endif
97+
rustup target add aarch64-apple-ios armv7-apple-ios x86_64-apple-ios i386-apple-ios
98+
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
99+
endif
100+
89101
vendor/github.com/celo-org/bls-zexe/bls/target/release/libbls_zexe.a:
90102
ifeq ("$(CARGO_exists)","")
91103
$(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
106118
@echo "Done building."
107119
@echo "Import \"$(GOBIN)/geth.aar\" to use the library."
108120

109-
ios:
121+
ios: bls-zexe-ios
110122
build/env.sh go run build/ci.go xcode --local
123+
pushd "$(GOBIN)"; rm -rf Geth.framework.zip; zip -r9y Geth.framework.zip Geth.framework; popd
111124
@echo "Done building."
112125
@echo "Import \"$(GOBIN)/Geth.framework\" to use the library."
113126

build/ci.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,8 @@ func doXCodeFramework(cmdline []string) {
942942

943943
// Build the iOS XCode framework
944944
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind"))
945+
// Patch gomobile to disable bitcode for now (rust generated bls lib output is not compatible)
946+
build.MustRunCommand("sed", "-i", "", `/^[[:space:]]*cflags += \" -fembed-bitcode\"$/s/^/\/\//`, filepath.Join(build.GOPATH(), "src/golang.org/x/mobile/cmd/gomobile/env.go"))
945947
bind := gomobileTool("bind", "-ldflags", "-s -w", "--target", "ios", "--tags", "ios", "-v", "github.com/ethereum/go-ethereum/mobile")
946948

947949
if *local {

mobile/geth.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ type NodeConfig struct {
9898
// scrypt KDF at the expense of security.
9999
// See https://geth.ethereum.org/doc/Mobile_Account-management for reference
100100
UseLightweightKDF bool
101+
102+
// IPCPath is the requested location to place the IPC endpoint. If the path is
103+
// a simple file name, it is placed inside the data directory (or on the root
104+
// pipe path on Windows), whereas if it's a resolvable path name (absolute or
105+
// relative), then that specific path is enforced. An empty path disables IPC.
106+
IPCPath string
101107
}
102108

103109
// defaultNodeConfig contains the default node configuration values to use if all
@@ -145,7 +151,7 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
145151
DataDir: datadir,
146152
KeyStoreDir: filepath.Join(datadir, "keystore"), // Mobile should never use internal keystores!
147153
UseLightweightKDF: config.UseLightweightKDF,
148-
IPCPath: "geth.ipc",
154+
IPCPath: config.IPCPath,
149155
P2P: p2p.Config{
150156
NoDiscovery: true,
151157
DiscoveryV5: false,

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22
"name": "@celo/client",
33
"version": "0.0.1",
44
"description": "Celo client for mobile",
5+
"homepage": "https://celo.org",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/celo-org/celo-blockchain.git"
9+
},
10+
"license": "LGPL-3.0",
511
"files": [
6-
"build/bin/geth.aar"
7-
]
12+
"build/bin/geth.aar",
13+
"build/bin/Geth.framework.zip",
14+
"CeloBlockchain.podspec",
15+
"vendor/github.com/celo-org/bls-zexe/bls/target/universal/release/libbls_zexe.a"
16+
],
17+
"scripts": {
18+
"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"
19+
}
820
}

vendor/github.com/celo-org/bls-zexe/go/bls_ios.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)