mirror of https://github.com/oxen-io/lokinet
Compare commits
No commits in common. 'dev' and 'v0.2.2' have entirely different histories.
@ -1,2 +0,0 @@
|
||||
HeaderFilterRegex: 'llarp/.*'
|
||||
Checks: 'readability-else-after-return,clang-analyzer-core-*,modernize-*,-modernize-use-trailing-return-type,-modernize-use-nodiscard,bugprone-*,-bugprone-easily-swappable-parameters'
|
@ -1,4 +0,0 @@
|
||||
build/
|
||||
.vscode/
|
||||
lokinet
|
||||
lokinet.exe
|
@ -1,450 +0,0 @@
|
||||
local default_deps_base = [
|
||||
'libsystemd-dev',
|
||||
'python3-dev',
|
||||
'libuv1-dev',
|
||||
'libunbound-dev',
|
||||
'nettle-dev',
|
||||
'libssl-dev',
|
||||
'libevent-dev',
|
||||
'libsqlite3-dev',
|
||||
'libcurl4-openssl-dev',
|
||||
'libzmq3-dev',
|
||||
'make',
|
||||
];
|
||||
local default_deps_nocxx = ['libsodium-dev'] + default_deps_base; // libsodium-dev needs to be >= 1.0.18
|
||||
local default_deps = ['g++'] + default_deps_nocxx;
|
||||
local docker_base = 'registry.oxen.rocks/lokinet-ci-';
|
||||
|
||||
local submodule_commands = [
|
||||
'git fetch --tags',
|
||||
'git submodule update --init --recursive --depth=1 --jobs=4',
|
||||
];
|
||||
local submodules = {
|
||||
name: 'submodules',
|
||||
image: 'drone/git',
|
||||
commands: submodule_commands,
|
||||
};
|
||||
|
||||
// cmake options for static deps mirror
|
||||
local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https://oxen.rocks/deps ' else '');
|
||||
|
||||
local apt_get_quiet = 'apt-get -o=Dpkg::Use-Pty=0 -q';
|
||||
|
||||
// Regular build on a debian-like system:
|
||||
local debian_pipeline(name,
|
||||
image,
|
||||
arch='amd64',
|
||||
deps=default_deps,
|
||||
build_type='Release',
|
||||
lto=false,
|
||||
werror=true,
|
||||
cmake_extra='',
|
||||
local_mirror=true,
|
||||
extra_cmds=[],
|
||||
jobs=6,
|
||||
tests=true,
|
||||
oxen_repo=false,
|
||||
allow_fail=false) = {
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
name: name,
|
||||
platform: { arch: arch },
|
||||
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
|
||||
steps: [
|
||||
submodules,
|
||||
{
|
||||
name: 'build',
|
||||
image: image,
|
||||
pull: 'always',
|
||||
[if allow_fail then 'failure']: 'ignore',
|
||||
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
|
||||
commands: [
|
||||
'echo "Building on ${DRONE_STAGE_MACHINE}"',
|
||||
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
|
||||
apt_get_quiet + ' update',
|
||||
apt_get_quiet + ' install -y eatmydata',
|
||||
] + (
|
||||
if oxen_repo then [
|
||||
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y lsb-release',
|
||||
'cp contrib/deb.oxen.io.gpg /etc/apt/trusted.gpg.d',
|
||||
'echo deb http://deb.oxen.io $$(lsb_release -sc) main >/etc/apt/sources.list.d/oxen.list',
|
||||
'eatmydata ' + apt_get_quiet + ' update',
|
||||
] else []
|
||||
) + [
|
||||
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
|
||||
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y gdb cmake git pkg-config ccache ' + std.join(' ', deps),
|
||||
'mkdir build',
|
||||
'cd build',
|
||||
'cmake .. -DWITH_SETCAP=OFF -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_BUILD_TYPE=' + build_type + ' ' +
|
||||
(if build_type == 'Debug' then ' -DWARN_DEPRECATED=OFF ' else '') +
|
||||
(if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') +
|
||||
'-DWITH_LTO=' + (if lto then 'ON ' else 'OFF ') +
|
||||
'-DWITH_TESTS=' + (if tests then 'ON ' else 'OFF ') +
|
||||
cmake_extra +
|
||||
ci_dep_mirror(local_mirror),
|
||||
'VERBOSE=1 make -j' + jobs,
|
||||
'cd ..',
|
||||
]
|
||||
+ (if tests then ['./contrib/ci/drone-gdb.sh ./build/test/testAll --use-colour yes'] else [])
|
||||
+ extra_cmds,
|
||||
},
|
||||
],
|
||||
};
|
||||
local apk_builder(name, image, extra_cmds=[], allow_fail=false, jobs=6) = {
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
name: name,
|
||||
platform: { arch: 'amd64' },
|
||||
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
|
||||
steps: [
|
||||
submodules,
|
||||
{
|
||||
name: 'build',
|
||||
image: image,
|
||||
pull: 'always',
|
||||
[if allow_fail then 'failure']: 'ignore',
|
||||
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, ANDROID: 'android' },
|
||||
commands: [
|
||||
'VERBOSE=1 JOBS=' + jobs + ' NDK=/usr/lib/android-ndk ./contrib/android.sh',
|
||||
'git clone https://github.com/oxen-io/lokinet-flutter-app lokinet-mobile',
|
||||
'cp -av build-android/out/* lokinet-mobile/lokinet_lib/android/src/main/jniLibs/',
|
||||
'cd lokinet-mobile',
|
||||
'flutter build apk --debug',
|
||||
'cd ..',
|
||||
'cp lokinet-mobile/build/app/outputs/apk/debug/app-debug.apk lokinet.apk',
|
||||
] + extra_cmds,
|
||||
},
|
||||
],
|
||||
};
|
||||
// windows cross compile on debian
|
||||
local windows_cross_pipeline(name,
|
||||
image,
|
||||
gui_image=docker_base + 'nodejs-lts',
|
||||
arch='amd64',
|
||||
build_type='Release',
|
||||
lto=false,
|
||||
werror=false,
|
||||
cmake_extra='',
|
||||
local_mirror=true,
|
||||
extra_cmds=[],
|
||||
jobs=6,
|
||||
allow_fail=false) = {
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
name: name,
|
||||
platform: { arch: arch },
|
||||
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
|
||||
steps: [
|
||||
submodules,
|
||||
{
|
||||
name: 'GUI',
|
||||
image: gui_image,
|
||||
pull: 'always',
|
||||
[if allow_fail then 'failure']: 'ignore',
|
||||
commands: [
|
||||
'echo "Building on ${DRONE_STAGE_MACHINE}"',
|
||||
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
|
||||
apt_get_quiet + ' update',
|
||||
apt_get_quiet + ' install -y eatmydata',
|
||||
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y p7zip-full wine',
|
||||
'cd gui',
|
||||
'yarn install --frozen-lockfile',
|
||||
'USE_SYSTEM_7ZA=true DISPLAY= WINEDEBUG=-all yarn win32',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'build',
|
||||
image: image,
|
||||
pull: 'always',
|
||||
[if allow_fail then 'failure']: 'ignore',
|
||||
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, WINDOWS_BUILD_NAME: 'x64' },
|
||||
commands: [
|
||||
'echo "Building on ${DRONE_STAGE_MACHINE}"',
|
||||
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
|
||||
apt_get_quiet + ' update',
|
||||
apt_get_quiet + ' install -y eatmydata',
|
||||
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y build-essential cmake git pkg-config ccache g++-mingw-w64-x86-64-posix nsis zip icoutils automake libtool librsvg2-bin bison',
|
||||
'JOBS=' + jobs + ' VERBOSE=1 ./contrib/windows.sh -DSTRIP_SYMBOLS=ON -DGUI_EXE=$${DRONE_WORKSPACE}/gui/release/Lokinet-GUI_portable.exe' +
|
||||
ci_dep_mirror(local_mirror),
|
||||
] + extra_cmds,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// linux cross compile on debian
|
||||
local linux_cross_pipeline(name,
|
||||
cross_targets,
|
||||
arch='amd64',
|
||||
build_type='Release',
|
||||
cmake_extra='',
|
||||
local_mirror=true,
|
||||
extra_cmds=[],
|
||||
jobs=6,
|
||||
allow_fail=false) = {
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
name: name,
|
||||
platform: { arch: arch },
|
||||
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
|
||||
steps: [
|
||||
submodules,
|
||||
{
|
||||
name: 'build',
|
||||
image: docker_base + 'debian-stable-cross',
|
||||
pull: 'always',
|
||||
[if allow_fail then 'failure']: 'ignore',
|
||||
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, CROSS_TARGETS: std.join(':', cross_targets) },
|
||||
commands: [
|
||||
'echo "Building on ${DRONE_STAGE_MACHINE}"',
|
||||
'VERBOSE=1 JOBS=' + jobs + ' ./contrib/cross.sh ' + std.join(' ', cross_targets) +
|
||||
' -- ' + cmake_extra + ci_dep_mirror(local_mirror),
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// Builds a snapshot .deb on a debian-like system by merging into the debian/* or ubuntu/* branch
|
||||
local deb_builder(image, distro, distro_branch, arch='amd64', oxen_repo=true) = {
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
name: 'DEB (' + distro + (if arch == 'amd64' then '' else '/' + arch) + ')',
|
||||
platform: { arch: arch },
|
||||
environment: { distro_branch: distro_branch, distro: distro },
|
||||
steps: [
|
||||
submodules,
|
||||
{
|
||||
name: 'build',
|
||||
image: image,
|
||||
pull: 'always',
|
||||
failure: 'ignore',
|
||||
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
|
||||
commands: [
|
||||
'echo "Building on ${DRONE_STAGE_MACHINE}"',
|
||||
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
|
||||
] + (if oxen_repo then [
|
||||
'cp contrib/deb.oxen.io.gpg /etc/apt/trusted.gpg.d',
|
||||
'echo deb http://deb.oxen.io $${distro} main >/etc/apt/sources.list.d/oxen.list',
|
||||
] else []) + [
|
||||
apt_get_quiet + ' update',
|
||||
apt_get_quiet + ' install -y eatmydata',
|
||||
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y git devscripts equivs ccache git-buildpackage python3-dev',
|
||||
|||
|
||||
# Look for the debian branch in this repo first, try upstream if that fails.
|
||||
if ! git checkout $${distro_branch}; then
|
||||
git remote add --fetch upstream https://github.com/oxen-io/lokinet.git &&
|
||||
git checkout $${distro_branch}
|
||||
fi
|
||||
|||,
|
||||
// Tell the merge how to resolve conflicts in the source .drone.jsonnet (we don't
|
||||
// care about it at all since *this* .drone.jsonnet is already loaded).
|
||||
'git config merge.ours.driver true',
|
||||
'echo .drone.jsonnet merge=ours >>.gitattributes',
|
||||
|
||||
'git merge ${DRONE_COMMIT}',
|
||||
'export DEBEMAIL="${DRONE_COMMIT_AUTHOR_EMAIL}" DEBFULLNAME="${DRONE_COMMIT_AUTHOR_NAME}"',
|
||||
'gbp dch -S -s "HEAD^" --spawn-editor=never -U low',
|
||||
'eatmydata mk-build-deps --install --remove --tool "' + apt_get_quiet + ' -o Debug::pkgProblemResolver=yes --no-install-recommends -y"',
|
||||
'export DEB_BUILD_OPTIONS="parallel=$$(nproc)"',
|
||||
//'grep -q lib debian/lokinet-bin.install || echo "/usr/lib/lib*.so*" >>debian/lokinet-bin.install',
|
||||
'debuild -e CCACHE_DIR -b',
|
||||
'./contrib/ci/drone-debs-upload.sh ' + distro,
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
local clang(version) = debian_pipeline(
|
||||
'Debian sid/clang-' + version + ' (amd64)',
|
||||
docker_base + 'debian-sid-clang',
|
||||
deps=['clang-' + version] + default_deps_nocxx,
|
||||
cmake_extra='-DCMAKE_C_COMPILER=clang-' + version + ' -DCMAKE_CXX_COMPILER=clang++-' + version + ' '
|
||||
);
|
||||
|
||||
local full_llvm(version) = debian_pipeline(
|
||||
'Debian sid/llvm-' + version + ' (amd64)',
|
||||
docker_base + 'debian-sid-clang',
|
||||
deps=['clang-' + version, ' lld-' + version, ' libc++-' + version + '-dev', 'libc++abi-' + version + '-dev']
|
||||
+ default_deps_nocxx,
|
||||
cmake_extra='-DCMAKE_C_COMPILER=clang-' + version +
|
||||
' -DCMAKE_CXX_COMPILER=clang++-' + version +
|
||||
' -DCMAKE_CXX_FLAGS=-stdlib=libc++ ' +
|
||||
std.join(' ', [
|
||||
'-DCMAKE_' + type + '_LINKER_FLAGS=-fuse-ld=lld-' + version
|
||||
for type in ['EXE', 'MODULE', 'SHARED']
|
||||
])
|
||||
);
|
||||
|
||||
// Macos build
|
||||
local mac_builder(name,
|
||||
build_type='Release',
|
||||
werror=true,
|
||||
cmake_extra='',
|
||||
local_mirror=true,
|
||||
extra_cmds=[],
|
||||
jobs=6,
|
||||
codesign='-DCODESIGN=OFF',
|
||||
allow_fail=false) = {
|
||||
kind: 'pipeline',
|
||||
type: 'exec',
|
||||
name: name,
|
||||
platform: { os: 'darwin', arch: 'amd64' },
|
||||
steps: [
|
||||
{ name: 'submodules', commands: submodule_commands },
|
||||
{
|
||||
name: 'build',
|
||||
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
|
||||
commands: [
|
||||
'echo "Building on ${DRONE_STAGE_MACHINE}"',
|
||||
// If you don't do this then the C compiler doesn't have an include path containing
|
||||
// basic system headers. WTF apple:
|
||||
'export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"',
|
||||
'ulimit -n 1024', // because macos sets ulimit to 256 for some reason yeah idk
|
||||
'./contrib/mac-configure.sh ' +
|
||||
ci_dep_mirror(local_mirror) +
|
||||
(if build_type == 'Debug' then ' -DWARN_DEPRECATED=OFF ' else '') +
|
||||
codesign,
|
||||
'cd build-mac',
|
||||
// We can't use the 'package' target here because making a .dmg requires an active logged in
|
||||
// macos gui to invoke Finder to invoke the partitioning tool to create a partitioned (!)
|
||||
// disk image. Most likely the GUI is required because if you lose sight of how pretty the
|
||||
// surface of macOS is you might see how ugly the insides are.
|
||||
'ninja -j' + jobs + ' assemble_gui',
|
||||
'cd ..',
|
||||
] + extra_cmds,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
local docs_pipeline(name, image, extra_cmds=[], allow_fail=false) = {
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
name: name,
|
||||
platform: { arch: 'amd64' },
|
||||
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
|
||||
steps: [
|
||||
submodules,
|
||||
{
|
||||
name: 'build',
|
||||
image: image,
|
||||
pull: 'always',
|
||||
[if allow_fail then 'failure']: 'ignore',
|
||||
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
|
||||
commands: [
|
||||
'cmake -S . -B build-docs',
|
||||
'make -C build-docs doc',
|
||||
] + extra_cmds,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
[
|
||||
{
|
||||
name: 'lint check',
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
steps: [{
|
||||
name: 'build',
|
||||
image: docker_base + 'lint',
|
||||
pull: 'always',
|
||||
commands: [
|
||||
'echo "Building on ${DRONE_STAGE_MACHINE}"',
|
||||
apt_get_quiet + ' update',
|
||||
apt_get_quiet + ' install -y eatmydata',
|
||||
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y git clang-format-14 jsonnet',
|
||||
'./contrib/ci/drone-format-verify.sh',
|
||||
],
|
||||
}],
|
||||
},
|
||||
// documentation builder
|
||||
docs_pipeline('Documentation',
|
||||
docker_base + 'docbuilder',
|
||||
extra_cmds=['UPLOAD_OS=docs ./contrib/ci/drone-static-upload.sh']),
|
||||
|
||||
// Various debian builds
|
||||
debian_pipeline('Debian sid (amd64)', docker_base + 'debian-sid'),
|
||||
debian_pipeline('Debian sid/Debug (amd64)', docker_base + 'debian-sid', build_type='Debug'),
|
||||
clang(13),
|
||||
full_llvm(13),
|
||||
debian_pipeline('Debian stable (i386)', docker_base + 'debian-stable/i386'),
|
||||
debian_pipeline('Debian buster (amd64)', docker_base + 'debian-buster', cmake_extra='-DDOWNLOAD_SODIUM=ON'),
|
||||
debian_pipeline('Ubuntu latest (amd64)', docker_base + 'ubuntu-rolling'),
|
||||
debian_pipeline('Ubuntu LTS (amd64)', docker_base + 'ubuntu-lts'),
|
||||
debian_pipeline('Ubuntu bionic (amd64)',
|
||||
docker_base + 'ubuntu-bionic',
|
||||
deps=['g++-8'] + default_deps_nocxx,
|
||||
cmake_extra='-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8',
|
||||
oxen_repo=true),
|
||||
|
||||
// ARM builds (ARM64 and armhf)
|
||||
debian_pipeline('Debian sid (ARM64)', docker_base + 'debian-sid', arch='arm64', jobs=4),
|
||||
debian_pipeline('Debian stable (armhf)', docker_base + 'debian-stable/arm32v7', arch='arm64', jobs=4),
|
||||
|
||||
// cross compile targets
|
||||
// Aug 11: these are exhibiting some dumb failures in libsodium and external deps, TOFIX later
|
||||
//linux_cross_pipeline('Cross Compile (arm/arm64)', cross_targets=['arm-linux-gnueabihf', 'aarch64-linux-gnu']),
|
||||
//linux_cross_pipeline('Cross Compile (ppc64le)', cross_targets=['powerpc64le-linux-gnu']),
|
||||
|
||||
// Not currently building successfully:
|
||||
//linux_cross_pipeline('Cross Compile (mips)', cross_targets=['mips-linux-gnu', 'mipsel-linux-gnu']),
|
||||
|
||||
// android apk builder
|
||||
// Aug 11: this is also failing in openssl, TOFIX later
|
||||
//apk_builder('android apk', docker_base + 'flutter', extra_cmds=['UPLOAD_OS=android ./contrib/ci/drone-static-upload.sh']),
|
||||
|
||||
// Windows builds (x64)
|
||||
windows_cross_pipeline('Windows (amd64)',
|
||||
docker_base + 'debian-bookworm',
|
||||
extra_cmds=[
|
||||
'./contrib/ci/drone-static-upload.sh',
|
||||
]),
|
||||
|
||||
// Static build (on bionic) which gets uploaded to builds.lokinet.dev:
|
||||
debian_pipeline('Static (bionic amd64)',
|
||||
docker_base + 'ubuntu-bionic',
|
||||
deps=['g++-8', 'python3-dev', 'automake', 'libtool'],
|
||||
lto=true,
|
||||
tests=false,
|
||||
oxen_repo=true,
|
||||
cmake_extra='-DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON ' +
|
||||
'-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 ' +
|
||||
'-DCMAKE_CXX_FLAGS="-march=x86-64 -mtune=haswell" ' +
|
||||
'-DCMAKE_C_FLAGS="-march=x86-64 -mtune=haswell" ' +
|
||||
'-DNATIVE_BUILD=OFF -DWITH_SYSTEMD=OFF -DWITH_BOOTSTRAP=OFF -DBUILD_LIBLOKINET=OFF',
|
||||
extra_cmds=[
|
||||
'./contrib/ci/drone-check-static-libs.sh',
|
||||
'./contrib/ci/drone-static-upload.sh',
|
||||
]),
|
||||
// Static armhf build (gets uploaded)
|
||||
debian_pipeline('Static (buster armhf)',
|
||||
docker_base + 'debian-buster/arm32v7',
|
||||
arch='arm64',
|
||||
deps=['g++', 'python3-dev', 'automake', 'libtool'],
|
||||
cmake_extra='-DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON ' +
|
||||
'-DCMAKE_CXX_FLAGS="-march=armv7-a+fp -Wno-psabi" -DCMAKE_C_FLAGS="-march=armv7-a+fp" ' +
|
||||
'-DNATIVE_BUILD=OFF -DWITH_SYSTEMD=OFF -DWITH_BOOTSTRAP=OFF',
|
||||
extra_cmds=[
|
||||
'./contrib/ci/drone-check-static-libs.sh',
|
||||
'UPLOAD_OS=linux-armhf ./contrib/ci/drone-static-upload.sh',
|
||||
],
|
||||
jobs=4),
|
||||
|
||||
// integration tests
|
||||
debian_pipeline('Router Hive',
|
||||
docker_base + 'ubuntu-lts',
|
||||
deps=['python3-dev', 'python3-pytest', 'python3-pybind11'] + default_deps,
|
||||
cmake_extra='-DWITH_HIVE=ON'),
|
||||
|
||||
// Deb builds:
|
||||
deb_builder(docker_base + 'debian-sid-builder', 'sid', 'debian/sid'),
|
||||
deb_builder(docker_base + 'debian-bullseye-builder', 'bullseye', 'debian/bullseye'),
|
||||
deb_builder(docker_base + 'ubuntu-jammy-builder', 'jammy', 'ubuntu/jammy'),
|
||||
deb_builder(docker_base + 'debian-sid-builder', 'sid', 'debian/sid', arch='arm64'),
|
||||
|
||||
// Macos builds:
|
||||
mac_builder('macOS (Release)', extra_cmds=[
|
||||
'./contrib/ci/drone-check-static-libs.sh',
|
||||
'./contrib/ci/drone-static-upload.sh',
|
||||
]),
|
||||
mac_builder('macOS (Debug)', build_type='Debug'),
|
||||
]
|
@ -1,5 +0,0 @@
|
||||
external/date/test export-ignore
|
||||
external/nlohmann/doc export-ignore
|
||||
external/nlohmann/test export-ignore
|
||||
external/nlohmann/benchmarks/data export-ignore
|
||||
*.signed binary
|
@ -1,4 +0,0 @@
|
||||
|
||||
* RUN `make format && make lint -j8` BEFORE COMMITING ALWAYS.
|
||||
|
||||
* no tabs
|
@ -1,22 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
**Screenshots Or Logs**
|
||||
If applicable, add screenshots or log files to help explain your problem.
|
||||
|
||||
**Device and Operating system (please complete the following information):**
|
||||
- OS: [e.g. iOS, Windows, Android]
|
||||
- Device: [ e.g. Mac, PC, IPhone]
|
||||
- Lokinet Version number or Git commit hash:
|
@ -1,22 +0,0 @@
|
||||
name: Close incomplete issues
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 1 * * *"
|
||||
|
||||
jobs:
|
||||
close-issues:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- uses: actions/stale@v4.1.1
|
||||
with:
|
||||
only-labels: incomplete
|
||||
days-before-issue-stale: 14
|
||||
days-before-issue-close: 7
|
||||
stale-issue-label: "stale"
|
||||
stale-issue-message: "This issue is stale because it has been 'incomplete' for 14 days with no activity."
|
||||
close-issue-message: "This issue was closed because it has been inactive for 7 days since being marked as stale."
|
||||
days-before-pr-stale: -1
|
||||
days-before-pr-close: -1
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
@ -0,0 +1,20 @@
|
||||
variables:
|
||||
GIT_STRATEGY: fetch
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
build:linux:
|
||||
image: alpine:latest
|
||||
tags:
|
||||
- linux
|
||||
stage: build
|
||||
before_script:
|
||||
- apk add --update g++ make cmake automake libtool autoconf linux-headers libsodium ninja
|
||||
script:
|
||||
- make
|
||||
artifacts:
|
||||
paths:
|
||||
- "lokinet"
|
||||
|
@ -1,41 +0,0 @@
|
||||
[submodule "external/nlohmann"]
|
||||
path = external/nlohmann
|
||||
url = https://github.com/nlohmann/json.git
|
||||
[submodule "external/ghc-filesystem"]
|
||||
path = external/ghc-filesystem
|
||||
url = https://github.com/gulrak/filesystem.git
|
||||
[submodule "test/Catch2"]
|
||||
path = test/Catch2
|
||||
url = https://github.com/catchorg/Catch2
|
||||
[submodule "external/pybind11"]
|
||||
path = external/pybind11
|
||||
url = https://github.com/pybind/pybind11
|
||||
branch = stable
|
||||
[submodule "external/sqlite_orm"]
|
||||
path = external/sqlite_orm
|
||||
url = https://github.com/fnc12/sqlite_orm
|
||||
[submodule "external/oxen-mq"]
|
||||
path = external/oxen-mq
|
||||
url = https://github.com/oxen-io/oxen-mq
|
||||
[submodule "external/uvw"]
|
||||
path = external/uvw
|
||||
url = https://github.com/jagerman/uvw.git
|
||||
[submodule "external/cpr"]
|
||||
path = external/cpr
|
||||
url = https://github.com/whoshuu/cpr
|
||||
[submodule "external/ngtcp2"]
|
||||
path = external/ngtcp2
|
||||
url = https://github.com/ngtcp2/ngtcp2.git
|
||||
branch = v0.1.0
|
||||
[submodule "external/oxen-encoding"]
|
||||
path = external/oxen-encoding
|
||||
url = https://github.com/oxen-io/oxen-encoding.git
|
||||
[submodule "external/oxen-logging"]
|
||||
path = external/oxen-logging
|
||||
url = https://github.com/oxen-io/oxen-logging.git
|
||||
[submodule "gui"]
|
||||
path = gui
|
||||
url = https://github.com/oxen-io/lokinet-gui.git
|
||||
[submodule "external/CLI11"]
|
||||
path = external/CLI11
|
||||
url = https://github.com/CLIUtils/CLI11.git
|
@ -1 +0,0 @@
|
||||
5.4.2
|
@ -0,0 +1,27 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"browse": {
|
||||
"path": [
|
||||
"${workspaceFolder}/llarp",
|
||||
"${workspaceFolder}/daemon",
|
||||
"${workspaceFolder}/include",
|
||||
"${workspaceFolder}/vendor/cppbackport-master/lib"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true
|
||||
},
|
||||
"includePath": [
|
||||
"${workspaceFolder}/include",
|
||||
"${workspaceFolder}/llarp",
|
||||
"${workspaceFolder}/vendor/cppbackport-master/lib"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"intelliSenseMode": "clang-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(gdb) Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "enter program name, for example ${workspaceFolder}/a.out",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
{
|
||||
"editor.formatOnSave": true,
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"limits": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"atomic": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"chrono": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"exception": "cpp",
|
||||
"filesystem": "cpp",
|
||||
"string_view": "cpp",
|
||||
"fstream": "cpp",
|
||||
"functional": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"memory": "cpp",
|
||||
"mutex": "cpp",
|
||||
"optional": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ratio": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"system_error": "cpp",
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"tuple": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"utility": "cpp",
|
||||
"__config": "cpp",
|
||||
"__nullptr": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"io": "cpp",
|
||||
"strstream": "cpp",
|
||||
"numeric": "cpp",
|
||||
"valarray": "cpp",
|
||||
"*.ipp": "cpp",
|
||||
"csignal": "cpp",
|
||||
"future": "cpp",
|
||||
"map": "cpp",
|
||||
"vector": "cpp",
|
||||
"new": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"complex": "cpp"
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"type": "shell",
|
||||
"command": "make",
|
||||
"group": "build",
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,340 +1,539 @@
|
||||
cmake_minimum_required(VERSION 3.13...3.24) # 3.13 is buster's version
|
||||
cmake_minimum_required(VERSION 2.8.10)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(PROJECT_NAME lokinet)
|
||||
project(${PROJECT_NAME})
|
||||
|
||||
# Has to be set before `project()`, and ignored on non-macos:
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE STRING "macOS deployment target (Apple clang only)")
|
||||
macro(add_cflags)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGN}")
|
||||
endmacro(add_cflags)
|
||||
|
||||
option(BUILD_DAEMON "build lokinet daemon and associated utils" ON)
|
||||
macro(add_cxxflags)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGN}")
|
||||
endmacro(add_cxxflags)
|
||||
|
||||
|
||||
set(LANGS C CXX)
|
||||
if(APPLE AND BUILD_DAEMON)
|
||||
set(LANGS ${LANGS} OBJC Swift)
|
||||
endif()
|
||||
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if(CCACHE_PROGRAM)
|
||||
foreach(lang ${LANGS})
|
||||
if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND NOT CMAKE_${lang}_COMPILER MATCHES ".*/ccache")
|
||||
message(STATUS "Enabling ccache for ${lang}")
|
||||
set(CMAKE_${lang}_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
project(lokinet
|
||||
VERSION 0.9.11
|
||||
DESCRIPTION "lokinet - IP packet onion router"
|
||||
LANGUAGES ${LANGS})
|
||||
|
||||
if(APPLE)
|
||||
# Apple build number: must be incremented to submit a new build for the same lokinet version,
|
||||
# should be reset to 0 when the lokinet version increments.
|
||||
set(LOKINET_APPLE_BUILD 5)
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
if (WIN32 AND NOT MINGW)
|
||||
CHECK_CXX_COMPILER_FLAG("/std:c++17" COMPILER_SUPPORTS_CXX17)
|
||||
else()
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
|
||||
endif()
|
||||
|
||||
set(RELEASE_MOTTO "Our Lord And Savior" CACHE STRING "Release motto")
|
||||
option(HAVE_CXX17_FILESYSTEM "Disable if your C++ compiler and runtime library lacks std::[experimental::]filesystem" ON)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
set(DEFAULT_WITH_BOOTSTRAP ON)
|
||||
if(APPLE)
|
||||
set(DEFAULT_WITH_BOOTSTRAP OFF)
|
||||
if(COMPILER_SUPPORTS_CXX11 AND NOT HAVE_CXX17_FILESYSTEM)
|
||||
add_cxxflags("-std=c++11")
|
||||
elseif(COMPILER_SUPPORTS_CXX17 AND HAVE_CXX17_FILESYSTEM)
|
||||
if (WIN32 AND NOT MINGW)
|
||||
add_cxxflags("/std:c++17")
|
||||
else()
|
||||
add_cxxflags("-std=c++17")
|
||||
endif()
|
||||
add_definitions(-DUSE_CXX17_FILESYSTEM)
|
||||
else()
|
||||
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or C++17 support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
|
||||
add_cxxflags("-fpermissive")
|
||||
|
||||
# Core options
|
||||
option(USE_AVX2 "enable avx2 code" OFF)
|
||||
option(USE_NETNS "enable networking namespace support. Linux only" OFF)
|
||||
option(NATIVE_BUILD "optimise for host system and FPU" ON)
|
||||
option(WITH_EMBEDDED_LOKINET "build liblokinet.so for embedded lokinet" OFF)
|
||||
option(XSAN "use sanitiser, if your system has it (requires -DCMAKE_BUILD_TYPE=Debug)" OFF)
|
||||
option(USE_JEMALLOC "Link to jemalloc for memory allocations, if found" ON)
|
||||
option(TESTNET "testnet build" OFF)
|
||||
option(WITH_COVERAGE "generate coverage data" OFF)
|
||||
option(WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for development, on for release" OFF)
|
||||
option(WITH_TESTS "build unit tests" OFF)
|
||||
option(WITH_HIVE "build simulation stubs" OFF)
|
||||
option(BUILD_PACKAGE "builds extra components for making an installer (with 'make package')" OFF)
|
||||
option(WITH_BOOTSTRAP "build lokinet-bootstrap tool" ${DEFAULT_WITH_BOOTSTRAP})
|
||||
option(WITH_PEERSTATS "build with experimental peerstats db support" OFF)
|
||||
option(STRIP_SYMBOLS "strip off all debug symbols into an external archive for all executables built" OFF)
|
||||
|
||||
set(BOOTSTRAP_FALLBACK_MAINNET "${PROJECT_SOURCE_DIR}/contrib/bootstrap/mainnet.signed" CACHE PATH "Fallback bootstrap path (mainnet)")
|
||||
set(BOOTSTRAP_FALLBACK_TESTNET "${PROJECT_SOURCE_DIR}/contrib/bootstrap/testnet.signed" CACHE PATH "Fallback bootstrap path (testnet)")
|
||||
|
||||
include(cmake/enable_lto.cmake)
|
||||
|
||||
option(CROSS_PLATFORM "cross compiler platform" "Linux")
|
||||
option(CROSS_PREFIX "toolchain cross compiler prefix" "")
|
||||
|
||||
option(BUILD_STATIC_DEPS "Download, build, and statically link against core dependencies" OFF)
|
||||
option(STATIC_LINK "link statically against dependencies" ${BUILD_STATIC_DEPS})
|
||||
if(BUILD_STATIC_DEPS AND NOT STATIC_LINK)
|
||||
message(FATAL_ERROR "Option BUILD_STATIC_DEPS requires STATIC_LINK to be enabled as well")
|
||||
endif()
|
||||
if(BUILD_STATIC_DEPS)
|
||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
|
||||
include(StaticBuild)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo)
|
||||
if(DEBIAN)
|
||||
add_definitions(-DDEBIAN)
|
||||
endif()
|
||||
|
||||
set(debug OFF)
|
||||
if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
|
||||
set(debug ON)
|
||||
add_definitions(-DLOKINET_DEBUG)
|
||||
if(ANDROID)
|
||||
set(THREAD_LIB "-pthread")
|
||||
# finally removed pthread dependency for MSC++
|
||||
elseif(WIN32 AND NOT MINGW)
|
||||
set(THREAD_LIB)
|
||||
else()
|
||||
set(THREAD_LIB pthread)
|
||||
endif()
|
||||
|
||||
option(WARN_DEPRECATED "show deprecation warnings" ${debug})
|
||||
|
||||
if(BUILD_STATIC_DEPS AND STATIC_LINK)
|
||||
message(STATUS "we are building static deps so we won't build shared libs")
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
|
||||
if(STATIC_LINK)
|
||||
add_cflags("-static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")
|
||||
add_cxxflags("-static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")
|
||||
endif()
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckLibraryExists)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_C_EXTENSIONS OFF)
|
||||
|
||||
include(cmake/target_link_libraries_system.cmake)
|
||||
include(cmake/add_import_library.cmake)
|
||||
include(cmake/libatomic.cmake)
|
||||
|
||||
if (STATIC_LINK)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
message(STATUS "setting static library suffix search")
|
||||
if(SHADOW)
|
||||
set(WITH_STATIC OFF)
|
||||
else()
|
||||
set(WITH_STATIC ON)
|
||||
endif()
|
||||
|
||||
include(cmake/gui-option.cmake)
|
||||
|
||||
include(cmake/solaris.cmake)
|
||||
include(cmake/win32.cmake)
|
||||
include(cmake/macos.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]'.")
|
||||
|
||||
# Always build PIC
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
include(cmake/unix.cmake)
|
||||
include(cmake/check_for_std_optional.cmake)
|
||||
include(cmake/check_for_std_filesystem.cmake)
|
||||
|
||||
if(NOT WIN32)
|
||||
if(IOS OR ANDROID)
|
||||
set(NON_PC_TARGET ON)
|
||||
else()
|
||||
include(TargetArch)
|
||||
target_architecture(COMPILE_ARCH)
|
||||
if(COMPILE_ARCH MATCHES i386 OR COMPILE_ARCH MATCHES x86_64)
|
||||
set(NON_PC_TARGET OFF)
|
||||
else()
|
||||
set(NON_PC_TARGET ON)
|
||||
endif()
|
||||
endif()
|
||||
if (UNIX OR MINGW OR APPLE)
|
||||
add_cflags("-Wall")
|
||||
add_cxxflags("-Wall")
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
if(NOT BUILD_STATIC_DEPS)
|
||||
pkg_check_modules(LIBUV libuv>=1.18.0 IMPORTED_TARGET)
|
||||
endif()
|
||||
if(LIBUV_FOUND AND NOT BUILD_STATIC_DEPS)
|
||||
add_library(libuv INTERFACE)
|
||||
target_link_libraries(libuv INTERFACE PkgConfig::LIBUV)
|
||||
if (WIN32 AND NOT MINGW)
|
||||
set(OPTIMIZE_FLAGS "-Od")
|
||||
set(DEBUG_FLAGS "-ZI")
|
||||
else()
|
||||
if(NOT BUILD_STATIC_DEPS)
|
||||
message(FATAL_ERROR "Could not find libuv >= 1.28.0; install it on your system or use -DBUILD_STATIC_DEPS=ON")
|
||||
endif()
|
||||
set(OPTIMIZE_FLAGS "-O0")
|
||||
set(DEBUG_FLAGS "-g")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET sodium)
|
||||
# Allow -D DOWNLOAD_SODIUM=FORCE to download without even checking for a local libsodium
|
||||
option(DOWNLOAD_SODIUM "Allow libsodium to be downloaded and built locally if not found on the system" OFF)
|
||||
if(NOT DOWNLOAD_SODIUM STREQUAL "FORCE" AND NOT BUILD_STATIC_DEPS)
|
||||
pkg_check_modules(SODIUM libsodium>=1.0.18 IMPORTED_TARGET)
|
||||
endif()
|
||||
if(ASAN)
|
||||
set(DEBUG_FLAGS "${DEBUG_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
||||
set(OPTIMIZE_FLAGS "-O0")
|
||||
endif(ASAN)
|
||||
|
||||
add_library(sodium INTERFACE)
|
||||
if(SODIUM_FOUND AND NOT DOWNLOAD_SODIUM STREQUAL "FORCE" AND NOT BUILD_STATIC_DEPS)
|
||||
target_link_libraries(sodium INTERFACE PkgConfig::SODIUM)
|
||||
if(SHADOW)
|
||||
if("${SHADOW_ROOT}" STREQUAL "")
|
||||
set(SHADOW_ROOT "$ENV{HOME}/.shadow")
|
||||
endif("${SHADOW_ROOT}" STREQUAL "")
|
||||
if(EXISTS "${SHADOW_ROOT}")
|
||||
message(STATUS "SHADOW_ROOT = ${SHADOW_ROOT}")
|
||||
else()
|
||||
if(NOT DOWNLOAD_SODIUM AND NOT BUILD_STATIC_DEPS)
|
||||
message(FATAL_ERROR "Could not find libsodium >= 1.0.18; either install it on your system or use -DDOWNLOAD_SODIUM=ON to download and build an internal copy")
|
||||
endif()
|
||||
message(STATUS "Sodium >= 1.0.18 not found, but DOWNLOAD_SODIUM specified, so downloading it")
|
||||
include(DownloadLibSodium)
|
||||
target_link_libraries(sodium INTERFACE sodium_vendor)
|
||||
message(FATAL_ERROR "SHADOW_ROOT path does not exist: '${SHADOW_ROOT}'")
|
||||
endif()
|
||||
|
||||
# Need this target export so that loki-mq properly picks up sodium
|
||||
export(TARGETS sodium NAMESPACE sodium:: FILE sodium-exports.cmake)
|
||||
endif()
|
||||
|
||||
set(warning_flags -Wall -Wextra -Wno-unknown-pragmas -Wno-unused-function -Werror=vla)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
list(APPEND warning_flags -Wno-unknown-warning-option)
|
||||
endif()
|
||||
if(WARN_DEPRECATED)
|
||||
list(APPEND warning_flags -Wdeprecated-declarations)
|
||||
set(CMAKE_MODULE_PATH "${SHADOW_ROOT}/share/cmake/Modules")
|
||||
include_directories(${CMAKE_MODULE_PATH})
|
||||
include(ShadowTools)
|
||||
add_cxxflags("-fno-inline -fno-strict-aliasing")
|
||||
add_cflags("-fno-inline -fno-strict-aliasing")
|
||||
add_definitions(-DTESTNET=true)
|
||||
add_definitions(-DSHADOW_TESTNET)
|
||||
include_directories(${SHADOW_ROOT}/include)
|
||||
endif()
|
||||
|
||||
if (WIN32 AND NOT MINGW)
|
||||
add_cflags("-wd4996 -wd4244 -MP ${OPTIMIZE_FLAGS}")
|
||||
add_cxxflags("-wd4996 -wd4244 -MP ${OPTIMIZE_FLAGS}")
|
||||
else()
|
||||
list(APPEND warning_flags -Wno-deprecated-declarations)
|
||||
endif()
|
||||
|
||||
# If we blindly add these directly as compile_options then they get passed to swiftc on Apple and
|
||||
# break, so we use a generate expression to set them only for C++/C/ObjC
|
||||
add_compile_options("$<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:OBJC>>:${warning_flags}>")
|
||||
|
||||
if(XSAN)
|
||||
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fsanitize=${XSAN} -fno-omit-frame-pointer -fno-sanitize-recover")
|
||||
foreach(type EXE MODULE SHARED STATIC)
|
||||
string(APPEND CMAKE_${type}_LINKER_FLAGS_DEBUG " -fsanitize=${XSAN} -fno-omit-frame-pointer -fno-sanitize-recover")
|
||||
endforeach()
|
||||
message(STATUS "Doing a ${XSAN} sanitizer build")
|
||||
endif()
|
||||
|
||||
include(cmake/coverage.cmake)
|
||||
|
||||
# these vars are set by the cmake toolchain spec
|
||||
if (WOW64_CROSS_COMPILE OR WIN64_CROSS_COMPILE)
|
||||
include(cmake/cross_compile.cmake)
|
||||
add_cflags("-Wall -Wno-deprecated-declarations ${OPTIMIZE_FLAGS}")
|
||||
add_cxxflags("-Wall -Wno-deprecated-declarations ${OPTIMIZE_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(NOT APPLE)
|
||||
if(NATIVE_BUILD)
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le)
|
||||
add_compile_options(-mcpu=native -mtune=native)
|
||||
else()
|
||||
add_compile_options(-march=native -mtune=native)
|
||||
endif()
|
||||
elseif(NOT NON_PC_TARGET)
|
||||
if (USE_AVX2)
|
||||
add_compile_options(-march=haswell -mtune=haswell -mfpmath=sse)
|
||||
else()
|
||||
# Public binary releases
|
||||
add_compile_options(-march=nocona -mtune=haswell -mfpmath=sse)
|
||||
endif()
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
|
||||
add_cflags("${DEBUG_FLAGS}")
|
||||
add_cxxflags("${DEBUG_FLAGS}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if(TESTNET)
|
||||
add_definitions(-DTESTNET)
|
||||
# 5 times slower than realtime
|
||||
# add_definitions(-DTESTNET_SPEED=5)
|
||||
if(SHADOW)
|
||||
add_cflags("-fPIC")
|
||||
add_cxxflags("-fPIC")
|
||||
endif()
|
||||
|
||||
unset(GIT_VERSION)
|
||||
unset(GIT_VERSION_REAL)
|
||||
|
||||
if(NOT GIT_VERSION)
|
||||
exec_program("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "rev-parse --short HEAD" OUTPUT_VARIABLE GIT_VERSION_UNSTRIP)
|
||||
string(STRIP "${GIT_VERSION_UNSTRIP}" GIT_VERSION)
|
||||
exec_program("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "rev-parse --short HEAD" OUTPUT_VARIABLE GIT_VERSION)
|
||||
add_definitions(-DGIT_REV="${GIT_VERSION}")
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "^fatal.*$" nogit GIT_VERSION_REAL "${GIT_VERSION}")
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
if (NOT BUILD_STATIC_DEPS)
|
||||
pkg_check_modules(UNBOUND libunbound REQUIRED IMPORTED_TARGET)
|
||||
add_library(libunbound INTERFACE)
|
||||
target_link_libraries(libunbound INTERFACE PkgConfig::UNBOUND)
|
||||
if(RELEASE_MOTTO)
|
||||
add_definitions(-DLLARP_RELEASE_MOTTO="${RELEASE_MOTTO}")
|
||||
endif()
|
||||
|
||||
pkg_check_modules(SD libsystemd IMPORTED_TARGET)
|
||||
# Default WITH_SYSTEMD to true if we found it
|
||||
option(WITH_SYSTEMD "enable systemd integration for sd_notify" ${SD_FOUND})
|
||||
|
||||
# Base interface target where we set up global link libraries, definitions, includes, etc.
|
||||
add_library(base_libs INTERFACE)
|
||||
set(EXE lokinet)
|
||||
set(EXE_SRC daemon/main.cpp)
|
||||
|
||||
if(WITH_SYSTEMD AND (NOT ANDROID))
|
||||
if(NOT SD_FOUND)
|
||||
message(FATAL_ERROR "libsystemd not found")
|
||||
endif()
|
||||
target_link_libraries(base_libs INTERFACE PkgConfig::SD)
|
||||
target_compile_definitions(base_libs INTERFACE WITH_SYSTEMD)
|
||||
if(SODIUM_INCLUDE_DIR)
|
||||
include_directories(${SODIUM_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
add_subdirectory(external)
|
||||
|
||||
if(USE_JEMALLOC AND NOT STATIC_LINK)
|
||||
pkg_check_modules(JEMALLOC jemalloc IMPORTED_TARGET)
|
||||
if(JEMALLOC_FOUND)
|
||||
target_link_libraries(base_libs INTERFACE PkgConfig::JEMALLOC)
|
||||
else()
|
||||
message(STATUS "jemalloc not found, not linking to jemalloc")
|
||||
if(SODIUM_LIBRARIES)
|
||||
set(SODIUM_LIB ${SODIUM_LIBRARIES})
|
||||
else()
|
||||
find_library (
|
||||
SODIUM_LIB
|
||||
NAMES sodium libsodium
|
||||
HINTS "/usr/local/lib"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(JEMALLOC)
|
||||
set(MALLOC_LIB jemalloc)
|
||||
endif()
|
||||
|
||||
set(LIBS ${SODIUM_LIB} ${THREAD_LIB} ${MALLOC_LIB})
|
||||
if(HAVE_CXX17_FILESYSTEM)
|
||||
set(LIBS ${LIBS} stdc++fs)
|
||||
endif()
|
||||
|
||||
set(LIB lokinet)
|
||||
set(SHARED_LIB ${LIB})
|
||||
set(STATIC_LIB ${LIB}-static)
|
||||
|
||||
set(TT_ROOT vendor/libtuntap-master)
|
||||
|
||||
add_definitions(-D${CMAKE_SYSTEM_NAME})
|
||||
|
||||
if (UNIX)
|
||||
add_definitions(-DUNIX)
|
||||
add_definitions(-DPOSIX)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-linux.c)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-linux.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-openbsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-netbsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-freebsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-darwin.c ${TT_ROOT}/tuntap-unix-bsd.c)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-sunos.c)
|
||||
else()
|
||||
message(FATAL_ERROR "Your operating system is not supported yet")
|
||||
endif()
|
||||
elseif(WIN32 OR MINGW)
|
||||
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-windows.c)
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
add_definitions(-DWIN32)
|
||||
else()
|
||||
message(FATAL_ERROR "What operating system _are_ you building on/for?")
|
||||
endif(UNIX)
|
||||
|
||||
if(TUNTAP)
|
||||
set(LIBTUNTAP_SRC_BASE
|
||||
${TT_ROOT}/tuntap.cpp
|
||||
${TT_ROOT}/tuntap_log.cpp
|
||||
${LIBTUNTAP_IMPL})
|
||||
if (UNIX)
|
||||
set(LIBTUNTAP_SRC
|
||||
${TT_ROOT}/tuntap-unix.c
|
||||
${LIBTUNTAP_SRC_BASE})
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "jemalloc support disabled")
|
||||
endif()
|
||||
|
||||
set(LIBTUNTAP_SRC "")
|
||||
endif()
|
||||
|
||||
#if(BACKPORT)
|
||||
#else()
|
||||
#set(CPP_BACKPORT_SRC "")
|
||||
#endif()
|
||||
|
||||
set(CPP_BACKPORT_SRC
|
||||
vendor/cppbackport-master/lib/fs/rename.cpp
|
||||
vendor/cppbackport-master/lib/fs/filestatus.cpp
|
||||
vendor/cppbackport-master/lib/fs/filetype.cpp
|
||||
vendor/cppbackport-master/lib/fs/cleanpath.cpp
|
||||
vendor/cppbackport-master/lib/fs/perms.cpp
|
||||
vendor/cppbackport-master/lib/fs/equivalent.cpp
|
||||
vendor/cppbackport-master/lib/fs/current_path.cpp
|
||||
vendor/cppbackport-master/lib/fs/basename.cpp
|
||||
vendor/cppbackport-master/lib/fs/tempdir.cpp
|
||||
vendor/cppbackport-master/lib/fs/create_directory.cpp
|
||||
vendor/cppbackport-master/lib/fs/path.cpp
|
||||
vendor/cppbackport-master/lib/fs/remove.cpp
|
||||
vendor/cppbackport-master/lib/fs/diriter.cpp
|
||||
vendor/cppbackport-master/lib/fs/copyfile.cpp
|
||||
vendor/cppbackport-master/lib/fs/absolute.cpp
|
||||
vendor/cppbackport-master/lib/fs/direntry.cpp
|
||||
)
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(base_libs INTERFACE log)
|
||||
target_compile_definitions(base_libs INTERFACE ANDROID)
|
||||
set(ANDROID_PLATFORM_SRC android/ifaddrs.c)
|
||||
endif()
|
||||
|
||||
if(WITH_HIVE)
|
||||
add_definitions(-DLOKINET_HIVE)
|
||||
endif()
|
||||
|
||||
add_subdirectory(crypto)
|
||||
add_subdirectory(llarp)
|
||||
if(BUILD_DAEMON)
|
||||
add_subdirectory(daemon)
|
||||
endif()
|
||||
|
||||
if(WITH_HIVE)
|
||||
add_subdirectory(pybind)
|
||||
endif()
|
||||
if(WITH_TESTS OR WITH_HIVE)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
if(ANDROID)
|
||||
add_subdirectory(jni)
|
||||
endif()
|
||||
|
||||
add_subdirectory(docs)
|
||||
|
||||
include(cmake/gui.cmake)
|
||||
|
||||
if(APPLE)
|
||||
macos_target_setup()
|
||||
endif()
|
||||
add_definitions(-DANDROID)
|
||||
set(ANDROID_PLATFORM_SRC llarp/android/ifaddrs.c)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(ISOLATE_PROC_SRC llarp/linux/netns.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
set(LIB_PLATFORM_SRC
|
||||
# for outpug
|
||||
llarp/logger.cpp
|
||||
# needed for threading
|
||||
llarp/logic.cpp
|
||||
# for zero (for net.hpp stuff for llarp::addr stuff)
|
||||
llarp/mem.cpp
|
||||
# for networking
|
||||
llarp/ev.cpp
|
||||
# for timer
|
||||
llarp/time.cpp
|
||||
# for logic
|
||||
llarp/timer.cpp
|
||||
# for threading
|
||||
llarp/threadpool.cpp
|
||||
# for android shim
|
||||
${ANDROID_PLATFORM_SRC}
|
||||
# process isolation implementation
|
||||
${ISOLATE_PROC_SRC}
|
||||
# tun
|
||||
${LIBTUNTAP_SRC}
|
||||
# win32 inline procs
|
||||
llarp/win32_inet.c
|
||||
llarp/win32_intrnl.c
|
||||
contrib/msc/getopt.c
|
||||
contrib/msc/getopt1.c
|
||||
)
|
||||
|
||||
set(NTRU_AVX_SRC
|
||||
crypto/libntrup/src/avx/randomsmall.c
|
||||
crypto/libntrup/src/avx/weight.c
|
||||
crypto/libntrup/src/avx/swap.c
|
||||
crypto/libntrup/src/avx/rq_round3.c
|
||||
crypto/libntrup/src/avx/rq_recip3.c
|
||||
crypto/libntrup/src/avx/small.c
|
||||
crypto/libntrup/src/avx/randomweightw.c
|
||||
crypto/libntrup/src/avx/dec.c
|
||||
crypto/libntrup/src/avx/r3_recip.c
|
||||
crypto/libntrup/src/avx/keypair.c
|
||||
crypto/libntrup/src/avx/rq_rounded.c
|
||||
crypto/libntrup/src/avx/mult.c
|
||||
crypto/libntrup/src/avx/enc.c
|
||||
crypto/libntrup/src/avx/int32_sort.c
|
||||
crypto/libntrup/src/avx/rq.c
|
||||
crypto/libntrup/src/avx/rq_mod3.c
|
||||
)
|
||||
|
||||
set(NTRU_REF_SRC
|
||||
crypto/libntrup/src/ref/randomsmall.c
|
||||
crypto/libntrup/src/ref/swap.c
|
||||
crypto/libntrup/src/ref/rq_round3.c
|
||||
crypto/libntrup/src/ref/rq_recip3.c
|
||||
crypto/libntrup/src/ref/small.c
|
||||
crypto/libntrup/src/ref/rq_mult.c
|
||||
crypto/libntrup/src/ref/randomweightw.c
|
||||
crypto/libntrup/src/ref/random32.c
|
||||
crypto/libntrup/src/ref/dec.c
|
||||
crypto/libntrup/src/ref/r3_mult.c
|
||||
crypto/libntrup/src/ref/r3_recip.c
|
||||
crypto/libntrup/src/ref/keypair.c
|
||||
crypto/libntrup/src/ref/rq_rounded.c
|
||||
crypto/libntrup/src/ref/enc.c
|
||||
crypto/libntrup/src/ref/int32_sort.c
|
||||
crypto/libntrup/src/ref/rq.c
|
||||
)
|
||||
|
||||
include_directories(crypto/libntrup/include)
|
||||
|
||||
set(NTRU_SRC
|
||||
${NTRU_AVX_SRC}
|
||||
${NTRU_REF_SRC}
|
||||
crypto/libntrup/src/ntru.cpp
|
||||
)
|
||||
|
||||
|
||||
set(UTP_SRC
|
||||
libutp/utp_callbacks.cpp
|
||||
libutp/utp_utils.cpp
|
||||
libutp/utp_internal.cpp
|
||||
libutp/utp_api.cpp
|
||||
libutp/utp_packedsockaddr.cpp
|
||||
libutp/utp_hash.cpp
|
||||
)
|
||||
|
||||
|
||||
if(WIN32)
|
||||
set(UTP_SRC ${UTP_SRC} libutp/libutp_inet_ntop.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
set(LIB_SRC
|
||||
${UTP_SRC}
|
||||
${NTRU_SRC}
|
||||
llarp/address_info.cpp
|
||||
llarp/bencode.cpp
|
||||
llarp/buffer.cpp
|
||||
llarp/config.cpp
|
||||
llarp/context.cpp
|
||||
llarp/crypto_async.cpp
|
||||
llarp/crypto_libsodium.cpp
|
||||
llarp/dht.cpp
|
||||
llarp/dns.cpp
|
||||
llarp/dnsc.cpp
|
||||
llarp/dnsd.cpp
|
||||
llarp/encode.cpp
|
||||
llarp/encrypted_frame.cpp
|
||||
llarp/exit_info.cpp
|
||||
llarp/exit_route.cpp
|
||||
llarp/ip.cpp
|
||||
llarp/link_intro.cpp
|
||||
llarp/link_message.cpp
|
||||
llarp/net.cpp
|
||||
llarp/nodedb.cpp
|
||||
llarp/path.cpp
|
||||
llarp/pathbuilder.cpp
|
||||
llarp/pathset.cpp
|
||||
llarp/proofofwork.cpp
|
||||
llarp/relay_commit.cpp
|
||||
llarp/relay_up_down.cpp
|
||||
llarp/router_contact.cpp
|
||||
llarp/router.cpp
|
||||
llarp/service.cpp
|
||||
llarp/transit_hop.cpp
|
||||
llarp/testnet.c
|
||||
llarp/dht/context.cpp
|
||||
llarp/dht/decode.cpp
|
||||
llarp/dht/dht_immediate.cpp
|
||||
llarp/dht/find_intro.cpp
|
||||
llarp/dht/find_router.cpp
|
||||
llarp/dht/got_intro.cpp
|
||||
llarp/dht/got_router.cpp
|
||||
llarp/dht/publish_intro.cpp
|
||||
llarp/handlers/tun.cpp
|
||||
llarp/link/curvecp.cpp
|
||||
llarp/link/server.cpp
|
||||
llarp/link/utp.cpp
|
||||
llarp/routing/dht_message.cpp
|
||||
llarp/routing/message_parser.cpp
|
||||
llarp/routing/path_confirm.cpp
|
||||
llarp/routing/path_latency.cpp
|
||||
llarp/routing/path_transfer.cpp
|
||||
llarp/service/address.cpp
|
||||
llarp/service/context.cpp
|
||||
llarp/service/endpoint.cpp
|
||||
llarp/service/lookup.cpp
|
||||
llarp/service/protocol.cpp
|
||||
llarp/service/tag.cpp
|
||||
llarp/service/info.cpp
|
||||
|
||||
)
|
||||
|
||||
set(RC_SRC
|
||||
daemon/rcutil.cpp
|
||||
)
|
||||
|
||||
set(DNS_SRC
|
||||
llarp/dns.cpp
|
||||
llarp/dnsc.cpp
|
||||
llarp/dnsd.cpp
|
||||
llarp/net.cpp
|
||||
daemon/dns.cpp
|
||||
)
|
||||
|
||||
set(TEST_SRC
|
||||
test/main.cpp
|
||||
test/base32_unittest.cpp
|
||||
test/dht_unittest.cpp
|
||||
test/encrypted_frame_unittest.cpp
|
||||
test/hiddenservice_unittest.cpp
|
||||
test/pq_unittest.cpp
|
||||
)
|
||||
|
||||
|
||||
set(TEST_EXE testAll)
|
||||
set(GTEST_DIR test/gtest)
|
||||
|
||||
set(CLIENT_EXE llarpc)
|
||||
|
||||
set(CLIENT_SRC
|
||||
client/main.cpp
|
||||
)
|
||||
|
||||
set(ALL_SRC ${CLIENT_SRC} ${RC_SRC} ${EXE_SRC} ${DNS_SRC} ${LIB_PLATFORM_SRC} ${LIB_SRC} ${TEST_SRC} ${CPP_BACKPORT_SRC})
|
||||
|
||||
foreach(F ${ALL_SRC})
|
||||
set_source_files_properties(${F} PROPERTIES COMPILE_FLAGS -DLOG_TAG=\\\"${F}\\\")
|
||||
endforeach(F)
|
||||
|
||||
set(LIB lokinet)
|
||||
set(SHARED_LIB ${LIB})
|
||||
set(STATIC_LIB ${LIB}-static)
|
||||
set(BACKPORT_LIB ${LIB}-backport)
|
||||
set(PLATFORM_LIB ${LIB}-platform)
|
||||
set(ANDROID_LIB ${LIB}android)
|
||||
|
||||
# TODO: exclude this from includes and expose stuff properly for rcutil
|
||||
include_directories(llarp)
|
||||
include_directories(include)
|
||||
include_directories(vendor/cppbackport-master/lib)
|
||||
include_directories(${sodium_INCLUDE_DIR})
|
||||
|
||||
if (WIN32 AND NOT MINGW)
|
||||
include_directories(contrib/msc/include)
|
||||
link_directories(contrib/msc/lib)
|
||||
endif()
|
||||
|
||||
set(RC_EXE rcutil)
|
||||
set(DNS_EXE dns)
|
||||
|
||||
|
||||
if(SHADOW)
|
||||
add_shadow_plugin(shadow-plugin-${SHARED_LIB} ${EXE_SRC} ${LIB_SRC} ${LIB_PLATFORM_SRC} ${CPP_BACKPORT_SRC})
|
||||
target_link_libraries(shadow-plugin-${SHARED_LIB} ${LIBS})
|
||||
install(TARGETS shadow-plugin-${SHARED_LIB} DESTINATION plugins)
|
||||
else()
|
||||
add_executable(${RC_EXE} ${RC_SRC})
|
||||
add_executable(${EXE} ${EXE_SRC})
|
||||
add_executable(${CLIENT_EXE} ${CLIENT_SRC})
|
||||
add_executable(${DNS_EXE} ${DNS_SRC})
|
||||
|
||||
# uninstall target
|
||||
if(NOT TARGET uninstall)
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
endif()
|
||||
|
||||
if(BUILD_PACKAGE AND NOT APPLE)
|
||||
include(cmake/installer.cmake)
|
||||
endif()
|
||||
if(NOT WIN32)
|
||||
add_subdirectory(${GTEST_DIR})
|
||||
include_directories(${GTEST_DIR}/include ${GTEST_DIR})
|
||||
add_executable(${TEST_EXE} ${TEST_SRC})
|
||||
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB})
|
||||
endif()
|
||||
if(WITH_STATIC)
|
||||
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
|
||||
if(NOT HAVE_CXX17_FILESYSTEM)
|
||||
add_library(${BACKPORT_LIB} STATIC ${CPP_BACKPORT_SRC})
|
||||
endif(NOT HAVE_CXX17_FILESYSTEM)
|
||||
add_library(${PLATFORM_LIB} STATIC ${LIB_PLATFORM_SRC})
|
||||
target_link_libraries(${PLATFORM_LIB} ${THREAD_LIB})
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
target_link_libraries(${PLATFORM_LIB} -lcap)
|
||||
endif()
|
||||
if(NOT HAVE_CXX17_FILESYSTEM)
|
||||
target_link_libraries(${STATIC_LIB} ${LIBS} ${PLATFORM_LIB} ${BACKPORT_LIB})
|
||||
else()
|
||||
target_link_libraries(${STATIC_LIB} ${LIBS} ${PLATFORM_LIB})
|
||||
endif(NOT HAVE_CXX17_FILESYSTEM)
|
||||
if(NOT WITH_SHARED)
|
||||
if(NOT HAVE_CXX17_FILESYSTEM)
|
||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB})
|
||||
if (MINGW)
|
||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 stdc++fs iphlpapi)
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 stdc++fs iphlpapi)
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 stdc++fs iphlpapi)
|
||||
elseif(WIN32)
|
||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
endif(MINGW)
|
||||
else()
|
||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB})
|
||||
if (MINGW)
|
||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 stdc++fs iphlpapi)
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 stdc++fs iphlpapi)
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 stdc++fs iphlpapi)
|
||||
elseif(WIN32)
|
||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
endif(MINGW)
|
||||
endif(NOT HAVE_CXX17_FILESYSTEM)
|
||||
if (MINGW)
|
||||
target_link_libraries(${DNS_EXE} ${STATIC_LIB} ${PLATFORM_LIB} ${THREAD_LIB} ws2_32 stdc++fs iphlpapi)
|
||||
elseif(WIN32)
|
||||
target_link_libraries(${DNS_EXE} ${STATIC_LIB} ${PLATFORM_LIB} ${THREAD_LIB} ws2_32 iphlpapi)
|
||||
endif(MINGW)
|
||||
target_link_libraries(${DNS_EXE} ${STATIC_LIB} ${PLATFORM_LIB} ${THREAD_LIB})
|
||||
endif(NOT WITH_SHARED)
|
||||
endif(WITH_STATIC)
|
||||
if(ANDROID)
|
||||
add_library(${ANDROID_LIB} SHARED jni/lokinet_android.cpp)
|
||||
target_link_libraries(${ANDROID_LIB} ${STATIC_LIB} ${LIBS} log)
|
||||
endif()
|
||||
|
||||
if(TARGET package)
|
||||
add_dependencies(package assemble_gui)
|
||||
endif()
|
||||
if(WITH_SHARED)
|
||||
if(HAVE_CXX17_FILESYSTEM)
|
||||
set(LIB_SRC ${LIB_SRC} ${CPP_BACKPORT_SRC})
|
||||
endif(HAVE_CXX17_FILESYSTEM)
|
||||
add_library(${SHARED_LIB} SHARED ${LIB_SRC} ${LIB_PLATFORM_SRC})
|
||||
if (MINGW)
|
||||
set(${LIBS} ${LIBS} ws2_32 stdc++fs iphlpapi)
|
||||
elseif(WIN32)
|
||||
set(${LIBS} ${LIBS} ws2_32 iphlpapi)
|
||||
endif(MINGW)
|
||||
target_link_libraries(${SHARED_LIB} ${LIBS} ${THREAD_LIB})
|
||||
target_link_libraries(${EXE} ${SHARED_LIB})
|
||||
target_link_libraries(${RC_EXE} ${SHARED_LIB})
|
||||
target_link_libraries(${DNS_EXE} ${SHARED_LIB} ${THREAD_LIB})
|
||||
endif(WITH_SHARED)
|
||||
endif(SHADOW)
|
||||
|
@ -1,28 +0,0 @@
|
||||
[Español](CONTRIBUTING_es.md)
|
||||
# Do
|
||||
|
||||
* Act like a responsible adult.
|
||||
|
||||
* RUN `./contrib/format.sh` BEFORE COMMITING ALWAYS.
|
||||
|
||||
# Do NOT
|
||||
|
||||
* Bring off topic or non technical issues to the issue tracker.
|
||||
|
||||
* Pester contributors.
|
||||
|
||||
# We WILL
|
||||
|
||||
* Merge Spelling mistake corrections (I have lots of those because spelling is HARD)
|
||||
|
||||
* Merge code based on its correctness, Including patches via email from (pseudo/fully) anonymous contributors.
|
||||
|
||||
# We WILL NOT
|
||||
|
||||
* Accept patches with tabs
|
||||
|
||||
* Merge large and pointless or pedantic changes, (i.e. code formatting shift)
|
||||
|
||||
## additional notes
|
||||
|
||||
github's ui doesn't seem accept this file as a real code of conduct.
|
@ -1,28 +0,0 @@
|
||||
[Ingles](CONTRIBUTING.md)
|
||||
# Lo que debe
|
||||
|
||||
* Actuar como un adulto responsable.
|
||||
|
||||
* CORRER `make format` SIEMPRE ANTES DEL COMMIT.
|
||||
|
||||
# Lo que NO debe
|
||||
|
||||
* Plantear asuntos fuera de lugar o que no son tecnicos en el registro de problemas.
|
||||
|
||||
* Ser un contribuyente molestoso.
|
||||
|
||||
# Lo que nosotros HAREMOS
|
||||
|
||||
* Integrar correcciones de Ortografia (Yo tengo un monton porque la ortografia es COMPLICADA)
|
||||
|
||||
* Integrar codigo en base a que tan correcto es, Incluyendo parches recibidos por correo electronico de contribuyentes (pseudo/completamente) anonimos.
|
||||
|
||||
# Lo que nosotros NO HAREMOS
|
||||
|
||||
* Aceptar parches con tabulaciones
|
||||
|
||||
* Integrar cambios grandes sin sentido o pedantes, (por ejemplo codigo con cambios de formato)
|
||||
|
||||
## notas adicionales
|
||||
|
||||
github no parece aceptar este archivo como un codigo de conducta real.
|
@ -1,674 +1,17 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
Copyright (c) 2018 Jeff Becker
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
@ -0,0 +1,107 @@
|
||||
|
||||
all: test
|
||||
|
||||
SIGN = gpg --sign --detach
|
||||
|
||||
REPO := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
CC ?= cc
|
||||
CXX ?= c++
|
||||
|
||||
TARGETS = lokinet
|
||||
SIGS = $(TARGETS:=.sig)
|
||||
|
||||
|
||||
SHADOW_ROOT ?= $(HOME)/.shadow
|
||||
SHADOW_BIN=$(SHADOW_ROOT)/bin/shadow
|
||||
SHADOW_CONFIG=$(REPO)/shadow.config.xml
|
||||
SHADOW_PLUGIN=$(REPO)/libshadow-plugin-llarp.so
|
||||
SHADOW_LOG=$(REPO)/shadow.log.txt
|
||||
|
||||
SHADOW_SRC ?= $(HOME)/local/shadow
|
||||
SHADOW_PARSE ?= python $(SHADOW_SRC)/src/tools/parse-shadow.py - -m 0 --packet-data
|
||||
SHADOW_PLOT ?= python $(SHADOW_SRC)/src/tools/plot-shadow.py -d $(REPO) LokiNET -c $(SHADOW_CONFIG) -r 10000 -e '.*'
|
||||
|
||||
TESTNET_ROOT=/tmp/lokinet_testnet_tmp
|
||||
TESTNET_CONF=$(TESTNET_ROOT)/supervisor.conf
|
||||
TESTNET_LOG=$(TESTNET_ROOT)/testnet.log
|
||||
|
||||
EXE = $(REPO)/lokinet
|
||||
TEST_EXE = $(REPO)/testAll
|
||||
|
||||
TESTNET_EXE=$(REPO)/lokinet-testnet
|
||||
TESTNET_CLIENTS ?= 50
|
||||
TESTNET_SERVERS ?= 50
|
||||
TESTNET_DEBUG ?= 0
|
||||
|
||||
clean:
|
||||
rm -f build.ninja rules.ninja cmake_install.cmake CMakeCache.txt
|
||||
rm -rf CMakeFiles
|
||||
rm -f $(TARGETS) llarpd llarpc dns rcutil testAll
|
||||
rm -f $(SHADOW_PLUGIN) $(SHADOW_CONFIG)
|
||||
rm -f *.sig
|
||||
rm -f *.a *.so
|
||||
|
||||
debug-configure:
|
||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DTUNTAP=ON
|
||||
|
||||
release-configure: clean
|
||||
cmake -GNinja -DSTATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DTUNTAP=ON
|
||||
|
||||
debug: debug-configure
|
||||
ninja
|
||||
|
||||
release-compile: release-configure
|
||||
ninja
|
||||
strip $(TARGETS)
|
||||
|
||||
$(TARGETS): release-compile
|
||||
|
||||
|
||||
%.sig: $(TARGETS)
|
||||
$(SIGN) $*
|
||||
|
||||
release: $(SIGS)
|
||||
|
||||
shadow-configure: clean
|
||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DSHADOW=ON -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX)
|
||||
|
||||
shadow-build: shadow-configure
|
||||
ninja clean
|
||||
ninja
|
||||
|
||||
shadow-run: shadow-build
|
||||
python3 contrib/shadow/genconf.py $(SHADOW_CONFIG)
|
||||
bash -c "$(SHADOW_BIN) -w $$(cat /proc/cpuinfo | grep processor | wc -l) $(SHADOW_CONFIG) | $(SHADOW_PARSE)"
|
||||
|
||||
shadow-plot: shadow-run
|
||||
$(SHADOW_PLOT)
|
||||
|
||||
shadow: shadow-plot
|
||||
|
||||
testnet-clean: clean
|
||||
rm -rf $(TESTNET_ROOT)
|
||||
|
||||
testnet-configure: testnet-clean
|
||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DTUNTAP=ON
|
||||
|
||||
testnet-build: testnet-configure
|
||||
ninja
|
||||
|
||||
shared-configure: clean
|
||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DWITH_TESTS=ON -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DWITH_SHARED=ON -DTUNTAP=ON
|
||||
|
||||
shared: shared-configure
|
||||
ninja
|
||||
|
||||
testnet:
|
||||
cp $(EXE) $(TESTNET_EXE)
|
||||
mkdir -p $(TESTNET_ROOT)
|
||||
python3 contrib/testnet/genconf.py --bin=$(TESTNET_EXE) --svc=$(TESTNET_SERVERS) --clients=$(TESTNET_CLIENTS) --dir=$(TESTNET_ROOT) --out $(TESTNET_CONF) --connect=3
|
||||
LLARP_DEBUG=$(TESTNET_DEBUG) supervisord -n -d $(TESTNET_ROOT) -l $(TESTNET_LOG) -c $(TESTNET_CONF)
|
||||
|
||||
test: debug
|
||||
$(TEST_EXE)
|
||||
|
||||
format:
|
||||
clang-format -i $$(find daemon llarp include | grep -E '\.[h,c](pp)?$$')
|
@ -0,0 +1,8 @@
|
||||
#include <llarp/logger.h>
|
||||
#include <llarp/logger.hpp>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
return 1;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
set(LIBCURL_PREFIX ${CMAKE_BINARY_DIR}/libcurl)
|
||||
set(LIBCURL_URL https://github.com/curl/curl/releases/download/curl-7_67_0/curl-7.67.0.tar.xz)
|
||||
set(LIBCURL_HASH SHA256=f5d2e7320379338c3952dcc7566a140abb49edb575f9f99272455785c40e536c)
|
||||
|
||||
if(CURL_TARBALL_URL)
|
||||
# make a build time override of the tarball url so we can fetch it if the original link goes away
|
||||
set(LIBCURL_URL ${CURL_TARBALL_URL})
|
||||
endif()
|
||||
|
||||
|
||||
file(MAKE_DIRECTORY ${LIBCURL_PREFIX}/include)
|
||||
|
||||
include(ExternalProject)
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(PROCESSOR_COUNT)
|
||||
if(PROCESSOR_COUNT EQUAL 0)
|
||||
set(PROCESSOR_COUNT 1)
|
||||
endif()
|
||||
|
||||
set(libcurl_cc ${CMAKE_C_COMPILER})
|
||||
if(CCACHE_PROGRAM)
|
||||
set(libcurl_cc "${CCACHE_PROGRAM} ${libcurl_cc}")
|
||||
endif()
|
||||
set(CURL_CONFIGURE ./configure --prefix=${LIBCURL_PREFIX}
|
||||
--without-ssl --without-nss --without-gnutls --without-mbedtls --without-wolfssl --without-mesalink
|
||||
--without-bearssl --without-ca-bundle --without-libidn2 --without-zlib --without-nghttp2 --without-nghttp3
|
||||
--without-quiche --without-zsh-functions-dir --without-fish-functions-dir
|
||||
--without-librtmp --without-ca-fallback --without-ca-path --without-brotli --without-libpsl
|
||||
--disable-manual --disable-dict --disable-file --disable-ftp --disable-gopher --disable-imap --disable-ldap --disable-ldaps
|
||||
--disable-pop3 --disable-rtsp --disable-smtp --disable-telnet --disable-tftp
|
||||
--enable-static --disable-shared CC=${libcurl_cc})
|
||||
|
||||
if (CMAKE_C_COMPILER_ARG1)
|
||||
set(CURL_CONFIGURE ${CURL_CONFIGURE} CPPFLAGS=${CMAKE_C_COMPILER_ARG1})
|
||||
endif()
|
||||
|
||||
if (CROSS_TARGET)
|
||||
set(CURL_CONFIGURE ${CURL_CONFIGURE} --target=${CROSS_TARGET} --host=${CROSS_TARGET})
|
||||
endif()
|
||||
|
||||
|
||||
ExternalProject_Add(libcurl_external
|
||||
BUILD_IN_SOURCE ON
|
||||
PREFIX ${LIBCURL_PREFIX}
|
||||
URL ${LIBCURL_URL}
|
||||
URL_HASH ${LIBCURL_HASH}
|
||||
CONFIGURE_COMMAND ${CURL_CONFIGURE}
|
||||
BUILD_COMMAND make -j${PROCESSOR_COUNT}
|
||||
BUILD_BYPRODUCTS ${LIBCURL_PREFIX}/lib/libcurl.a ${LIBCURL_PREFIX}/include
|
||||
)
|
||||
|
||||
add_library(curl_vendor STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(curl_vendor curl_external)
|
||||
set_target_properties(curl_vendor PROPERTIES
|
||||
IMPORTED_LOCATION ${LIBCURL_PREFIX}/lib/libcurl.a
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${LIBCURL_PREFIX}/include
|
||||
)
|
@ -1,51 +0,0 @@
|
||||
set(LIBSODIUM_PREFIX ${CMAKE_BINARY_DIR}/libsodium)
|
||||
set(LIBSODIUM_URL https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz)
|
||||
set(LIBSODIUM_HASH SHA512=17e8638e46d8f6f7d024fe5559eccf2b8baf23e143fadd472a7d29d228b186d86686a5e6920385fe2020729119a5f12f989c3a782afbd05a8db4819bb18666ef)
|
||||
|
||||
if(SODIUM_TARBALL_URL)
|
||||
# make a build time override of the tarball url so we can fetch it if the original link goes away
|
||||
set(LIBSODIUM_URL ${SODIUM_TARBALL_URL})
|
||||
endif()
|
||||
|
||||
|
||||
file(MAKE_DIRECTORY ${LIBSODIUM_PREFIX}/include)
|
||||
|
||||
include(ExternalProject)
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(PROCESSOR_COUNT)
|
||||
if(PROCESSOR_COUNT EQUAL 0)
|
||||
set(PROCESSOR_COUNT 1)
|
||||
endif()
|
||||
|
||||
set(sodium_cc ${CMAKE_C_COMPILER})
|
||||
if(CCACHE_PROGRAM)
|
||||
set(sodium_cc "${CCACHE_PROGRAM} ${sodium_cc}")
|
||||
endif()
|
||||
set(SODIUM_CONFIGURE ./configure --prefix=${LIBSODIUM_PREFIX} --enable-static --disable-shared --with-pic --quiet CC=${sodium_cc})
|
||||
if (CMAKE_C_COMPILER_ARG1)
|
||||
set(SODIUM_CONFIGURE ${SODIUM_CONFIGURE} CPPFLAGS=${CMAKE_C_COMPILER_ARG1})
|
||||
endif()
|
||||
|
||||
if (CROSS_TARGET)
|
||||
set(SODIUM_CONFIGURE ${SODIUM_CONFIGURE} --target=${CROSS_TARGET} --host=${CROSS_TARGET})
|
||||
endif()
|
||||
|
||||
|
||||
ExternalProject_Add(libsodium_external
|
||||
BUILD_IN_SOURCE ON
|
||||
PREFIX ${LIBSODIUM_PREFIX}
|
||||
URL ${LIBSODIUM_URL}
|
||||
URL_HASH ${LIBSODIUM_HASH}
|
||||
CONFIGURE_COMMAND ${SODIUM_CONFIGURE}
|
||||
PATCH_COMMAND patch -p1 -d <SOURCE_DIR> < ${CMAKE_SOURCE_DIR}/win32-setup/libsodium-1.0.18-win32.patch
|
||||
BUILD_COMMAND make -j${PROCESSOR_COUNT}
|
||||
INSTALL_COMMAND ${MAKE}
|
||||
BUILD_BYPRODUCTS ${LIBSODIUM_PREFIX}/lib/libsodium.a ${LIBSODIUM_PREFIX}/include
|
||||
)
|
||||
|
||||
add_library(sodium_vendor STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(sodium_vendor libsodium_external)
|
||||
set_target_properties(sodium_vendor PROPERTIES
|
||||
IMPORTED_LOCATION ${LIBSODIUM_PREFIX}/lib/libsodium.a
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${LIBSODIUM_PREFIX}/include
|
||||
)
|
@ -1,57 +0,0 @@
|
||||
#
|
||||
# Find the JEMALLOC client includes and library
|
||||
#
|
||||
|
||||
# This module defines
|
||||
# JEMALLOC_INCLUDE_DIR, where to find jemalloc.h
|
||||
# JEMALLOC_LIBRARIES, the libraries to link against
|
||||
# JEMALLOC_FOUND, if false, you cannot build anything that requires JEMALLOC
|
||||
|
||||
# also defined, but not for general use are
|
||||
# JEMALLOC_LIBRARY, where to find the JEMALLOC library.
|
||||
|
||||
set( JEMALLOC_FOUND 0 )
|
||||
|
||||
if ( UNIX )
|
||||
FIND_PATH( JEMALLOC_INCLUDE_DIR
|
||||
NAMES
|
||||
jemalloc/jemalloc.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/include/jemalloc
|
||||
/usr/local/include
|
||||
/usr/local/include/jemalloc
|
||||
$ENV{JEMALLOC_ROOT}
|
||||
$ENV{JEMALLOC_ROOT}/include
|
||||
DOC
|
||||
"Specify include-directories that might contain jemalloc.h here."
|
||||
)
|
||||
FIND_LIBRARY( JEMALLOC_LIBRARY
|
||||
NAMES
|
||||
jemalloc libjemalloc JEMALLOC
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/lib/jemalloc
|
||||
/usr/local/lib
|
||||
/usr/local/lib/jemalloc
|
||||
/usr/local/jemalloc/lib
|
||||
$ENV{JEMALLOC_ROOT}/lib
|
||||
$ENV{JEMALLOC_ROOT}
|
||||
DOC "Specify library-locations that might contain the jemalloc library here."
|
||||
)
|
||||
|
||||
if ( JEMALLOC_LIBRARY )
|
||||
if ( JEMALLOC_INCLUDE_DIR )
|
||||
set( JEMALLOC_FOUND 1 )
|
||||
message( STATUS "Found JEMALLOC library: ${JEMALLOC_LIBRARY}")
|
||||
message( STATUS "Found JEMALLOC headers: ${JEMALLOC_INCLUDE_DIR}")
|
||||
else ( JEMALLOC_INCLUDE_DIR )
|
||||
message(FATAL_ERROR "Could not find jemalloc headers! Please install jemalloc libraries and headers")
|
||||
endif ( JEMALLOC_INCLUDE_DIR )
|
||||
endif ( JEMALLOC_LIBRARY )
|
||||
add_library(jemalloc SHARED IMPORTED)
|
||||
set_target_properties(jemalloc PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${JEMALLOC_INCLUDE_DUR}"
|
||||
IMPORTED_LOCATION "${JEMALLOC_LIBRARY}")
|
||||
mark_as_advanced( JEMALLOC_FOUND JEMALLOC_LIBRARY JEMALLOC_EXTRA_LIBRARIES JEMALLOC_INCLUDE_DIR )
|
||||
endif (UNIX)
|
@ -1,95 +0,0 @@
|
||||
# Taken from https://github.com/neovim/neovim/blob/master/cmake/FindLibUV.cmake
|
||||
# - Try to find libuv
|
||||
# Once done, this will define
|
||||
#
|
||||
# LIBUV_FOUND - system has libuv
|
||||
# LIBUV_INCLUDE_DIRS - the libuv include directories
|
||||
# LIBUV_LIBRARIES - link these to use libuv
|
||||
#
|
||||
# Set the LIBUV_USE_STATIC variable to specify if static libraries should
|
||||
# be preferred to shared ones.
|
||||
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_LIBUV QUIET libuv)
|
||||
endif()
|
||||
|
||||
find_path(LIBUV_INCLUDE_DIR uv.h
|
||||
HINTS ${PC_LIBUV_INCLUDEDIR} ${PC_LIBUV_INCLUDE_DIRS})
|
||||
|
||||
# If we're asked to use static linkage, add libuv.a as a preferred library name.
|
||||
if(LIBUV_USE_STATIC)
|
||||
list(APPEND LIBUV_NAMES
|
||||
"${CMAKE_STATIC_LIBRARY_PREFIX}uv${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endif(LIBUV_USE_STATIC)
|
||||
|
||||
list(APPEND LIBUV_NAMES uv)
|
||||
|
||||
find_library(LIBUV_LIBRARY NAMES ${LIBUV_NAMES}
|
||||
HINTS ${PC_LIBUV_LIBDIR} ${PC_LIBUV_LIBRARY_DIRS})
|
||||
|
||||
mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
|
||||
|
||||
if(PC_LIBUV_LIBRARIES)
|
||||
list(REMOVE_ITEM PC_LIBUV_LIBRARIES uv)
|
||||
endif()
|
||||
|
||||
set(LIBUV_LIBRARIES ${LIBUV_LIBRARY} ${PC_LIBUV_LIBRARIES})
|
||||
set(LIBUV_INCLUDE_DIRS ${LIBUV_INCLUDE_DIR})
|
||||
|
||||
# Deal with the fact that libuv.pc is missing important dependency information.
|
||||
|
||||
include(CheckLibraryExists)
|
||||
|
||||
check_library_exists(dl dlopen "dlfcn.h" HAVE_LIBDL)
|
||||
if(HAVE_LIBDL)
|
||||
list(APPEND LIBUV_LIBRARIES dl)
|
||||
endif()
|
||||
|
||||
check_library_exists(kstat kstat_lookup "kstat.h" HAVE_LIBKSTAT)
|
||||
if(HAVE_LIBKSTAT)
|
||||
list(APPEND LIBUV_LIBRARIES kstat)
|
||||
endif()
|
||||
|
||||
check_library_exists(kvm kvm_open "kvm.h" HAVE_LIBKVM)
|
||||
if(HAVE_LIBKVM AND NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
||||
list(APPEND LIBUV_LIBRARIES kvm)
|
||||
endif()
|
||||
|
||||
check_library_exists(nsl gethostbyname "nsl.h" HAVE_LIBNSL)
|
||||
if(HAVE_LIBNSL)
|
||||
list(APPEND LIBUV_LIBRARIES nsl)
|
||||
endif()
|
||||
|
||||
check_library_exists(perfstat perfstat_cpu "libperfstat.h" HAVE_LIBPERFSTAT)
|
||||
if(HAVE_LIBPERFSTAT)
|
||||
list(APPEND LIBUV_LIBRARIES perfstat)
|
||||
endif()
|
||||
|
||||
check_library_exists(rt clock_gettime "time.h" HAVE_LIBRT)
|
||||
if(HAVE_LIBRT)
|
||||
list(APPEND LIBUV_LIBRARIES rt)
|
||||
endif()
|
||||
|
||||
check_library_exists(sendfile sendfile "" HAVE_LIBSENDFILE)
|
||||
if(HAVE_LIBSENDFILE)
|
||||
list(APPEND LIBUV_LIBRARIES sendfile)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
# check_library_exists() does not work for Win32 API calls in X86 due to name
|
||||
# mangling calling conventions
|
||||
list(APPEND LIBUV_LIBRARIES iphlpapi)
|
||||
list(APPEND LIBUV_LIBRARIES psapi)
|
||||
list(APPEND LIBUV_LIBRARIES userenv)
|
||||
list(APPEND LIBUV_LIBRARIES ws2_32)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set LIBUV_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(LibUV DEFAULT_MSG
|
||||
LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
|
@ -1,60 +0,0 @@
|
||||
# Copyright (c) 2014-2019, The Monero Project
|
||||
# Copyright (c) 2019, The Loki Project
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other
|
||||
# materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software without specific
|
||||
# prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
# Check what commit we're on
|
||||
execute_process(COMMAND "${GIT}" rev-parse --short HEAD RESULT_VARIABLE RET OUTPUT_VARIABLE COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(RET)
|
||||
# Something went wrong, set the version tag to -unknown
|
||||
message(WARNING "Cannot determine current commit. Make sure that you are building either from a Git working tree or from a source archive.")
|
||||
set(VERSIONTAG "unknown")
|
||||
else()
|
||||
message(STATUS "You are currently on commit ${COMMIT}")
|
||||
|
||||
# Get all the tags
|
||||
execute_process(COMMAND "${GIT}" rev-list --tags --max-count=1 --abbrev-commit RESULT_VARIABLE RET OUTPUT_VARIABLE TAGGEDCOMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(NOT TAGGEDCOMMIT)
|
||||
message(WARNING "Cannot determine most recent tag. Make sure that you are building either from a Git working tree or from a source archive.")
|
||||
set(VERSIONTAG "${COMMIT}")
|
||||
else()
|
||||
# Check if we're building that tagged commit or a different one
|
||||
if(COMMIT STREQUAL TAGGEDCOMMIT)
|
||||
message(STATUS "${COMMIT} is a tagged release; setting version tag to 'release'")
|
||||
set(VERSIONTAG "release")
|
||||
else()
|
||||
message(STATUS "You are not building a tagged release; setting version tag to '${COMMIT}'")
|
||||
set(VERSIONTAG "${COMMIT}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
configure_file("${SRC}" "${DEST}" @ONLY)
|
@ -1,39 +0,0 @@
|
||||
# - MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
|
||||
# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
|
||||
|
||||
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license:
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
macro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage)
|
||||
|
||||
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource)
|
||||
if (_insource)
|
||||
message(SEND_ERROR "${_errorMessage}")
|
||||
message(FATAL_ERROR "Remove the file CMakeCache.txt in ${CMAKE_SOURCE_DIR} first.")
|
||||
endif (_insource)
|
||||
|
||||
endmacro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD)
|
@ -1,482 +0,0 @@
|
||||
# cmake bits to do a full static build, downloading and building all dependencies.
|
||||
|
||||
# Most of these are CACHE STRINGs so that you can override them using -DWHATEVER during cmake
|
||||
# invocation to override.
|
||||
|
||||
set(LOCAL_MIRROR "" CACHE STRING "local mirror path/URL for lib downloads")
|
||||
|
||||
set(OPENSSL_VERSION 3.0.7 CACHE STRING "openssl version")
|
||||
set(OPENSSL_MIRROR ${LOCAL_MIRROR} https://www.openssl.org/source CACHE STRING "openssl download mirror(s)")
|
||||
set(OPENSSL_SOURCE openssl-${OPENSSL_VERSION}.tar.gz)
|
||||
set(OPENSSL_HASH SHA256=83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e
|
||||
CACHE STRING "openssl source hash")
|
||||
|
||||
set(EXPAT_VERSION 2.5.0 CACHE STRING "expat version")
|
||||
string(REPLACE "." "_" EXPAT_TAG "R_${EXPAT_VERSION}")
|
||||
set(EXPAT_MIRROR ${LOCAL_MIRROR} https://github.com/libexpat/libexpat/releases/download/${EXPAT_TAG}
|
||||
CACHE STRING "expat download mirror(s)")
|
||||
set(EXPAT_SOURCE expat-${EXPAT_VERSION}.tar.xz)
|
||||
set(EXPAT_HASH SHA512=2da73b991b7c0c54440485c787e5edeb3567230204e31b3cac1c3a6713ec6f9f1554d3afffc0f8336168dfd5df02db4a69bcf21b4d959723d14162d13ab87516
|
||||
CACHE STRING "expat source hash")
|
||||
|
||||
set(UNBOUND_VERSION 1.17.0 CACHE STRING "unbound version")
|
||||
set(UNBOUND_MIRROR ${LOCAL_MIRROR} https://nlnetlabs.nl/downloads/unbound CACHE STRING "unbound download mirror(s)")
|
||||
set(UNBOUND_SOURCE unbound-${UNBOUND_VERSION}.tar.gz)
|
||||
set(UNBOUND_HASH SHA512=f6b9f279330fb19b5feca09524959940aad8c4e064528aa82b369c726d77e9e8e5ca23f366f6e9edcf2c061b96f482ed7a2c26ac70fc15ae5762b3d7e36a5284
|
||||
CACHE STRING "unbound source hash")
|
||||
|
||||
set(SQLITE3_VERSION 3400000 CACHE STRING "sqlite3 version")
|
||||
set(SQLITE3_MIRROR ${LOCAL_MIRROR} https://www.sqlite.org/2022
|
||||
CACHE STRING "sqlite3 download mirror(s)")
|
||||
set(SQLITE3_SOURCE sqlite-autoconf-${SQLITE3_VERSION}.tar.gz)
|
||||
set(SQLITE3_HASH SHA3_256=7ee8f02b21edb4489df5082b5cf5b7ef47bcebcdb0e209bf14240db69633c878
|
||||
CACHE STRING "sqlite3 source hash")
|
||||
|
||||
set(SODIUM_VERSION 1.0.18 CACHE STRING "libsodium version")
|
||||
set(SODIUM_MIRROR ${LOCAL_MIRROR}
|
||||
https://download.libsodium.org/libsodium/releases
|
||||
https://github.com/jedisct1/libsodium/releases/download/${SODIUM_VERSION}-RELEASE
|
||||
CACHE STRING "libsodium mirror(s)")
|
||||
set(SODIUM_SOURCE libsodium-${SODIUM_VERSION}.tar.gz)
|
||||
set(SODIUM_HASH SHA512=17e8638e46d8f6f7d024fe5559eccf2b8baf23e143fadd472a7d29d228b186d86686a5e6920385fe2020729119a5f12f989c3a782afbd05a8db4819bb18666ef
|
||||
CACHE STRING "libsodium source hash")
|
||||
|
||||
set(ZMQ_VERSION 4.3.4 CACHE STRING "libzmq version")
|
||||
set(ZMQ_MIRROR ${LOCAL_MIRROR} https://github.com/zeromq/libzmq/releases/download/v${ZMQ_VERSION}
|
||||
CACHE STRING "libzmq mirror(s)")
|
||||
set(ZMQ_SOURCE zeromq-${ZMQ_VERSION}.tar.gz)
|
||||
set(ZMQ_HASH SHA512=e198ef9f82d392754caadd547537666d4fba0afd7d027749b3adae450516bcf284d241d4616cad3cb4ad9af8c10373d456de92dc6d115b037941659f141e7c0e
|
||||
CACHE STRING "libzmq source hash")
|
||||
|
||||
set(LIBUV_VERSION 1.44.2 CACHE STRING "libuv version")
|
||||
set(LIBUV_MIRROR ${LOCAL_MIRROR} https://dist.libuv.org/dist/v${LIBUV_VERSION}
|
||||
CACHE STRING "libuv mirror(s)")
|
||||
set(LIBUV_SOURCE libuv-v${LIBUV_VERSION}.tar.gz)
|
||||
set(LIBUV_HASH SHA512=91197ff9303112567bbb915bbb88058050e2ad1c048815a3b57c054635d5dc7df458b956089d785475290132236cb0edcfae830f5d749de29a9a3213eeaf0b20
|
||||
CACHE STRING "libuv source hash")
|
||||
|
||||
set(ZLIB_VERSION 1.2.13 CACHE STRING "zlib version")
|
||||
set(ZLIB_MIRROR ${LOCAL_MIRROR} https://zlib.net
|
||||
CACHE STRING "zlib mirror(s)")
|
||||
set(ZLIB_SOURCE zlib-${ZLIB_VERSION}.tar.xz)
|
||||
set(ZLIB_HASH SHA256=d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da0540107fb98
|
||||
CACHE STRING "zlib source hash")
|
||||
|
||||
set(CURL_VERSION 7.86.0 CACHE STRING "curl version")
|
||||
set(CURL_MIRROR ${LOCAL_MIRROR} https://curl.haxx.se/download https://curl.askapache.com
|
||||
CACHE STRING "curl mirror(s)")
|
||||
set(CURL_SOURCE curl-${CURL_VERSION}.tar.xz)
|
||||
set(CURL_HASH SHA512=18e03a3c00f22125e07bddb18becbf5acdca22baeb7b29f45ef189a5c56f95b2d51247813f7a9a90f04eb051739e9aa7d3a1c5be397bae75d763a2b918d1b656
|
||||
CACHE STRING "curl source hash")
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
set(DEPS_DESTDIR ${CMAKE_BINARY_DIR}/static-deps)
|
||||
set(DEPS_SOURCEDIR ${CMAKE_BINARY_DIR}/static-deps-sources)
|
||||
|
||||
include_directories(BEFORE SYSTEM ${DEPS_DESTDIR}/include)
|
||||
|
||||
file(MAKE_DIRECTORY ${DEPS_DESTDIR}/include)
|
||||
|
||||
set(deps_cc "${CMAKE_C_COMPILER}")
|
||||
set(deps_cxx "${CMAKE_CXX_COMPILER}")
|
||||
if(CMAKE_C_COMPILER_LAUNCHER)
|
||||
set(deps_cc "${CMAKE_C_COMPILER_LAUNCHER} ${deps_cc}")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_LAUNCHER)
|
||||
set(deps_cxx "${CMAKE_CXX_COMPILER_LAUNCHER} ${deps_cxx}")
|
||||
endif()
|
||||
|
||||
|
||||
function(expand_urls output source_file)
|
||||
set(expanded)
|
||||
foreach(mirror ${ARGN})
|
||||
list(APPEND expanded "${mirror}/${source_file}")
|
||||
endforeach()
|
||||
set(${output} "${expanded}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(add_static_target target ext_target libname)
|
||||
add_library(${target} STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(${target} ${ext_target})
|
||||
set_target_properties(${target} PROPERTIES
|
||||
IMPORTED_LOCATION ${DEPS_DESTDIR}/lib/${libname}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
set(cross_host "")
|
||||
set(cross_rc "")
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(cross_host "--host=${ARCH_TRIPLET}")
|
||||
if (ARCH_TRIPLET MATCHES mingw AND CMAKE_RC_COMPILER)
|
||||
set(cross_rc "WINDRES=${CMAKE_RC_COMPILER}")
|
||||
endif()
|
||||
endif()
|
||||
if(ANDROID)
|
||||
set(android_toolchain_suffix linux-android)
|
||||
set(android_compiler_suffix linux-android23)
|
||||
if(CMAKE_ANDROID_ARCH_ABI MATCHES x86_64)
|
||||
set(android_machine x86_64)
|
||||
set(cross_host "--host=x86_64-linux-android")
|
||||
set(android_compiler_prefix x86_64)
|
||||
set(android_compiler_suffix linux-android23)
|
||||
set(android_toolchain_prefix x86_64)
|
||||
set(android_toolchain_suffix linux-android)
|
||||
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES x86)
|
||||
set(android_machine x86)
|
||||
set(cross_host "--host=i686-linux-android")
|
||||
set(android_compiler_prefix i686)
|
||||
set(android_compiler_suffix linux-android23)
|
||||
set(android_toolchain_prefix i686)
|
||||
set(android_toolchain_suffix linux-android)
|
||||
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES armeabi-v7a)
|
||||
set(android_machine arm)
|
||||
set(cross_host "--host=armv7a-linux-androideabi")
|
||||
set(android_compiler_prefix armv7a)
|
||||
set(android_compiler_suffix linux-androideabi23)
|
||||
set(android_toolchain_prefix arm)
|
||||
set(android_toolchain_suffix linux-androideabi)
|
||||
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES arm64-v8a)
|
||||
set(android_machine arm64)
|
||||
set(cross_host "--host=aarch64-linux-android")
|
||||
set(android_compiler_prefix aarch64)
|
||||
set(android_compiler_suffix linux-android23)
|
||||
set(android_toolchain_prefix aarch64)
|
||||
set(android_toolchain_suffix linux-android)
|
||||
else()
|
||||
message(FATAL_ERROR "unknown android arch: ${CMAKE_ANDROID_ARCH_ABI}")
|
||||
endif()
|
||||
set(deps_cc "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/${android_compiler_prefix}-${android_compiler_suffix}-clang")
|
||||
set(deps_cxx "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/${android_compiler_prefix}-${android_compiler_suffix}-clang++")
|
||||
set(deps_ld "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/${android_compiler_prefix}-${android_toolchain_suffix}-ld")
|
||||
set(deps_ranlib "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/${android_toolchain_prefix}-${android_toolchain_suffix}-ranlib")
|
||||
set(deps_ar "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/${android_toolchain_prefix}-${android_toolchain_suffix}-ar")
|
||||
endif()
|
||||
|
||||
set(deps_CFLAGS "-O2")
|
||||
set(deps_CXXFLAGS "-O2")
|
||||
|
||||
if(WITH_LTO)
|
||||
set(deps_CFLAGS "${deps_CFLAGS} -flto")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(deps_CFLAGS "${deps_CFLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
set(deps_CXXFLAGS "${deps_CXXFLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
endif()
|
||||
|
||||
if(_winver)
|
||||
set(deps_CFLAGS "${deps_CFLAGS} -D_WIN32_WINNT=${_winver}")
|
||||
set(deps_CXXFLAGS "${deps_CXXFLAGS} -D_WIN32_WINNT=${_winver}")
|
||||
endif()
|
||||
|
||||
|
||||
if("${CMAKE_GENERATOR}" STREQUAL "Unix Makefiles")
|
||||
set(_make $(MAKE))
|
||||
else()
|
||||
set(_make make)
|
||||
endif()
|
||||
|
||||
|
||||
# Builds a target; takes the target name (e.g. "readline") and builds it in an external project with
|
||||
# target name suffixed with `_external`. Its upper-case value is used to get the download details
|
||||
# (from the variables set above). The following options are supported and passed through to
|
||||
# ExternalProject_Add if specified. If omitted, these defaults are used:
|
||||
set(build_def_DEPENDS "")
|
||||
set(build_def_PATCH_COMMAND "")
|
||||
set(build_def_CONFIGURE_COMMAND ./configure ${cross_host} --disable-shared --prefix=${DEPS_DESTDIR} --with-pic
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS}" "CXXFLAGS=${deps_CXXFLAGS}" ${cross_rc})
|
||||
set(build_def_BUILD_COMMAND ${_make})
|
||||
set(build_def_INSTALL_COMMAND ${_make} install)
|
||||
set(build_def_BUILD_BYPRODUCTS ${DEPS_DESTDIR}/lib/lib___TARGET___.a ${DEPS_DESTDIR}/include/___TARGET___.h)
|
||||
|
||||
function(build_external target)
|
||||
set(options DEPENDS PATCH_COMMAND CONFIGURE_COMMAND BUILD_COMMAND INSTALL_COMMAND BUILD_BYPRODUCTS)
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "${options}")
|
||||
foreach(o ${options})
|
||||
if(NOT DEFINED arg_${o})
|
||||
set(arg_${o} ${build_def_${o}})
|
||||
endif()
|
||||
endforeach()
|
||||
string(REPLACE ___TARGET___ ${target} arg_BUILD_BYPRODUCTS "${arg_BUILD_BYPRODUCTS}")
|
||||
|
||||
string(TOUPPER "${target}" prefix)
|
||||
expand_urls(urls ${${prefix}_SOURCE} ${${prefix}_MIRROR})
|
||||
ExternalProject_Add("${target}_external"
|
||||
DEPENDS ${arg_DEPENDS}
|
||||
BUILD_IN_SOURCE ON
|
||||
PREFIX ${DEPS_SOURCEDIR}
|
||||
URL ${urls}
|
||||
URL_HASH ${${prefix}_HASH}
|
||||
DOWNLOAD_NO_PROGRESS ON
|
||||
PATCH_COMMAND ${arg_PATCH_COMMAND}
|
||||
CONFIGURE_COMMAND ${arg_CONFIGURE_COMMAND}
|
||||
BUILD_COMMAND ${arg_BUILD_COMMAND}
|
||||
INSTALL_COMMAND ${arg_INSTALL_COMMAND}
|
||||
BUILD_BYPRODUCTS ${arg_BUILD_BYPRODUCTS}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
build_external(libuv
|
||||
CONFIGURE_COMMAND ./autogen.sh && ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --with-pic --disable-shared --enable-static "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}"
|
||||
BUILD_BYPRODUCTS
|
||||
${DEPS_DESTDIR}/lib/libuv.a
|
||||
${DEPS_DESTDIR}/include/uv.h
|
||||
)
|
||||
add_static_target(libuv libuv_external libuv.a)
|
||||
target_link_libraries(libuv INTERFACE ${CMAKE_DL_LIBS})
|
||||
|
||||
|
||||
build_external(zlib
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS} -fPIC" ${cross_extra} ./configure --prefix=${DEPS_DESTDIR} --static
|
||||
BUILD_BYPRODUCTS
|
||||
${DEPS_DESTDIR}/lib/libz.a
|
||||
${DEPS_DESTDIR}/include/zlib.h
|
||||
)
|
||||
add_static_target(zlib zlib_external libz.a)
|
||||
|
||||
|
||||
set(openssl_system_env "")
|
||||
set(openssl_arch "")
|
||||
set(openssl_configure_command ./config)
|
||||
set(openssl_flags "CFLAGS=${deps_CFLAGS}")
|
||||
set(unbound_ldflags "")
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
if(ARCH_TRIPLET STREQUAL x86_64-w64-mingw32)
|
||||
set(openssl_arch mingw64)
|
||||
set(openssl_system_env RC=${CMAKE_RC_COMPILER} AR=${ARCH_TRIPLET}-ar RANLIB=${ARCH_TRIPLET}-ranlib)
|
||||
elseif(ARCH_TRIPLET STREQUAL i686-w64-mingw32)
|
||||
set(openssl_arch mingw)
|
||||
set(openssl_system_env RC=${CMAKE_RC_COMPILER} AR=${ARCH_TRIPLET}-ar RANLIB=${ARCH_TRIPLET}-ranlib)
|
||||
elseif(ANDROID)
|
||||
set(openssl_arch android-${android_machine})
|
||||
set(openssl_system_env LD=${deps_ld} RANLIB=${deps_ranlib} AR=${deps_ar} ANDROID_NDK_ROOT=${CMAKE_ANDROID_NDK} "PATH=${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin:$ENV{PATH}")
|
||||
list(APPEND openssl_flags "CPPFLAGS=-D__ANDROID_API__=${ANDROID_API}")
|
||||
set(openssl_extra_opts no-asm)
|
||||
elseif(ARCH_TRIPLET STREQUAL mips64-linux-gnuabi64)
|
||||
set(openssl_arch linux-mips64)
|
||||
elseif(ARCH_TRIPLET STREQUAL mips-linux-gnu)
|
||||
set(openssl_arch linux-mips32)
|
||||
elseif(ARCH_TRIPLET STREQUAL mips-openwrt-linux)
|
||||
set(unbound_ldflags "-latomic")
|
||||
set(openssl_arch linux-mips32)
|
||||
elseif(ARCH_TRIPLET STREQUAL mipsel-linux-gnu)
|
||||
set(openssl_arch linux-mips)
|
||||
elseif(ARCH_TRIPLET STREQUAL aarch64-linux-gnu OR ARCH_TRIPLET STREQUAL aarch64-openwrt-linux-musl)
|
||||
# cross compile arm64
|
||||
set(openssl_arch linux-aarch64)
|
||||
elseif(ARCH_TRIPLET MATCHES arm-linux)
|
||||
# cross compile armhf
|
||||
set(openssl_arch linux-armv4)
|
||||
elseif(ARCH_TRIPLET MATCHES powerpc64le)
|
||||
# cross compile ppc64le
|
||||
set(openssl_arch linux-ppc64le)
|
||||
endif()
|
||||
elseif(CMAKE_C_FLAGS MATCHES "-march=armv7")
|
||||
# Help openssl figure out that we're building from armv7 even if on armv8 hardware:
|
||||
set(openssl_arch linux-armv4)
|
||||
endif()
|
||||
|
||||
|
||||
build_external(openssl
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CC=${deps_cc} ${openssl_system_env} ${openssl_configure_command}
|
||||
--prefix=${DEPS_DESTDIR} --libdir=lib ${openssl_extra_opts}
|
||||
no-shared no-capieng no-dso no-dtls1 no-ec_nistp_64_gcc_128 no-gost
|
||||
no-md2 no-rc5 no-rdrand no-rfc3779 no-sctp no-ssl-trace no-ssl3
|
||||
no-static-engine no-tests no-weak-ssl-ciphers no-zlib no-zlib-dynamic ${openssl_flags}
|
||||
${openssl_arch}
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} -E env ${openssl_system_env} ${_make}
|
||||
INSTALL_COMMAND ${_make} install_sw
|
||||
BUILD_BYPRODUCTS
|
||||
${DEPS_DESTDIR}/lib/libssl.a ${DEPS_DESTDIR}/lib/libcrypto.a
|
||||
${DEPS_DESTDIR}/include/openssl/ssl.h ${DEPS_DESTDIR}/include/openssl/crypto.h
|
||||
)
|
||||
add_static_target(OpenSSL::SSL openssl_external libssl.a)
|
||||
add_static_target(OpenSSL::Crypto openssl_external libcrypto.a)
|
||||
if(WIN32)
|
||||
target_link_libraries(OpenSSL::Crypto INTERFACE "ws2_32;crypt32;iphlpapi")
|
||||
endif()
|
||||
|
||||
set(OPENSSL_INCLUDE_DIR ${DEPS_DESTDIR}/include)
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${DEPS_DESTDIR}/lib/libcrypto.a ${DEPS_DESTDIR}/lib/libssl.a)
|
||||
set(OPENSSL_ROOT_DIR ${DEPS_DESTDIR})
|
||||
|
||||
build_external(expat
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} --prefix=${DEPS_DESTDIR} --enable-static
|
||||
--disable-shared --with-pic --without-examples --without-tests --without-docbook --without-xmlwf
|
||||
"CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}"
|
||||
)
|
||||
add_static_target(expat expat_external libexpat.a)
|
||||
|
||||
|
||||
if(WIN32)
|
||||
set(unbound_patch
|
||||
PATCH_COMMAND ${PROJECT_SOURCE_DIR}/contrib/apply-patches.sh
|
||||
${PROJECT_SOURCE_DIR}/contrib/patches/unbound-delete-crash-fix.patch)
|
||||
endif()
|
||||
build_external(unbound
|
||||
DEPENDS openssl_external expat_external
|
||||
${unbound_patch}
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --disable-shared
|
||||
--enable-static --with-libunbound-only --with-pic
|
||||
--$<IF:$<BOOL:${WITH_LTO}>,enable,disable>-flto --with-ssl=${DEPS_DESTDIR}
|
||||
--with-libexpat=${DEPS_DESTDIR}
|
||||
"CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}" "LDFLAGS=${unbound_ldflags}"
|
||||
)
|
||||
add_static_target(libunbound unbound_external libunbound.a)
|
||||
if(NOT WIN32)
|
||||
set_target_properties(libunbound PROPERTIES INTERFACE_LINK_LIBRARIES "OpenSSL::SSL;OpenSSL::Crypto")
|
||||
else()
|
||||
set_target_properties(libunbound PROPERTIES INTERFACE_LINK_LIBRARIES "OpenSSL::SSL;OpenSSL::Crypto;ws2_32;crypt32;iphlpapi")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
build_external(sodium CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --disable-shared
|
||||
--enable-static --with-pic "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}")
|
||||
add_static_target(sodium sodium_external libsodium.a)
|
||||
|
||||
|
||||
if(WITH_PEERSTATS_BACKEND)
|
||||
build_external(sqlite3)
|
||||
add_static_target(sqlite3 sqlite3_external libsqlite3.a)
|
||||
endif()
|
||||
|
||||
|
||||
if(ARCH_TRIPLET MATCHES mingw)
|
||||
option(WITH_WEPOLL "use wepoll zmq poller (crashy)" OFF)
|
||||
if(WITH_WEPOLL)
|
||||
set(zmq_extra --with-poller=wepoll)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CROSSCOMPILING AND ARCH_TRIPLET MATCHES mingw)
|
||||
set(zmq_patch
|
||||
PATCH_COMMAND ${PROJECT_SOURCE_DIR}/contrib/apply-patches.sh
|
||||
${PROJECT_SOURCE_DIR}/contrib/patches/libzmq-mingw-wepoll.patch
|
||||
${PROJECT_SOURCE_DIR}/contrib/patches/libzmq-mingw-unistd.patch)
|
||||
endif()
|
||||
|
||||
build_external(zmq
|
||||
DEPENDS sodium_external
|
||||
${zmq_patch}
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} --prefix=${DEPS_DESTDIR} --enable-static --disable-shared
|
||||
--disable-curve-keygen --enable-curve --disable-drafts --disable-libunwind --with-libsodium
|
||||
--without-pgm --without-norm --without-vmci --without-docs --with-pic --disable-Werror --disable-libbsd ${zmq_extra}
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS} -fstack-protector" "CXXFLAGS=${deps_CXXFLAGS} -fstack-protector"
|
||||
"sodium_CFLAGS=-I${DEPS_DESTDIR}/include" "sodium_LIBS=-L${DEPS_DESTDIR}/lib -lsodium"
|
||||
)
|
||||
add_static_target(libzmq zmq_external libzmq.a)
|
||||
|
||||
set(libzmq_link_libs "sodium")
|
||||
if(CMAKE_CROSSCOMPILING AND ARCH_TRIPLET MATCHES mingw)
|
||||
list(APPEND libzmq_link_libs iphlpapi)
|
||||
endif()
|
||||
|
||||
set_target_properties(libzmq PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${libzmq_link_libs}"
|
||||
INTERFACE_COMPILE_DEFINITIONS "ZMQ_STATIC")
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
# Everything that follows is *only* for lokinet-bootstrap (i.e. if adding new deps put them *above*
|
||||
# this).
|
||||
#
|
||||
#
|
||||
#
|
||||
if(NOT WITH_BOOTSTRAP)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(curl_extra)
|
||||
if(WIN32)
|
||||
set(curl_ssl_opts --without-ssl --with-schannel)
|
||||
elseif(APPLE)
|
||||
set(curl_ssl_opts --without-ssl --with-secure-transport)
|
||||
if(IOS)
|
||||
# This CPP crap shouldn't be necessary but is because Apple's toolchain is trash
|
||||
set(curl_extra "LDFLAGS=-L${DEPS_DESTDIR}/lib -isysroot ${CMAKE_OSX_SYSROOT}" CPP=cpp)
|
||||
endif()
|
||||
else()
|
||||
set(curl_ssl_opts --with-ssl=${DEPS_DESTDIR})
|
||||
set(curl_extra "LIBS=-pthread")
|
||||
endif()
|
||||
|
||||
set(curl_arches default)
|
||||
set(curl_lib_outputs)
|
||||
if(IOS)
|
||||
# On iOS things get a little messy: curl won't build a multi-arch library (with `clang -arch arch1
|
||||
# -arch arch2`) so we have to build them separately then glue them together if we're building
|
||||
# multiple.
|
||||
set(curl_arches ${CMAKE_OSX_ARCHITECTURES})
|
||||
list(GET curl_arches 0 curl_arch0)
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES num_arches)
|
||||
endif()
|
||||
|
||||
foreach(curl_arch ${curl_arches})
|
||||
set(curl_target_suffix "")
|
||||
set(curl_prefix "${DEPS_DESTDIR}")
|
||||
if(curl_arch STREQUAL "default")
|
||||
set(curl_cflags_extra "")
|
||||
elseif(IOS)
|
||||
set(cflags_extra " -arch ${curl_arch}")
|
||||
if(num_arches GREATER 1)
|
||||
set(curl_target_suffix "-${curl_arch}")
|
||||
set(curl_prefix "${DEPS_DESTDIR}/tmp/${curl_arch}")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "unexpected curl_arch=${curl_arch}")
|
||||
endif()
|
||||
|
||||
build_external(curl
|
||||
TARGET_SUFFIX ${curl_target_suffix}
|
||||
DEPENDS openssl_external zlib_external
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} ${cross_extra} --prefix=${curl_prefix} --disable-shared
|
||||
--enable-static --disable-ares --disable-ftp --disable-ldap --disable-laps --disable-rtsp
|
||||
--disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb
|
||||
--disable-smtp --disable-gopher --disable-manual --disable-libcurl-option --enable-http
|
||||
--enable-ipv6 --disable-threaded-resolver --disable-pthreads --disable-verbose --disable-sspi
|
||||
--enable-crypto-auth --disable-ntlm-wb --disable-tls-srp --disable-unix-sockets --disable-cookies
|
||||
--enable-http-auth --enable-doh --disable-mime --enable-dateparse --disable-netrc --without-libidn2
|
||||
--disable-progress-meter --without-brotli --with-zlib=${DEPS_DESTDIR} ${curl_ssl_opts}
|
||||
--without-librtmp --disable-versioned-symbols --enable-hidden-symbols
|
||||
--without-zsh-functions-dir --without-fish-functions-dir
|
||||
--without-nghttp3 --without-zstd
|
||||
"CC=${deps_cc}" "CFLAGS=${deps_noarch_CFLAGS}${cflags_extra}" ${curl_extra}
|
||||
BUILD_COMMAND true
|
||||
INSTALL_COMMAND ${_make} -C lib install && ${_make} -C include install
|
||||
BUILD_BYPRODUCTS
|
||||
${curl_prefix}/lib/libcurl.a
|
||||
${curl_prefix}/include/curl/curl.h
|
||||
)
|
||||
list(APPEND curl_lib_targets curl${curl_target_suffix}_external)
|
||||
list(APPEND curl_lib_outputs ${curl_prefix}/lib/libcurl.a)
|
||||
endforeach()
|
||||
|
||||
|
||||
|
||||
if(IOS AND num_arches GREATER 1)
|
||||
# We are building multiple architectures for different iOS devices, so we need to glue the
|
||||
# separate libraries into one. (Normally multiple -arch values passed to clang does this for us,
|
||||
# but curl refuses to build that way).
|
||||
add_custom_target(curl_external
|
||||
COMMAND lipo ${curl_lib_outputs} -create -output ${DEPS_DESTDIR}/libcurl.a
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPS_DESTDIR}/tmp/${curl_arch0}/include/curl ${DEPS_DESTDIR}/include/curl
|
||||
BYPRODUCTS ${DEPS_DESTDIR}/lib/libcurl.a ${DEPS_DESTDIR}/include/curl/curl.h
|
||||
DEPENDS ${curl_lib_targets})
|
||||
endif()
|
||||
|
||||
add_static_target(CURL::libcurl curl_external libcurl.a)
|
||||
set(libcurl_link_libs zlib)
|
||||
if(CMAKE_CROSSCOMPILING AND ARCH_TRIPLET MATCHES mingw)
|
||||
list(APPEND libcurl_link_libs crypt32)
|
||||
elseif(APPLE)
|
||||
list(APPEND libcurl_link_libs "-framework Security -framework CoreFoundation")
|
||||
endif()
|
||||
set_target_properties(CURL::libcurl PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${libcurl_link_libs}"
|
||||
INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB")
|
@ -1,134 +0,0 @@
|
||||
# Based on the Qt 5 processor detection code, so should be very accurate
|
||||
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
|
||||
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
|
||||
|
||||
# Regarding POWER/PowerPC, just as is noted in the Qt source,
|
||||
# "There are many more known variants/revisions that we do not handle/detect."
|
||||
|
||||
set(archdetect_c_code "
|
||||
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
|
||||
#if defined(__ARM_ARCH_7__) \\
|
||||
|| defined(__ARM_ARCH_7A__) \\
|
||||
|| defined(__ARM_ARCH_7R__) \\
|
||||
|| defined(__ARM_ARCH_7M__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
|
||||
#error cmake_ARCH armv7
|
||||
#elif defined(__ARM_ARCH_6__) \\
|
||||
|| defined(__ARM_ARCH_6J__) \\
|
||||
|| defined(__ARM_ARCH_6T2__) \\
|
||||
|| defined(__ARM_ARCH_6Z__) \\
|
||||
|| defined(__ARM_ARCH_6K__) \\
|
||||
|| defined(__ARM_ARCH_6ZK__) \\
|
||||
|| defined(__ARM_ARCH_6M__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
|
||||
#error cmake_ARCH armv6
|
||||
#elif defined(__ARM_ARCH_5TEJ__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
|
||||
#error cmake_ARCH armv5
|
||||
#else
|
||||
#error cmake_ARCH arm
|
||||
#endif
|
||||
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#error cmake_ARCH i386
|
||||
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
|
||||
#error cmake_ARCH x86_64
|
||||
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||
#error cmake_ARCH ia64
|
||||
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|
||||
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|
||||
|| defined(_M_MPPC) || defined(_M_PPC)
|
||||
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
|
||||
#error cmake_ARCH ppc64
|
||||
#else
|
||||
#error cmake_ARCH ppc
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#error cmake_ARCH unknown
|
||||
")
|
||||
|
||||
# Set ppc_support to TRUE before including this file or ppc and ppc64
|
||||
# will be treated as invalid architectures since they are no longer supported by Apple
|
||||
|
||||
function(target_architecture output_var)
|
||||
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
||||
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
|
||||
# First let's normalize the order of the values
|
||||
|
||||
# Note that it's not possible to compile PowerPC applications if you are using
|
||||
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
|
||||
# disable it by default
|
||||
# See this page for more information:
|
||||
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
|
||||
|
||||
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
|
||||
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
|
||||
|
||||
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
|
||||
set(osx_arch_ppc TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "i386")
|
||||
set(osx_arch_i386 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "x86_64")
|
||||
set(osx_arch_x86_64 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
|
||||
set(osx_arch_ppc64 TRUE)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Now add all the architectures in our normalized order
|
||||
if(osx_arch_ppc)
|
||||
list(APPEND ARCH ppc)
|
||||
endif()
|
||||
|
||||
if(osx_arch_i386)
|
||||
list(APPEND ARCH i386)
|
||||
endif()
|
||||
|
||||
if(osx_arch_x86_64)
|
||||
list(APPEND ARCH x86_64)
|
||||
endif()
|
||||
|
||||
if(osx_arch_ppc64)
|
||||
list(APPEND ARCH ppc64)
|
||||
endif()
|
||||
else()
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
|
||||
|
||||
enable_language(C)
|
||||
|
||||
# Detect the architecture in a rather creative way...
|
||||
# This compiles a small C program which is a series of ifdefs that selects a
|
||||
# particular #error preprocessor directive whose message string contains the
|
||||
# target architecture. The program will always fail to compile (both because
|
||||
# file is not a valid C program, and obviously because of the presence of the
|
||||
# #error preprocessor directives... but by exploiting the preprocessor in this
|
||||
# way, we can detect the correct target architecture even when cross-compiling,
|
||||
# since the program itself never needs to be run (only the compiler/preprocessor)
|
||||
try_run(
|
||||
run_result_unused
|
||||
compile_result_unused
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
"${CMAKE_BINARY_DIR}/arch.c"
|
||||
COMPILE_OUTPUT_VARIABLE ARCH
|
||||
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
|
||||
)
|
||||
|
||||
# Parse the architecture name from the compiler output
|
||||
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
|
||||
|
||||
# Get rid of the value marker leaving just the architecture name
|
||||
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
|
||||
|
||||
# If we are compiling with an unknown architecture this variable should
|
||||
# already be set to "unknown" but in the case that it's empty (i.e. due
|
||||
# to a typo in the code), then set it to unknown
|
||||
if (NOT ARCH)
|
||||
set(ARCH unknown)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(${output_var} "${ARCH}" PARENT_SCOPE)
|
||||
endfunction()
|
@ -1,46 +0,0 @@
|
||||
# We do this via a custom command that re-invokes a cmake script because we need the DEPENDS on .git/index so that we will re-run it (to regenerate the commit tag in the version) whenever the current commit changes. If we used a configure_file directly here, it would only re-run when something else causes cmake to re-run.
|
||||
|
||||
if(LOKINET_VERSIONTAG)
|
||||
set(VERSIONTAG "${LOKINET_VERSIONTAG}")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp" @ONLY)
|
||||
else()
|
||||
set(VERSIONTAG "${GIT_VERSION}")
|
||||
set(GIT_INDEX_FILE "${PROJECT_SOURCE_DIR}/.git/index")
|
||||
find_package(Git)
|
||||
if(EXISTS "${GIT_INDEX_FILE}" AND ( GIT_FOUND OR Git_FOUND) )
|
||||
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
||||
set(genversion_args "-DGIT=${GIT_EXECUTABLE}")
|
||||
foreach(v lokinet_VERSION lokinet_VERSION_MAJOR lokinet_VERSION_MINOR lokinet_VERSION_PATCH RELEASE_MOTTO)
|
||||
list(APPEND genversion_args "-D${v}=${${v}}")
|
||||
endforeach()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
${genversion_args}
|
||||
"-D" "SRC=${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
|
||||
"-D" "DEST=${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
|
||||
"-P" "${CMAKE_CURRENT_LIST_DIR}/GenVersion.cmake"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
|
||||
"${GIT_INDEX_FILE}")
|
||||
else()
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp" @ONLY)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(WIN32)
|
||||
foreach(exe IN ITEMS lokinet lokinet-vpn lokinet-bootstrap)
|
||||
set(lokinet_EXE_NAME "${exe}.exe")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/win32/version.rc.in" "${CMAKE_BINARY_DIR}/${exe}.rc" @ONLY)
|
||||
set_property(SOURCE "${CMAKE_BINARY_DIR}/${exe}.rc" PROPERTY GENERATED 1)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
add_custom_target(genversion_cpp DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp")
|
||||
if(WIN32)
|
||||
add_custom_target(genversion_rc DEPENDS "${CMAKE_BINARY_DIR}/lokinet.rc" "${CMAKE_BINARY_DIR}/lokinet-vpn.rc" "${CMAKE_BINARY_DIR}/lokinet-bootstrap.rc")
|
||||
else()
|
||||
add_custom_target(genversion_rc)
|
||||
endif()
|
||||
add_custom_target(genversion DEPENDS genversion_cpp genversion_rc)
|
@ -1,6 +0,0 @@
|
||||
function(add_import_library libname)
|
||||
add_library(libname SHARED IMPORTED)
|
||||
if(NOT TARGET libname)
|
||||
message(FATAL "unable to find library ${libname}")
|
||||
endif()
|
||||
endfunction()
|
@ -1,51 +0,0 @@
|
||||
# Figure out if we need -lstdc++fs or -lc++fs and add it to the `filesystem` interface, if needed
|
||||
# (otherwise just leave it an empty interface library; linking to it will do nothing). The former
|
||||
# is needed for gcc before v9, and the latter with libc++ before llvm v9. But this gets more
|
||||
# complicated than just using the compiler, because clang on linux by default uses libstdc++, so
|
||||
# we'll just give up and see what works.
|
||||
|
||||
add_library(filesystem INTERFACE)
|
||||
|
||||
set(filesystem_code [[
|
||||
#include <filesystem>
|
||||
|
||||
int main() {
|
||||
auto cwd = std::filesystem::current_path();
|
||||
return !cwd.string().empty();
|
||||
}
|
||||
]])
|
||||
|
||||
if(CMAKE_CXX_COMPILER STREQUAL "AppleClang" AND CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
# It seems that check_cxx_source_compiles doesn't respect the CMAKE_OSX_DEPLOYMENT_TARGET, so this
|
||||
# check would pass on Catalina (10.15) and then later compilation would fail because you aren't
|
||||
# allowed to use <filesystem> when the deployment target is anything before 10.15.
|
||||
set(CMAKE_REQUIRED_FLAGS -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
|
||||
endif()
|
||||
|
||||
check_cxx_source_compiles("${filesystem_code}" filesystem_compiled)
|
||||
if(filesystem_compiled)
|
||||
message(STATUS "No extra link flag needed for std::filesystem")
|
||||
set(filesystem_is_good 1)
|
||||
else()
|
||||
foreach(fslib stdc++fs c++fs)
|
||||
set(CMAKE_REQUIRED_LIBRARIES -l${fslib})
|
||||
check_cxx_source_compiles("${filesystem_code}" filesystem_compiled_${fslib})
|
||||
if (filesystem_compiled_${fslib})
|
||||
message(STATUS "Using -l${fslib} for std::filesystem support")
|
||||
target_link_libraries(filesystem INTERFACE ${fslib})
|
||||
set(filesystem_is_good 1)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||
if(filesystem_is_good EQUAL 1)
|
||||
message(STATUS "we have std::filesystem")
|
||||
else()
|
||||
# Probably broken AF macos
|
||||
message(STATUS "std::filesystem is not available, apparently this compiler isn't C++17 compliant; falling back to ghc::filesystem")
|
||||
set(GHC_FILESYSTEM_WITH_INSTALL OFF CACHE INTERNAL "")
|
||||
add_subdirectory(external/ghc-filesystem)
|
||||
target_link_libraries(filesystem INTERFACE ghc_filesystem)
|
||||
target_compile_definitions(filesystem INTERFACE USE_GHC_FILESYSTEM CLI11_HAS_FILESYSTEM=0)
|
||||
endif()
|
@ -1,18 +0,0 @@
|
||||
# check for std::optional because macos is broke af sometimes
|
||||
|
||||
set(std_optional_code [[
|
||||
#include <optional>
|
||||
|
||||
int main() {
|
||||
std::optional<int> maybe;
|
||||
maybe = 1;
|
||||
return *maybe == 1;
|
||||
}
|
||||
]])
|
||||
|
||||
check_cxx_source_compiles("${std_optional_code}" was_compiled)
|
||||
if(was_compiled)
|
||||
message(STATUS "we have std::optional")
|
||||
else()
|
||||
message(FATAL_ERROR "we dont have std::optional your compiler is broke af")
|
||||
endif()
|
@ -1,21 +0,0 @@
|
||||
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
endif()
|
||||
|
||||
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
foreach(file ${files})
|
||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
exec_program(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
if(NOT "${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
||||
endif()
|
||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||
endif()
|
||||
endforeach()
|
@ -1,9 +0,0 @@
|
||||
if (WITH_COVERAGE)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options( -fprofile-instr-generate -fcoverage-mapping )
|
||||
link_libraries( -fprofile-instr-generate )
|
||||
else()
|
||||
add_compile_options( --coverage -g0 )
|
||||
link_libraries( --coverage )
|
||||
endif()
|
||||
endif()
|
@ -1,15 +0,0 @@
|
||||
# dynamic linking does this all the time
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
option(NO_LIBGCC "use libunwind+compiler-rt instead, must already be installed in mingw-w64 sysroot" OFF)
|
||||
add_compile_options(-Wno-unused-command-line-argument -Wno-c++11-narrowing)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-bad-function-cast>)
|
||||
if (NO_LIBGCC)
|
||||
find_library(UNWIND_LIB unwind)
|
||||
link_libraries(${UNWIND_LIB})
|
||||
find_library(PSAPI_LIB psapi)
|
||||
link_libraries(${PSAPI_LIB})
|
||||
endif(NO_LIBGCC)
|
||||
else()
|
||||
# found it. this is GNU only
|
||||
add_compile_options(-Wno-cast-function-type)
|
||||
endif()
|
@ -1,23 +0,0 @@
|
||||
# -flto
|
||||
include(CheckIPOSupported)
|
||||
option(WITH_LTO "enable lto on compile time" ON)
|
||||
if(WITH_LTO)
|
||||
if(WIN32)
|
||||
message(FATAL_ERROR "LTO not supported on win32 targets, please set -DWITH_LTO=OFF")
|
||||
endif()
|
||||
check_ipo_supported(RESULT IPO_ENABLED OUTPUT ipo_error)
|
||||
if(IPO_ENABLED)
|
||||
message(STATUS "LTO enabled")
|
||||
else()
|
||||
message(WARNING "LTO not supported by compiler: ${ipo_error}")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "LTO disabled")
|
||||
set(IPO_ENABLED OFF)
|
||||
endif()
|
||||
|
||||
function(enable_lto)
|
||||
if(IPO_ENABLED)
|
||||
set_target_properties(${ARGN} PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON)
|
||||
endif()
|
||||
endfunction()
|
@ -1,17 +0,0 @@
|
||||
set(default_build_gui OFF)
|
||||
if(APPLE OR WIN32)
|
||||
set(default_build_gui ON)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(GUI_EXE "" CACHE FILEPATH "path to a pre-built Windows GUI .exe to use (implies -DBUILD_GUI=OFF)")
|
||||
if(GUI_EXE)
|
||||
set(default_build_gui OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(BUILD_GUI "build electron gui from 'gui' submodule source" ${default_build_gui})
|
||||
|
||||
if(BUILD_GUI AND GUI_EXE)
|
||||
message(FATAL_ERROR "-DGUI_EXE=... and -DBUILD_GUI=ON are mutually exclusive")
|
||||
endif()
|
@ -1,67 +0,0 @@
|
||||
|
||||
if(WIN32 AND GUI_EXE)
|
||||
message(STATUS "using pre-built lokinet gui executable: ${GUI_EXE}")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${GUI_EXE}" "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe")
|
||||
elseif(BUILD_GUI)
|
||||
message(STATUS "Building lokinet-gui from source")
|
||||
|
||||
set(default_gui_target pack)
|
||||
if(APPLE)
|
||||
set(default_gui_target macos:raw)
|
||||
elseif(WIN32)
|
||||
set(default_gui_target win32)
|
||||
endif()
|
||||
|
||||
set(GUI_YARN_TARGET "${default_gui_target}" CACHE STRING "yarn target for building the GUI")
|
||||
set(GUI_YARN_EXTRA_OPTS "" CACHE STRING "extra options to pass into the yarn build command")
|
||||
|
||||
# allow manually specifying yarn with -DYARN=
|
||||
if(NOT YARN)
|
||||
find_program(YARN NAMES yarnpkg yarn REQUIRED)
|
||||
endif()
|
||||
message(STATUS "Building lokinet-gui with yarn ${YARN}, target ${GUI_YARN_TARGET}")
|
||||
|
||||
if(NOT WIN32)
|
||||
add_custom_target(lokinet-gui
|
||||
COMMAND ${YARN} install --frozen-lockfile &&
|
||||
${YARN} ${GUI_YARN_EXTRA_OPTS} ${GUI_YARN_TARGET}
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/gui")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
add_custom_target(assemble_gui ALL
|
||||
DEPENDS assemble lokinet-gui
|
||||
COMMAND mkdir "${lokinet_app}/Contents/Helpers"
|
||||
COMMAND cp -a "${PROJECT_SOURCE_DIR}/gui/release/mac/Lokinet-GUI.app" "${lokinet_app}/Contents/Helpers/"
|
||||
COMMAND mkdir -p "${lokinet_app}/Contents/Resources/en.lproj"
|
||||
COMMAND cp "${PROJECT_SOURCE_DIR}/contrib/macos/InfoPlist.strings" "${lokinet_app}/Contents/Resources/en.lproj/"
|
||||
COMMAND cp "${lokinet_app}/Contents/Resources/icon.icns" "${lokinet_app}/Contents/Helpers/Lokinet-GUI.app/Contents/Resources/icon.icns"
|
||||
COMMAND cp "${PROJECT_SOURCE_DIR}/contrib/macos/InfoPlist.strings" "${lokinet_app}/Contents/Helpers/Lokinet-GUI.app/Contents/Resources/en.lproj/"
|
||||
COMMAND /usr/libexec/PlistBuddy
|
||||
-c "Delete :CFBundleDisplayName"
|
||||
-c "Add :LSHasLocalizedDisplayName bool true"
|
||||
-c "Add :CFBundleDevelopmentRegion string en"
|
||||
-c "Set :CFBundleShortVersionString ${lokinet_VERSION}"
|
||||
-c "Set :CFBundleVersion ${lokinet_VERSION}.${LOKINET_APPLE_BUILD}"
|
||||
"${lokinet_app}/Contents/Helpers/Lokinet-GUI.app/Contents/Info.plist"
|
||||
)
|
||||
elseif(WIN32)
|
||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/gui")
|
||||
add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe"
|
||||
COMMAND ${YARN} install --frozen-lockfile &&
|
||||
USE_SYSTEM_7ZA=true DISPLAY= WINEDEBUG=-all WINEPREFIX="${PROJECT_BINARY_DIR}/wineprefix" ${YARN} ${GUI_YARN_EXTRA_OPTS} ${GUI_YARN_TARGET}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/gui/release/Lokinet-GUI_portable.exe"
|
||||
"${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe"
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/gui")
|
||||
add_custom_target(assemble_gui ALL COMMAND "true" DEPENDS "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe")
|
||||
else()
|
||||
message(FATAL_ERROR "Building/bundling the GUI from this repository is not supported on this platform")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "not building gui")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET assemble_gui)
|
||||
add_custom_target(assemble_gui COMMAND "true")
|
||||
endif()
|
@ -1,46 +0,0 @@
|
||||
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")
|
||||
|
||||
if(WIN32)
|
||||
include(cmake/win32_installer_deps.cmake)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/configs/00-exit.ini DESTINATION share/conf.d COMPONENT exit_configs)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/configs/00-keyfile.ini DESTINATION share/conf.d COMPONENT keyfile_configs)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/configs/00-debug-log.ini DESTINATION share/conf.d COMPONENT debug_configs)
|
||||
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
|
||||
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "Unspecified" "lokinet" "gui" "exit_configs" "keyfile_configs" "debug_configs")
|
||||
list(APPEND CPACK_COMPONENTS_ALL "lokinet" "gui" "exit_configs" "keyfile_configs" "debug_configs")
|
||||
elseif(APPLE)
|
||||
set(CPACK_GENERATOR DragNDrop;ZIP)
|
||||
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
|
||||
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "Unspecified")
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
|
||||
if(WIN32)
|
||||
cpack_add_component(lokinet
|
||||
DISPLAY_NAME "lokinet"
|
||||
DESCRIPTION "core required lokinet files"
|
||||
REQUIRED)
|
||||
|
||||
cpack_add_component(gui
|
||||
DISPLAY_NAME "lokinet gui"
|
||||
DESCRIPTION "electron based control panel for lokinet")
|
||||
|
||||
cpack_add_component(exit_configs
|
||||
DISPLAY_NAME "auto-enable exit"
|
||||
DESCRIPTION "automatically enable usage of exit.loki as an exit node\n"
|
||||
DISABLED)
|
||||
|
||||
cpack_add_component(keyfile_configs
|
||||
DISPLAY_NAME "persist address"
|
||||
DESCRIPTION "persist .loki address across restarts of lokinet\nnot recommended when enabling exit nodes"
|
||||
DISABLED)
|
||||
|
||||
cpack_add_component(debug_configs
|
||||
DISPLAY_NAME "debug logging"
|
||||
DESCRIPTION "enable debug spew log level by default"
|
||||
DISABLED)
|
||||
endif()
|
@ -1,49 +0,0 @@
|
||||
function(check_working_cxx_atomics64 varname)
|
||||
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
if (EMBEDDED_CFG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -m32 -march=i486")
|
||||
elseif(MSVC OR MSVC_VERSION)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -arch:IA32 -std:c++14")
|
||||
else()
|
||||
# CMAKE_CXX_STANDARD does not propagate to cmake compile tests
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++14")
|
||||
endif()
|
||||
check_cxx_source_compiles("
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
std::atomic<uint64_t> x (0);
|
||||
int main() {
|
||||
uint64_t i = x.load(std::memory_order_relaxed);
|
||||
return 0;
|
||||
}
|
||||
" ${varname})
|
||||
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
||||
endfunction()
|
||||
|
||||
function(link_libatomic)
|
||||
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
|
||||
|
||||
if(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
|
||||
message(STATUS "Have working 64bit atomics")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (NOT MSVC AND NOT MSVC_VERSION)
|
||||
check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
|
||||
if (HAVE_CXX_LIBATOMICS64)
|
||||
message(STATUS "Have 64bit atomics via library")
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
|
||||
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
|
||||
if (HAVE_CXX_ATOMICS64_WITH_LIB)
|
||||
message(STATUS "Can link with libatomic")
|
||||
link_libraries(-latomic)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if (MSVC OR MSVC_VERSION)
|
||||
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic! (What does MSVC do to inline atomics?)")
|
||||
else()
|
||||
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic!")
|
||||
endif()
|
||||
endfunction()
|
@ -1,214 +0,0 @@
|
||||
if(NOT APPLE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
option(MACOS_SYSTEM_EXTENSION
|
||||
"Build the network extension as a system extension rather than a plugin. This must be ON for non-app store release builds, and must be OFF for dev builds and Mac App Store distribution builds"
|
||||
OFF)
|
||||
option(CODESIGN "codesign the resulting app and extension" ON)
|
||||
set(CODESIGN_ID "" CACHE STRING "codesign the macos app using this key identity; if empty we'll try to guess")
|
||||
set(default_profile_type "dev")
|
||||
if(MACOS_SYSTEM_EXTENSION)
|
||||
set(default_profile_type "release")
|
||||
endif()
|
||||
set(CODESIGN_PROFILE "${PROJECT_SOURCE_DIR}/contrib/macos/lokinet.${default_profile_type}.provisionprofile" CACHE FILEPATH
|
||||
"Path to a .provisionprofile to use for the main app")
|
||||
set(CODESIGN_EXT_PROFILE "${PROJECT_SOURCE_DIR}/contrib/macos/lokinet-extension.${default_profile_type}.provisionprofile" CACHE FILEPATH
|
||||
"Path to a .provisionprofile to use for the lokinet extension")
|
||||
|
||||
if(CODESIGN AND NOT CODESIGN_ID)
|
||||
if(MACOS_SYSTEM_EXTENSION)
|
||||
set(codesign_cert_pattern "Developer ID Application")
|
||||
else()
|
||||
set(codesign_cert_pattern "Apple Development")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND security find-identity -v -p codesigning
|
||||
COMMAND sed -n "s/^ *[0-9][0-9]*) *\\([A-F0-9]\\{40\\}\\) *\"\\(${codesign_cert_pattern}.*\\)\"\$/\\1 \\2/p"
|
||||
RESULT_VARIABLE find_id_exit_code
|
||||
OUTPUT_VARIABLE find_id_output)
|
||||
if(NOT find_id_exit_code EQUAL 0)
|
||||
message(FATAL_ERROR "Finding signing identities with security find-identity failed; try specifying an id using -DCODESIGN_ID=...")
|
||||
endif()
|
||||
|
||||
string(REGEX MATCHALL "(^|\n)[0-9A-F]+" find_id_sign_id "${find_id_output}")
|
||||
if(NOT find_id_sign_id)
|
||||
message(FATAL_ERROR "Did not find any \"${codesign_cert_pattern}\" identity; try specifying an id using -DCODESIGN_ID=...")
|
||||
endif()
|
||||
if (find_id_sign_id MATCHES ";")
|
||||
message(FATAL_ERROR "Found multiple \"${codesign_cert_pattern}\" identities:\n${find_id_output}\nSpecify an identify using -DCODESIGN_ID=...")
|
||||
endif()
|
||||
set(CODESIGN_ID "${find_id_sign_id}" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
|
||||
if(CODESIGN)
|
||||
message(STATUS "Codesigning using ${CODESIGN_ID}")
|
||||
|
||||
if (NOT MACOS_NOTARIZE_USER AND NOT MACOS_NOTARIZE_PASS AND NOT MACOS_NOTARIZE_ASC AND EXISTS "$ENV{HOME}/.notarization.cmake")
|
||||
message(STATUS "Loading notarization info from ~/.notarization.cmake")
|
||||
include("$ENV{HOME}/.notarization.cmake")
|
||||
endif()
|
||||
|
||||
if (MACOS_NOTARIZE_USER AND MACOS_NOTARIZE_PASS AND MACOS_NOTARIZE_ASC)
|
||||
message(STATUS "Enabling notarization with account ${MACOS_NOTARIZE_ASC}/${MACOS_NOTARIZE_USER}")
|
||||
else()
|
||||
message(WARNING "You have not set one or more of MACOS_NOTARIZE_USER, MACOS_NOTARIZE_PASS, MACOS_NOTARIZE_ASC: notarization will fail; see contrib/macos/README.txt")
|
||||
endif()
|
||||
|
||||
else()
|
||||
message(WARNING "Codesigning disabled; the resulting build will not run on most macOS systems")
|
||||
endif()
|
||||
|
||||
|
||||
foreach(prof IN ITEMS CODESIGN_PROFILE CODESIGN_EXT_PROFILE)
|
||||
if(NOT ${prof})
|
||||
message(WARNING "Missing a ${prof} provisioning profile: Apple will most likely log an uninformative error message to the system log and then kill harmless kittens if you try to run the result")
|
||||
elseif(NOT EXISTS "${${prof}}")
|
||||
message(FATAL_ERROR "Provisioning profile ${${prof}} does not exist; fix your -D${prof} path")
|
||||
endif()
|
||||
endforeach()
|
||||
message(STATUS "Using ${CODESIGN_PROFILE} app provisioning profile")
|
||||
message(STATUS "Using ${CODESIGN_EXT_PROFILE} extension provisioning profile")
|
||||
|
||||
|
||||
|
||||
set(lokinet_installer "${PROJECT_BINARY_DIR}/Lokinet ${PROJECT_VERSION}")
|
||||
if(NOT CODESIGN)
|
||||
set(lokinet_installer "${lokinet_installer}-UNSIGNED")
|
||||
endif()
|
||||
set(lokinet_app "${lokinet_installer}/Lokinet.app")
|
||||
|
||||
|
||||
if(MACOS_SYSTEM_EXTENSION)
|
||||
set(lokinet_ext_dir Contents/Library/SystemExtensions)
|
||||
else()
|
||||
set(lokinet_ext_dir Contents/PlugIns)
|
||||
endif()
|
||||
|
||||
if(CODESIGN)
|
||||
if(MACOS_SYSTEM_EXTENSION)
|
||||
set(LOKINET_ENTITLEMENTS_TYPE sysext)
|
||||
set(notarize_py_is_sysext True)
|
||||
else()
|
||||
set(LOKINET_ENTITLEMENTS_TYPE plugin)
|
||||
set(notarize_py_is_sysext False)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/contrib/macos/sign.sh.in"
|
||||
"${PROJECT_BINARY_DIR}/sign.sh"
|
||||
@ONLY)
|
||||
|
||||
add_custom_target(
|
||||
sign
|
||||
DEPENDS "${PROJECT_BINARY_DIR}/sign.sh"
|
||||
COMMAND "${PROJECT_BINARY_DIR}/sign.sh"
|
||||
)
|
||||
|
||||
if(MACOS_NOTARIZE_USER AND MACOS_NOTARIZE_PASS AND MACOS_NOTARIZE_ASC)
|
||||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/contrib/macos/notarize.py.in"
|
||||
"${PROJECT_BINARY_DIR}/notarize.py"
|
||||
@ONLY)
|
||||
add_custom_target(
|
||||
notarize
|
||||
DEPENDS "${PROJECT_BINARY_DIR}/notarize.py" sign
|
||||
COMMAND "${PROJECT_BINARY_DIR}/notarize.py"
|
||||
)
|
||||
else()
|
||||
message(WARNING "You have not set one or more of MACOS_NOTARIZE_USER, MACOS_NOTARIZE_PASS, MACOS_NOTARIZE_ASC: notarization disabled")
|
||||
endif()
|
||||
else()
|
||||
add_custom_target(sign COMMAND "true")
|
||||
add_custom_target(notarize DEPENDS sign COMMAND "true")
|
||||
endif()
|
||||
|
||||
set(mac_icon "${PROJECT_BINARY_DIR}/lokinet.icns")
|
||||
add_custom_command(OUTPUT "${mac_icon}"
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/contrib/macos/mk-icns.sh ${PROJECT_SOURCE_DIR}/contrib/lokinet-mac.svg "${mac_icon}"
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/contrib/lokinet-mac.svg ${PROJECT_SOURCE_DIR}/contrib/macos/mk-icns.sh)
|
||||
add_custom_target(icon DEPENDS "${mac_icon}")
|
||||
|
||||
if(BUILD_PACKAGE)
|
||||
add_executable(seticon "${PROJECT_SOURCE_DIR}/contrib/macos/seticon.swift")
|
||||
add_custom_command(OUTPUT "${lokinet_installer}.dmg"
|
||||
DEPENDS notarize seticon
|
||||
COMMAND create-dmg
|
||||
--volname "Lokinet ${PROJECT_VERSION}"
|
||||
--volicon lokinet.icns
|
||||
--background "${PROJECT_SOURCE_DIR}/contrib/macos/installer.tiff"
|
||||
--text-size 16
|
||||
--icon-size 128
|
||||
--window-size 555 440
|
||||
--icon Lokinet.app 151 196
|
||||
--hide-extension Lokinet.app
|
||||
--app-drop-link 403 196
|
||||
--eula "${PROJECT_SOURCE_DIR}/LICENSE"
|
||||
--no-internet-enable
|
||||
"${lokinet_installer}.dmg"
|
||||
"${lokinet_installer}"
|
||||
COMMAND ./seticon lokinet.icns "${lokinet_installer}.dmg"
|
||||
)
|
||||
add_custom_target(dmg DEPENDS "${lokinet_installer}.dmg")
|
||||
endif()
|
||||
|
||||
|
||||
# Called later to set things up, after the main lokinet targets are set up
|
||||
function(macos_target_setup)
|
||||
|
||||
if(MACOS_SYSTEM_EXTENSION)
|
||||
target_compile_definitions(lokinet PRIVATE MACOS_SYSTEM_EXTENSION)
|
||||
endif()
|
||||
|
||||
set_target_properties(lokinet
|
||||
PROPERTIES
|
||||
OUTPUT_NAME Lokinet
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_BUNDLE_INFO_STRING "Lokinet IP Packet Onion Router"
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "Lokinet"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION "${lokinet_VERSION}"
|
||||
MACOSX_BUNDLE_LONG_VERSION_STRING "${lokinet_VERSION}"
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING "${lokinet_VERSION_MAJOR}.${lokinet_VERSION_MINOR}"
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "org.lokinet"
|
||||
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/contrib/macos/lokinet.Info.plist.in"
|
||||
MACOSX_BUNDLE_COPYRIGHT "© 2022, The Oxen Project"
|
||||
)
|
||||
|
||||
add_custom_target(copy_bootstrap
|
||||
DEPENDS lokinet-extension
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/contrib/bootstrap/mainnet.signed
|
||||
$<TARGET_BUNDLE_DIR:lokinet-extension>/Contents/Resources/bootstrap.signed
|
||||
)
|
||||
|
||||
|
||||
add_dependencies(lokinet lokinet-extension icon)
|
||||
|
||||
|
||||
if(CODESIGN_PROFILE)
|
||||
add_custom_target(copy_prov_prof
|
||||
DEPENDS lokinet
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CODESIGN_PROFILE}
|
||||
$<TARGET_BUNDLE_DIR:lokinet>/Contents/embedded.provisionprofile
|
||||
)
|
||||
else()
|
||||
add_custom_target(copy_prov_prof COMMAND true)
|
||||
endif()
|
||||
|
||||
add_custom_target(assemble ALL
|
||||
DEPENDS lokinet lokinet-extension icon copy_prov_prof copy_bootstrap
|
||||
COMMAND rm -rf "${lokinet_app}"
|
||||
COMMAND mkdir -p "${lokinet_installer}"
|
||||
COMMAND cp -a $<TARGET_BUNDLE_DIR:lokinet> "${lokinet_app}"
|
||||
COMMAND mkdir -p "${lokinet_app}/${lokinet_ext_dir}"
|
||||
COMMAND cp -a $<TARGET_BUNDLE_DIR:lokinet-extension> "${lokinet_app}/${lokinet_ext_dir}/"
|
||||
COMMAND mkdir -p "${lokinet_app}/Contents/Resources"
|
||||
COMMAND cp -a "${mac_icon}" "${lokinet_app}/Contents/Resources/icon.icns"
|
||||
)
|
||||
|
||||
if(BUILD_GUI)
|
||||
add_dependencies(sign assemble_gui)
|
||||
else()
|
||||
add_dependencies(sign assemble)
|
||||
endif()
|
||||
endfunction()
|
@ -1,53 +0,0 @@
|
||||
# ngtcp2's top-level CMakeLists.txt loads a bunch of crap we don't want (examples, a conflicting
|
||||
# 'check' target, etc.); instead we directly include it's lib subdirectory to build just the
|
||||
# library, but we have to set up a couple things to make that work:
|
||||
function(add_ngtcp2_lib)
|
||||
file(STRINGS ngtcp2/CMakeLists.txt ngtcp2_project_line REGEX "^project\\(ngtcp2 ")
|
||||
if(NOT ngtcp2_project_line MATCHES "^project\\(ngtcp2 VERSION ([0-9]+)\\.([0-9]+)\\.([0-9]+)\\)$")
|
||||
message(FATAL_ERROR "Unable to extract ngtcp2 version from ngtcp2/CMakeLists.txt (found '${ngtcp2_project_line}')")
|
||||
endif()
|
||||
|
||||
set(PACKAGE_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
|
||||
include(ngtcp2/cmake/Version.cmake)
|
||||
HexVersion(PACKAGE_VERSION_NUM ${CMAKE_MATCH_1} ${CMAKE_MATCH_2} ${CMAKE_MATCH_3})
|
||||
configure_file("ngtcp2/lib/includes/ngtcp2/version.h.in" "ngtcp2/lib/includes/ngtcp2/version.h" @ONLY)
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
|
||||
# Checks for header files.
|
||||
include(CheckIncludeFile)
|
||||
check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
|
||||
check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
|
||||
check_include_file("stddef.h" HAVE_STDDEF_H)
|
||||
check_include_file("stdint.h" HAVE_STDINT_H)
|
||||
check_include_file("stdlib.h" HAVE_STDLIB_H)
|
||||
check_include_file("string.h" HAVE_STRING_H)
|
||||
check_include_file("unistd.h" HAVE_UNISTD_H)
|
||||
check_include_file("sys/endian.h" HAVE_SYS_ENDIAN_H)
|
||||
check_include_file("endian.h" HAVE_ENDIAN_H)
|
||||
check_include_file("byteswap.h" HAVE_BYTESWAP_H)
|
||||
|
||||
include(CheckTypeSize)
|
||||
check_type_size("ssize_t" SIZEOF_SSIZE_T)
|
||||
if(SIZEOF_SSIZE_T STREQUAL "")
|
||||
set(ssize_t ptrdiff_t)
|
||||
endif()
|
||||
|
||||
include(CheckSymbolExists)
|
||||
if(HAVE_ENDIAN_H)
|
||||
check_symbol_exists(be64toh "endian.h" HAVE_BE64TOH)
|
||||
endif()
|
||||
if(NOT HAVE_BE64TO AND HAVE_SYS_ENDIAN_H)
|
||||
check_symbol_exists(be64toh "sys/endian.h" HAVE_BE64TOH)
|
||||
endif()
|
||||
|
||||
check_symbol_exists(bswap_64 "byteswap.h" HAVE_BSWAP_64)
|
||||
|
||||
configure_file(ngtcp2/cmakeconfig.h.in ngtcp2/config.h)
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}/ngtcp2") # for config.h
|
||||
set(ENABLE_STATIC_LIB ON FORCE BOOL)
|
||||
set(ENABLE_SHARED_LIB OFF FORCE BOOL)
|
||||
add_subdirectory(ngtcp2/lib EXCLUDE_FROM_ALL)
|
||||
|
||||
target_compile_definitions(ngtcp2_static PRIVATE -DHAVE_CONFIG_H -D_GNU_SOURCE)
|
||||
endfunction()
|
@ -1,6 +0,0 @@
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
|
||||
# we switched to libuv
|
||||
set(SOLARIS ON)
|
||||
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lsocket -lnsl")
|
||||
add_definitions(-D_POSIX_PTHREAD_SEMANTICS)
|
||||
endif()
|
@ -1,7 +0,0 @@
|
||||
if(STATIC_LINK)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
link_libraries( -static-libstdc++ )
|
||||
else()
|
||||
link_libraries( -static-libstdc++ -static-libgcc )
|
||||
endif()
|
||||
endif()
|
@ -1,9 +0,0 @@
|
||||
# This adds a dependency as a "system" dep - e.g -isystem
|
||||
function(target_link_libraries_system target)
|
||||
set(libs ${ARGN})
|
||||
foreach(lib ${libs})
|
||||
get_target_property(lib_include_dirs ${lib} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
target_include_directories(${target} SYSTEM PUBLIC ${lib_include_dirs})
|
||||
target_link_libraries(${target} PUBLIC ${lib})
|
||||
endforeach(lib)
|
||||
endfunction()
|
@ -1,21 +0,0 @@
|
||||
if(NOT ANDROID)
|
||||
if(NOT UNIX)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckLibraryExists)
|
||||
|
||||
add_definitions(-DUNIX)
|
||||
add_definitions(-DPOSIX)
|
||||
|
||||
if(EMBEDDED_CFG OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
link_libatomic()
|
||||
endif()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||
add_definitions(-D_BSD_SOURCE)
|
||||
add_definitions(-D_GNU_SOURCE)
|
||||
add_definitions(-D_XOPEN_SOURCE=700)
|
||||
endif()
|
@ -1,49 +0,0 @@
|
||||
if(NOT WIN32)
|
||||
return()
|
||||
endif()
|
||||
if (NOT STATIC_LINK)
|
||||
message(FATAL_ERROR "windows requires static builds (thanks balmer)")
|
||||
endif()
|
||||
|
||||
enable_language(RC)
|
||||
|
||||
option(WITH_WINDOWS_32 "build 32 bit windows" OFF)
|
||||
|
||||
# unlike unix where you get a *single* compiler ID string in .comment
|
||||
# GNU ld sees fit to merge *all* the .ident sections in object files
|
||||
# to .r[o]data section one after the other!
|
||||
add_compile_options(-fno-ident -Wa,-mbig-obj)
|
||||
|
||||
if(EMBEDDED_CFG)
|
||||
link_libatomic()
|
||||
endif()
|
||||
|
||||
set(WINTUN_VERSION 0.14.1 CACHE STRING "wintun version")
|
||||
set(WINTUN_MIRROR https://www.wintun.net/builds
|
||||
CACHE STRING "wintun mirror(s)")
|
||||
set(WINTUN_SOURCE wintun-${WINTUN_VERSION}.zip)
|
||||
set(WINTUN_HASH SHA256=07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51
|
||||
CACHE STRING "wintun source hash")
|
||||
|
||||
set(WINDIVERT_VERSION 2.2.0-A CACHE STRING "windivert version")
|
||||
set(WINDIVERT_MIRROR https://reqrypt.org/download
|
||||
CACHE STRING "windivert mirror(s)")
|
||||
set(WINDIVERT_SOURCE WinDivert-${WINDIVERT_VERSION}.zip)
|
||||
set(WINDIVERT_HASH SHA256=2a7630aac0914746fbc565ac862fa096e3e54233883ac52d17c83107496b7a7f
|
||||
CACHE STRING "windivert source hash")
|
||||
|
||||
set(WINTUN_URL ${WINTUN_MIRROR}/${WINTUN_SOURCE}
|
||||
CACHE STRING "wintun download url")
|
||||
set(WINDIVERT_URL ${WINDIVERT_MIRROR}/${WINDIVERT_SOURCE}
|
||||
CACHE STRING "windivert download url")
|
||||
|
||||
message(STATUS "Downloading wintun from ${WINTUN_URL}")
|
||||
file(DOWNLOAD ${WINTUN_URL} ${CMAKE_BINARY_DIR}/wintun.zip EXPECTED_HASH ${WINTUN_HASH})
|
||||
message(STATUS "Downloading windivert from ${WINDIVERT_URL}")
|
||||
file(DOWNLOAD ${WINDIVERT_URL} ${CMAKE_BINARY_DIR}/windivert.zip EXPECTED_HASH ${WINDIVERT_HASH})
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar x ${CMAKE_BINARY_DIR}/wintun.zip
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar x ${CMAKE_BINARY_DIR}/windivert.zip
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
@ -1,46 +0,0 @@
|
||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/gui DESTINATION share COMPONENT gui)
|
||||
|
||||
if(WITH_WINDOWS_32)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/wintun/bin/x86/wintun.dll DESTINATION bin COMPONENT lokinet)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/x86/WinDivert.sys DESTINATION lib COMPONENT lokinet)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/x86/WinDivert.dll DESTINATION bin COMPONENT lokinet)
|
||||
else()
|
||||
install(FILES ${CMAKE_BINARY_DIR}/wintun/bin/amd64/wintun.dll DESTINATION bin COMPONENT lokinet)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/x64/WinDivert64.sys DESTINATION lib COMPONENT lokinet)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/x64/WinDivert.dll DESTINATION bin COMPONENT lokinet)
|
||||
endif()
|
||||
|
||||
set(BOOTSTRAP_FILE "${PROJECT_SOURCE_DIR}/contrib/bootstrap/mainnet.signed")
|
||||
install(FILES ${BOOTSTRAP_FILE} DESTINATION share COMPONENT lokinet RENAME bootstrap.signed)
|
||||
|
||||
set(win_ico "${PROJECT_BINARY_DIR}/lokinet.ico")
|
||||
add_custom_command(OUTPUT "${win_ico}"
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/contrib/make-ico.sh ${PROJECT_SOURCE_DIR}/contrib/lokinet.svg "${win_ico}"
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/contrib/lokinet.svg ${PROJECT_SOURCE_DIR}/contrib/make-ico.sh)
|
||||
add_custom_target(icon ALL DEPENDS "${win_ico}")
|
||||
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Lokinet")
|
||||
set(CPACK_NSIS_MUI_ICON "${PROJECT_BINARY_DIR}/lokinet.ico")
|
||||
set(CPACK_NSIS_DEFINES "RequestExecutionLevel admin")
|
||||
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
|
||||
|
||||
function(read_nsis_file filename outvar)
|
||||
file(STRINGS "${filename}" _outvar)
|
||||
list(TRANSFORM _outvar REPLACE "\\\\" "\\\\\\\\")
|
||||
list(JOIN _outvar "\\n" out)
|
||||
set(${outvar} ${out} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_preinstall.nsis" _extra_preinstall)
|
||||
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_install.nsis" _extra_install)
|
||||
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_uninstall.nsis" _extra_uninstall)
|
||||
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_create_icons.nsis" _extra_create_icons)
|
||||
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_delete_icons.nsis" _extra_delete_icons)
|
||||
|
||||
set(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "${_extra_preinstall}")
|
||||
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${_extra_install}")
|
||||
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "${_extra_uninstall}")
|
||||
set(CPACK_NSIS_CREATE_ICONS_EXTRA "${_extra_create_icons}")
|
||||
set(CPACK_NSIS_DELETE_ICONS_EXTRA "${_extra_delete_icons}")
|
||||
|
||||
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
|
@ -1,13 +0,0 @@
|
||||
Place in `/etc/NetworkManager/dnsmasq.d/lokinet.conf`.
|
||||
|
||||
To make use of this, first install dnsmasq.
|
||||
|
||||
Then enable NetworkManager dnsmasq backend by editing `/etc/NetworkManager/NetworkManager.conf` to something like:
|
||||
```
|
||||
[main]
|
||||
dns=dnsmasq
|
||||
```
|
||||
If NetworkManager is currently running, restart it for changes to take effect:
|
||||
```
|
||||
sudo systemctl restart NetworkManager
|
||||
```
|
@ -1 +0,0 @@
|
||||
server=/loki/snode/127.3.2.1
|
@ -1,67 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
default_abis="armeabi-v7a arm64-v8a x86_64"
|
||||
build_abis=${ABIS:-$default_abis}
|
||||
|
||||
test x$NDK = x && test -e /usr/lib/android-ndk && export NDK=/usr/lib/android-ndk
|
||||
test x$NDK = x && exit 1
|
||||
|
||||
echo "building abis: $build_abis"
|
||||
|
||||
root=$(readlink -f "$1")
|
||||
shift
|
||||
build=$(readlink -f "$1")
|
||||
shift
|
||||
mkdir -p $build
|
||||
cd $build
|
||||
|
||||
for abi in $build_abis; do
|
||||
mkdir -p build-$abi
|
||||
cd build-$abi
|
||||
cmake \
|
||||
-S "$root" -B . \
|
||||
-G 'Unix Makefiles' \
|
||||
-DANDROID=ON \
|
||||
-DANDROID_ABI=$abi \
|
||||
-DANDROID_ARM_MODE=arm \
|
||||
-DANDROID_PLATFORM=android-23 \
|
||||
-DANDROID_API=23 \
|
||||
-DANDROID_STL=c++_static \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \
|
||||
-DBUILD_STATIC_DEPS=ON \
|
||||
-DBUILD_PACKAGE=ON \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DBUILD_TESTING=OFF \
|
||||
-DWITH_TESTS=OFF \
|
||||
-DWITH_BOOTSTRAP=OFF \
|
||||
-DNATIVE_BUILD=OFF \
|
||||
-DSTATIC_LINK=ON \
|
||||
-DWITH_SYSTEMD=OFF \
|
||||
-DFORCE_OXENMQ_SUBMODULE=ON \
|
||||
-DFORCE_OXENC_SUBMODULE=ON \
|
||||
-DFORCE_FMT_SUBMODULE=ON \
|
||||
-DFORCE_SPDLOG_SUBMODULE=ON \
|
||||
-DFORCE_NLOHMANN_SUBMODULE=ON \
|
||||
-DSUBMODULE_CHECK=OFF \
|
||||
-DWITH_LTO=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
"$@"
|
||||
cd -
|
||||
done
|
||||
rm -f $build/Makefile
|
||||
echo "# generated makefile" >> $build/Makefile
|
||||
echo "all: $build_abis" >> $build/Makefile
|
||||
for abi in $build_abis; do
|
||||
echo -ne "$abi:\n\t" >> $build/Makefile
|
||||
echo -ne '$(MAKE) -C ' >> $build/Makefile
|
||||
echo "build-$abi lokinet-android" >> $build/Makefile
|
||||
echo -ne "\tmkdir -p out/$abi && cp build-$abi/jni/liblokinet-android.so out/$abi/liblokinet-android.so\n\n" >> $build/Makefile
|
||||
echo -ne "clean-$abi:\n\t" >> $build/Makefile
|
||||
echo -ne '$(MAKE) -C ' >> $build/Makefile
|
||||
echo "build-$abi clean" >> $build/Makefile
|
||||
done
|
||||
|
||||
echo -ne "clean:" >> $build/Makefile
|
||||
for targ in $build_abis ; do echo -ne " clean-$targ" >> $build/Makefile ; done
|
||||
echo "" >> $build/Makefile
|
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set +x
|
||||
|
||||
root="$(readlink -f $(dirname $0)/../)"
|
||||
cd "$root"
|
||||
./contrib/android-configure.sh . build-android "$@"
|
||||
make -C build-android -j ${JOBS:-$(nproc)}
|
@ -1,27 +0,0 @@
|
||||
# Last Modified: Fri 05 Feb 2021 08:13:58 PM UTC
|
||||
#include <tunables/global>
|
||||
|
||||
profile lokinet /usr/bin/lokinet {
|
||||
#include <abstractions/base>
|
||||
#include <abstractions/nameservice>
|
||||
|
||||
capability net_admin,
|
||||
capability net_bind_service,
|
||||
|
||||
network inet dgram,
|
||||
network inet6 dgram,
|
||||
network netlink raw,
|
||||
|
||||
/etc/loki/lokinet.ini r,
|
||||
/dev/net/tun rw,
|
||||
/usr/bin/lokinet mr,
|
||||
|
||||
owner /{var/,}lib/lokinet/ rw,
|
||||
owner /{var/,}lib/lokinet/** rwk,
|
||||
owner ${HOME}/.lokinet/ rw,
|
||||
owner ${HOME}/.lokinet/** rwk,
|
||||
owner @{PROC}/@{pid}/task/@{pid}/comm rw,
|
||||
owner /tmp/lokinet.*/{**,} rw,
|
||||
|
||||
#include if exists <local/usr.bin.lokinet>
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
for f in "$@" ; do
|
||||
patch -p1 -i "$f"
|
||||
done
|
@ -1,109 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import pprint
|
||||
|
||||
if len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == '-'):
|
||||
f = sys.stdin.buffer
|
||||
elif len(sys.argv) != 2 or sys.argv[1].startswith('-'):
|
||||
print("Usage: {} FILE -- dumps a bencoded file".format(sys.argv[0]), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
else:
|
||||
f = open(sys.argv[1], 'rb')
|
||||
|
||||
|
||||
initial = f.peek(2)
|
||||
is_hex = False
|
||||
if initial.startswith(b'64') or initial.startswith(b'6c'):
|
||||
print("Input looks like hex bencoded data; parsing as hex input", file=sys.stderr)
|
||||
is_hex = True
|
||||
|
||||
class HexPrinter():
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
def __repr__(self):
|
||||
return "hex({} bytes):'{}'".format(len(self.data), self.data.hex())
|
||||
|
||||
|
||||
def next_byte():
|
||||
if is_hex:
|
||||
pair = f.read(2)
|
||||
assert pair is not None and len(pair) == 2
|
||||
b = int(pair, 16).to_bytes(1, 'big')
|
||||
else:
|
||||
b = f.read(1)
|
||||
assert b is not None and len(b) == 1
|
||||
return b
|
||||
|
||||
|
||||
def parse_int():
|
||||
s = b''
|
||||
x = next_byte()
|
||||
while x in b"0123456789-":
|
||||
s += x
|
||||
x = next_byte()
|
||||
assert x == b'e' and len(s) > 0, "Invalid integer encoding"
|
||||
return int(s)
|
||||
|
||||
|
||||
def parse_string(s):
|
||||
x = next_byte()
|
||||
while x in b"0123456789":
|
||||
s += x
|
||||
x = next_byte()
|
||||
assert x == b':', "Invalid string encoding"
|
||||
s = int(s)
|
||||
if is_hex:
|
||||
data = bytes.fromhex(f.read(2*s).decode('ascii'))
|
||||
else:
|
||||
data = f.read(s)
|
||||
assert len(data) == s, "Truncated string data"
|
||||
# If the string is ascii then convert to string:
|
||||
if all(0x20 <= b <= 0x7e for b in data):
|
||||
return data.decode()
|
||||
# Otherwise display as hex:
|
||||
return HexPrinter(data)
|
||||
|
||||
|
||||
def parse_dict():
|
||||
d = {}
|
||||
last_key = None
|
||||
while True:
|
||||
t = next_byte()
|
||||
if t == b'e':
|
||||
return d
|
||||
assert t in b"0123456789", "Invalid dict: dict keys must be strings"
|
||||
key = parse_string(t)
|
||||
raw_key = key.data if isinstance(key, HexPrinter) else key.encode()
|
||||
if last_key is not None and raw_key <= last_key:
|
||||
print("Warning: found out-of-order dict keys ({} after {})".format(raw_key, last_key), file=sys.stderr)
|
||||
last_key = raw_key
|
||||
t = next_byte()
|
||||
d[key] = parse_thing(t)
|
||||
|
||||
|
||||
def parse_list():
|
||||
l = []
|
||||
while True:
|
||||
t = next_byte()
|
||||
if t == b'e':
|
||||
return l
|
||||
l.append(parse_thing(t))
|
||||
|
||||
|
||||
def parse_thing(t):
|
||||
if t == b'd':
|
||||
return parse_dict()
|
||||
if t == b'l':
|
||||
return parse_list()
|
||||
if t == b'i':
|
||||
return parse_int()
|
||||
if t in b"0123456789":
|
||||
return parse_string(t)
|
||||
assert False, "Parsing error: encountered invalid type '{}'".format(t)
|
||||
|
||||
|
||||
pprint.PrettyPrinter(
|
||||
indent=2
|
||||
).pprint(parse_thing(next_byte()))
|
Binary file not shown.
@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
echo -n 'l'
|
||||
for arg in $@ ; do cat "$arg" ; done
|
||||
echo -n 'e'
|
@ -1,3 +0,0 @@
|
||||
usage:
|
||||
|
||||
./make-bootstrap-list.sh $(find $HOME/.lokinet/netdb | grep \\.signed$) > bootstrap.signed
|
@ -1,9 +0,0 @@
|
||||
## drone-ci docker jizz
|
||||
|
||||
To rebuild all ci images and push them to the oxen registry server do:
|
||||
|
||||
$ docker login registry.oxen.rocks
|
||||
$ ./rebuild-docker-images.py
|
||||
|
||||
If you aren't part of the Oxen team, you'll likely need to set up your own registry and change
|
||||
registry.oxen.rocks to your own domain name in order to do anything useful with this.
|
@ -1,350 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
import tempfile
|
||||
import optparse
|
||||
import sys
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import threading
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("--no-cache", action="store_true",
|
||||
help="Run `docker build` with the `--no-cache` option to ignore existing images")
|
||||
parser.add_option("--parallel", "-j", type="int", default=1,
|
||||
help="Run up to this many builds in parallel")
|
||||
parser.add_option("--distro", type="string", default="",
|
||||
help="Build only this distro; should be DISTRO-CODE or DISTRO-CODE/ARCH, "
|
||||
"e.g. debian-sid/amd64")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
registry_base = 'registry.oxen.rocks/lokinet-ci-'
|
||||
|
||||
distros = [*(('debian', x) for x in ('sid', 'stable', 'testing', 'bullseye', 'buster')),
|
||||
*(('ubuntu', x) for x in ('rolling', 'lts', 'impish', 'hirsute', 'focal', 'bionic'))]
|
||||
|
||||
if options.distro:
|
||||
d = options.distro.split('-')
|
||||
if len(d) != 2 or d[0] not in ('debian', 'ubuntu') or not d[1]:
|
||||
print("Bad --distro value '{}'".format(options.distro), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
distros = [(d[0], d[1].split('/')[0])]
|
||||
|
||||
|
||||
manifests = {} # "image:latest": ["image/amd64", "image/arm64v8", ...]
|
||||
manifestlock = threading.Lock()
|
||||
|
||||
|
||||
def arches(distro):
|
||||
if options.distro and '/' in options.distro:
|
||||
arch = options.distro.split('/')
|
||||
if arch not in ('amd64', 'i386', 'arm64v8', 'arm32v7'):
|
||||
print("Bad --distro value '{}'".format(options.distro), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
return [arch]
|
||||
|
||||
a = ['amd64', 'arm64v8', 'arm32v7']
|
||||
if distro[0] == 'debian' or distro == ('ubuntu', 'bionic'):
|
||||
a.append('i386') # i386 builds don't work on later ubuntu
|
||||
return a
|
||||
|
||||
|
||||
hacks = {
|
||||
registry_base + 'ubuntu-bionic-builder': """g++-8 \
|
||||
&& mkdir -p /usr/lib/x86_64-linux-gnu/pgm-5.2/include""",
|
||||
}
|
||||
|
||||
|
||||
failure = False
|
||||
|
||||
lineno = 0
|
||||
linelock = threading.Lock()
|
||||
|
||||
|
||||
def print_line(myline, value):
|
||||
linelock.acquire()
|
||||
global lineno
|
||||
if sys.__stdout__.isatty():
|
||||
jump = lineno - myline
|
||||
print("\033[{jump}A\r\033[K{value}\033[{jump}B\r".format(jump=jump, value=value), end='')
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
print(value)
|
||||
linelock.release()
|
||||
|
||||
|
||||
def run_or_report(*args, myline):
|
||||
try:
|
||||
subprocess.run(
|
||||
args, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8')
|
||||
except subprocess.CalledProcessError as e:
|
||||
with tempfile.NamedTemporaryFile(suffix=".log", delete=False) as log:
|
||||
log.write("Error running {}: {}\n\nOutput:\n\n".format(' '.join(args), e).encode())
|
||||
log.write(e.output.encode())
|
||||
global failure
|
||||
failure = True
|
||||
print_line(myline, "\033[31;1mError! See {} for details".format(log.name))
|
||||
raise e
|
||||
|
||||
|
||||
def build_tag(tag_base, arch, contents):
|
||||
if failure:
|
||||
raise ChildProcessError()
|
||||
|
||||
linelock.acquire()
|
||||
global lineno
|
||||
myline = lineno
|
||||
lineno += 1
|
||||
print()
|
||||
linelock.release()
|
||||
|
||||
with tempfile.NamedTemporaryFile() as dockerfile:
|
||||
dockerfile.write(contents.encode())
|
||||
dockerfile.flush()
|
||||
|
||||
tag = '{}/{}'.format(tag_base, arch)
|
||||
print_line(myline, "\033[33;1mRebuilding \033[35;1m{}\033[0m".format(tag))
|
||||
run_or_report('docker', 'build', '--pull', '-f', dockerfile.name, '-t', tag,
|
||||
*(('--no-cache',) if options.no_cache else ()), '.', myline=myline)
|
||||
print_line(myline, "\033[33;1mPushing \033[35;1m{}\033[0m".format(tag))
|
||||
run_or_report('docker', 'push', tag, myline=myline)
|
||||
print_line(myline, "\033[32;1mFinished build \033[35;1m{}\033[0m".format(tag))
|
||||
|
||||
latest = tag_base + ':latest'
|
||||
global manifests
|
||||
manifestlock.acquire()
|
||||
if latest in manifests:
|
||||
manifests[latest].append(tag)
|
||||
else:
|
||||
manifests[latest] = [tag]
|
||||
manifestlock.release()
|
||||
|
||||
|
||||
def base_distro_build(distro, arch):
|
||||
tag = '{r}{distro[0]}-{distro[1]}-base'.format(r=registry_base, distro=distro)
|
||||
codename = 'latest' if distro == ('ubuntu', 'lts') else distro[1]
|
||||
build_tag(tag, arch, """
|
||||
FROM {}/{}:{}
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q autoremove -y \
|
||||
{hacks}
|
||||
""".format(arch, distro[0], codename, hacks=hacks.get(tag, '')))
|
||||
|
||||
|
||||
def distro_build(distro, arch):
|
||||
prefix = '{r}{distro[0]}-{distro[1]}'.format(r=registry_base, distro=distro)
|
||||
fmtargs = dict(arch=arch, distro=distro, prefix=prefix)
|
||||
|
||||
# (distro)-(codename)-base: Base image from upstream: we sync the repos, but do nothing else.
|
||||
if (distro, arch) != (('debian', 'stable'), 'amd64'): # debian-stable-base/amd64 already built
|
||||
base_distro_build(distro, arch)
|
||||
|
||||
# (distro)-(codename)-builder: Deb builder image used for building debs; we add the basic tools
|
||||
# we use to build debs, not including things that should come from the dependencies in the
|
||||
# debian/control file.
|
||||
build_tag(prefix + '-builder', arch, """
|
||||
FROM {prefix}-base/{arch}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
ccache \
|
||||
devscripts \
|
||||
equivs \
|
||||
g++ \
|
||||
git \
|
||||
git-buildpackage \
|
||||
openssh-client \
|
||||
{hacks}
|
||||
""".format(**fmtargs, hacks=hacks.get(prefix + '-builder', '')))
|
||||
|
||||
# (distro)-(codename): Basic image we use for most builds. This takes the -builder and adds
|
||||
# most dependencies found in our packages.
|
||||
build_tag(prefix, arch, """
|
||||
FROM {prefix}-builder/{arch}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
pybind11-dev \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-pybind11 \
|
||||
python3-pytest \
|
||||
python3-setuptools \
|
||||
qttools5-dev \
|
||||
{hacks}
|
||||
""".format(**fmtargs, hacks=hacks.get(prefix, '')))
|
||||
|
||||
|
||||
# Android and flutter builds on top of debian-stable-base and adds a ton of android crap; we
|
||||
# schedule this job as soon as the debian-sid-base/amd64 build finishes, because they easily take
|
||||
# the longest and are by far the biggest images.
|
||||
def android_builds():
|
||||
build_tag(registry_base + 'android', 'amd64', """
|
||||
FROM {r}debian-stable-base
|
||||
RUN /bin/bash -c 'sed -i "s/main/main contrib/g" /etc/apt/sources.list'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
android-sdk \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
curl \
|
||||
git \
|
||||
google-android-ndk-installer \
|
||||
libtool \
|
||||
make \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
wget \
|
||||
xz-utils \
|
||||
zip \
|
||||
&& git clone https://github.com/Shadowstyler/android-sdk-licenses.git /tmp/android-sdk-licenses \
|
||||
&& cp -a /tmp/android-sdk-licenses/*-license /usr/lib/android-sdk/licenses \
|
||||
&& rm -rf /tmp/android-sdk-licenses
|
||||
""".format(r=registry_base))
|
||||
|
||||
build_tag(registry_base + 'flutter', 'amd64', """
|
||||
FROM {r}android
|
||||
RUN cd /opt \
|
||||
&& curl https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_2.2.2-stable.tar.xz \
|
||||
| tar xJv \
|
||||
&& ln -s /opt/flutter/bin/flutter /usr/local/bin/ \
|
||||
&& flutter precache
|
||||
""".format(r=registry_base))
|
||||
|
||||
|
||||
# lint is a tiny build (on top of debian-stable-base) with just formatting checking tools
|
||||
def lint_build():
|
||||
build_tag(registry_base + 'lint', 'amd64', """
|
||||
FROM {r}debian-stable-base
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
clang-format-11 \
|
||||
eatmydata \
|
||||
git \
|
||||
jsonnet
|
||||
""".format(r=registry_base))
|
||||
|
||||
|
||||
def nodejs_build():
|
||||
build_tag(registry_base + 'nodejs', 'amd64', """
|
||||
FROM node:14.16.1
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
make \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
wine
|
||||
""")
|
||||
|
||||
|
||||
# Start debian-stable-base/amd64 on its own, because other builds depend on it and we want to get
|
||||
# those (especially android/flutter) fired off as soon as possible (because it's slow and huge).
|
||||
if ('debian', 'stable') in distros:
|
||||
base_distro_build(['debian', 'stable'], 'amd64')
|
||||
|
||||
executor = ThreadPoolExecutor(max_workers=max(options.parallel, 1))
|
||||
|
||||
if options.distro:
|
||||
jobs = []
|
||||
else:
|
||||
jobs = [executor.submit(b) for b in (android_builds, lint_build, nodejs_build)]
|
||||
|
||||
for d in distros:
|
||||
for a in arches(d):
|
||||
jobs.append(executor.submit(distro_build, d, a))
|
||||
while len(jobs):
|
||||
j = jobs.pop(0)
|
||||
try:
|
||||
j.result()
|
||||
except (ChildProcessError, subprocess.CalledProcessError):
|
||||
for k in jobs:
|
||||
k.cancel()
|
||||
|
||||
|
||||
if failure:
|
||||
print("Error(s) occured, aborting!", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
print("\n\n\033[32;1mAll builds finished successfully; pushing manifests...\033[0m\n")
|
||||
|
||||
|
||||
def push_manifest(latest, tags):
|
||||
if failure:
|
||||
raise ChildProcessError()
|
||||
|
||||
linelock.acquire()
|
||||
global lineno
|
||||
myline = lineno
|
||||
lineno += 1
|
||||
print()
|
||||
linelock.release()
|
||||
|
||||
subprocess.run(['docker', 'manifest', 'rm', latest], stderr=subprocess.DEVNULL, check=False)
|
||||
print_line(myline, "\033[33;1mCreating manifest \033[35;1m{}\033[0m".format(latest))
|
||||
run_or_report('docker', 'manifest', 'create', latest, *tags, myline=myline)
|
||||
print_line(myline, "\033[33;1mPushing manifest \033[35;1m{}\033[0m".format(latest))
|
||||
run_or_report('docker', 'manifest', 'push', latest, myline=myline)
|
||||
print_line(myline, "\033[32;1mFinished manifest \033[35;1m{}\033[0m".format(latest))
|
||||
|
||||
|
||||
for latest, tags in manifests.items():
|
||||
jobs.append(executor.submit(push_manifest, latest, tags))
|
||||
|
||||
while len(jobs):
|
||||
j = jobs.pop(0)
|
||||
try:
|
||||
j.result()
|
||||
except (ChildProcessError, subprocess.CalledProcessError):
|
||||
for k in jobs:
|
||||
k.cancel()
|
||||
|
||||
|
||||
print("\n\n\033[32;1mAll done!\n")
|
@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Script used with Drone CI to check that a statically build lokinet only links against the expected
|
||||
# base system libraries. Expects to be run with pwd of the build directory.
|
||||
|
||||
set -o errexit
|
||||
|
||||
bad=
|
||||
if [ "$DRONE_STAGE_OS" == "darwin" ]; then
|
||||
if otool -L llarp/apple/org.lokinet.network-extension.systemextension/Contents/MacOS/org.lokinet.network-extension | \
|
||||
grep -Ev '^llarp/apple:|^\t(/usr/lib/lib(System\.|c\+\+|objc))|/System/Library/Frameworks/(CoreFoundation|NetworkExtension|Foundation|Network)\.framework'; then
|
||||
bad=1
|
||||
fi
|
||||
elif [ "$DRONE_STAGE_OS" == "linux" ]; then
|
||||
if ldd daemon/lokinet | grep -Ev '(linux-vdso|ld-linux-(x86-64|armhf|aarch64)|lib(pthread|dl|rt|stdc\+\+|gcc_s|c|m))\.so'; then
|
||||
bad=1
|
||||
fi
|
||||
else
|
||||
echo -e "\n\n\n\n\e[31;1mDon't know how to check linked libs on $DRONE_STAGE_OS\e[0m\n\n\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$bad" ]; then
|
||||
echo -e "\n\n\n\n\e[31;1mlokinet links to unexpected libraries\e[0m\n\n\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\n\n\n\n\e[32;1mNo unexpected linked libraries found\e[0m\n\n\n"
|
@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script used with Drone CI to upload debs from the deb building pipelines (because specifying all
|
||||
# this in .drone.jsonnet is too painful). This is expected to run from the base project dir after
|
||||
# having build with debuild (which will leave the debs in ..).
|
||||
|
||||
set -o errexit
|
||||
|
||||
distro="$1"
|
||||
|
||||
if [ -z "$distro" ]; then
|
||||
echo "Bad usage: need distro name as first argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$SSH_KEY" ]; then
|
||||
echo -e "\n\n\n\e[31;1mUnable to upload debs: SSH_KEY not set\e[0m"
|
||||
# Just warn but don't fail, so that this doesn't trigger a build failure for untrusted builds
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "$SSH_KEY" >~/ssh_key
|
||||
|
||||
set -o xtrace # Don't start tracing until *after* we write the ssh key
|
||||
|
||||
chmod 600 ~/ssh_key
|
||||
|
||||
upload_to="oxen.rocks/debs/${DRONE_REPO// /_}@${DRONE_BRANCH// /_}/$(date --date=@$DRONE_BUILD_CREATED +%Y%m%dT%H%M%SZ)-${DRONE_COMMIT:0:9}/$distro/$DRONE_STAGE_ARCH"
|
||||
|
||||
# sftp doesn't have any equivalent to mkdir -p, so we have to split the above up into a chain of
|
||||
# -mkdir a/, -mkdir a/b/, -mkdir a/b/c/, ... commands. The leading `-` allows the command to fail
|
||||
# without error.
|
||||
upload_dirs=(${upload_to//\// })
|
||||
mkdirs=
|
||||
dir_tmp=""
|
||||
for p in "${upload_dirs[@]}"; do
|
||||
dir_tmp="$dir_tmp$p/"
|
||||
mkdirs="$mkdirs
|
||||
-mkdir $dir_tmp"
|
||||
done
|
||||
|
||||
sftp -i ~/ssh_key -b - -o StrictHostKeyChecking=off drone@oxen.rocks <<SFTP
|
||||
$mkdirs
|
||||
put ../*.*deb $upload_to
|
||||
SFTP
|
||||
|
||||
set +o xtrace
|
||||
|
||||
echo -e "\n\n\n\n\e[32;1mUploaded debs to https://${upload_to}/\e[0m\n\n\n"
|
||||
|
@ -1,9 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
test "x$IGNORE" != "x" && exit 0
|
||||
|
||||
. $(dirname $0)/../format-version.sh
|
||||
|
||||
repo=$(readlink -e $(dirname $0)/../../)
|
||||
$CLANG_FORMAT -i $(find $repo/jni $repo/daemon $repo/llarp $repo/include $repo/pybind | grep -E '\.[hc](pp)?$')
|
||||
jsonnetfmt -i $repo/.drone.jsonnet
|
||||
git --no-pager diff --exit-code --color || (echo -ne '\n\n\e[31;1mLint check failed; please run ./contrib/format.sh\e[0m\n\n' ; exit 1)
|
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
rm -f crash.out.txt exit.out.txt
|
||||
gdb -q -x $(readlink -e $(dirname $0))/gdb-filter.py --args $@
|
||||
test -e crash.out.txt && cat crash.out.txt
|
||||
exit $(cat exit.out.txt)
|
@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
export PYTHONPATH=pybind
|
||||
rm -f crash.out.txt exit.out.txt
|
||||
gdb -q -x $(readlink -e $(dirname $0))/gdb-filter.py --args /usr/bin/python3 -m pytest ../test/
|
||||
test -e crash.out.txt && cat crash.out.txt
|
||||
exit $(cat exit.out.txt)
|
@ -1,96 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Script used with Drone CI to upload build artifacts (because specifying all this in
|
||||
# .drone.jsonnet is too painful).
|
||||
|
||||
|
||||
|
||||
set -o errexit
|
||||
|
||||
if [ -z "$SSH_KEY" ]; then
|
||||
echo -e "\n\n\n\e[31;1mUnable to upload artifact: SSH_KEY not set\e[0m"
|
||||
# Just warn but don't fail, so that this doesn't trigger a build failure for untrusted builds
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "$SSH_KEY" >ssh_key
|
||||
|
||||
set -o xtrace # Don't start tracing until *after* we write the ssh key
|
||||
|
||||
chmod 600 ssh_key
|
||||
|
||||
os="$UPLOAD_OS"
|
||||
if [ -z "$os" ]; then
|
||||
if [ "$DRONE_STAGE_OS" == "darwin" ]; then
|
||||
os="macos-$DRONE_STAGE_ARCH"
|
||||
elif [ -n "$WINDOWS_BUILD_NAME" ]; then
|
||||
os="windows-$WINDOWS_BUILD_NAME"
|
||||
else
|
||||
os="$DRONE_STAGE_OS-$DRONE_STAGE_ARCH"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$DRONE_TAG" ]; then
|
||||
# For a tag build use something like `lokinet-linux-amd64-v1.2.3`
|
||||
base="lokinet-$os-$DRONE_TAG"
|
||||
else
|
||||
# Otherwise build a length name from the datetime and commit hash, such as:
|
||||
# lokinet-linux-amd64-20200522T212342Z-04d7dcc54
|
||||
base="lokinet-$os-$(date --date=@$DRONE_BUILD_CREATED +%Y%m%dT%H%M%SZ)-${DRONE_COMMIT:0:9}"
|
||||
fi
|
||||
|
||||
mkdir -v "$base"
|
||||
if [ -e build/win32 ]; then
|
||||
# save debug symbols
|
||||
cp -av build/win32/daemon/debug-symbols.tar.xz "$base-debug-symbols.tar.xz"
|
||||
# save installer
|
||||
cp -av build/win32/*.exe "$base"
|
||||
# zipit up yo
|
||||
archive="$base.zip"
|
||||
zip -r "$archive" "$base"
|
||||
elif [ -e lokinet.apk ] ; then
|
||||
# android af ngl
|
||||
archive="$base.apk"
|
||||
cp -av lokinet.apk "$archive"
|
||||
elif [ -e build-docs ]; then
|
||||
archive="$base.tar.xz"
|
||||
cp -av build-docs/docs/mkdocs.yml build-docs/docs/markdown "$base"
|
||||
tar cJvf "$archive" "$base"
|
||||
elif [ -e build-mac ]; then
|
||||
archive="$base.tar.xz"
|
||||
mv build-mac/Lokinet*/ "$base"
|
||||
tar cJvf "$archive" "$base"
|
||||
else
|
||||
cp -av build/daemon/lokinet{,-vpn} "$base"
|
||||
cp -av contrib/bootstrap/mainnet.signed "$base/bootstrap.signed"
|
||||
# tar dat shiz up yo
|
||||
archive="$base.tar.xz"
|
||||
tar cJvf "$archive" "$base"
|
||||
fi
|
||||
|
||||
upload_to="oxen.rocks/${DRONE_REPO// /_}/${DRONE_BRANCH// /_}"
|
||||
|
||||
# sftp doesn't have any equivalent to mkdir -p, so we have to split the above up into a chain of
|
||||
# -mkdir a/, -mkdir a/b/, -mkdir a/b/c/, ... commands. The leading `-` allows the command to fail
|
||||
# without error.
|
||||
upload_dirs=(${upload_to//\// })
|
||||
put_debug=
|
||||
mkdirs=
|
||||
dir_tmp=""
|
||||
for p in "${upload_dirs[@]}"; do
|
||||
dir_tmp="$dir_tmp$p/"
|
||||
mkdirs="$mkdirs
|
||||
-mkdir $dir_tmp"
|
||||
done
|
||||
if [ -e "$base-debug-symbols.tar.xz" ] ; then
|
||||
put_debug="put $base-debug-symbols.tar.xz $upload_to"
|
||||
fi
|
||||
sftp -i ssh_key -b - -o StrictHostKeyChecking=off drone@oxen.rocks <<SFTP
|
||||
$mkdirs
|
||||
put $archive $upload_to
|
||||
$put_debug
|
||||
SFTP
|
||||
|
||||
set +o xtrace
|
||||
|
||||
echo -e "\n\n\n\n\e[32;1mUploaded to https://${upload_to}/${archive}\e[0m\n\n\n"
|
@ -1,36 +0,0 @@
|
||||
def exit_handler (event):
|
||||
"""
|
||||
write exit code of the program running in gdb to a file called exit.out.txt
|
||||
"""
|
||||
code = 1
|
||||
if hasattr(event, "exit_code"):
|
||||
code = event.exit_code
|
||||
with open("exit.out.txt", 'w') as f:
|
||||
f.write("{}".format(code))
|
||||
|
||||
def gdb_execmany(*cmds):
|
||||
"""
|
||||
run multiple gdb commands
|
||||
"""
|
||||
for cmd in cmds:
|
||||
gdb.execute(cmd)
|
||||
|
||||
def crash_handler (event):
|
||||
"""
|
||||
handle a crash from the program running in gdb
|
||||
"""
|
||||
if isinstance(event, gdb.SignalEvent):
|
||||
log_file_name = "crash.out.txt"
|
||||
# poop out log file for stack trace of all threads
|
||||
gdb_execmany("set logging file {}".format(log_file_name), "set logging on", "set logging redirect on", "thread apply all bt full")
|
||||
# quit gdb
|
||||
gdb.execute("q")
|
||||
|
||||
# set up event handlers to catch shit
|
||||
gdb.events.stop.connect(crash_handler)
|
||||
gdb.events.exited.connect(exit_handler)
|
||||
|
||||
# run settings setup
|
||||
gdb_execmany("set confirm off", "set pagination off", "set print thread-events off")
|
||||
# run program and exit
|
||||
gdb_execmany("r", "q")
|
@ -1,2 +0,0 @@
|
||||
[logging]
|
||||
level=debug
|
@ -1,5 +0,0 @@
|
||||
#
|
||||
# "suggested" default exit node config
|
||||
#
|
||||
[network]
|
||||
exit-node=exit.loki
|
@ -1,5 +0,0 @@
|
||||
#
|
||||
# persist .loki address in a private key file in the data dir
|
||||
#
|
||||
[network]
|
||||
keyfile=lokinet-addr.privkey
|
@ -1,65 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# helper script for me for when i cross compile
|
||||
# t. jeff
|
||||
#
|
||||
set -e
|
||||
|
||||
die() {
|
||||
echo $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
platform=${PLATFORM:-Linux}
|
||||
root="$(readlink -e $(dirname $0)/../)"
|
||||
cd $root
|
||||
mkdir -p build-cross
|
||||
|
||||
targets=()
|
||||
cmake_extra=()
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
if [ "$1" = "--" ]; then
|
||||
shift
|
||||
cmake_extra=("$@")
|
||||
break
|
||||
fi
|
||||
targets+=("$1")
|
||||
shift
|
||||
done
|
||||
test ${#targets[@]} = 0 && die no targets provided
|
||||
|
||||
archs="${targets[@]}"
|
||||
echo "all: $archs" > build-cross/Makefile
|
||||
for arch in $archs ; do
|
||||
mkdir -p $root/build-cross/build-$arch
|
||||
cd $root/build-cross/build-$arch
|
||||
cmake \
|
||||
-G 'Unix Makefiles' \
|
||||
-DCROSS_PLATFORM=$platform \
|
||||
-DCROSS_PREFIX=$arch \
|
||||
-DCMAKE_EXE_LINKER_FLAGS=-fstack-protector \
|
||||
-DCMAKE_CXX_FLAGS=-fdiagnostics-color=always \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$root/contrib/cross/cross.toolchain.cmake \
|
||||
-DBUILD_STATIC_DEPS=ON \
|
||||
-DSTATIC_LINK=ON \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DBUILD_TESTING=OFF \
|
||||
-DBUILD_LIBLOKINET=OFF \
|
||||
-DWITH_TESTS=OFF \
|
||||
-DNATIVE_BUILD=OFF \
|
||||
-DSTATIC_LINK=ON \
|
||||
-DWITH_SYSTEMD=OFF \
|
||||
-DFORCE_OXENMQ_SUBMODULE=ON \
|
||||
-DSUBMODULE_CHECK=OFF \
|
||||
-DWITH_LTO=OFF \
|
||||
-DWITH_BOOTSTRAP=OFF \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDeb \
|
||||
"${cmake_extra[@]}" \
|
||||
$root
|
||||
cd $root/build-cross
|
||||
echo -ne "$arch:\n\t\$(MAKE) -C build-$arch\n" >> $root/build-cross/Makefile
|
||||
|
||||
done
|
||||
cd $root
|
||||
make -j${JOBS:-$(nproc)} -C build-cross
|
@ -1,6 +0,0 @@
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Android)
|
||||
set(CMAKE_SYSTEM_VERSION ${ANDROID_API}) # API level
|
||||
set(CMAKE_ANDROID_ARCH_ABI ${ANDROID_ARCH_ABI})
|
||||
set(CMAKE_ANDROID_NDK ${ANDROID_NDK})
|
||||
set(CMAKE_ANDROID_STL_TYPE gnustl_static)
|
@ -1,11 +0,0 @@
|
||||
set(CMAKE_SYSTEM_NAME ${CROSS_PLATFORM})
|
||||
set(TOOLCHAIN_PREFIX ${CROSS_PREFIX})
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
set(ARCH_TRIPLET ${TOOLCHAIN_PREFIX})
|
@ -1,15 +0,0 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(TOOLCHAIN_PREFIX i686-w64-mingw32)
|
||||
set(WOW64_CROSS_COMPILE ON)
|
||||
set(CROSS_TARGET i686-w64-mingw32)
|
||||
|
||||
set(TOOLCHAIN_PATHS
|
||||
/usr/${TOOLCHAIN_PREFIX}
|
||||
/usr/local/opt/mingw-w64/toolchain-i686
|
||||
/usr/local/opt/mingw-w64/toolchain-i686/i686-w64-mingw32
|
||||
/opt/mingw32
|
||||
/home/$ENV{USER}/mingw32
|
||||
/home/$ENV{USER}/mingw32/${TOOLCHAIN_PREFIX}
|
||||
)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/mingw_core.cmake")
|
@ -1,16 +0,0 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
|
||||
set(WIN64_CROSS_COMPILE ON)
|
||||
set(CROSS_TARGET x86_64-w64-mingw32)
|
||||
|
||||
set(TOOLCHAIN_PATHS
|
||||
/usr/${TOOLCHAIN_PREFIX}
|
||||
/usr/local/opt/mingw-w64/toolchain-x86_64
|
||||
/usr/local/opt/mingw-w64/toolchain-x86_64/x86_64-w64-mingw32
|
||||
/opt/mingw64
|
||||
/home/$ENV{USER}/mingw32
|
||||
/home/$ENV{USER}/mingw64
|
||||
/home/$ENV{USER}/mingw64/${TOOLCHAIN_PREFIX}
|
||||
/home/$ENV{USER}/mingw32/${TOOLCHAIN_PREFIX})
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/mingw_core.cmake")
|
@ -1,30 +0,0 @@
|
||||
set(CMAKE_SYSTEM_VERSION 6.0)
|
||||
|
||||
# the minimum windows version, set to 6 rn because supporting older windows is hell
|
||||
set(_winver 0x0600)
|
||||
add_definitions(-D_WIN32_WINNT=${_winver})
|
||||
|
||||
# target environment on the build host system
|
||||
# second one is for non-root installs
|
||||
set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_PATHS})
|
||||
|
||||
add_definitions("-DWINNT_CROSS_COMPILE")
|
||||
|
||||
# modify default behavior of FIND_XXX() commands
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
# cross compilers to use
|
||||
if($ENV{COMPILER} MATCHES "clang")
|
||||
set(USING_CLANG ON)
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-clang)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-clang++)
|
||||
else()
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
endif()
|
||||
|
||||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
||||
set(ARCH_TRIPLET ${CROSS_TARGET})
|
Binary file not shown.
@ -1,19 +0,0 @@
|
||||
|
||||
CLANG_FORMAT_DESIRED_VERSION=15
|
||||
|
||||
CLANG_FORMAT=$(command -v clang-format-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null)
|
||||
if [ $? -ne 0 ]; then
|
||||
CLANG_FORMAT=$(command -v clang-format-mp-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null)
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
CLANG_FORMAT=$(command -v clang-format 2>/dev/null)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Please install clang-format version $CLANG_FORMAT_DESIRED_VERSION and re-run this script."
|
||||
exit 1
|
||||
fi
|
||||
version=$(clang-format --version)
|
||||
if [[ ! $version == *"clang-format version $CLANG_FORMAT_DESIRED_VERSION"* ]]; then
|
||||
echo "Please install clang-format version $CLANG_FORMAT_DESIRED_VERSION and re-run this script."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. $(dirname $0)/format-version.sh
|
||||
|
||||
cd "$(dirname $0)/../"
|
||||
|
||||
if [ "$1" = "verify" ] ; then
|
||||
if [ $($CLANG_FORMAT --output-replacements-xml $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|m(m)?)$' | grep -v '#') | grep '</replacement>' | wc -l) -ne 0 ] ; then
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
$CLANG_FORMAT -i $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|m(m)?)$' | grep -v '#') &> /dev/null
|
||||
fi
|
||||
|
||||
swift_format=$(command -v swiftformat 2>/dev/null)
|
||||
if [ $? -eq 0 ]; then
|
||||
if [ "$1" = "verify" ] ; then
|
||||
for f in $(find daemon | grep -E '\.swift$' | grep -v '#') ; do
|
||||
if [ $($swift_format --quiet --dryrun < "$f" | diff "$f" - | wc -l) -ne 0 ] ; then
|
||||
exit 3
|
||||
fi
|
||||
done
|
||||
else
|
||||
$swift_format --quiet $(find daemon | grep -E '\.swift$' | grep -v '#')
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
jsonnet_format=$(command -v jsonnetfmt 2>/dev/null)
|
||||
if [ $? -eq 0 ]; then
|
||||
if [ "$1" = "verify" ]; then
|
||||
if ! $jsonnet_format --test .drone.jsonnet; then
|
||||
exit 4
|
||||
fi
|
||||
else
|
||||
$jsonnet_format --in-place .drone.jsonnet
|
||||
fi
|
||||
fi
|
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# pre-push hook for git
|
||||
# this script is probably overkill for most contributors
|
||||
#
|
||||
# "i use this to prevent foot cannons caused by commiting broken code"
|
||||
#
|
||||
# ~ jeff (lokinet author and crazy person)
|
||||
#
|
||||
#
|
||||
# to use this as a git hook do this in the root of the repo:
|
||||
#
|
||||
# cp contrib/git-hook-pre-push.sh .git/hooks/pre-push
|
||||
#
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname $0)/../.."
|
||||
echo "check format..."
|
||||
./contrib/format.sh verify
|
||||
echo "format is gucci af fam"
|
||||
|
||||
echo "remove old test build directory..."
|
||||
rm -rf build-git-hook
|
||||
mkdir build-git-hook
|
||||
echo "configuring test build jizz..."
|
||||
cmake -S . -B build-git-hook -DWITH_LTO=OFF -DWITH_HIVE=ON -G Ninja
|
||||
echo "ensure this shit compiles..."
|
||||
ninja -C build-git-hook all
|
||||
echo "ensure unit tests aren't fucked..."
|
||||
ninja -C build-git-hook check
|
||||
|
||||
echo "we gud UmU"
|
||||
echo ""
|
@ -1,61 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
|
||||
base32z_dict = 'ybndrfg8ejkmcpqxot1uwisza345h769'
|
||||
base32z_map = {base32z_dict[i]: i for i in range(len(base32z_dict))}
|
||||
|
||||
def lokinet_snode_addr(pk_hex):
|
||||
"""Returns the lokinet snode address from a hex ed25519 pubkey"""
|
||||
assert(len(pk_hex) == 64)
|
||||
bits = 0
|
||||
val = 0
|
||||
result = ''
|
||||
for x in pk_hex:
|
||||
bits += 4
|
||||
val = (val << 4) + int(x, 16)
|
||||
if bits >= 5:
|
||||
bits -= 5
|
||||
v = val >> bits
|
||||
val &= (1 << bits) - 1
|
||||
result += base32z_dict[v]
|
||||
result += base32z_dict[val << (5 - bits)]
|
||||
return result + ".snode"
|
||||
|
||||
|
||||
def hex_from_snode(b32z):
|
||||
"""undoes what the above does; b32z should have '.snode' already stripped off"""
|
||||
assert(len(b32z) == 52)
|
||||
val = 0
|
||||
bits = 0
|
||||
for x in b32z:
|
||||
val = (val << 5) | base32z_map[x] # Arbitrary precision integers FTW
|
||||
|
||||
# `val` is now a 260 bit value (52 * 5 bits per char); but we only use the first bit of the last
|
||||
# value (which is why lokinet addresses always end with y or o)
|
||||
assert(b32z[-1] in 'yo')
|
||||
val >>= 4
|
||||
|
||||
return "{:64x}".format(val)
|
||||
|
||||
|
||||
reverse = False
|
||||
if len(sys.argv) >= 2 and sys.argv[1] == '-r':
|
||||
reverse = True
|
||||
del sys.argv[1]
|
||||
|
||||
if len(sys.argv) < 2 or (
|
||||
any(len(x) not in (52, 58) for x in sys.argv[1:])
|
||||
if reverse else
|
||||
any(len(x) != 64 for x in sys.argv[1:])
|
||||
):
|
||||
print("Usage: {} PUBKEY [PUBKEY ...] -- converts ed25519 pubkeys to .snode addresses".format(sys.argv[0]))
|
||||
print("Usage: {} -r SNODE [SNODE ...] -- converts snode addresses to ed25519 pubkeys".format(sys.argv[0]))
|
||||
sys.exit(1)
|
||||
|
||||
if reverse:
|
||||
for key in sys.argv[1:]:
|
||||
print("{}.snode -> {}".format(key[0:52], hex_from_snode(key[0:52])))
|
||||
else:
|
||||
for key in sys.argv[1:]:
|
||||
print("{} -> {}".format(key, lokinet_snode_addr(key)))
|
@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# .loki secret key generator script
|
||||
# makes keyfile contents
|
||||
#
|
||||
# usage: python3 keygen.py out.private
|
||||
# python3 keygen.py > /some/where/over/the/rainbow
|
||||
#
|
||||
from nacl.bindings import crypto_sign_keypair
|
||||
import sys
|
||||
|
||||
out = sys.stdout
|
||||
|
||||
close_out = lambda : None
|
||||
args = sys.argv[1:]
|
||||
|
||||
if args and args[0] != '-':
|
||||
out = open(args[0], 'wb')
|
||||
close_out = out.close
|
||||
|
||||
pk, sk = crypto_sign_keypair()
|
||||
out.write(b'64:')
|
||||
out.write(sk)
|
||||
out.flush()
|
||||
close_out()
|
||||
|
@ -1,10 +0,0 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(udptest LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
add_executable(udptest udptest.cpp)
|
||||
include_directories(../../include)
|
||||
target_link_libraries(udptest PUBLIC lokinet)
|
||||
|
@ -1,13 +0,0 @@
|
||||
# liblokinet examples
|
||||
|
||||
building:
|
||||
|
||||
$ mkdir -p build
|
||||
$ cd build
|
||||
$ cp /path/to/liblokinet.so .
|
||||
$ cmake .. -DCMAKE_EXE_LINKER_FLAGS='-L.'
|
||||
$ make
|
||||
|
||||
running:
|
||||
|
||||
$ ./udptest /path/to/bootstrap.signed
|
@ -1,239 +0,0 @@
|
||||
#include <lokinet.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
bool _run{true};
|
||||
|
||||
using Lokinet_ptr = std::shared_ptr<lokinet_context>;
|
||||
|
||||
[[nodiscard]] auto
|
||||
MakeLokinet(const std::vector<char>& bootstrap)
|
||||
{
|
||||
auto ctx = std::shared_ptr<lokinet_context>(lokinet_context_new(), lokinet_context_free);
|
||||
if (auto err = lokinet_add_bootstrap_rc(bootstrap.data(), bootstrap.size(), ctx.get()))
|
||||
throw std::runtime_error{strerror(err)};
|
||||
if (lokinet_context_start(ctx.get()))
|
||||
throw std::runtime_error{"could not start context"};
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void
|
||||
WaitForReady(const Lokinet_ptr& ctx)
|
||||
{
|
||||
while (_run and lokinet_wait_for_ready(1000, ctx.get()))
|
||||
{
|
||||
std::cout << "waiting for context..." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
class Flow
|
||||
{
|
||||
lokinet_udp_flowinfo const _info;
|
||||
lokinet_context* const _ctx;
|
||||
|
||||
public:
|
||||
explicit Flow(const lokinet_udp_flowinfo* info, lokinet_context* ctx) : _info{*info}, _ctx{ctx}
|
||||
{}
|
||||
|
||||
lokinet_context*
|
||||
Context() const
|
||||
{
|
||||
return _ctx;
|
||||
}
|
||||
|
||||
std::string
|
||||
String() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << std::string{_info.remote_host} << ":" << std::to_string(_info.remote_port)
|
||||
<< " on socket " << _info.socket_id;
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
struct ConnectJob
|
||||
{
|
||||
lokinet_udp_flowinfo remote;
|
||||
lokinet_context* ctx;
|
||||
};
|
||||
|
||||
void
|
||||
CreateOutboundFlow(void* user, void** flowdata, int* timeout)
|
||||
{
|
||||
auto* job = static_cast<ConnectJob*>(user);
|
||||
Flow* flow = new Flow{&job->remote, job->ctx};
|
||||
*flowdata = flow;
|
||||
*timeout = 30;
|
||||
std::cout << "made outbound flow: " << flow->String() << std::endl;
|
||||
;
|
||||
}
|
||||
|
||||
int
|
||||
ProcessNewInboundFlow(void* user, const lokinet_udp_flowinfo* remote, void** flowdata, int* timeout)
|
||||
{
|
||||
auto* ctx = static_cast<lokinet_context*>(user);
|
||||
Flow* flow = new Flow{remote, ctx};
|
||||
std::cout << "new udp flow: " << flow->String() << std::endl;
|
||||
*flowdata = flow;
|
||||
*timeout = 30;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
DeleteFlow(const lokinet_udp_flowinfo* remote, void* flowdata)
|
||||
{
|
||||
auto* flow = static_cast<Flow*>(flowdata);
|
||||
std::cout << "udp flow from " << flow->String() << " timed out" << std::endl;
|
||||
delete flow;
|
||||
}
|
||||
|
||||
void
|
||||
HandleUDPPacket(const lokinet_udp_flowinfo* remote, const char* pkt, size_t len, void* flowdata)
|
||||
{
|
||||
auto* flow = static_cast<Flow*>(flowdata);
|
||||
std::cout << "we got " << len << " bytes of udp from " << flow->String() << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
BounceUDPPacket(const lokinet_udp_flowinfo* remote, const char* pkt, size_t len, void* flowdata)
|
||||
{
|
||||
auto* flow = static_cast<Flow*>(flowdata);
|
||||
std::cout << "bounce " << len << " bytes of udp from " << flow->String() << std::endl;
|
||||
if (auto err = lokinet_udp_flow_send(remote, pkt, len, flow->Context()))
|
||||
{
|
||||
std::cout << "bounce failed: " << strerror(err) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Lokinet_ptr sender, recip;
|
||||
|
||||
void
|
||||
signal_handler(int)
|
||||
{
|
||||
_run = false;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
if (argc == 1)
|
||||
{
|
||||
std::cout << "usage: " << argv[0] << " bootstrap.signed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
*/
|
||||
|
||||
std::vector<char> bootstrap;
|
||||
|
||||
// load bootstrap.signed
|
||||
{
|
||||
std::ifstream inf{argv[1], std::ifstream::ate | std::ifstream::binary};
|
||||
size_t len = inf.tellg();
|
||||
inf.seekg(0);
|
||||
bootstrap.resize(len);
|
||||
inf.read(bootstrap.data(), bootstrap.size());
|
||||
}
|
||||
|
||||
if (auto* loglevel = getenv("LOKINET_LOG"))
|
||||
lokinet_log_level(loglevel);
|
||||
else
|
||||
lokinet_log_level("none");
|
||||
|
||||
std::cout << "starting up" << std::endl;
|
||||
|
||||
recip = MakeLokinet(bootstrap);
|
||||
WaitForReady(recip);
|
||||
|
||||
lokinet_udp_bind_result recipBindResult{};
|
||||
|
||||
const auto port = 10000;
|
||||
|
||||
if (auto err = lokinet_udp_bind(
|
||||
port,
|
||||
ProcessNewInboundFlow,
|
||||
BounceUDPPacket,
|
||||
DeleteFlow,
|
||||
recip.get(),
|
||||
&recipBindResult,
|
||||
recip.get()))
|
||||
{
|
||||
std::cout << "failed to bind recip udp socket " << strerror(err) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << "bound recip udp" << std::endl;
|
||||
|
||||
sender = MakeLokinet(bootstrap);
|
||||
WaitForReady(sender);
|
||||
|
||||
std::string recipaddr{lokinet_address(recip.get())};
|
||||
|
||||
std::cout << "recip ready at " << recipaddr << std::endl;
|
||||
|
||||
lokinet_udp_bind_result senderBindResult{};
|
||||
|
||||
if (auto err = lokinet_udp_bind(
|
||||
port,
|
||||
ProcessNewInboundFlow,
|
||||
HandleUDPPacket,
|
||||
DeleteFlow,
|
||||
sender.get(),
|
||||
&senderBindResult,
|
||||
sender.get()))
|
||||
{
|
||||
std::cout << "failed to bind sender udp socket " << strerror(err) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConnectJob connect{};
|
||||
connect.remote.socket_id = senderBindResult.socket_id;
|
||||
connect.remote.remote_port = port;
|
||||
std::copy_n(recipaddr.c_str(), recipaddr.size(), connect.remote.remote_host);
|
||||
connect.ctx = sender.get();
|
||||
|
||||
std::cout << "bound sender udp" << std::endl;
|
||||
|
||||
do
|
||||
{
|
||||
std::cout << "try establish to " << connect.remote.remote_host << std::endl;
|
||||
if (auto err =
|
||||
lokinet_udp_establish(CreateOutboundFlow, &connect, &connect.remote, sender.get()))
|
||||
{
|
||||
std::cout << "failed to establish to recip: " << strerror(err) << std::endl;
|
||||
usleep(100000);
|
||||
}
|
||||
else
|
||||
break;
|
||||
} while (true);
|
||||
std::cout << "sender established" << std::endl;
|
||||
|
||||
const std::string buf{"liblokinet"};
|
||||
|
||||
const std::string senderAddr{lokinet_address(sender.get())};
|
||||
|
||||
do
|
||||
{
|
||||
std::cout << senderAddr << " send to remote: " << buf << std::endl;
|
||||
if (auto err = lokinet_udp_flow_send(&connect.remote, buf.data(), buf.size(), sender.get()))
|
||||
{
|
||||
std::cout << "send failed: " << strerror(err) << std::endl;
|
||||
}
|
||||
usleep(100000);
|
||||
} while (_run);
|
||||
return 0;
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- our size/viewbox is positioned such that 0,0 is the center of the image (to simplify scaling and rotation). -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="-512px" y="-512px"
|
||||
viewBox="-512 -512 1024 1024" style="enable-background:new -512 -512 1024 1024;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.bg{fill:#FFFFFF;}
|
||||
</style>
|
||||
|
||||
<!--
|
||||
Draw the background shape in a 2x2 box (from -1 to 1 in each dimension), then scale it up
|
||||
(but not all the way to 512, because we want some padding around the outside.
|
||||
-->
|
||||
<g transform="scale(415)">
|
||||
<path class="bg" d="
|
||||
M 0.5 1
|
||||
H -0.5
|
||||
C -0.81,1 -1,0.81 -1,0.5
|
||||
V -0.5
|
||||
C -1,-0.81 -0.81,-1 -0.5,-1
|
||||
H 0.5
|
||||
C 0.81,-1 1,-0.81 1,-0.5
|
||||
V 0.5
|
||||
C 1,0.81 0.81,1 0.5,1
|
||||
z
|
||||
"/>
|
||||
</g>
|
||||
|
||||
<g id="shape0">
|
||||
<!--
|
||||
Start with a simple 3x2 shape, where each unit we draw corresponds to 1 block edge length in the
|
||||
final diagram, and shift it so that 2.5x2.5 becomes the new origin (around which we will rotate).
|
||||
Then we rotate and scale it to the desired size.
|
||||
|
||||
We can then copy that at 90, 180, 270 degree rotations to complete the logo.
|
||||
-->
|
||||
<g transform="rotate(45) scale(85) translate(-2.5, -2.5)">
|
||||
<polygon points="0,0 2,0 2,1 1,1 1,2 0,2"/>
|
||||
<rect x="1" y="2" width="1" height="1"/>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<use xlink:href="#shape0" transform="rotate(90)"/>
|
||||
<use xlink:href="#shape0" transform="rotate(180)"/>
|
||||
<use xlink:href="#shape0" transform="rotate(270)"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.6 KiB |
@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to invoke resolvconf (if installed) to add/remove lokinet into/from the resolvconf DNS
|
||||
# server list. This script does not add if any of these are true:
|
||||
#
|
||||
# - /sbin/resolvconf does not exist
|
||||
# - the systemd-resolved service is active
|
||||
# - a `no-resolvconf=1` item is present in the [dns] section of lokinet.ini
|
||||
#
|
||||
# It always attempts to remove if resolvconf is installed (so that commenting out while running,
|
||||
# then stopping still removes the added entry).
|
||||
#
|
||||
# Usage: lokinet-resolvconf {add|remove} /etc/loki/lokinet.ini
|
||||
|
||||
set -e
|
||||
|
||||
action="$1"
|
||||
conf="$2"
|
||||
|
||||
if [[ ! ("$action" == "add" || "$action" == "remove") || ! -f "$conf" ]]; then
|
||||
echo "Usage: $0 {add|remove} /path/to/lokinet.ini" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -x /sbin/resolvconf ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -x /bin/systemctl ] && /bin/systemctl --quiet is-active systemd-resolved.service; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$action" == "add" ]; then
|
||||
if ! [ -x /sbin/resolvconf ]; then exit 0; fi
|
||||
|
||||
lokinet_ns=$(perl -e '
|
||||
$ns = "127.3.2.1"; # default if none found in .ini
|
||||
while (<>) {
|
||||
if ((/^\[dns\]/ ... /^\[/)) {
|
||||
if (/^bind\s*=\s*([\d.]+)(?::53)?\s*$/) {
|
||||
$ns=$1;
|
||||
} elsif (/^no-resolvconf\s*=\s*1\s*/) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
print $ns' "$conf")
|
||||
|
||||
if [ -n "$lokinet_ns" ]; then
|
||||
echo "nameserver $lokinet_ns" | /sbin/resolvconf -a lo.000lokinet
|
||||
fi
|
||||
else
|
||||
/sbin/resolvconf -d lo.000lokinet
|
||||
fi
|
@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- our size/viewbox is positioned such that 0,0 is the center of the image (to simplify scaling and rotation). -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="-512px" y="-512px"
|
||||
viewBox="-512 -512 1024 1024" style="enable-background:new -512 -512 1024 1024;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.bg{fill:#FFFFFF;}
|
||||
</style>
|
||||
|
||||
<!--
|
||||
Draw the background shape in a 2x2 box (from -1 to 1 in each dimension), then scale it up
|
||||
(but not all the way to 512, because we want some padding around the outside.
|
||||
-->
|
||||
<g transform="scale(512)">
|
||||
<circle r="1" class="bg"/>
|
||||
</g>
|
||||
|
||||
<g id="shape0">
|
||||
<!--
|
||||
Start with a simple 3x2 shape, where each unit we draw corresponds to 1 block edge length in the
|
||||
final diagram, and shift it so that 2.5x2.5 becomes the new origin (around which we will rotate).
|
||||
Then we rotate and scale it to the desired size.
|
||||
|
||||
We can then copy that at 90, 180, 270 degree rotations to complete the logo.
|
||||
-->
|
||||
<g transform="rotate(45) scale(105) translate(-2.5, -2.5)">
|
||||
<polygon points="0,0 2,0 2,1 1,1 1,2 0,2"/>
|
||||
<rect x="1" y="2" width="1" height="1"/>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<use xlink:href="#shape0" transform="rotate(90)"/>
|
||||
<use xlink:href="#shape0" transform="rotate(180)"/>
|
||||
<use xlink:href="#shape0" transform="rotate(270)"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.4 KiB |
@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if ! [ -f LICENSE ] || ! [ -d llarp ]; then
|
||||
echo "You need to run this as ./contrib/mac.sh from the top-level lokinet project directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p build-mac
|
||||
cd build-mac
|
||||
cmake \
|
||||
-G Ninja \
|
||||
-DBUILD_STATIC_DEPS=ON \
|
||||
-DWITH_TESTS=OFF \
|
||||
-DWITH_BOOTSTRAP=OFF \
|
||||
-DNATIVE_BUILD=OFF \
|
||||
-DWITH_LTO=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DMACOS_SYSTEM_EXTENSION=ON \
|
||||
-DCODESIGN=ON \
|
||||
-DBUILD_PACKAGE=ON \
|
||||
"$@" \
|
||||
..
|
||||
|
||||
echo "cmake build configured in build-mac"
|
@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Build the shit on mac
|
||||
#
|
||||
# You will generally need to add: -DCODESIGN_APP=... to make this work, and (unless you are a
|
||||
# lokinet team member) will need to pay Apple money for your own team ID and arse around with
|
||||
# provisioning profiles. See macos/README.txt.
|
||||
#
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if ! [ -f LICENSE ] || ! [ -d llarp ]; then
|
||||
echo "You need to run this as ./contrib/mac.sh from the top-level lokinet project directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./contrib/mac-configure.sh "$@"
|
||||
|
||||
cd build-mac
|
||||
rm -rf Lokinet\ *
|
||||
ninja -j${JOBS:-1} dmg
|
||||
cd ..
|
||||
|
||||
echo -e "Build complete, your app is here:\n"
|
||||
ls -lad $(pwd)/build-mac/Lokinet\ *
|
||||
echo ""
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 7.3 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 18 KiB |
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Lokinet Network Extension</string>
|
||||
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>org.lokinet.network-extension</string>
|
||||
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.lokinet.network-extension</string>
|
||||
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>SYSX</string>
|
||||
|
||||
<key>CFBundleName</key>
|
||||
<string>org.lokinet.network-extension</string>
|
||||
|
||||
<key>CFBundleVersion</key>
|
||||
<string>@lokinet_VERSION@.@LOKINET_APPLE_BUILD@</string>
|
||||
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>@lokinet_VERSION@</string>
|
||||
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.15</string>
|
||||
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2022 The Oxen Project, licensed under GPLv3-or-later</string>
|
||||
|
||||
<key>NSSystemExtensionUsageDescription</key>
|
||||
<string>Provides Lokinet Network connectivity.</string>
|
||||
|
||||
<key>NetworkExtension</key>
|
||||
<dict>
|
||||
<key>NEMachServiceName</key>
|
||||
<string>SUQ8J2PCT7.org.lokinet.network-extension</string>
|
||||
|
||||
<key>NEProviderClasses</key>
|
||||
<dict>
|
||||
<key>com.apple.networkextension.packet-tunnel</key>
|
||||
<string>LLARPPacketTunnel</string>
|
||||
|
||||
<key>com.apple.networkextension.dns-proxy</key>
|
||||
<string>LLARPDNSProxy</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
Binary file not shown.
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.application-identifier</key>
|
||||
<string>SUQ8J2PCT7.org.lokinet.network-extension</string>
|
||||
|
||||
<key>com.apple.developer.networking.networkextension</key>
|
||||
<array>
|
||||
<string>packet-tunnel-provider</string>
|
||||
<string>dns-proxy</string>
|
||||
</array>
|
||||
|
||||
<key>com.apple.developer.team-identifier</key>
|
||||
<string>SUQ8J2PCT7</string>
|
||||
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
|
||||
<key>com.apple.security.network.server</key>
|
||||
<true/>
|
||||
|
||||
</dict>
|
||||
</plist>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue