Address feedback

This commit is contained in:
Andrea Maria Piana 2020-06-03 08:22:05 +02:00
parent de698e64a3
commit cbaf523b0e
4 changed files with 23 additions and 2 deletions

View File

@ -111,8 +111,9 @@ statusgo-ios: ##@cross-compile Build status-go for iOS
@echo "iOS framework cross compilation done in build/bin/Statusgo.framework" @echo "iOS framework cross compilation done in build/bin/Statusgo.framework"
statusgo-library: ##@cross-compile Build status-go as static library for current platform statusgo-library: ##@cross-compile Build status-go as static library for current platform
## cmd/library/README.md explains the magic incantation behind this
mkdir -p $(GOBIN)/statusgo-lib mkdir -p $(GOBIN)/statusgo-lib
go run cmd/library/* > $(GOBIN)/statusgo-lib/main.go go run cmd/library/*.go > $(GOBIN)/statusgo-lib/main.go
@echo "Building static library..." @echo "Building static library..."
go build -buildmode=c-archive -o $(GOBIN)/libstatus.a $(BUILD_FLAGS) $(GOBIN)/statusgo-lib go build -buildmode=c-archive -o $(GOBIN)/libstatus.a $(BUILD_FLAGS) $(GOBIN)/statusgo-lib
@echo "Static library built:" @echo "Static library built:"

View File

@ -52,6 +52,11 @@ pipeline {
sh 'make setup-build' sh 'make setup-build'
} } } } } }
/* Sanity-check C bindings */
stage('Sanity check bindings') { steps { dir(env.STATUS_PATH) {
sh 'make statusgo-library'
} } }
stage('Compress') { steps { dir(env.STATUS_PATH) { stage('Compress') { steps { dir(env.STATUS_PATH) {
sh "zip -q -r ${dest}/${artifact} . -x *.git" sh "zip -q -r ${dest}/${artifact} . -x *.git"
} } } } } }

13
cmd/library/README.md Normal file
View File

@ -0,0 +1,13 @@
### Library bindings
This unholy namespace generates C bindings for `mobile/`.
It does so by parsing the go files, identify any public function in the namespace
that is not a test file, and generate an equivalent function with the correct
C signature, which will then just call the version in `mobile/`.
This method is ad-hoc and not bullet-proof, the main limitation is that only some
types are supported for now, `C.int`, `*C.char` and `unsafer.Pointer`.
Functions that do not use these types will be ignored.
The problem this sledgehammer solves is to have to keep in sync the two namespaces,
which is fiddly and prone to error as they are modified by either teams.

View File

@ -1,6 +1,8 @@
package main package main
const prelude = `package main const prelude = `// Code generated by cmd/library to keep in sync with mobile. DO NOT EDIT.
package main
// #include <stdlib.h> // #include <stdlib.h>
import "C" import "C"
import "unsafe" import "unsafe"