From c1d1b60f4645be57485267b8e807190e72b0f800 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 14 May 2020 10:58:08 -0400 Subject: [PATCH] Adding nimbus-build-system --- .gitmodules | 18 ++++ Makefile | 86 +++++++++++++++++-- README.md | 43 ++-------- env.sh | 8 ++ nim-status.desktop | 8 ++ src/nim_status_client.nim.cfg | 9 +- status.svg | 26 ++++++ .../nim-nat-traversal.nimble-link | 2 + .../pkgs/nim-stew-#head/nim-stew.nimble-link | 2 + .../nim-stint-#head/nim-stint.nimble-link | 2 + .../pkgs/nimqml-#head/nimqml.nimble-link | 2 + vendor/DOtherSide | 1 + vendor/nim-nat-traversal | 1 + vendor/nim-stew | 1 + vendor/nim-stint | 1 + vendor/nimbus-build-system | 1 + vendor/nimqml | 1 + 17 files changed, 172 insertions(+), 40 deletions(-) create mode 100644 .gitmodules create mode 100644 env.sh create mode 100644 nim-status.desktop create mode 100644 status.svg create mode 100644 vendor/.nimble/pkgs/nim-nat-traversal-#head/nim-nat-traversal.nimble-link create mode 100644 vendor/.nimble/pkgs/nim-stew-#head/nim-stew.nimble-link create mode 100644 vendor/.nimble/pkgs/nim-stint-#head/nim-stint.nimble-link create mode 100644 vendor/.nimble/pkgs/nimqml-#head/nimqml.nimble-link create mode 160000 vendor/DOtherSide create mode 160000 vendor/nim-nat-traversal create mode 160000 vendor/nim-stew create mode 160000 vendor/nim-stint create mode 160000 vendor/nimbus-build-system create mode 160000 vendor/nimqml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..fb5690dd19 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,18 @@ +[submodule "vendor/DOtherSide"] + path = vendor/DOtherSide + url = https://github.com/filcuc/DOtherSide +[submodule "vendor/nim-stint"] + path = vendor/nim-stint + url = https://github.com/status-im/nim-stint +[submodule "vendor/nimqml"] + path = vendor/nimqml + url = https://github.com/filcuc/nimqml/ +[submodule "vendor/nimbus-build-system"] + path = vendor/nimbus-build-system + url = https://github.com/status-im/nimbus-build-system +[submodule "vendor/nim-nat-traversal"] + path = vendor/nim-nat-traversal + url = https://github.com/status-im/nim-nat-traversal/ +[submodule "vendor/nim-stew"] + path = vendor/nim-stew + url = https://github.com/status-im/nim-stew/ diff --git a/Makefile b/Makefile index da3376b8d2..ec8f03d10e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,83 @@ -SHELL := bash +# Copyright (c) 2019-2020 Status Research & Development GmbH. Licensed under +# either of: +# - Apache License, version 2.0 +# - MIT license +# at your option. This file may not be copied, modified, or distributed except +# according to those terms. -build: - nim c -L:lib/libstatus.a -d:ssl -L:-lm --outdir:./bin src/nim_status_client.nim +SHELL := bash # the shell used internally by Make -build-osx: - nim c -L:lib/libstatus.dylib -d:ssl -L:-lm -L:"-framework Foundation -framework Security -framework IOKit -framework CoreServices" --outdir:./bin src/nim_status_client.nim +# used inside the included makefiles +BUILD_SYSTEM_DIR := vendor/nimbus-build-system + +# we don't want an error here, so we can handle things later, in the ".DEFAULT" target +-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk + +.PHONY: \ + all \ + appimage \ + clean \ + deps \ + update + +ifeq ($(NIM_PARAMS),) +# "variables.mk" was not included, so we update the submodules. +GIT_SUBMODULE_UPDATE := git submodule update --init --recursive +.DEFAULT: + +@ echo -e "Git submodules not found. Running '$(GIT_SUBMODULE_UPDATE)'.\n"; \ + $(GIT_SUBMODULE_UPDATE); \ + echo +# Now that the included *.mk files appeared, and are newer than this file, Make will restart itself: +# https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles +# +# After restarting, it will execute its original goal, so we don't have to start a child Make here +# with "$(MAKE) $(MAKECMDGOALS)". Isn't hidden control flow great? + +else # "variables.mk" was included. Business as usual until the end of this file. + + +ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... + detected_OS := Windows +else + detected_OS := $(strip $(shell uname)) +endif + + +DEFAULT_TARGET := None +ifeq ($(detected_OS), Darwin) + DEFAULT_TARGET := build-macos +else + DEFAULT_TARGET := build-linux +endif + +all: $(DEFAULT_TARGET) + +# must be included after the default target +-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk + +deps: | deps-common + +update: | update-common + +DOTHERSIDE := vendor/DOtherSide/build/lib/libDOtherSideStatic.a + +$(DOTHERSIDE): | deps + echo -e $(BUILD_MSG) "DOtherSide" + + cd vendor/DOtherSide && \ + mkdir -p build && \ + cd build && \ + cmake -DCMAKE_BUILD_TYPE=Release .. $(HANDLE_OUTPUT) && \ + $(MAKE) # IF WE WANT TO USE LIBDOTHERSIDE AS STATIC LIBRARY, USE `$(MAKE) DOtherSideStatic` INSTEAD + +build-linux: $(DOTHERSIDE) src/nim_status_client.nim | deps + echo -e $(BUILD_MSG) "$@" && \ + $(ENV_SCRIPT) nim c -L:lib/libstatus.a -d:ssl -L:-lm -L:-Lvendor/DOtherSide/build/lib/ $(NIM_PARAMS) --outdir:./bin src/nim_status_client.nim + +build-macos: $(DOTHERSIDE) src/nim_status_client.nim | deps + echo -e $(BUILD_MSG) "$@" && \ + $(ENV_SCRIPT) nim c -L:lib/libstatus.a -d:ssl -L:-lm -L:"-framework Foundation -framework Security -framework IOKit -framework CoreServices" -L:-Lvendor/DOtherSide/build/lib/ $(NIM_PARAMS) --outdir:./bin src/nim_status_client.nim + +clean: | clean-common + rm -rf vendor/DOtherSide/build tmp/dist + +endif # "variables.mk" was not included diff --git a/README.md b/README.md index 2d36947daf..ee56e35576 100644 --- a/README.md +++ b/README.md @@ -22,59 +22,34 @@ export PATH=$PATH:/path/to/Qt/5.14.2/gcc_64/bin export PATH=$PATH:/path/to/Qt/5.14.2/clang_64/bin ``` -### 3. Clone and build DOtherside - -For Linux: - +### 3. Clone the repo ``` -sudo apt-get install build-essential libgl1-mesa-dev -sudo apt-get install doxygen +git clone https://github.com/status-im/nim-status-client/ --recurse-submodules ``` -``` -git clone https://github.com/filcuc/DOtherSide -cd DOtherSide -mkdir build && cd build -cmake .. -make -``` - -### 4. Setup Library Path - -``` -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/dotherside/build/lib -``` - -### 5. Copy libstatus to repo +### 4. Copy libstatus to repo Copy `libstatus.a` to the `./lib` folder. Can be obtained from `status-react/result` by executing `make status-go-desktop`. **macos:** rename `libstatus.a` to `libstatus.dylib` _before_ copying over. Alternatively, modify `desktop/default.nix` to output `libstatus.dylib` before copying over. -### 6. Install nim dependencies - -Use `-d` to only install dependencies and not build afterwards. +### 5. Build `nim-status-client` ``` -nimble install -d +make ``` -### 7. Build `nim-status-client` - +### 6. Setup Library Path ``` -# linux -make build - -# macos -make build-osx +export LD_LIBRARY_PATH=vendor/DOtherSide/build/lib/ ``` -### 8. Run the app +### 7. Run the app ``` ./bin/nim_status_client ``` -### 9. "Cold" reload using VSCode +### 8. "Cold" reload using VSCode We can setup a "cold" reload, whereby the app will be rebuilt and restarted when changes in the source are saved. This will not save state, as the app will be restarted, but it will save us some time from manually restarting the app. We can handily force an app rebuild/relaunch with the shortcut `Cmd+Shift+b` (execute the default build task, which we'll setup below). diff --git a/env.sh b/env.sh new file mode 100644 index 0000000000..f90ba9a74c --- /dev/null +++ b/env.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# We use ${BASH_SOURCE[0]} instead of $0 to allow sourcing this file +# and we fall back to a Zsh-specific special var to also support Zsh. +REL_PATH="$(dirname ${BASH_SOURCE[0]:-${(%):-%x}})" +ABS_PATH="$(cd ${REL_PATH}; pwd)" +source ${ABS_PATH}/vendor/nimbus-build-system/scripts/env.sh + diff --git a/nim-status.desktop b/nim-status.desktop new file mode 100644 index 0000000000..d302c6e83f --- /dev/null +++ b/nim-status.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Nim Status Client +Exec=nim %F +Icon=status +Comment=Hello World +Terminal=true +Categories=Network; diff --git a/src/nim_status_client.nim.cfg b/src/nim_status_client.nim.cfg index 4024805b9a..fbbf66627e 100644 --- a/src/nim_status_client.nim.cfg +++ b/src/nim_status_client.nim.cfg @@ -1,2 +1,9 @@ --threads:on ---tlsEmulation:off \ No newline at end of file +--tlsEmulation:off + +@if release: + nimcache = "nimcache/release/$projectName" +@else: + nimcache = "nimcache/debug/$projectName" +@end + diff --git a/status.svg b/status.svg new file mode 100644 index 0000000000..24e33c17fd --- /dev/null +++ b/status.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + diff --git a/vendor/.nimble/pkgs/nim-nat-traversal-#head/nim-nat-traversal.nimble-link b/vendor/.nimble/pkgs/nim-nat-traversal-#head/nim-nat-traversal.nimble-link new file mode 100644 index 0000000000..29d8d96013 --- /dev/null +++ b/vendor/.nimble/pkgs/nim-nat-traversal-#head/nim-nat-traversal.nimble-link @@ -0,0 +1,2 @@ +/home/richard/status/nim-status-client/vendor/nim-nat-traversal +/home/richard/status/nim-status-client/vendor/nim-nat-traversal diff --git a/vendor/.nimble/pkgs/nim-stew-#head/nim-stew.nimble-link b/vendor/.nimble/pkgs/nim-stew-#head/nim-stew.nimble-link new file mode 100644 index 0000000000..68e13f489a --- /dev/null +++ b/vendor/.nimble/pkgs/nim-stew-#head/nim-stew.nimble-link @@ -0,0 +1,2 @@ +/home/richard/status/nim-status-client/vendor/nim-stew +/home/richard/status/nim-status-client/vendor/nim-stew diff --git a/vendor/.nimble/pkgs/nim-stint-#head/nim-stint.nimble-link b/vendor/.nimble/pkgs/nim-stint-#head/nim-stint.nimble-link new file mode 100644 index 0000000000..43b1fef300 --- /dev/null +++ b/vendor/.nimble/pkgs/nim-stint-#head/nim-stint.nimble-link @@ -0,0 +1,2 @@ +/home/richard/status/nim-status-client/vendor/nim-stint +/home/richard/status/nim-status-client/vendor/nim-stint diff --git a/vendor/.nimble/pkgs/nimqml-#head/nimqml.nimble-link b/vendor/.nimble/pkgs/nimqml-#head/nimqml.nimble-link new file mode 100644 index 0000000000..ec56b1cc73 --- /dev/null +++ b/vendor/.nimble/pkgs/nimqml-#head/nimqml.nimble-link @@ -0,0 +1,2 @@ +/home/richard/status/nim-status-client/vendor/nimqml/src +/home/richard/status/nim-status-client/vendor/nimqml/src diff --git a/vendor/DOtherSide b/vendor/DOtherSide new file mode 160000 index 0000000000..4d0d6a353c --- /dev/null +++ b/vendor/DOtherSide @@ -0,0 +1 @@ +Subproject commit 4d0d6a353c33ff2227b83562a127b3514a7e2169 diff --git a/vendor/nim-nat-traversal b/vendor/nim-nat-traversal new file mode 160000 index 0000000000..2403c33929 --- /dev/null +++ b/vendor/nim-nat-traversal @@ -0,0 +1 @@ +Subproject commit 2403c33929c74f2d150f50dc8bc3a598af70661a diff --git a/vendor/nim-stew b/vendor/nim-stew new file mode 160000 index 0000000000..d0f5be4971 --- /dev/null +++ b/vendor/nim-stew @@ -0,0 +1 @@ +Subproject commit d0f5be4971ad34d115b9749d9fb69bdd2aecf525 diff --git a/vendor/nim-stint b/vendor/nim-stint new file mode 160000 index 0000000000..9e49b00148 --- /dev/null +++ b/vendor/nim-stint @@ -0,0 +1 @@ +Subproject commit 9e49b00148884a01d61478ae5d2c69b543b93ceb diff --git a/vendor/nimbus-build-system b/vendor/nimbus-build-system new file mode 160000 index 0000000000..89709a0913 --- /dev/null +++ b/vendor/nimbus-build-system @@ -0,0 +1 @@ +Subproject commit 89709a091361bb42df9d16f4e79fe764c265f2c4 diff --git a/vendor/nimqml b/vendor/nimqml new file mode 160000 index 0000000000..5c42890e5b --- /dev/null +++ b/vendor/nimqml @@ -0,0 +1 @@ +Subproject commit 5c42890e5b14b7d84a2345b060d1b54bfb7aed1b