From 5fe4b752fec9b56da213c38127cab4e70efddc6d Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 11 Feb 2019 20:25:02 +0200 Subject: Add configure script Configure script is not needed when building, it is provided as a convenience tool. Requires python3. --- configure | 64 ++++++++++++++++++++++++++++++++++++++++++ doc/Building/meson.asciidoc | 39 +++++++++++++++++++++++++ doc/Development/meson.asciidoc | 30 -------------------- linux/makepkg/PKGBUILD | 2 ++ 4 files changed, 105 insertions(+), 30 deletions(-) create mode 100755 configure create mode 100644 doc/Building/meson.asciidoc delete mode 100644 doc/Development/meson.asciidoc diff --git a/configure b/configure new file mode 100755 index 0000000..a619ff6 --- /dev/null +++ b/configure @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +import shutil +import os +import subprocess +from colorama import Fore +from colorama import Style + +def concat_options(default, options=[]): + if not options: + return default + r = '' + for option in options: + if option is default: + r += '*' + option + '* ' + else: + r += option + ' ' + return r.strip() + +def prompt(prompt, default, options=[]): + v = input("{} ({}): ".format(prompt, concat_options(default, options))) + if v is not '': + return v + return default + +if __name__ is "__main__": + # build options + build_dir = prompt('build folder', 'build') + build_type = prompt('build type', 'release', ['plain', 'debug', 'debugoptimized', 'release']) + build_prefix = prompt('prefix', '/usr/local') + + build_pie = prompt('position-independent executable', 'true', ['true', 'false']) + build_lto = prompt('link-time optimization', 'true', ['true', 'false']) + + # feature selection + auto_features = prompt('Feature auto state', 'disabled', ['auto', 'enabled', 'disabled']) + f_breakpad = prompt('Use breakpad', 'disabled', ['enabled', 'disabled']) + f_plasma = prompt('Use plasma', 'disabled', ['enabled', 'disabled']) + f_manpage = prompt('make manpage', 'enabled', ['enabled', 'disabled']) + + # compilers + cc = prompt('C compiler', 'gcc') + cpp = prompt('CPP compiler', 'g++') + ld = prompt('Linker', 'gold') + + # clean build folder + if os.path.isdir(build_dir): + shutil.rmtree(build_dir) + os.mkdir(build_dir, 0o700) + + env = { + **os.environ, + 'CC' : cc, + 'CXX' : cpp + } + # configure build dir + subprocess.run(['meson', '--buildtype={}'.format(build_type), '--prefix={}'.format(build_prefix), '--auto-features={}'.format(auto_features), + '-Db_pie={}'.format(build_pie), '-Db_lto={}'.format(build_lto), '-Dcpp_link_args="-fuse-ld={}"'.format(ld), + '-DBreakpad={}'.format(f_breakpad), '-DPlasma={}'.format(f_plasma), '-Dmanpage={}'.format(f_manpage), + build_dir], env=env, check=True) + + print(f"{Style.BRIGHT}Configure step complete{Style.RESET_ALL}") + print("For more configuration options run 'meson configure' in the configured build directory.") + print("You can now build with 'ninja -C {}'.".format(build_dir)) + diff --git a/doc/Building/meson.asciidoc b/doc/Building/meson.asciidoc new file mode 100644 index 0000000..255e0ad --- /dev/null +++ b/doc/Building/meson.asciidoc @@ -0,0 +1,39 @@ +==== Setting compiler +Compiler can only be set when initially configuring the build, and cannot be +changed with --reconfigure: + +[source, sh] +---- +export CXX="ccache clang++" +meson build-path +---- + +==== Setting linker +[source, sh] +---- +build% meson configure -Dcpp_link_args='-fuse_ld=gold' +---- + +==== Listing build options +[source, sh] +---- +build% meson configure +---- + +==== Changing build options +[source, sh] +---- +build% meson configure -D= +# for example: +build% meson configure -DPlasma=enabled +---- + +==== Prevent meson from downloading wraps +During configure, meson can download missing dependencies on its own using +wraps. To disable this, pass '--wrap-mode=nodownload' during the configure +phase: +[source, sh] +---- +repo% meson --wrap-mode=nodownload build-path +---- + diff --git a/doc/Development/meson.asciidoc b/doc/Development/meson.asciidoc deleted file mode 100644 index 1eb08c6..0000000 --- a/doc/Development/meson.asciidoc +++ /dev/null @@ -1,30 +0,0 @@ -==== Setting compiler -Compiler can only be set when initially configuring the build, and cannot be -changed with --reconfigure: - -[source, sh] ----- -export CXX="ccache clang++" -meson build-path ----- - -==== Setting linker -[source, sh] ----- -build% meson configure -Dcpp_link_args='-fuse_ld=gold' ----- - -==== Listing build options -[source, sh] ----- -build% meson configure ----- - -==== Changing build options -[source, sh] ----- -build% meson configure -D= -# for example: -build% meson configure -DPlasma=enabled ----- - diff --git a/linux/makepkg/PKGBUILD b/linux/makepkg/PKGBUILD index 52537d1..8c6bed3 100644 --- a/linux/makepkg/PKGBUILD +++ b/linux/makepkg/PKGBUILD @@ -51,6 +51,8 @@ build() { # For a list of configureable options, check smolbote/meson_options.txt, or # run `meson configure` in $srcdir/build + + # --wrap-mode=nodownload - disable meson from downloading dependency wraps. This will cause it to fail if makedepends are not found by pkg-config or cmake. # --buildtype=plain - meson won't add any flags to the command line # --prefix=... - install prefix # --auto-features=disabled - features should be explicitly enabled -- cgit v1.2.1