diff options
-rw-r--r-- | CODEOWNERS | 6 | ||||
-rw-r--r-- | data/shell-completions/zsh/_meson | 295 | ||||
-rw-r--r-- | docs/markdown/Tutorial.md | 15 | ||||
-rw-r--r-- | mesonbuild/mdist.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/windows.py | 9 | ||||
-rw-r--r-- | test cases/frameworks/1 boost/meson.build | 4 |
6 files changed, 278 insertions, 53 deletions
@@ -2,7 +2,7 @@ /mesonbuild/modules/pkgconfig.py @xclaesse /mesonbuild/modules/cmake.py @mensinda /mesonbuild/modules/unstable_external_project.py @xclaesse -/mesonbuild/ast/* @mensinda -/mesonbuild/cmake/* @mensinda -/mesonbuild/compilers/* @dcbaker +/mesonbuild/ast/ @mensinda +/mesonbuild/cmake/ @mensinda +/mesonbuild/compilers/ @dcbaker /mesonbuild/linkers.py @dcbaker diff --git a/data/shell-completions/zsh/_meson b/data/shell-completions/zsh/_meson index e7fe968..f8946de 100644 --- a/data/shell-completions/zsh/_meson +++ b/data/shell-completions/zsh/_meson @@ -1,4 +1,4 @@ -#compdef meson mesonconf=meson-configure mesontest=meson-test mesonintrospect=meson-introspect +#compdef meson # vim:ts=2 sw=2 @@ -32,13 +32,55 @@ local -i ret local __meson_backends="(ninja xcode ${(j. .)${:-vs{,2010,2015,2017}}})" local __meson_build_types="(plain debug debugoptimized minsize release)" local __meson_wrap_modes="(WrapMode.{default,nofallback,nodownload,forcefallback})" +local __meson_dist_formats=("xztar" "gztar" "zip") +local __meson_cd='-C[change into this directory before running]:target dir:_directories' +local -a __meson_common=( + '--prefix=[installation prefix]: :_directories' + '--bindir=[executable directory]: :_directories' + '--datadir=[data file directory]: :_directories' + '--includedir=[header file directory]: :_directories' + '--infodir=[info page directory]: :_directories' + '--libdir=[library directory]: :_directories' + '--libexecdir=[library executable directory]: :_directories' + '--localedir=[locale data directory]: :_directories' + '--localstatedir=[local state data directory]: :_directories' + '--mandir=[manual page directory]: :_directories' + '--sbindir=[system executable directory]: :_directories' + '--sharedstatedir=[arch-independent data directory]: :_directories' + '--sysconfdir=[system configuration directory]: :_directories' + '--auto-features=[default value for auto features]:auto features types:(auto disabled enabled)' + '--backend=[backend to use]:Meson backend:'"$__meson_backends" + '--buildtype=[build type to use]:Meson build type:'"$__meson_build_types" + '--debug[turn on building with debug]' + '--default-library=[default library type]:default library type:(shared static both)' + '--errorlogs[prints the logs from failing tests]' + '--install-umask=[default umask for permissions of all installed files]' + '--layout=[build directory layout]:build directory layout:(flat mirror)' + '--optimization=[optimization level for compiled targets]:optimization:(0 g 1 2 3 s)' + '--stdsplit=[split stdout and stderr in test logs]' + '--strip[strip targets on install]' + '--unity=[unity builds on/off]:whether to do unity builds:(on off subprojects)' + '--warnlevel=[compiler warning level]:compiler warning level:warning level:(1 2 3)' + '--werror[treat warnings as errors]' + '--wrap-mode=[special wrap mode]:wrap mode:'"$__meson_wrap_modes" + '--force-fallback-for=[force fallback for listed subprojects]' + '--pkg-config-path=[extra paths for HOST pkg-config to search]:paths:_dir_list -s ,' + '--build.pkg-config-path=[extra paths for BUILD pkg-config to search]:paths:_dir_list -s ,' + '--cmake-prefix-path=[extra prefixes for HOST cmake to search]:paths:_dir_list -s ,' + '--build.cmake-prefix-path=[extra prefix for BUILD cmake to search]:paths:_dir_list -s ,' +) local -a meson_commands=( -'setup:set up a build directory' 'configure:configure a project' -'test:run tests' +'dist:generate release archive' +'init:create a new project' +'install:install one more more targets' 'introspect:query project properties' +'setup:set up a build directory' +'test:run tests' 'wrap:manage source dependencies' +'subprojects:manage subprojects' +'compile:Build the project' ) (( $+functions[__meson_is_build_dir] )) || __meson_is_build_dir() { @@ -68,6 +110,21 @@ local -a meson_commands=( fi } +(( $+functions[__meson_wrap_names] )) || __meson_wrap_names() { + local rwraps + rwraps="$(_call_program meson meson wrap list)" + local -a wraps=(${(@f)rwraps}) + _describe -t wraps "Meson wraps" wraps +} + +(( $+functions[__meson_installed_wraps] )) || __meson_installed_wraps() { + local rwraps + if rwraps="$(ls subprojects/ | grep '\.wrap$' | cut -d . -f 1)"; then + local -a wraps=(${(@f)rwraps}) + _describe -t wraps "Meson wraps" wraps + fi +} + (( $+functions[_meson_commands] )) || _meson_commands() { _describe -t commands "Meson subcommands" meson_commands } @@ -89,49 +146,30 @@ local -a meson_commands=( _arguments \ '*-D-[set the value of a build option]:build option:__meson_build_options' \ - '--prefix=[installation prefix]: :_directories' \ - '--libdir=[library directory]: :_directories' \ - '--libexecdir=[library executable directory]: :_directories' \ - '--bindir=[executable directory]: :_directories' \ - '--sbindir=[system executable directory]: :_directories' \ - '--includedir=[header file directory]: :_directories' \ - '--datadir=[data file directory]: :_directories' \ - '--mandir=[manual page directory]: :_directories' \ - '--infodir=[info page directory]: :_directories' \ - '--localedir=[locale data directory]: :_directories' \ - '--sysconfdir=[system configuration directory]: :_directories' \ - '--localstatedir=[local state data directory]: :_directories' \ - '--sharedstatedir=[arch-independent data directory]: :_directories' \ - '--backend=[backend to use]:Meson backend:'"$__meson_backends" \ - '--buildtype=[build type to use]:Meson build type:'"$__meson_build_types" \ - '--strip[strip targets on install]' \ - '--unity=[unity builds on/off]:whether to do unity builds:(on off subprojects)' \ - '--werror[treat warnings as errors]' \ - '--layout=[build directory layout]:build directory layout:(flat mirror)' \ - '--default-library=[default library type]:default library type:(shared static)' \ - '--warnlevel=[compiler warning level]:compiler warning level:warning level:(1 2 3)' \ - '--stdsplit=[split stdout and stderr in test logs]' \ - '--errorlogs=[prints the logs from failing tests]' \ '--cross-file=[cross-compilation environment description]:cross file:_files' \ '--native-file=[build machine compilation environment description]:native file:_files' \ - '--wrap-mode=[special wrap mode]:wrap mode:'"$__meson_wrap_modes" \ + '--clearcache[clear cached state]' \ + '--fatal-meson-warnings=[exit when any meson warnings are encountered]' \ + '(-v --version)'{'-v','--version'}'[print the meson version and exit]' \ + '--reconfigure=[re-run build configuration]' \ + '--wipe=[delete saved state and restart using saved command line options]' \ ":$firstd directory:_directories" \ "::$secondd directory:_directories" \ - # + "${(@)__meson_common}" } (( $+functions[_meson-configure] )) || _meson-configure() { local curcontext="$curcontext" # TODO: implement 'mesonconf @file' local -a specs=( - '--clearcache[clear cached state]' '*-D-[set the value of a build option]:build option:__meson_build_options' '::build directory:_directories' ) _arguments \ '(: -)'{'--help','-h'}'[show a help message and quit]' \ - "${(@)specs}" + "${(@)specs}" \ + "${(@)__meson_common}" } (( $+functions[_meson-test] )) || _meson-test() { @@ -139,22 +177,23 @@ local -a meson_commands=( # TODO: complete test suites local -a specs=( - '(--quiet -q)'{'--quiet','-q'}'[produce less output to the terminal]' - '(--verbose -v)'{'--verbose','-v'}'[do not redirect stdout and stderr]' - '(--timeout-multiplier -t)'{'--timeout-multiplier','-t'}'[a multiplier for test timeouts]:Python floating-point number: ' - '-C[directory to cd into]: :_directories' '--repeat[number of times to run the tests]:number of times to repeat: ' '--no-rebuild[do not rebuild before running tests]' '--gdb[run tests under gdb]' + '--gdb-path=[program to run for gdb (can be wrapper or compaitble program)]:program:_path_commands' '--list[list available tests]' '(--wrapper --wrap)'{'--wrapper=','--wrap='}'[wrapper to run tests with]:wrapper program:_path_commands' - '(--no-suite)--suite[only run tests from this suite]:test suite: ' + "$__meson_cd" '(--suite)--no-suite[do not run tests from this suite]:test suite: ' + '(--no-suite)--suite[only run tests from this suite]:test suite: ' '--no-stdsplit[do not split stderr and stdout in logs]' '--print-errorlogs[print logs for failing tests]' '--benchmark[run benchmarks instead of tests]' '--logbase[base name for log file]:filename: ' '--num-processes[how many threads to use]:number of processes: ' + '(--verbose -v)'{'--verbose','-v'}'[do not redirect stdout and stderr]' + '(--quiet -q)'{'--quiet','-q'}'[produce less output to the terminal]' + '(--timeout-multiplier -t)'{'--timeout-multiplier','-t'}'[a multiplier for test timeouts]:Python floating-point number: ' '--setup[which test setup to use]:test setup: ' '--test-args[arguments to pass to the tests]: : ' '*:Meson tests:__meson_test_names' @@ -165,17 +204,32 @@ local -a meson_commands=( "${(@)specs}" } +(( $+functions[_meson-install] )) || _meson-install() { + local curcontext="$curcontext" + local -a specs=( + "$__meson_cd" + '--no-rebuild[Do not rebuild before installing]' + '--only-changed[Do not overwrite files that are older than the copied file]' + '--quiet[Do not print every fiel that was installed]' + ) +_arguments \ + '(: -)'{'--help','-h'}'[show a help message and quit]' \ + "${(@)specs}" +} + (( $+functions[_meson-introspect] )) || _meson-introspect() { local curcontext="$curcontext" local -a specs=( - '--targets[list top level targets]' - '--installed[list all installed files and directories]' - '--buildsystem-files[list files that belong to the build system]' - '--buildoptions[list all build options]' - '--tests[list all unit tests]' + '--ast[dump the ASK of the meson file]' '--benchmarks[list all benchmarks]' + '--buildoptions[list all build options]' + '--buildsystem-files[list files that belong to the build system]' '--dependencies[list external dependencies]' + '--installed[list all installed files and directories]' '--projectinfo[show project information]' + '--targets[list top level targets]' + '--tests[list all unit tests]' + '--backend=[backend to use]:Meson backend:'"$__meson_backends" '::build directory:_directories' ) _arguments \ @@ -183,8 +237,167 @@ _arguments \ "${(@)specs}" } +(( $+functions[_meson-init] )) || _meson-init() { + local curcontext="$curcontext" + local -a specs=( + "$__meson_cd" + '(-n --name)'{'-n','--name'}'=[the name of the project (defaults to directory name)]' + '(-e --executable)'{'-e','--executable'}'=[the name of the executable target to create (defaults to project name)]' + '(-d --deps)'{'-d','--deps'}'=[comma seperated list of dependencies]' + '(-l --language)'{'-l','--language'}'=[comma seperated list of languages (autodetected based on sources if unset)]:languages:_values , (c cpp cs cuda d fortran java objc objcpp rust)' + '(-b --build)'{'-b','--build'}'[build the project immediately after generation]' + '--builddir=[directory for building]:directory:_directories' + '(-f --force)'{'-f','--force'}'[overwrite any existing files and directories]' + '(-t --type)'{'-t','--type'}'=[project type, defaults to executable]:type:(executable library)' + '(-v --version)'{'-v','--version'}'[print the meson version and exit]' + ) +_arguments \ + '(: -)'{'--help','-h'}'[show a help message and quit]' \ + "${(@)specs}" +} + (( $+functions[_meson-wrap] )) || _meson-wrap() { - # TODO + local -a commands=( + 'list:list all available wraps' + 'search:search the db by name' + 'install:install the specified project' + 'update:Update a project to its newest available version' + 'info:Show info about a wrap' + 'status:Show the status of your subprojects' + ) + + if (( CURRENT == 2 )); then + _describe -t commands "Meson wrap subcommands" commands + else + local curcontext="$curcontext" + cmd="${${commands[(r)$words[2]:*]%%:*}}" + if (( $#cmd )); then + if [[ $cmd == status ]]; then + _message "no options" + elif [[ $cmd == "list" ]]; then + _arguments '*:meson wraps' + elif [[ $cmd == "search" ]]; then + _arguments '*:meson wraps' + elif [[ $cmd == "install" ]]; then + _arguments '*:meson wraps:__meson_wrap_names' + elif [[ $cmd == "update" ]]; then + _arguments '*:meson wraps:__meson_installed_wraps' + elif [[ $cmd == "info" ]]; then + _arguments '*:meson wraps:__meson_wrap_name' + elif [[ $cmd == "status" ]]; then + _arguments '*:' + elif [[ $cmd == "promote" ]]; then + # TODO: how do you figure out what wraps are provided by subprojects if + # they haven't been fetched yet? + _arguments '*:' + fi + else + _message "unknown meson wrap command: $words[2]" + fi + fi + +} + +(( $+functions[_meson-dist] )) || _meson-dist() { + local curcontext="$curcontext" + local -a specs=( + '--formats=[comma seperated list of archive types to create]:archive formats:_values -s , format '"$__meson_dist_formats" + '--include-subprojects[Include source code of subprojects that have been used for the build]' + '--no-tests[Do not build and test generated packages]' + "$__meson_cd" + ) +_arguments \ + '(: -)'{'--help','-h'}'[show a help message and quit]' \ + "${(@)specs}" +} + +(( $+functions[_meson-subprojects-update] )) || _meson-subprojects-update() { + local curcontext="$curcontext" + local -a specs=( + "--rebase[rebase your branch on top of wrap's revision (git only)]" + '--sourcedir=[path to source directory]:_directories' + '*:subprojects:__meson_installed_wraps' + ) +_arguments \ + '(: -)'{'--help','-h'}'[show a help message and quit]' \ + "${(@)specs}" +} + +(( $+functions[_meson-subprojects-checkout] )) || _meson-subprojects-checkout() { + local curcontext="$curcontext" + local -a specs=( + '-b[create a new branch]' + '--sourcedir=[path to source directory]:_directories' + # FIXME: this doesn't work exactly right, but I can't figure it out + ':branch name' + '*:subprojects:__meson_installed_wraps' + ) +_arguments \ + '(: -)'{'--help','-h'}'[show a help message and quit]' \ + "${(@)specs}" +} + +(( $+functions[_meson-subprojects-download] )) || _meson-subprojects-download() { + local curcontext="$curcontext" + local -a specs=( + '--sourcedir=[path to source directory]:_directories' + ) +_arguments \ + '(: -)'{'--help','-h'}'[show a help message and quit]' \ + "${(@)specs}" +} + +(( $+functions[_meson-subprojects-foreach] )) || _meson-subprojects-foreach() { + local curcontext="$curcontext" + local -a specs=( + '--sourcedir=[path to source directory]:_directories' + '*:command:_command_names -e' + ) +_arguments \ + '(: -)'{'--help','-h'}'[show a help message and quit]' \ + "${(@)specs}" +} + +(( $+functions[_meson-subprojects] )) || _meson-subprojects() { + local -a commands=( + 'update:update all subprojects from wrap files' + 'checkout:checkout a branch (git only)' + 'download:ensure subprojects are fetched, even if not in use. Already downloaded subprojects are not modified.' + 'foreach:execute a command in each subproject directory' + ) + + if (( CURRENT == 2 )); then + _describe -t commands "Meson subproject subcommands" commands + else + local curcontext="$curcontext" + cmd="${${commands[(r)$words[2]:*]%%:*}}" + if (( $#cmd )); then + if [[ $cmd == status ]]; then + _message "no options" + else + _meson-subprojects-$cmd + fi + else + _message "unknown meson subproject command: $words[2]" + fi + fi + +} + +(( $+functions[_meson-compile] )) || _meson-compile() { + local curcontext="$curcontext" + local -a specs=( + "$__meson_cd" + '--clean[Clean the build directory]' + '(-j --jobs)'{'-j','--jobs'}'=[the number fo work jobs to run (if supported)]:_guard "[0-9]#" "number of jobs"' + '(-l --load-averate)'{'-l','--load-average'}'=[the system load average to try to maintain (if supported)]:_guard "[0-9]#" "load average"' + '(-v --verbose)'{'-v','--verbose'}'[Show more output]' + '--ninja-args=[Arguments to pass to ninja (only when using ninja)]' + '--vs-args=[Arguments to pass to vs (only when using msbuild)]' + ) +_arguments \ + '(: -)'{'--help','-h'}'[show a help message and quit]' \ + "${(@)specs}" } if [[ $service != meson ]]; then diff --git a/docs/markdown/Tutorial.md b/docs/markdown/Tutorial.md index f108c0c..bf337ba 100644 --- a/docs/markdown/Tutorial.md +++ b/docs/markdown/Tutorial.md @@ -75,12 +75,23 @@ When Meson is run it prints the following output. Now we are ready to build our code. + +```console +$ cd builddir +$ ninja ``` + +If your Meson version is newer than 0.55.0, you can use the new +backend-agnostic build command: + +```console $ cd builddir $ meson compile ``` -Once that is done we can run the resulting binary. +For the rest of this document we are going to use the latter form. + +Once the executable is built we can run it. ```console $ ./demo @@ -135,7 +146,7 @@ need to recreate our build directory, run any sort of magical commands or the like. Instead we just type the exact same command as if we were rebuilding our code without any build system changes. -``` +```console $ meson compile ``` diff --git a/mesonbuild/mdist.py b/mesonbuild/mdist.py index fbda240..6985ca9 100644 --- a/mesonbuild/mdist.py +++ b/mesonbuild/mdist.py @@ -35,7 +35,7 @@ archive_extension = {'gztar': '.tar.gz', def add_arguments(parser): parser.add_argument('-C', default='.', dest='wd', help='directory to cd into before running') - parser.add_argument('--formats', default='xztar', + parser.add_argument('--formats', default='xztar', choices=archive_choices, help='Comma separated list of archive types to create.') parser.add_argument('--include-subprojects', action='store_true', help='Include source code of subprojects that have been used for the build.') diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py index 6050705..a5faa32 100644 --- a/mesonbuild/modules/windows.py +++ b/mesonbuild/modules/windows.py @@ -119,22 +119,23 @@ class WindowsModule(ExtensionModule): src = unholder(src) if isinstance(src, str): - name_format = 'file {!r}' + name_formatted = src name = os.path.join(state.subdir, src) elif isinstance(src, mesonlib.File): - name_format = 'file {!r}' + name_formatted = src.fname name = src.relative_name() elif isinstance(src, build.CustomTarget): if len(src.get_outputs()) > 1: raise MesonException('windows.compile_resources does not accept custom targets with more than 1 output.') - name_format = 'target {!r}' + name_formatted = src.get_filename() name = src.get_id() else: raise MesonException('Unexpected source type {!r}. windows.compile_resources accepts only strings, files, custom targets, and lists thereof.'.format(src)) # Path separators are not allowed in target names name = name.replace('/', '_').replace('\\', '_') + name_formatted = name_formatted.replace('/', '_').replace('\\', '_') res_kwargs = { 'output': name + '_@BASENAME@.' + suffix, @@ -149,7 +150,7 @@ class WindowsModule(ExtensionModule): res_kwargs['depfile'] = res_kwargs['output'] + '.d' res_kwargs['command'] += ['--preprocessor-arg=-MD', '--preprocessor-arg=-MQ@OUTPUT@', '--preprocessor-arg=-MF@DEPFILE@'] - res_targets.append(build.CustomTarget('Windows resource for ' + name_format.format(name), state.subdir, state.subproject, res_kwargs)) + res_targets.append(build.CustomTarget(name_formatted, state.subdir, state.subproject, res_kwargs)) add_target(args) diff --git a/test cases/frameworks/1 boost/meson.build b/test cases/frameworks/1 boost/meson.build index 5a2e1a1..83570f0 100644 --- a/test cases/frameworks/1 boost/meson.build +++ b/test cases/frameworks/1 boost/meson.build @@ -51,8 +51,8 @@ extralibexe = executable('extralibexe', 'extralib.cpp', dependencies : extralibd python2module = shared_library('python2_module', ['python_module.cpp'], dependencies: [python2dep, bpython2dep], name_prefix: '', cpp_args: ['-DMOD_NAME=python2_module']) python3module = shared_library('python3_module', ['python_module.cpp'], dependencies: [python3dep, bpython3dep], name_prefix: '', cpp_args: ['-DMOD_NAME=python3_module']) -test('Boost linktest', linkexe) -test('Boost UTF test', unitexe) +test('Boost linktest', linkexe, timeout: 60) +test('Boost UTF test', unitexe, timeout: 60) test('Boost nomod', nomodexe) if host_machine.system() != 'darwin' or s # Segfaults on macOS with dynamic linking since Boost 1.73 |