From: Kirill Isakov Date: Sat, 28 May 2022 13:13:44 +0000 (+0600) Subject: Make build files compatible with muon X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=9e7b3e5dd0d950790c1cc44be8e4716a7ed2e8f2;p=tinc Make build files compatible with muon --- diff --git a/INSTALL.md b/INSTALL.md index 7f1c6fab..4ba0bffd 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,14 +1,26 @@ # Dependencies +## Required + Before you can start compiling tinc from a fresh git clone, you have to install the very latest versions of the following packages: -- `meson` -- `ninja` +- `meson` or `muon` (read below) +- `ninja` or `samurai` - `pkgconf` or `pkg-config` - `GCC` or `Clang` (any version with C11 support, although older versions might work) - `OpenSSL`\* (1.1.0+) or `LibreSSL` or `libgcrypt` (not needed if legacy protocol is disabled) +### No Python? + +If you're on a constrained system that doesn't have (or cannot run) Python, you can try building tinc with [muon][muon], +which is a pure C reimplementation of the same idea. +Please note that `meson` is considered to be the main way of building tinc, and `muon` is supported on a best-effort basis. + +[muon]: https://git.sr.ht/~lattis/muon + +## Optional + Plus a few optional dependencies. Support for them will be enabled if they're present: - `ncurses` or `PDCurses` diff --git a/VERSION b/VERSION deleted file mode 100644 index c0540cbd..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.1pre18 diff --git a/meson.build b/meson.build index 7354953d..15542198 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('tinc', 'c', - version: run_command([find_program('python3'), 'version.py', 'short'], check: true).stdout(), + version: '1.1pre18', license: 'GPL-2.0-or-later', meson_version: '>=0.51', default_options: [ @@ -36,11 +36,15 @@ os_name = host_machine.system() cpu_family = host_machine.cpu_family() cc_name = cc.get_id() -python = find_program('python3') -if meson_version.version_compare('>=0.55') - python_path = python.full_path() +python = find_program('python3', required: false) +if python.found() + if meson_version.version_compare('>=0.55') + python_path = python.full_path() + else + python_path = python.path() + endif else - python_path = python.path() + python_path = '' endif cc_defs = ['-D_GNU_SOURCE'] @@ -155,16 +159,18 @@ if os_name == 'linux' and not opt_systemd.disabled() subdir('systemd') endif -run_target('reformat', command: [ - python, - '@SOURCE_ROOT@/lint.py', - '--fix', -]) - -run_target('lint', command: [ - python, - '@SOURCE_ROOT@/lint.py', -]) +if python.found() + run_target('reformat', command: [ + python, + '@SOURCE_ROOT@/lint.py', + '--fix', + ]) + + run_target('lint', command: [ + python, + '@SOURCE_ROOT@/lint.py', + ]) +endif if meson_version.version_compare('>=0.53') summary({ diff --git a/src/include/meson.build b/src/include/meson.build index f8e6f0d2..c192f186 100644 --- a/src/include/meson.build +++ b/src/include/meson.build @@ -2,7 +2,6 @@ configure_file(output: 'config.h', configuration: cdata) src_lib_common += vcs_tag( command: [python_path, src_root / 'version.py'], - fallback: 'unknown', input: '../version_git.h.in', output: 'version_git.h', ) diff --git a/test/meson.build b/test/meson.build index 48e66898..60f4eeb0 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,3 +1,6 @@ -subdir('integration') +if python.found() + subdir('integration') +endif + subdir('unit') diff --git a/version.py b/version.py index 3213e327..85f3b713 100755 --- a/version.py +++ b/version.py @@ -1,17 +1,9 @@ #!/usr/bin/env python3 -"""Print current tinc version for using in build scripts. - -First try to determine the latest version using git tags. If this fails (because -the .git directory is missing, git is not installed, or for some other reason), -fall back to using the VERSION file. If it is not present or could not be read, -use 'unknown'. -""" +"""Print current tinc version for using in build scripts.""" from os import path, environ -from sys import argv, stderr import subprocess as subp -import typing as T PREFIX = "release-" SOURCE_ROOT = path.dirname(path.realpath(__file__)) @@ -27,25 +19,6 @@ cmd = [ "--match=" + PREFIX + "*", ] -if "short" in argv: - cmd.append("--abbrev=0") - -version: T.Optional[str] = None - -try: - result = subp.run(cmd, stdout=subp.PIPE, encoding="utf-8", check=False) - if not result.returncode: - version = result.stdout -except FileNotFoundError: - pass - -if not version: - try: - with open(path.join(SOURCE_ROOT, "VERSION"), "r", encoding="utf-8") as f: - version = f.read().strip() - except OSError as e: - print("could not read version from file", e, file=stderr) -elif version.startswith(PREFIX): - version = version[len(PREFIX) :].strip() - -print(version if version else "unknown", end="") +result = subp.run(cmd, stdout=subp.PIPE, encoding="utf-8", check=True) +version = result.stdout.strip().removeprefix("release-") +print(version)