From 011e594422aebb54e48cb0375f38fd89f3239d75 Mon Sep 17 00:00:00 2001 From: t h Date: Fri, 13 Nov 2020 06:23:53 +0000 Subject: Updating makefile to support Cygwin64 for Windows users. - Closes: #394 --- .gitignore | 4 ++++ Makefile | 38 ++++++++++++++++++++++++++++++++++---- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++------ gui/build.sh | 7 ++----- 4 files changed, 84 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 4586b0f..6dab9c2 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,7 @@ providers/assets .*.swp *.exe + +# IDE +.idea +.vs diff --git a/Makefile b/Makefile index 086729d..97f1e97 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,10 @@ TARGET_GOLIB=lib/libgoshim.a SOURCE_GOLIB=gui/backend.go # detect OS +UNAME = $(shell uname -s) ifeq ($(OS), Windows_NT) PLATFORM = windows else -UNAME = $(shell uname -s) PLATFORM ?= $(shell echo ${UNAME} | awk "{print tolower(\$$0)}") endif @@ -70,6 +70,13 @@ dependsDarwin: @brew install python3 golang make pkg-config curl @brew install --default-names gnu-sed +dependsCYGWIN_NT-10.0: + @echo + @echo "==================================WARNING==================================" + @echo "You need to install all dependencies manually, please see README.md!" + @echo "==================================WARNING==================================" + @echo + ifeq ($(PLATFORM), darwin) EXTRA_FLAGS = MACOSX_DEPLOYMENT_TARGET=10.10 GOOS=darwin CC=clang else @@ -90,6 +97,14 @@ lib/%.a: $(PKGFILES) @XBUILD=no ./gui/build.sh --just-golib relink_vendor: + @echo "==========RELINK VENDOR==========" + @echo "PLATFORM: ${PLATFORM}" + @echo "VENDOR_PATH: ${VENDOR_PATH}" + @echo "PROVIDER: ${PROVIDER}" +ifeq ($(UNAME), CYGWIN_NT-10.0) + [ -L providers/assets ] || (CYGWIN=winsymlinks:nativestrict ln -s ${PROVIDER}/assets providers/assets) +endif +ifneq ($(UNAME), CYGWIN_NT-10.0) ifeq ($(PLATFORM), windows) rm -rf providers/assets endif @@ -97,19 +112,29 @@ ifeq ($(VENDOR_PATH), providers) @unlink providers/assets || true @ln -s ${PROVIDER}/assets providers/assets endif +endif + @echo "==========RELINK VENDOR==========" build_golib: lib/libgoshim.a build_gui: relink_vendor + @echo "==========BUILD GUI==========" + @echo "TARGET: ${TARGET}" + @echo "VENDOR_PATH: ${VENDOR_PATH}" @XBUILD=no TARGET=${TARGET} VENDOR_PATH=${VENDOR_PATH} gui/build.sh --skip-golib + @echo "==========BUILD GUI==========" build: build_golib build_helper build_gui build_helper: + @echo "==========BUILDER HELPER==========" @echo "PLATFORM: ${PLATFORM}" + @echo "APPNAME: ${APPNAME}" + @echo "VERSION: ${VERSION}" + @echo "EXTRA_GO_LDFLAGS: ${EXTRA_GO_LDFLAGS}" @mkdir -p build/bin/${PLATFORM} @go build -o build/bin/${PLATFORM}/bitmask-helper -ldflags "-X main.AppName=${APPNAME} -X main.Version=${VERSION} ${EXTRA_GO_LDFLAGS}" ./cmd/bitmask-helper/ - @echo "build helper done." + @echo "==========BUILDER HELPER==========" build_openvpn: @[ -f $(OPENVPN_BIN) ] && echo "OpenVPN already built at" $(OPENVPN_BIN) || ./branding/thirdparty/openvpn/build_openvpn.sh @@ -190,7 +215,7 @@ ifeq (${PLATFORM}, windows) "c:\windows\system32\signtool.exe" sign -f "z:\leap\LEAP.pfx" -p ${WINCERTPASS} build/installer/${APPNAME}-installer-${VERSION}.exe endif -check_qtifw: +check_qtifw: ifdef HAS_QTIFW @echo "[+] Found QTIFW" else @@ -201,9 +226,11 @@ clean: @rm -rf build/ @unlink branding/assets/default || true + ######################################################################## # tests ######################################################################### + qmllint: @qmllint gui/qml/*.qml @@ -214,7 +241,11 @@ test_ui: build_golib @qmake -o tests/Makefile test.pro @make -C tests clean @make -C tests +ifeq ($(PLATFORM), windows) + @./tests/build/test_ui.exe +else @./tests/build/test_ui +endif ######################################################################### @@ -282,7 +313,6 @@ endif endif - ######################################################################### # packaging action ######################################################################### diff --git a/README.md b/README.md index c0f5b65..9187a36 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ -Build ------ +## Build Clone this repo, install dependencies and build the application. Dependencies -assume debian packages, or homebrew for osx. For other systems try +assume debian packages, or homebrew for osx. For Windows OS see corresponding section below. For other systems try manually, or send us a patch. ``` - git clone 0xacab.org/leap/bitmask-vpn && cd bitmask-vpn + git clone git@0xacab.org:leap/bitmask-vpn.git && cd bitmask-vpn sudo make depends make build ``` @@ -19,8 +18,7 @@ You need at least go 1.11. If you have something older and are using ubuntu, you For other situations, have a look at https://github.com/golang/go/wiki/Ubuntu or https://golang.org/dl/ -Test ----- +## Test You can run some tests too. @@ -30,6 +28,46 @@ You can run some tests too. make test_ui ``` +## Windows +As for now app can be build on Win OS using `Cygwin` terminal. + +#### Precondition +You need to have installed and added to your user PATH (mentioned version tested in Win10): +1) Go (>= go1.15.4) +2) QT (>= Qt5.12.9) +3) QtIFW (>= QtIFW-4.0.0) +4) Cygwin64 (>= 2.905 64 bit) +5) Using Cygwin `Package Select` window install `python3` and `make` packages. + +**Note:** for #5 you don't need to add packages to PATH they will available in `cygwin` after installation. + +#### Get Source +``` + git clone git@0xacab.org:leap/bitmask-vpn.git && cd bitmask-vpn +``` + +#### Build +Build script uses a symbolic link in one of the stages. Unfortunately Cygwin can't create native symlink from local non +admin user due to windows security restriction. To avoid this issue we need to call next target from cygwin terminal as +Administrator. This need to be done only once. +```bash + make relink_vendor +``` + +After `relink_vendor` use this to build the app: +```bash + make build +``` +After successful build application will be available at: `build/qt/release/riseup-vpn.exe` + +#### Test + +To run tests: + +```bash + make test + make test_ui +``` Translations ------------ diff --git a/gui/build.sh b/gui/build.sh index c8433c1..9dfcbda 100755 --- a/gui/build.sh +++ b/gui/build.sh @@ -85,15 +85,12 @@ function renameOutput { mv $RELEASE/bitmask $RELEASE/$TARGET strip $RELEASE/$TARGET echo "[+] Binary is in" $RELEASE/$TARGET - fi - if [ "$PLATFORM" == "Darwin" ] + elif [ "$PLATFORM" == "Darwin" ] then rm -rf $RELEASE/$TARGET.app mv $RELEASE/bitmask.app/ $RELEASE/$TARGET.app/ echo "[+] App is in" $RELEASE/$TARGET - fi - if [ "$PLATFORM" == "MINGW64_NT-10.0" ] - then + else # for MINGWIN or CYGWIN mv $RELEASE/bitmask.exe $RELEASE/$TARGET.exe fi } -- cgit v1.2.3