Skip to content

Commit 034a1a2

Browse files
authored
chore: move gnoboard in example/js/expo and simplify the root Makefile (#178)
Gnoboard uses Expo in its dependencies, so we decided to move it in the `example/js/expo` folder. The Makefile in the root directory had some rules that compiled the `node_modules` and the `xcworkspace` for Gnoboard, so I removed them to be consistent (that was the only example app that had rules in the root Makefile). --------- Signed-off-by: D4ryl00 <[email protected]>
1 parent 38e461b commit 034a1a2

File tree

190 files changed

+160
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+160
-197
lines changed

Makefile

+16-29
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ APP_NAME ?= gnoboard
1212
# Define the directory that contains the current Makefile
1313
make_dir := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
1414
cache_dir := $(make_dir)/.cache
15-
gnoboard_dir := $(make_dir)/examples/js/react-native/gnoboard
1615
expo_dir := $(make_dir)/expo
1716

1817
# Argument Defaults
19-
APP_OUTPUT_DIR ?= $(make_dir)/examples/js/react-native/$(APP_NAME)
2018
IOS_OUTPUT_FRAMEWORK_DIR ?= framework/ios
2119
ANDROID_OUTPUT_LIBS_DIR ?= framework/android
2220
GO_BIND_BIN_DIR ?= $(cache_dir)/bind
@@ -44,20 +42,8 @@ PATH := $(GO_BIND_BIN_DIR):$(PATH)
4442

4543
# * Main commands
4644

47-
# `all` and `build` command builds everything (generate, build.ios, build.android)
48-
all build: generate build.ios build.android
49-
50-
# Build iOS framework
51-
build.ios: generate framework.ios
52-
ifeq ($(OS),Darwin)
53-
@echo "generate iOS framework"
54-
cd $(APP_OUTPUT_DIR); $(MAKE) node_modules
55-
cd $(APP_OUTPUT_DIR); $(MAKE) ios/$(APP_NAME).xcworkspace TEMPLATE_PROJECT=$(APP_NAME)
56-
endif
57-
58-
# Build Android aar & jar
59-
build.android: generate framework.android
60-
cd $(APP_OUTPUT_DIR); $(MAKE) node_modules
45+
# `all` and `build` command build the Go Framework
46+
all build: framework
6147

6248
# Generate API from protofiles
6349
generate: api.generate
@@ -66,14 +52,10 @@ generate: api.generate
6652
regenerate: api.clean api.generate
6753

6854
# Clean all generated files
69-
clean: bind.clean
70-
71-
# Force clean (clean and remove node_modules)
72-
fclean:
73-
cd $(APP_OUTPUT_DIR); ls; rm -rf node_modules
55+
clean: framework.clean
7456
rm -rf $(cache_dir)
7557

76-
.PHONY: generate regenerate build.ios build.android clean fclean
58+
.PHONY: generate regenerate clean
7759

7860
# - API : Handle API generation and cleaning
7961

@@ -82,8 +64,8 @@ api.clean: _api.clean.protocol _api.clean.modules
8264

8365
# - API - rpc
8466

85-
protos_src := $(wildcard service/rpc/*.proto)
86-
gen_src := $(protos_src) Makefile buf.gen.yaml $(wildcard service/gnonativetypes/*.go)
67+
protos_src := $(wildcard api/*.proto)
68+
gen_src := $(protos_src) Makefile buf.gen.yaml $(wildcard api/gnonativetypes/*.go)
8769
gen_sum := gen.sum
8870

8971
_api.generate.protocol: $(gen_sum)
@@ -104,7 +86,9 @@ $(gen_sum): $(gen_src)
10486
go mod tidy \
10587
)
10688

107-
_api.generate.modules:
89+
_api.generate.modules: api/package-lock.json
90+
91+
api/package-lock.json:
10892
$(call check-program, npm)
10993
cd api; npm install
11094

@@ -140,6 +124,7 @@ framework.ios: $(gnocore_xcframework)
140124
.PHONY: framework.ios
141125

142126
$(gnocore_xcframework): $(bind_init_files) $(go_deps)
127+
$(MAKE) generate
143128
ifeq ($(OS),Darwin)
144129
@mkdir -p $(dir $@)
145130
# need to use `nowatchdog` tags, see https://github.com/libp2p/go-libp2p-connmgr/issues/98
@@ -157,6 +142,7 @@ framework.android: $(gnocore_aar) $(gnocore_jar)
157142
.PHONY: framework.android
158143

159144
$(gnocore_aar): $(bind_init_files) $(go_deps)
145+
$(MAKE) generate
160146
@mkdir -p $(dir $@) .cache/bind/android
161147
$(gomobile) bind -v \
162148
-cache $(cache_dir)/android-gnonative \
@@ -165,10 +151,11 @@ $(gnocore_aar): $(bind_init_files) $(go_deps)
165151
_bind.clean.android:
166152
rm -rf $(gnocore_jar) $(gnocore_aar)
167153

154+
# - Bind
155+
framework: framework.ios framework.android
156+
.PHONY: framework
168157

169-
# - Bind - cleaning
170-
171-
bind.clean: _bind.clean.ios _bind.clean.android
158+
framework.clean: _bind.clean.ios _bind.clean.android
172159
rm -rf $(bind_init_files)
173160

174161
# - asdf
@@ -213,7 +200,7 @@ new-expo-app:
213200
@echo "Installing npm dependencies"
214201
cd $(OUTPUT_DIR)/$(APP_NAME) && npm install ${npm_basic_dependencies}
215202

216-
# copy js files from gnoboard to the new app
203+
# copy js files from the Expo example app to the new app
217204
copy-js-files:
218205
@echo "Copying js files"
219206
@cp $(expo_dir)/example/App.tsx $(OUTPUT_DIR)/$(APP_NAME)/App.tsx

README.md

+54-120
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,29 @@ These API calls are a programming language-independent wrapper on top of the cor
99

1010
Watch [this Gno Native Kit tutorial](https://www.youtube.com/watch?v=N1HLyQDHGQ0) to easily get started on building and bringing your (d)apps to mobile and desktop.
1111

12-
## Build instructions
12+
## Expo module
1313

14-
### Install prerequisites for macOS 13
14+
To use Gno Native Kit, we advise you to use the Expo module in your Expo React-Native project. Please read the [README](expo/README.md) in the `expo` folder.
1515

16-
(If you are on Ubuntu, see the next section to install prerequisites.)
16+
In the `expo/example` folder, you can find a minimal app using the Expo module.
17+
18+
Other examples are available in the `example/js/expo` folder.
19+
20+
## Bare React-Native project
21+
22+
If you are interested in using Gno Native Kit in a bare React-Native project, please check the `hello` example app in the `example/js/react-native/hello` folder.
23+
24+
## Prerequisites for building Gno Native Kit or example apps
25+
26+
### Install requirements for macOS 13 and macOS 14
27+
28+
(If you are on Ubuntu, see the next section to install requirements.)
1729

1830
Install Xcode. To install the Command Line Developer Tools, in a terminal enter:
1931

20-
xcode-select --install
32+
```sh
33+
xcode-select --install
34+
```
2135

2236
After the Developer Tools are installed, we need to make sure it is updated. In
2337
System Preferences, click Software Update and update it if needed.
@@ -26,50 +40,69 @@ To install asdf using brew, follow instructions at https://asdf-vm.com . In shor
2640
first install brew following the instructions at https://brew.sh . Then, in
2741
a terminal enter:
2842

29-
brew install asdf gnu-tar gpg jq
43+
```sh
44+
brew install asdf gnu-tar gpg
45+
```
3046

3147
If your terminal is zsh, enter:
3248

33-
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc
49+
```sh
50+
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc
51+
```
3452

3553
If your terminal is bash, enter:
3654

37-
echo -e "\n. \"$(brew --prefix asdf)/libexec/asdf.sh\"" >> ~/.bash_profile
55+
```sh
56+
echo -e "\n. \"$(brew --prefix asdf)/libexec/asdf.sh\"" >> ~/.bash_profile
57+
```
3858

39-
Start a new terminal to get the changes to the environment.
59+
Start a new terminal to get the changes to the environment .
4060

4161
(optional) To install Android Studio, download and install the latest
4262
android-studio-{version}-mac.dmg from https://developer.android.com/studio .
4363
(Tested with Jellyfish 2023.3.1 .)
4464

45-
### Install prerequisites for Ubuntu 20.04, 22.04 and 24.04
65+
### Install requirements for Ubuntu 20.04, 22.04 and 24.04
4666

4767
To install asdf, follow instructions at https://asdf-vm.com . In short, in
4868
a terminal enter:
4969

50-
sudo apt install curl git make
51-
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
52-
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.profile
53-
source ~/.profile
70+
```sh
71+
sudo apt install curl git make
72+
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
73+
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
74+
echo 'export ANDROID_HOME="$HOME/Android/Sdk"' >> ~/.bashrc
75+
echo 'export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/23.1.7779620"' >> ~/.bashrc
76+
```
5477

55-
Start a new terminal to get the changes to the environment.
78+
Start a new terminal to get the changes to the environment .
5679

57-
(optional) To install Android Studio, download the latest
80+
To install Android Studio, download the latest
5881
android-studio-{version}-linux.tar.gz from
5982
https://developer.android.com/studio . (Tested with Jellyfish 2023.3.1 .)
6083
In a terminal, enter the following with the correct {version}:
6184

62-
sudo tar -C /usr/local -xzf android-studio-{version}-linux.tar.gz
85+
```sh
86+
sudo tar -C /usr/local -xzf android-studio-{version}-linux.tar.gz
87+
```
6388

6489
To launch Android Studio, in a terminal enter:
6590

66-
/usr/local/android-studio/bin/studio.sh &
91+
```sh
92+
/usr/local/android-studio/bin/studio.sh &
93+
```
94+
95+
### Install the tools with asdf (only need to do once)
96+
97+
```sh
98+
make asdf.install_tools
99+
```
67100

68-
### Get a copy of the repo
101+
On macOS, if you get an error like "https://github.com/CocoaPods/CLAide.git (at master@97b765e) is not yet checked out" then reinstall cocoapods like this:
69102

70-
```console
71-
git clone https://github.com/gnolang/gnonative
72-
cd gnonative
103+
```sh
104+
asdf uninstall cocoapods
105+
make asdf.install_tools
73106
```
74107

75108
### Build for Android
@@ -82,102 +115,3 @@ cd gnonative
82115
- In the "SDK Tools" tab, click "Show Package Details". Expand
83116
"NDK (Side by side)" and check "23.1.7779620".
84117
- Click OK to install and close the SDK Manager.
85-
86-
#### Install the tools with asdf (only need to do once)
87-
88-
(If not building for iOS, edit the file `.tool-versions` and remove the unneeded lines for `ruby` and `cocoapods`.)
89-
90-
```console
91-
make asdf.install_tools
92-
```
93-
94-
#### Build the Go code as a library
95-
96-
```console
97-
make build.android
98-
```
99-
100-
#### Start metro
101-
102-
```console
103-
cd examples/js/react-native/gnoboard
104-
npm start
105-
```
106-
107-
#### Connect your Android phone/emulator and bind its port to metro
108-
109-
You can either connect an Android phone via USB cable, or launch an emulator device from Android Studio.
110-
111-
##### Real device
112-
113-
Connect your device and bind the port to metro:
114-
115-
```console
116-
cd examples/js/react-native/gnoboard
117-
make android.reverse_tcp
118-
```
119-
120-
##### Emulator device
121-
122-
You can either run Android Studio and open the Android project in `examples/js/react-native/gnoboard/android`.
123-
If you prefer the CLI option:
124-
125-
```console
126-
android-studio ./android
127-
```
128-
129-
Once done, bind the port to metro:
130-
131-
```console
132-
make android.reverse_tcp
133-
```
134-
135-
#### Build with Android Studio
136-
137-
Open Android Studio and open the current Android project if it's not already done.
138-
Select the right device in the device list. Open the `Run` menu, and select `Run app`.
139-
See more: https://developer.android.com/studio/run#basic-build-run
140-
141-
### Build for iOS
142-
143-
#### Install the tools with asdf (only need to do once)
144-
145-
```console
146-
make asdf.install_tools
147-
```
148-
149-
If you get an error like "https://github.com/CocoaPods/CLAide.git (at master@97b765e) is not yet checked out" then reinstall cocoapods like this:
150-
151-
```console
152-
asdf uninstall cocoapods
153-
make asdf.install_tools
154-
```
155-
156-
#### Build the Go code as a library
157-
158-
```console
159-
make build.ios
160-
```
161-
162-
#### Start metro
163-
164-
```console
165-
cd examples/js/react-native/gnoboard
166-
npm start
167-
```
168-
169-
#### Open Xcode and connect your iOS device
170-
171-
Open Xcode and open the GnoBoard Xcode workspace: `examples/js/react-native/gnoboard/ios/gnoboard.xcworkspace`
172-
You can either connect an iOS phone via USB cable, or launch an emulator device from Xcode.
173-
See more: https://developer.apple.com/documentation/xcode/running-your-app-in-simulator-or-on-a-device
174-
175-
#### Select a developer certificate
176-
177-
In Xcode, double click on gnoboard project on the left pane, go to the `Signing & Capabilities` pane.
178-
In the `Signing` section, select your `team` certificate.
179-
180-
#### Build with Xcode
181-
182-
Select the right device in the device list. Open the `Product` menu, and select `Run`.
183-
See more: https://developer.apple.com/documentation/xcode/building-and-running-an-app
File renamed without changes.

0 commit comments

Comments
 (0)