From 76f1988539c477ad3b906f254654929aec04283c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 Nov 2021 10:15:33 +0200 Subject: Add support for dynamic dependencies as byproduct of script body Specifically, the `depdb dyndep` builtin now has the --byproduct option (which must come first). In this mode only the --file input is supported. For example: obje{hello.o}: cxx{hello} {{ o = $path($>) t = $(o).t depdb dyndep --byproduct --what=header --default-type=h --file $t diag c++ ($<[0]) $cxx.path $cxx.poptions $cc.poptions $cc.coptions $cxx.coptions $cxx.mode -o $o -MD -MF $t -c $path($<[0]) }} Naturally, this mode does not support dynamic auto-generated prerequisites. If present, such prerequisites must be specified statically in the buildfile. Note also that the --default-prereq-type option has been rename to --default-type. --- libbuild2/build/script/builtin.cli | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'libbuild2/build/script/builtin.cli') diff --git a/libbuild2/build/script/builtin.cli b/libbuild2/build/script/builtin.cli index 3ed3659..fafb330 100644 --- a/libbuild2/build/script/builtin.cli +++ b/libbuild2/build/script/builtin.cli @@ -15,17 +15,33 @@ namespace build2 { // Pseudo-builtin options. // - class depdb_dep_options + class depdb_dyndep_options { // Note that --byproduct, if any, must be the first option and is // handled ad hoc, kind of as a sub-command. // - path --file; // Read from file rather than stdin. - string --format; // Dependency format: make (default). - string --what; // Dependency kind, e.g., "header". - dir_paths --include-path|-I; // Search paths for generated files. - string --default-prereq-type; // Default prerequisite type to use - // if none could be derived from ext. + // Note that in the future we may extend --cwd support to the non- + // byproduct mode where it will also have the `env --cwd` semantics + // (thus the matching name). Note that it will also be incompatible + // with support for generated files (and thus -I) at least in the make + // format where we use relative paths for non-existent files. + // + // Note on naming: whenever we (may) have two options, one for target + // and the other for prerequisite, we omit "prerequisite" as that's + // what we extract by default and most commonly. For example: + // + // --what --what-target + // --default-type --default-target-type + // + path --file; // Read from file rather than stdin. + string --format; // Dependency format: make (default). + string --what; // Dependency kind, e.g., "header". + dir_paths --include-path|-I; // Search paths for generated files. + string --default-type; // Default prerequisite type to use + // if none could be derived from ext. + dir_path --cwd; // Builtin's working directory used + // to complete relative paths (only + // in --byproduct mode). }; } } -- cgit v1.1