From 1c8731a10018e8ba1e6b30411a290ca50fa45d81 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 11 Jun 2020 16:04:50 -0400 Subject: envconfig: Add [constants] section in machine files Machine files already supports `+` operator as an implementation detail, since it's using eval(). Now make it an officially supported feature and add a way to define constants that are used while evaluating an entry value. --- docs/markdown/Machine-files.md | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'docs/markdown/Machine-files.md') diff --git a/docs/markdown/Machine-files.md b/docs/markdown/Machine-files.md index 404c3d2..9011f79 100644 --- a/docs/markdown/Machine-files.md +++ b/docs/markdown/Machine-files.md @@ -8,10 +8,83 @@ environments](Native-environments.md). ## Sections The following sections are allowed: +- constants - binaries - paths - properties +### constants + +*Since 0.55.0* + +String and list concatenation is supported using the `+` operator, joining paths +is supported using the `/` operator. +Entries defined in the `[constants]` section can be used in any other section +(they are always parsed first), entries in any other section can be used only +within that same section and only after it has been defined. + +```ini +[constants] +toolchain = '/toolchain' +common_flags = ['--sysroot=' + toolchain / 'sysroot'] + +[properties] +c_args = common_flags + ['-DSOMETHING'] +cpp_args = c_args + ['-DSOMETHING_ELSE'] + +[binaries] +c = toolchain / 'gcc' +``` + +This can be useful with cross file composition as well. A generic cross file +could be composed with a platform specific file where constants are defined: +```ini +# aarch64.ini +[constants] +arch = 'aarch64-linux-gnu' +``` + +```ini +# cross.ini +[binaries] +c = arch + '-gcc' +cpp = arch + '-g++' +strip = arch + '-strip' +pkgconfig = arch + '-pkg-config' +... +``` + +This can be used as `meson setup --cross-file aarch64.ini --cross-file cross.ini builddir`. + +Note that file composition happens before the parsing of values. The example +below results in `b` being `'HelloWorld'`: +```ini +# file1.ini: +[constants] +a = 'Foo' +b = a + 'World' +``` + +```ini +#file2.ini: +[constants] +a = 'Hello' +``` + +The example below results in an error when file1.ini is included before file2.ini +because `b` would be defined before `a`: +```ini +# file1.ini: +[constants] +b = a + 'World' +``` + +```ini +#file2.ini: +[constants] +a = 'Hello' +``` + ### Binaries The binaries section contains a list of binaries. These can be used -- cgit v1.1 From a6164ca5a81224b7ed672401a47260f498f06e44 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 6 Feb 2020 09:10:01 -0800 Subject: Allow setting project options from cross or native files This allows adding a `[project options]` section to a cross or native file that contains the options defined for a project in it's meson_option.txt file. --- docs/markdown/Machine-files.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'docs/markdown/Machine-files.md') diff --git a/docs/markdown/Machine-files.md b/docs/markdown/Machine-files.md index 9011f79..26af44a 100644 --- a/docs/markdown/Machine-files.md +++ b/docs/markdown/Machine-files.md @@ -12,6 +12,7 @@ The following sections are allowed: - binaries - paths - properties +- project options ### constants @@ -166,6 +167,25 @@ section may contain random key value pairs accessed using the The properties section can contain any variable you like, and is accessed via `meson.get_external_property`, or `meson.get_cross_property`. +### Project specific options + +*New in 0.54.0* + +Being able to set project specific options in a native or cross files can be +done using the `[project options]` section of the specific file (if doing a +cross build the options from the native file will be ignored) + +For setting options in supbprojects use the `:project options` +section instead. + +```ini +[project options] +build-tests = true + +[zlib:project options] +build-tests = false +``` + ## Loading multiple machine files Native files allow layering (cross files can be layered since meson 0.52.0). -- cgit v1.1 From 54fb61627851a0fe765d31955629ff5d7be2d064 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 3 Jun 2020 11:19:36 -0700 Subject: docs/Machine-files: remove duplicate Properties section --- docs/markdown/Machine-files.md | 7 ------- 1 file changed, 7 deletions(-) (limited to 'docs/markdown/Machine-files.md') diff --git a/docs/markdown/Machine-files.md b/docs/markdown/Machine-files.md index 26af44a..ae0219b 100644 --- a/docs/markdown/Machine-files.md +++ b/docs/markdown/Machine-files.md @@ -158,13 +158,6 @@ command line will override any options in the native file. For example, passing In addition to special data that may be specified in cross files, this section may contain random key value pairs accessed using the -`meson.get_external_property()` - -## Properties - -*New for native files in 0.54.0* - -The properties section can contain any variable you like, and is accessed via `meson.get_external_property`, or `meson.get_cross_property`. ### Project specific options -- cgit v1.1 From bbba6a7f365f8b7dc7f2d4c3ce7f3e5f4c05fc5e Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 6 Feb 2020 12:18:10 -0800 Subject: Allow setting built-in options from cross/native files This is like the project options, but for meson builtin options. The only real differences here have to do with the differences between meson builtin options and project options. Some meson options can be set on a per-machine basis (build.pkg_config_path vs pkg_config_path) others can be set on a per-subproject basis, but should inherit the parent setting. --- docs/markdown/Machine-files.md | 56 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'docs/markdown/Machine-files.md') diff --git a/docs/markdown/Machine-files.md b/docs/markdown/Machine-files.md index ae0219b..e3de808 100644 --- a/docs/markdown/Machine-files.md +++ b/docs/markdown/Machine-files.md @@ -13,6 +13,7 @@ The following sections are allowed: - paths - properties - project options +- built-in options ### constants @@ -158,17 +159,23 @@ command line will override any options in the native file. For example, passing In addition to special data that may be specified in cross files, this section may contain random key value pairs accessed using the -`meson.get_external_property`, or `meson.get_cross_property`. +`meson.get_external_property()`, or `meson.get_cross_property()`. + +*Changed in 0.55.0* putting `_args` and `_link_args` in the +properties section has been deprecated, and should be put in the built-in +options section. ### Project specific options -*New in 0.54.0* +*New in 0.55.0* + +Path options are not allowed, those must be set in the `[paths]` section. -Being able to set project specific options in a native or cross files can be +Being able to set project specific options in a cross or native file can be done using the `[project options]` section of the specific file (if doing a cross build the options from the native file will be ignored) -For setting options in supbprojects use the `:project options` +For setting options in subprojects use the `[:project options]` section instead. ```ini @@ -179,6 +186,47 @@ build-tests = true build-tests = false ``` + +### Meson built-in options + +Meson built-in options can be set the same way: + +```ini +[built-in options] +c_std = 'c99' +``` + +You can set some meson built-in options on a per-subproject basis, such as +`default_library` and `werror`. The order of precedence is: +1) Command line +2) Machine file +3) Build system definitions + +```ini +[zlib:built-in options] +default_library = 'static' +werror = false +``` + +Options set on a per-subproject basis will inherit the +option from the parent if the parent has a setting but the subproject +doesn't, even when there is a default set meson language. + +```ini +[built-in options] +default_library = 'static' +``` + +will make subprojects use default_library as static. + +Some options can be set on a per-machine basis (in other words, the value of +the build machine can be different than the host machine in a cross compile). +In these cases the values from both a cross file and a native file are used. + +An incomplete list of options is: +- pkg_config_path +- cmake_prefix_path + ## Loading multiple machine files Native files allow layering (cross files can be layered since meson 0.52.0). -- cgit v1.1 From 1ca17dc853ece6225a46b46330e436d46d74bc4b Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 10 Jun 2020 13:02:30 -0700 Subject: docs/machine-files: Add a section on data types This attempts to clarify the usage of strings and arrays, as well as document the boolean type that has been exposed via the project and built-in options --- docs/markdown/Machine-files.md | 48 +++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'docs/markdown/Machine-files.md') diff --git a/docs/markdown/Machine-files.md b/docs/markdown/Machine-files.md index e3de808..9affdca 100644 --- a/docs/markdown/Machine-files.md +++ b/docs/markdown/Machine-files.md @@ -5,6 +5,37 @@ documentation on the common values used by both, for the specific values of one or the other see the [cross compilation](Cross-compilation.md) and [native environments](Native-environments.md). +## Data Types + +There are four basic data types in a machine file: +- strings +- arrays +- booleans +- integers + +A string is specified single quoted: +```ini +[section] +option1 = 'false' +option2 = '2' +``` + +An array is enclosed in square brackets, and must consist of strings or booleans +```ini +[section] +option = ['value'] +``` + +A boolean must be either `true` or `false`, and unquoted. +```ini +option = false +``` + +An integer must be either an unquoted numeric constant; +```ini +option = 42 +``` + ## Sections The following sections are allowed: @@ -90,14 +121,16 @@ a = 'Hello' ### Binaries The binaries section contains a list of binaries. These can be used -internally by meson, or by the `find_program` function: +internally by meson, or by the `find_program` function. + +These values must be either strings or an array of strings Compilers and linkers are defined here using `` and `_ld`. `_ld` is special because it is compiler specific. For compilers like gcc and clang which are used to invoke the linker this is a value to pass to their "choose the linker" argument (-fuse-ld= in this case). For compilers like MSVC and Clang-Cl, this is the path to a linker for meson to invoke, -such as `link.exe` or `lld-link.exe`. Support for ls is *new in 0.53.0* +such as `link.exe` or `lld-link.exe`. Support for `ld` is *new in 0.53.0* *changed in 0.53.1* the `ld` variable was replaced by `_ld`, because it *regressed a large number of projects. in 0.53.0 the `ld` variable was used @@ -115,8 +148,8 @@ llvm-config = '/usr/lib/llvm8/bin/llvm-config' Cross example: ```ini -c = '/usr/bin/i586-mingw32msvc-gcc' -cpp = '/usr/bin/i586-mingw32msvc-g++' +c = ['ccache', '/usr/bin/i586-mingw32msvc-gcc'] +cpp = ['ccache', '/usr/bin/i586-mingw32msvc-g++'] c_ld = 'gold' cpp_ld = 'gold' ar = '/usr/i586-mingw32msvc/bin/ar' @@ -140,7 +173,7 @@ An incomplete list of internally used programs that can be overridden here is: ### Paths and Directories As of 0.50.0 paths and directories such as libdir can be defined in the native -file in a paths section +and cross files in a paths section. These should be strings ```ini [paths] @@ -186,7 +219,6 @@ build-tests = true build-tests = false ``` - ### Meson built-in options Meson built-in options can be set the same way: @@ -230,9 +262,9 @@ An incomplete list of options is: ## Loading multiple machine files Native files allow layering (cross files can be layered since meson 0.52.0). -More than one native file can be loaded, with values from a previous file being +More than one file can be loaded, with values from a previous file being overridden by the next. The intention of this is not overriding, but to allow -composing native files. This composition is done by passing the command line +composing files. This composition is done by passing the command line argument multiple times: ```console -- cgit v1.1 From 601789cc7ce3692fbefe14047d8b8cc68a3d5160 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 16 Jun 2020 15:23:15 -0700 Subject: machine-files: deprecate the paths section --- docs/markdown/Machine-files.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs/markdown/Machine-files.md') diff --git a/docs/markdown/Machine-files.md b/docs/markdown/Machine-files.md index 9affdca..60c4dd5 100644 --- a/docs/markdown/Machine-files.md +++ b/docs/markdown/Machine-files.md @@ -172,8 +172,10 @@ An incomplete list of internally used programs that can be overridden here is: ### Paths and Directories +*Deprecated in 0.55.0* use the built-in section instead. + As of 0.50.0 paths and directories such as libdir can be defined in the native -and cross files in a paths section. These should be strings +and cross files in a paths section. These should be strings. ```ini [paths] -- cgit v1.1 From 3a4d8dde52a5755901ec97784e9f3d883162873b Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 30 Jul 2020 19:46:36 -0700 Subject: update version from 0.55. to 0.56 --- docs/markdown/Machine-files.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/markdown/Machine-files.md') diff --git a/docs/markdown/Machine-files.md b/docs/markdown/Machine-files.md index 60c4dd5..5ac66a8 100644 --- a/docs/markdown/Machine-files.md +++ b/docs/markdown/Machine-files.md @@ -48,7 +48,7 @@ The following sections are allowed: ### constants -*Since 0.55.0* +*Since 0.56.0* String and list concatenation is supported using the `+` operator, joining paths is supported using the `/` operator. @@ -172,7 +172,7 @@ An incomplete list of internally used programs that can be overridden here is: ### Paths and Directories -*Deprecated in 0.55.0* use the built-in section instead. +*Deprecated in 0.56.0* use the built-in section instead. As of 0.50.0 paths and directories such as libdir can be defined in the native and cross files in a paths section. These should be strings. @@ -196,13 +196,13 @@ In addition to special data that may be specified in cross files, this section may contain random key value pairs accessed using the `meson.get_external_property()`, or `meson.get_cross_property()`. -*Changed in 0.55.0* putting `_args` and `_link_args` in the +*Changed in 0.56.0* putting `_args` and `_link_args` in the properties section has been deprecated, and should be put in the built-in options section. ### Project specific options -*New in 0.55.0* +*New in 0.56.0* Path options are not allowed, those must be set in the `[paths]` section. -- cgit v1.1