Skip to content

Commit

Permalink
Merge pull request #1233 from jagerman/dev-backport
Browse files Browse the repository at this point in the history
0.7.1 - Backport minor fixes and packaging from dev to master
  • Loading branch information
majestrate authored Apr 21, 2020
2 parents 250a817 + 47806b4 commit 8b72a5a
Show file tree
Hide file tree
Showing 101 changed files with 1,259 additions and 5,711 deletions.
26 changes: 26 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,32 @@ build:linux_debug:
- build/daemon/lokinet
- build/daemon/lokinetctl


build:win32:
image: ubuntu:bionic
tags:
- linux
stage: build
before_script:
- apt-get update && apt-get install -y build-essential cmake nsis git g++-mingw-w64
script:
- DOWNLOAD_SODIUM=ON IS_NOTIFICATION=1 STATIC_LINK=ON WINDOWS_ARCH=64 make windows
artifacts:
paths:
- build/lokinet-*.exe

build:macos:
tags:
- osx
stage: build
script:
- IS_NOTIFICATION=1 STATIC_LINK=ON DOWNLOAD_SODIUM=ON make mac
artifacts:
paths:
- build/*.pkg
- build/daemon/lokinet


# needs libuv and libcurl
#build:freebsd:
# tags:
Expand Down
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,30 @@ matrix:
dist: xenial
env: DOCKER_FILE=docker/gcc-trunk.Dockerfile
services: docker
- name: "native windows debug"
os: windows
env: BUILD_TYPE=Debug
- name: "native windows release"
os: windows
env: BUILD_TYPE=Release
- name: "windows installer"
os: linux
env: MAKE_TARGET=windows STATIC_LINK=ON DOWNLOAD_SODIUM=ON
allow_failures:
- name: "windows installer"
os: linux
env: MAKE_TARGET=windows STATIC_LINK=ON DOWNLOAD_SODIUM=ON
- name: "make windows docker image"
os: linux
dist: xenial
env: DOCKER_FILE=docker/alpine-windows.Dockerfile
services: docker
- name: "native windows debug"
os: windows
env: BUILD_TYPE=Debug
- name: "native windows release"
os: windows
env: BUILD_TYPE=Release
# - name: "native windows debug"
# os: windows
# env: BUILD_TYPE=Debug
Expand All @@ -137,6 +161,25 @@ env:
- STATIC_LINK=OFF

addons:
apt:
packages:
- binutils-gold
- build-essential
- clang-format
- cmake
- curl
- docker-ce
- nsis
- g++-mingw-w64
- g++-mingw-w64-x86-64
- gcc-mingw-w64-base
- git
- libcap-dev
- libcurl4-openssl-dev
- libuv1-dev
- mingw-w64 mingw-w64-common
- ninja-build
- libsodium-dev
homebrew:
update: true
packages:
Expand Down
41 changes: 29 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
cmake_minimum_required(VERSION 3.5.1) # xenial's cmake version
cmake_minimum_required(VERSION 3.10) # bionic's cmake version

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()

set(PROJECT_NAME lokinet)
project(${PROJECT_NAME} C CXX)
project(${PROJECT_NAME}
VERSION 0.7.1
DESCRIPTION "lokinet - IP packet onion router"
LANGUAGES C CXX)

set(RELEASE_MOTTO "I'll remember that..." CACHE STRING "Release motto")

add_definitions(-DLLARP_VERSION_MAJOR=${lokinet_VERSION_MAJOR})
add_definitions(-DLLARP_VERSION_MINOR=${lokinet_VERSION_MINOR})
add_definitions(-DLLARP_VERSION_PATCH=${lokinet_VERSION_PATCH})


# Core options
option(USE_AVX2 "enable avx2 code" OFF)
Expand All @@ -30,6 +40,7 @@ option(WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for developmen
option(TRACY_ROOT "include tracy profiler source" OFF)
option(WITH_TESTS "build unit tests" ON)
#option(WITH_SYSTEMD ...) defined below
option(BUILD_PACKAGE "builds extra components for making an installer (with 'make package')" OFF)

include(cmake/target_link_libraries_system.cmake)
include(cmake/add_import_library.cmake)
Expand All @@ -45,12 +56,6 @@ if (STATIC_LINK)
message(STATUS "setting static library suffix search")
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

# No in-source building
include(MacroEnsureOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out-of-source build. Create a build directory and run 'cmake ${CMAKE_SOURCE_DIR} [options]'.")

include(cmake/basic_definitions.cmake)

if(MSVC_VERSION)
Expand All @@ -62,9 +67,16 @@ else()
endif(MSVC_VERSION)

include(cmake/solaris.cmake)
include(cmake/unix.cmake)
include(cmake/win32.cmake)
# try detecting the target arch and set the flags needed here

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

# No in-source building
include(MacroEnsureOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out-of-source build. Create a build directory and run 'cmake ${CMAKE_SOURCE_DIR} [options]'.")

include(cmake/unix.cmake)

if(NOT WIN32)
if(IOS OR ANDROID)
set(NON_PC_TARGET ON)
Expand Down Expand Up @@ -144,7 +156,8 @@ if (NOT MSVC_VERSION)
add_compile_options(-Wno-unused-function -Wno-deprecated-declarations -Wno-unknown-pragmas)
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# STREQUAL because AppleClang's libc++ doesn't yet support thread safety annotations
add_compile_options(-Wthread-safety)
endif()

Expand Down Expand Up @@ -223,7 +236,7 @@ endif(JEMALLOC)


find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
if(PKG_CONFIG_FOUND AND LINUX)
pkg_check_modules(SD libsystemd)
# Default WITH_SYSTEMD to true if we found it
option(WITH_SYSTEMD "enable systemd integration for sd_notify" ${SD_FOUND})
Expand Down Expand Up @@ -298,3 +311,7 @@ if (NOT SHADOW)
add_subdirectory(jni)
endif(ANDROID)
endif()

if(BUILD_PACKAGE)
include(cmake/installer.cmake)
endif()
File renamed without changes.
30 changes: 22 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ JAVA_HOME ?= /usr/lib/jvm/default-java

TOOLCHAIN ?=

# 64 for 64bit windows, 32 for 32bit windows
# defaults to 64 bit for now
WINDOWS_ARCH ?= 64

# native avx2 code
AVX2 ?= OFF
# statically link everything
Expand Down Expand Up @@ -132,7 +136,7 @@ ANALYZE_CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "$(SCA
COVERAGE_CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DWITH_COVERAGE=yes $(COMMON_CMAKE_OPTIONS) '$(REPO)'")
else
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DUSE_SHELLHOOKS=$(SHELL_HOOKS) -DTRACY_ROOT=$(TRACY_ROOT) $(COMMON_CMAKE_OPTIONS) '$(REPO)'")
CONFIG_CMD_WINDOWS = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=ON -DUSE_SHELLHOOKS=$(SHELL_HOOKS) $(COMMON_CMAKE_OPTIONS) '$(REPO)'")
CONFIG_CMD_WINDOWS = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=ON -DUSE_SHELLHOOKS=$(SHELL_HOOKS) $(COMMON_CMAKE_OPTIONS)")

ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) $(COMMON_CMAKE_OPTIONS) '$(REPO)'")

Expand Down Expand Up @@ -166,7 +170,7 @@ debug-configure:

release-configure: clean
mkdir -p '$(BUILD_ROOT)'
$(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)'
$(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)'

debug: debug-configure
$(MAKE) -C $(BUILD_ROOT)
Expand Down Expand Up @@ -230,7 +234,7 @@ check: debug
test: check

static-configure: $(LIBUV_PREFIX) $(LIBCURL_PREFIX)
(test x$(TOOLCHAIN) = x && $(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DSTATIC_LINK=ON -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DLIBCURL_ROOT='$(LIBCURL_PREFIX)' ) || (test x$(TOOLCHAIN) != x && $(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DSTATIC_LINK=ON -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DLIBCURL_ROOT='$(LIBCURL_PREFIX)' -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN) -DNATIVE_BUILD=OFF )
(test x$(TOOLCHAIN) = x && $(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DSTATIC_LINK=ON -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DLIBCURL_ROOT='$(LIBCURL_PREFIX)' -DNATIVE_BUILD=OFF ) || (test x$(TOOLCHAIN) != x && $(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DSTATIC_LINK=ON -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DLIBCURL_ROOT='$(LIBCURL_PREFIX)' -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN) -DNATIVE_BUILD=OFF )

static: static-configure
$(MAKE) -C '$(BUILD_ROOT)'
Expand Down Expand Up @@ -271,21 +275,31 @@ android: android-gradle

windows-debug-configure: $(LIBUV_PREFIX)
mkdir -p '$(BUILD_ROOT)'
$(CONFIG_CMD_WINDOWS) -DCMAKE_TOOLCHAIN_FILE='$(REPO)/contrib/cross/mingw.cmake' -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_ASM_FLAGS='$(ASFLAGS)' -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT=$(LIBUV_PREFIX)
$(CONFIG_CMD_WINDOWS) -DCMAKE_TOOLCHAIN_FILE='$(REPO)/contrib/cross/mingw$(WINDOWS_ARCH).cmake' -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_ASM_FLAGS='$(ASFLAGS)' -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT=$'(LIBUV_PREFIX)' '$(REPO)'

windows-debug: windows-debug-configure
$(MAKE) -C '$(BUILD_ROOT)'
cp '$(BUILD_ROOT)/daemon/lokinet.exe' '$(REPO)/lokinet.exe'

windows-release-configure: $(LIBUV_PREFIX)
mkdir -p '$(BUILD_ROOT)'
$(CONFIG_CMD_WINDOWS) -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE='$(REPO)/contrib/cross/mingw.cmake' -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_ASM_FLAGS='$(ASFLAGS)' -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT=$(LIBUV_PREFIX)
$(CONFIG_CMD_WINDOWS) -DNATIVE_BUILD=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_PACKAGE=ON -DCMAKE_TOOLCHAIN_FILE='$(REPO)/contrib/cross/mingw$(WINDOWS_ARCH).cmake' -DCMAKE_ASM_FLAGS='$(ASFLAGS)' -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DWITH_TESTS=OFF '$(REPO)'

windows-release: windows-release-configure
$(MAKE) -C '$(BUILD_ROOT)'
cp '$(BUILD_ROOT)/daemon/lokinet.exe' '$(REPO)/lokinet.exe'
cd '$(BUILD_ROOT)' && cpack -D CPACK_MONOLITHIC_INSTALL=1 -G NSIS ..

windows: windows-release

mac-release-configure: $(LIBUV_PREFIX)
mkdir -p '$(BUILD_ROOT)'
$(CONFIG_CMD) -DNATIVE_BUILD=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_PACKAGE=ON -DCMAKE_ASM_FLAGS='$(ASFLAGS)' -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)' -DLIBUV_ROOT='$(LIBUV_PREFIX)' -DWITH_TESTS=OFF '$(REPO)'

mac-release: mac-release-configure
$(MAKE) -C '$(BUILD_ROOT)'

windows: windows-debug
mac: mac-release
$(MAKE) -C '$(BUILD_ROOT)' package

abyss: debug
$(ABYSS_EXE)
Expand Down Expand Up @@ -341,7 +355,7 @@ docker-fedora:

debian-configure:
mkdir -p '$(BUILD_ROOT)'
$(CONFIG_CMD) -DDEBIAN=ON -DRELEASE_MOTTO="$(shell cat $(REPO)/motto.txt)" -DCMAKE_BUILD_TYPE=Release
$(CONFIG_CMD) -DDEBIAN=ON -DCMAKE_BUILD_TYPE=Release

debian: debian-configure
$(MAKE) -C '$(BUILD_ROOT)'
Expand Down
16 changes: 16 additions & 0 deletions cmake/installer.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set(CPACK_PACKAGE_VENDOR "lokinet.org")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://lokinet.org/")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/contrib/readme-installer.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt")

if(WIN32)
include(cmake/win32_installer_deps.cmake)
endif()

if(APPLE)
include(cmake/macos_installer_deps.cmake)
endif()


# This must always be last!
include(CPack)
90 changes: 90 additions & 0 deletions cmake/macos_installer_deps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# macos specific cpack stuff goes here

# Here we build lokinet-network-control-panel into 'lokinet-gui.app' in "extra/" where a postinstall
# script will then move it to /Applications/.

set(LOKINET_GUI_REPO "https://github.com/loki-project/loki-network-control-panel.git"
CACHE STRING "Can be set to override the default lokinet-gui git repository")
set(LOKINET_GUI_CHECKOUT "origin/master"
CACHE STRING "Can be set to specify a particular branch or tag to build from LOKINET_GUI_REPO")
set(MACOS_SIGN_APP "" # FIXME: it doesn't use a Apple Distribution key because WTF knows.
CACHE STRING "enable codesigning of the stuff inside the .app and the lokinet binary -- use a 'Apple Distribution' key (or description) from `security find-identity -v`")
set(MACOS_SIGN_PKG ""
CACHE STRING "enable codesigning of the .pkg -- use a 'Developer ID Installer' key (or description) from `security find-identity -v`")
set(MACOS_NOTARIZE_USER ""
CACHE STRING "set macos notarization username; can also set it in ~/.notarization.cmake")
set(MACOS_NOTARIZE_PASS ""
CACHE STRING "set macos notarization password; can also set it in ~/.notarization.cmake")
set(MACOS_NOTARIZE_ASC ""
CACHE STRING "set macos notarization asc provider; can also set it in ~/.notarization.cmake")

include(ExternalProject)

message(STATUS "Building LokinetGUI.app from ${LOKINET_GUI_REPO} @ ${LOKINET_GUI_CHECKOUT}")

ExternalProject_Add(lokinet-gui
GIT_REPOSITORY "${LOKINET_GUI_REPO}"
GIT_TAG "${LOKINET_GUI_CHECKOUT}"
CMAKE_ARGS -DMACOS_APP=ON -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DMACOS_SIGN=${MACOS_SIGN_APP}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
)



install(FILES ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_uninstall.sh
DESTINATION "bin/"
COMPONENT lokinet)

install(DIRECTORY ${PROJECT_BINARY_DIR}/LokinetGUI.app
DESTINATION "../../Applications"
USE_SOURCE_PERMISSIONS
COMPONENT gui
PATTERN "*"
)

# copy files that will be later moved by the postinstall script to proper locations
install(FILES ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_macos_daemon_script.sh
${CMAKE_SOURCE_DIR}/contrib/macos/network.loki.lokinet.daemon.plist
DESTINATION "extra/"
COMPONENT lokinet)

set(CPACK_COMPONENTS_ALL lokinet gui)

set(CPACK_COMPONENT_LOKINET_DISPLAY_NAME "Lokinet Service")
set(CPACK_COMPONENT_LOKINET_DESCRIPTION "Main Lokinet runtime service, managed by Launchd")

set(CPACK_COMPONENT_GUI_DISPLAY_NAME "Lokinet GUI")
set(CPACK_COMPONENT_GUI_DESCRIPTION "Small GUI which provides stats and limited runtime control of the Lokinet service. Resides in the system tray.")

set(CPACK_GENERATOR "productbuild")
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/lokinet")
set(CPACK_POSTFLIGHT_LOKINET_SCRIPT ${CMAKE_SOURCE_DIR}/contrib/macos/postinstall)

# The GUI is GPLv3, and so the bundled core+GUI must be as well:
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/contrib/gpl-3.0.txt")

set(CPACK_PRODUCTBUILD_IDENTITY_NAME "${MACOS_SIGN_PKG}")

if(MACOS_SIGN_APP)
add_custom_target(sign ALL
echo "Signing lokinet and lokinetctl binaries"
COMMAND codesign -s "${MACOS_SIGN_APP}" --strict --options runtime --force -vvv $<TARGET_FILE:lokinet> $<TARGET_FILE:lokinetctl>
DEPENDS lokinet lokinetctl
)
endif()

if(MACOS_SIGN_APP AND MACOS_SIGN_PKG)
if(NOT MACOS_NOTARIZE_USER)
if(EXISTS "$ENV{HOME}/.notarization.cmake")
include("$ENV{HOME}/.notarization.cmake")
endif()
endif()
if(MACOS_NOTARIZE_USER AND MACOS_NOTARIZE_PASS AND MACOS_NOTARIZE_ASC)
message(STATUS "'notarization' target enabled")
configure_file(${CMAKE_SOURCE_DIR}/contrib/macos/notarize.py.in ${CMAKE_CURRENT_BINARY_DIR}/contrib/notarize.py ESCAPE_QUOTES @ONLY)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/contrib/notarize.py DESTINATION ${PROJECT_BINARY_DIR} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
add_custom_target(notarize ./notarize.py)
else()
message(WARNING "Not enable 'notarization' target: signing is enabled but notarization info not provided. Create ~/.notarization.cmake or set cmake parameters directly")
endif()
endif()
5 changes: 5 additions & 0 deletions cmake/unix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ if(NOT UNIX)
return()
endif()

# because apple means embracing bitrot
if(APPLE)
add_compile_options(-mmacosx-version-min=10.13)
endif()

include(CheckCXXSourceCompiles)
include(CheckLibraryExists)

Expand Down
Loading

0 comments on commit 8b72a5a

Please sign in to comment.