aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/install/init.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-04-04 14:10:27 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-04-04 14:10:27 +0200
commit8b9701d2ad76a9a571c445b318557261a4922758 (patch)
tree1de11ba8c7e1d465f4a95005d7115774696a2a87 /libbuild2/install/init.cxx
parent7b06ee81ab0e8a2199c4dce07ec67282c4f52f62 (diff)
Remove global override restriction from config.install.filter
Diffstat (limited to 'libbuild2/install/init.cxx')
-rw-r--r--libbuild2/install/init.cxx167
1 files changed, 81 insertions, 86 deletions
diff --git a/libbuild2/install/init.cxx b/libbuild2/install/init.cxx
index 69f578b..dfd78df 100644
--- a/libbuild2/install/init.cxx
+++ b/libbuild2/install/init.cxx
@@ -421,10 +421,9 @@ namespace build2
using config::lookup_config;
using config::specified_config;
- // Note: ignore config.install.{scope,filter,manifest} (see below).
+ // Note: ignore config.install.{scope,manifest} (see below).
//
- bool s (specified_config (
- rs, "install", {"scope", "filter", "manifest"}));
+ bool s (specified_config (rs, "install", {"scope", "manifest"}));
// Adjust module priority so that the (numerous) config.install.*
// values are saved at the end of config.build.
@@ -461,77 +460,6 @@ namespace build2
config::unsave_variable (rs, v);
}
- // config.install.filter
- //
- // Installation filterting. The value of this variable is a list of
- // key-value pairs that specify the filesystem entries to include or
- // exclude from the installation. For example, the following filters
- // will omit installing headers and static libraries (notice the
- // quoting of the wildcard).
- //
- // !config.install.filter='include/@false "*.a"@false'
- //
- // The key in each pair is a file or directory path or a path wildcard
- // pattern. If a key is relative and contains a directory component or
- // is a directory, then it is treated relative to the corresponding
- // config.install.* location. Otherwise (simple path, normally a
- // pattern), it is matched against the leaf of any path. Note that if
- // an absolute path is specified, it should be without the
- // config.install.chroot prefix.
- //
- // The value in each pair is either true (include) or false (exclude).
- // The filters are evaluated in the order specified and the first
- // match that is found determines the outcome. If no match is found,
- // the default is to include. For a directory, while false means
- // exclude all the sub-paths inside this directory, true does not mean
- // that all the sub-paths will be included wholesale. Rather, the
- // matched component of the sub-path is treated as included with the
- // rest of the components matched against the following
- // sub-filters. For example:
- //
- // !config.install.filter='
- // include/x86_64-linux-gnu/@true
- // include/x86_64-linux-gnu/details/@false
- // include/@false'
- //
- // The true or false value may be followed by comma and the `symlink`
- // modifier to only apply to symlink filesystem entries. For example:
- //
- // !config.install.filter='"*.so"@false,symlink'
- //
- // Note that this mechanism only affects what gets physically copied
- // to the installation directory without affecting what gets built for
- // install or the view of what gets installed at the buildfile level.
- // For example, given the `include/@false *.a@false` filters, static
- // libraries will still be built (unless arranged not to with
- // config.bin.lib) and the pkg-config files will still end up with -I
- // options pointing to the header installation directory. Note also
- // that this mechanism applies to both install and uninstall
- // operations.
- //
- // If you are familiar with the Debian or Fedora packaging, this
- // mechanism is somewhat similar to (and can be used for a similar
- // purpose as) the Debian's .install files and Fedora's %files spec
- // file sections that are used to split the installation into multiple
- // binary packages.
- //
- // Note: can only be specified as a global override.
- //
- {
- auto& v (vp.insert<filters> ("config.install.filter"));
-
- // If specified, verify it is a global override.
- //
- if (lookup l = rs[v])
- {
- if (!l.belongs (rs.global_scope ()))
- fail << "config.install.filter must be a global override" <<
- info << "specify !config.install.filter=...";
- }
-
- config::unsave_variable (rs, v);
- }
-
// config.install.manifest
//
// Installation manifest. Valid values are a file path or `-` to dump
@@ -628,6 +556,27 @@ namespace build2
config::unsave_variable (rs, v);
}
+ // Support for relocatable install.
+ //
+ // Note that it is false by default since supporting relocatable
+ // installation may require extra effort and not all projects may
+ // support it. A project that is known not to support it should assert
+ // this fact in its root.build, for example:
+ //
+ // assert (!$install.relocatable) 'relocatable installation not supported'
+ //
+ {
+ auto& var (vp.insert<bool> ( "install.relocatable"));
+ auto& cvar (vp.insert<bool> ("config.install.relocatable"));
+
+ value& v (rs.assign (var));
+
+ // Note: unlike other variables, for ease of assertion set it to
+ // false if no config.install.* is specified.
+ //
+ v = s && cast_false<bool> (lookup_config (rs, cvar, false));
+ }
+
// Support for private install (aka poor man's Flatpack).
//
const dir_path* p;
@@ -665,25 +614,71 @@ namespace build2
}
}
- // Support for relocatable install.
+ // config.install.filter
//
- // Note that it is false by default since supporting relocatable
- // installation may require extra effort and not all projects may
- // support it. A project that is known not to support it should assert
- // this fact in its root.build, for example:
+ // Installation filterting. The value of this variable is a list of
+ // key-value pairs that specify the filesystem entries to include or
+ // exclude from the installation. For example, the following filters
+ // will omit installing headers and static libraries (notice the
+ // quoting of the wildcard).
//
- // assert (!$install.relocatable) 'relocatable installation not supported'
+ // config.install.filter='include/@false "*.a"@false'
+ //
+ // The key in each pair is a file or directory path or a path wildcard
+ // pattern. If a key is relative and contains a directory component or
+ // is a directory, then it is treated relative to the corresponding
+ // config.install.* location. Otherwise (simple path, normally a
+ // pattern), it is matched against the leaf of any path. Note that if
+ // an absolute path is specified, it should be without the
+ // config.install.chroot prefix.
+ //
+ // The value in each pair is either true (include) or false (exclude).
+ // The filters are evaluated in the order specified and the first
+ // match that is found determines the outcome. If no match is found,
+ // the default is to include. For a directory, while false means
+ // exclude all the sub-paths inside this directory, true does not mean
+ // that all the sub-paths will be included wholesale. Rather, the
+ // matched component of the sub-path is treated as included with the
+ // rest of the components matched against the following
+ // sub-filters. For example:
+ //
+ // config.install.filter='
+ // include/x86_64-linux-gnu/@true
+ // include/x86_64-linux-gnu/details/@false
+ // include/@false'
+ //
+ // The true or false value may be followed by comma and the `symlink`
+ // modifier to only apply to symlink filesystem entries. For example:
+ //
+ // config.install.filter='"*.so"@false,symlink'
+ //
+ // Note that this mechanism only affects what gets physically copied
+ // to the installation directory without affecting what gets built for
+ // install or the view of what gets installed at the buildfile level.
+ // For example, given the `include/@false *.a@false` filters, static
+ // libraries will still be built (unless arranged not to with
+ // config.bin.lib) and the pkg-config files will still end up with -I
+ // options pointing to the header installation directory. Note also
+ // that this mechanism applies to both install and uninstall
+ // operations.
+ //
+ // If you are familiar with the Debian or Fedora packaging, this
+ // mechanism is somewhat similar to (and can be used for a similar
+ // purpose as) the Debian's .install files and Fedora's %files spec
+ // file sections that are used to split the installation into multiple
+ // binary packages.
//
{
- auto& var (vp.insert<bool> ( "install.relocatable"));
- auto& cvar (vp.insert<bool> ("config.install.relocatable"));
+ auto& var (vp.insert<filters> ( "install.filter"));
+ auto& cvar (vp.insert<filters> ("config.install.filter"));
value& v (rs.assign (var));
- // Note: unlike other variables, for ease of assertion set it to
- // false if no config.install.* is specified.
- //
- v = s && cast_false<bool> (lookup_config (rs, cvar, false));
+ if (s)
+ {
+ if (lookup l = lookup_config (rs, cvar, nullptr))
+ v = cast<filters> (l);
+ }
}
// Global config.install.* values.