Skip to content

Commit

Permalink
Merge branch 'obd' of github.com:omnilaboratory/lnd into obd
Browse files Browse the repository at this point in the history
  • Loading branch information
wxf4150 committed Nov 9, 2022
2 parents eb67856 + 96d36f9 commit 698b913
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions mobile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,37 @@

### Prerequisites
#### protoc
download execute bianry from https://github.com/protocolbuffers/protobuf/releases for plateform;and make it in you system environment variable PATH.
any protoc version 3.0+ will be ok.
Download the executable binary from https://github.com/protocolbuffers/protobuf/releases for the platform. Make it in your system environment variable `PATH`.
Any `protoc` version 3.0+ is ok.

```bash
protoc --version
libprotoc 3.12.4
go install google.golang.org/protobuf/cmd/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc
# protoc-gen-go and protoc-gen-go-grpc are used with protoc for gen grpc code from proto file.
# protoc-gen-go and protoc-gen-go-grpc are used with protoc to generate grpc code from proto file.
```

#### android sdk ndk
sdk ndk can install use Android Studio. If you are not using Android Studio, in order to work with bindings for Android, you need to have [Android SDK](https://developer.android.com/sdk/index.html#Other) installed and ANDROID_HOME environment variable set to the SDK path. You also need the [NDK](https://developer.android.com/ndk/) installed; the easiest way is to run the SDK command sdkmanager ndk-bundle.
SDK(NDK) can be installed via Android Studio. If you are not using Android Studio, to work with bindings for Android, you need to have [Android SDK](https://developer.android.com/sdk/index.html#Other) installed and the `ANDROID_HOME` environment variable set to the SDK path. You also need the [NDK](https://developer.android.com/ndk/) installed; The easiest way is to run the SDK command `sdkmanager ndk-bundle`.


#### gomobile
```bash
go install golang.org/x/mobile/cmd/gomobile
go install golang.org/x/mobile/cmd/gomobile

#more document as below
```
Follow [gomobile](https://github.com/golang/go/wiki/Mobile) in order to install
`gomobile` and dependencies.
Follow the [gomobile instruction](https://github.com/golang/go/wiki/Mobile) to install the `gomobile` package and dependencies.

Remember to run `gomobile init` (otherwise the `lnd` build might just hang).
Remember to run `gomobile init` (otherwise the `obd` build might just hang).

Note that `gomobile` only supports building projects from `GOPATH` at this
point.
Note that `gomobile` only supports building projects from `GOPATH` at this point.

#### falafel
Install [`falafel`](https://github.com/lightninglabs/falafel):
```shell
⛰ go get -u -v github.com/lightninglabs/falafel
# falafel will used for genarate in-memory gRPC client code for mobile
# falafel will be used to genarate in-memory gRPC client code for mobile
```

### gen falafel's go code bind for mobile
Expand All @@ -40,45 +41,39 @@ go get -d golang.org/x/mobile/cmd/gomobile
cd ./mobile && ./gen_bindings.sh v0.9.1
```

### Building `lnd` for iOS
ios build should install xcode and swift; more docs reference [gomobile](https://github.com/golang/go/wiki/Mobile) office docs.
### Building `obd` for iOS
ios build should install xcode and swift; more docs reference [gomobile](https://github.com/golang/go/wiki/Mobile) official docs.
```shell
⛰ make ios
```

### Building `lnd` for Android
### Building `obd` for Android
```shell
⛰ make android
# now the ObdMobile.aar will build and outpu at ./mobile/build/android; ObdMobile.aar is the liabrary can be imported in android project .
# Now the `ObdMobile.aar` will be built and output under `./mobile/build/android`; `ObdMobile.aar` is the library that can be imported into an android project.
```

`make mobile` will build both iOS and Android libs.

### Libraries
After the build has succeeded, the libraries will be found in
`mobile/build/ios/Lndmobile.framework` and
`mobile/build/android/Lndmobile.aar`. Reference your platforms' SDK
`mobile/build/ios/Obdmobile.framework` and
`mobile/build/android/ObdMobile.aar`. Reference your platforms' SDK
documentation for how to add the library to your project.

#### Generating proto definitions for your language.
In order to call the methods in the generated library, the serialized proto for
the given RPC call must be provided. Similarly, the response will be a
serialized proto.
In order to call the methods in the generated library, the serialized proto for the given RPC call must be provided. Similarly, the response will be a serialized proto.

##### iOS

In order to generate protobuf definitions for iOS, add `--swift_out=.` to the
first `protoc` invocation found in [`gen_protos.sh`](../lnrpc/gen_protos.sh).
In order to generate protobuf definitions for iOS, add `--swift_out=.` to the first `protoc` invocation found in [`gen_protos.sh`](../lnrpc/gen_protos.sh).

Then, some changes to [Dockerfile]((../lnrpc/Dockerfile)) need to be done in
order to use the [Swift protobuf](https://github.com/apple/swift-protobuf)
plugin with protoc:
Then, some changes to [Dockerfile]((../lnrpc/Dockerfile)) need to be done in order to use the [Swift protobuf](https://github.com/apple/swift-protobuf) plugin with protoc:

1. Replace the base image with `FROM swift:focal` so that Swift can be used.
2. `clang-format='1:7.0*'` is unavailable in Ubuntu Focal. Change that to
`clang-format='1:10.0*`.
3. On the next line, install Go and set the environment variables by adding the
following commands:
3. On the next line, install Go and set the environment variables by adding the following commands:

```
RUN apt-get install -y wget \
Expand Down Expand Up @@ -123,4 +118,6 @@ flag. This will add the subserver name as a prefix to each method name:
```

### API docs
TODO(halseth)
TODO(healergyl, Ben)

The mobile API docs is at https:https://github.com/omnilaboratory/obd/tree/master/docs/mobile.md

0 comments on commit 698b913

Please sign in to comment.