build: dynamically link to status-go built as a shared library

This commit is contained in:
Michael Bradley, Jr 2020-08-06 16:14:06 -05:00 committed by Iuri Matias
parent 27a140e844
commit 507f510c62
2 changed files with 33 additions and 11 deletions

View File

@ -30,7 +30,8 @@ BUILD_SYSTEM_DIR := vendor/nimbus-build-system
pkg-macos \ pkg-macos \
pkg-windows \ pkg-windows \
run \ run \
run-linux-or-macos \ run-linux \
run-macos \
run-windows \ run-windows \
status-go \ status-go \
update update
@ -67,12 +68,14 @@ ifeq ($(detected_OS),Darwin)
export CFLAGS export CFLAGS
CGO_CFLAGS := -mmacosx-version-min=10.13 CGO_CFLAGS := -mmacosx-version-min=10.13
export CGO_CFLAGS export CGO_CFLAGS
LIBSTATUS_EXT := dylib
MACOSX_DEPLOYMENT_TARGET := 10.13 MACOSX_DEPLOYMENT_TARGET := 10.13
export MACOSX_DEPLOYMENT_TARGET export MACOSX_DEPLOYMENT_TARGET
PKG_TARGET := pkg-macos PKG_TARGET := pkg-macos
RUN_TARGET := run-linux-or-macos RUN_TARGET := run-macos
else ifeq ($(detected_OS),Windows) else ifeq ($(detected_OS),Windows)
BOTTLES_TARGET := bottles-dummy BOTTLES_TARGET := bottles-dummy
LIBSTATUS_EXT := dll
PKG_TARGET := pkg-windows PKG_TARGET := pkg-windows
QRCODEGEN_MAKE_PARAMS := CC=gcc QRCODEGEN_MAKE_PARAMS := CC=gcc
RUN_TARGET := run-windows RUN_TARGET := run-windows
@ -81,8 +84,9 @@ else ifeq ($(detected_OS),Windows)
export VCINSTALLDIR export VCINSTALLDIR
else else
BOTTLES_TARGET := bottles-dummy BOTTLES_TARGET := bottles-dummy
LIBSTATUS_EXT := so
PKG_TARGET := pkg-linux PKG_TARGET := pkg-linux
RUN_TARGET := run-linux-or-macos RUN_TARGET := run-linux
endif endif
check-pkg-target-linux: check-pkg-target-linux:
@ -187,13 +191,15 @@ $(DOTHERSIDE): | deps
.. $(HANDLE_OUTPUT) && \ .. $(HANDLE_OUTPUT) && \
$(DOTHERSIDE_BUILD_CMD) $(DOTHERSIDE_BUILD_CMD)
STATUSGO := vendor/status-go/build/bin/libstatus.a STATUSGO := vendor/status-go/build/bin/libstatus.$(LIBSTATUS_EXT)
STATUSGO_LIBDIR := $(shell pwd)/$(shell dirname "$(STATUSGO)")
export STATUSGO_LIBDIR
status-go: $(STATUSGO) status-go: $(STATUSGO)
$(STATUSGO): | deps $(STATUSGO): | deps
echo -e $(BUILD_MSG) "status-go" echo -e $(BUILD_MSG) "status-go"
+ cd vendor/status-go && \ + cd vendor/status-go && \
$(MAKE) statusgo-library $(HANDLE_OUTPUT) $(MAKE) statusgo-shared-library $(HANDLE_OUTPUT)
QRCODEGEN := vendor/QR-Code-generator/c/libqrcodegen.a QRCODEGEN := vendor/QR-Code-generator/c/libqrcodegen.a
@ -211,7 +217,12 @@ rcc:
nim_status_client: | $(DOTHERSIDE) $(STATUSGO) $(QRCODEGEN) rcc deps nim_status_client: | $(DOTHERSIDE) $(STATUSGO) $(QRCODEGEN) rcc deps
echo -e $(BUILD_MSG) "$@" && \ echo -e $(BUILD_MSG) "$@" && \
$(ENV_SCRIPT) nim c $(NIM_PARAMS) --passL:"$(STATUSGO)" $(NIM_EXTRA_PARAMS) --passL:"$(QRCODEGEN)" --passL:"-lm" src/nim_status_client.nim $(ENV_SCRIPT) nim c $(NIM_PARAMS) --passL:"-L$(STATUSGO_LIBDIR)" --passL:"-lstatus" $(NIM_EXTRA_PARAMS) --passL:"$(QRCODEGEN)" --passL:"-lm" src/nim_status_client.nim && \
[[ $(detected_OS) = Darwin ]] && \
install_name_tool -change \
libstatus.dylib \
@rpath/libstatus.dylib \
bin/nim_status_client || true
_APPIMAGE_TOOL := appimagetool-x86_64.AppImage _APPIMAGE_TOOL := appimagetool-x86_64.AppImage
APPIMAGE_TOOL := tmp/linux/tools/$(_APPIMAGE_TOOL) APPIMAGE_TOOL := tmp/linux/tools/$(_APPIMAGE_TOOL)
@ -242,6 +253,9 @@ $(STATUS_CLIENT_APPIMAGE): nim_status_client $(APPIMAGE_TOOL) nim-status.desktop
mkdir -p tmp/linux/dist/usr/i18n mkdir -p tmp/linux/dist/usr/i18n
cp ui/i18n/* tmp/linux/dist/usr/i18n cp ui/i18n/* tmp/linux/dist/usr/i18n
# Libraries
cp vendor/status-go/build/bin/libstatus.so tmp/linux/dist/usr/lib/
echo -e $(BUILD_MSG) "AppImage" echo -e $(BUILD_MSG) "AppImage"
linuxdeployqt tmp/linux/dist/nim-status.desktop -no-copy-copyright-files -qmldir=ui -qmlimport=$(QTDIR)/qml -bundle-non-qt-libs linuxdeployqt tmp/linux/dist/nim-status.desktop -no-copy-copyright-files -qmldir=ui -qmlimport=$(QTDIR)/qml -bundle-non-qt-libs
@ -346,6 +360,7 @@ $(STATUS_CLIENT_ZIP): nim_status_client nim_windows_launcher $(NIM_WINDOWS_PREBU
tmp/windows/dist/Status/Status.exe \ tmp/windows/dist/Status/Status.exe \
--set-icon tmp/windows/dist/Status/resources/status.ico --set-icon tmp/windows/dist/Status/resources/status.ico
cp $(DOTHERSIDE) tmp/windows/dist/Status/bin/ cp $(DOTHERSIDE) tmp/windows/dist/Status/bin/
cp $(STATUSGO) tmp/windows/dist/Status/bin/
cp tmp/windows/tools/*.dll tmp/windows/dist/Status/bin/ cp tmp/windows/tools/*.dll tmp/windows/dist/Status/bin/
mkdir -p tmp/windows/dist/Status/resources/i18n mkdir -p tmp/windows/dist/Status/resources/i18n
cp ui/i18n/* tmp/windows/dist/Status/resources/i18n cp ui/i18n/* tmp/windows/dist/Status/resources/i18n
@ -395,16 +410,21 @@ run: rcc $(RUN_TARGET)
NIM_STATUS_CLIENT_DEV ?= t NIM_STATUS_CLIENT_DEV ?= t
run-linux-or-macos: run-linux:
echo -e "\e[92mRunning:\e[39m bin/nim_status_client"
NIM_STATUS_CLIENT_DEV="$(NIM_STATUS_CLIENT_DEV)" \
LD_LIBRARY_PATH="$(QT5_LIBDIR)":"$(STATUSGO_LIBDIR)" \
./bin/nim_status_client
run-macos:
echo -e "\e[92mRunning:\e[39m bin/nim_status_client" echo -e "\e[92mRunning:\e[39m bin/nim_status_client"
NIM_STATUS_CLIENT_DEV="$(NIM_STATUS_CLIENT_DEV)" \ NIM_STATUS_CLIENT_DEV="$(NIM_STATUS_CLIENT_DEV)" \
LD_LIBRARY_PATH="$(QT5_LIBDIR)" \
./bin/nim_status_client ./bin/nim_status_client
run-windows: $(NIM_WINDOWS_PREBUILT_DLLS) run-windows: $(NIM_WINDOWS_PREBUILT_DLLS)
echo -e "\e[92mRunning:\e[39m bin/nim_status_client.exe" echo -e "\e[92mRunning:\e[39m bin/nim_status_client.exe"
NIM_STATUS_CLIENT_DEV="$(NIM_STATUS_CLIENT_DEV)" \ NIM_STATUS_CLIENT_DEV="$(NIM_STATUS_CLIENT_DEV)" \
PATH="$(shell pwd)"/"$(shell dirname "$(DOTHERSIDE)")":"$(shell pwd)"/"$(shell dirname "$(NIM_WINDOWS_PREBUILT_DLLS)")":"$(PATH)" \ PATH="$(shell pwd)"/"$(shell dirname "$(DOTHERSIDE)")":"$(STATUSGO_LIBDIR)":"$(shell pwd)"/"$(shell dirname "$(NIM_WINDOWS_PREBUILT_DLLS)")":"$(PATH)" \
./bin/nim_status_client.exe ./bin/nim_status_client.exe
endif # "variables.mk" was not included endif # "variables.mk" was not included

View File

@ -12,9 +12,11 @@ if defined(macosx):
--dynlibOverrideAll # don't use dlopen() --dynlibOverrideAll # don't use dlopen()
--tlsEmulation:off --tlsEmulation:off
switch("passL", "-lstdc++") switch("passL", "-lstdc++")
# DYLD_LIBRARY_PATH doesn't seem to work with Qt5 # DYLD_LIBRARY_PATH doesn't always work when running/packaging so set rpath
# note: macdeployqt rewrites rpath appropriately when building the .app bundle
switch("passL", "-rpath" & " " & getEnv("QT5_LIBDIR")) switch("passL", "-rpath" & " " & getEnv("QT5_LIBDIR"))
# statically linke these libs switch("passL", "-rpath" & " " & getEnv("STATUSGO_LIBDIR"))
# statically link these libs
switch("passL", "bottles/openssl/lib/libcrypto.a") switch("passL", "bottles/openssl/lib/libcrypto.a")
switch("passL", "bottles/openssl/lib/libssl.a") switch("passL", "bottles/openssl/lib/libssl.a")
switch("passL", "bottles/pcre/lib/libpcre.a") switch("passL", "bottles/pcre/lib/libpcre.a")