diff options
Diffstat (limited to 'libbuild2/buildfile')
-rw-r--r-- | libbuild2/buildfile | 190 |
1 files changed, 151 insertions, 39 deletions
diff --git a/libbuild2/buildfile b/libbuild2/buildfile index 52252d6..3518d93 100644 --- a/libbuild2/buildfile +++ b/libbuild2/buildfile @@ -4,7 +4,7 @@ # NOTE: remember to update bundled_modules in libbuild2/module.cxx if adding a # new module. # -bundled_modules = bash/ bin/ c/ cc/ cxx/ in/ version/ +bundled_modules = bash/ bin/ c/ cc/ cli/ cxx/ in/ version/ ./: lib{build2} $bundled_modules @@ -59,42 +59,120 @@ lib{build2}: cxx{utility-uninstalled}: for_install = false libul{build2}: config/{hxx ixx txx cxx}{** -host-config -**.test...} \ config/cxx{host-config} +# Derive ~host and ~build2 configurations from current configuration. +# # This will of course blow up spectacularly if we are cross-compiling. But # let's wait and enjoy the fireworks (and get a sense of why someone would # want to cross-compile a build system). # -config/cxx{host-config}: config/in{host-config} +# For the ~host configuration we only want c/cxx/cc and bin that they load. +# For ~build2 we want to keep everything except dist. +# +# We also remove comment lines which could be confused with preprocessor +# directives by some lesser compilers and blank lines between groups of +# options which could cause spurious rebuilds when we filter out entire +# groups. +# +# For ~host also filter out config.bin.lib/config.bin.*.lib (static/shared +# library build/link preferences). In particular, we don't want to force +# config.bin.lib=shared since that will cause static libraries to link shared +# versions of their prerequisites (see mysql-client for a case where this can +# make a difference). +# +# For ~build2 also filter out config.install.chroot -- we definitely don't +# want it carried through. Also filter out variables that control tests +# execution. +# +# Finally, for both ~host and ~build2 we keep config.config.environment +# but strip config.config.hermetic* (we shouldn't be forcing hermiticity +# on the users of ~host/~build2; they can decide for themselves if they +# want it). +# +# The *_no_warnings variants are with the suppressed C/C++ compiler warnings +# (in particular, used for private host configuration in bpkg). +# +# +host_config_lines = [strings] +build2_config_lines = [strings] + +host_config_no_warnings_lines = [strings] +build2_config_no_warnings_lines = [strings] + +for l: $regex.replace_lines( \ + $config.save(), \ + '^( *(#|(config\.(test[. ]|dist\.|install\.chroot|config\.hermetic))).*|)$', \ + [null]) { - # For the ~host configuration we only want c/cxx/cc and bin that they load. - # For ~build2 we want to keep everything except dist. - # - # We also remove comment lines which could be confused with preprocessor - # directives by some lesser compilers and blank lines between groups of - # options which could cause spurious rebuilds when we filter out entire - # groups. - # - # For ~build2 also filter out config.install.chroot -- we definitely don't - # want it carried through. Also filter out variables that control tests - # execution. + # Note: also preserve config.version. # - # Finally, for both ~host and ~build2 we keep config.config.environment - # but strip config.config.hermetic* (we shouldn't be forcing hermiticity - # on the users of ~host/~build2; they can decide for themselves if they - # want it). - # - build2_config = $regex.replace_lines( \ - $config.save(), \ - '^( *(#|(config\.(test[. ]|dist\.|install\.chroot|config\.hermetic))).*|)$', \ - [null], \ - return_lines) + h = [null] + if $regex.match( \ + $l, \ + ' *config\.(c[. ]|cxx[. ]|cc[.]|bin[.]|config.environment |version ).*') + { + if! ($regex.match(\ + $l, \ + ' *config\.bin\.(lib|exe\.lib|liba\.lib|libs\.lib)[ =].*')) + { + # Filter out sanitizer options in ~host. We run the toolchain with + # various sanitizers on CI but sanitizers cause issues in some packages. + # Note that we can have both -fsanitize and -fno-sanitize forms. For + # example: + # + # -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all + # + if $regex.match($l, ' *config\.(c|cxx|cc)\.(coptions|loptions)[ =].*') + { + h = $regex.replace($l, ' ?-f(no-)?sanitize[=-][^ ]+', '') + } + else + h = $l + } + } + + if ($h != [null]) + host_config_lines += $h - # Also preserve config.version. + build2_config_lines += $l + + # Append the warning suppressing option to config.{c,cxx}.coptions rather + # than config.cc.coptions since the former could re-enable them. # - host_config = $regex.replace_lines( \ - $build2_config, \ - '^ *config\.(c[. ]|cxx[. ]|cc[.]|bin[.]|config.environment |version ).*$', \ - '$&', \ - format_no_copy return_lines) + if ($regex.match($l, ' *config\.(c|cxx)\.coptions[ =].*')) + { + # Note that in MSVC overriding one warning option (say /W3) with another + # (say /w) triggers a warning. However, our compile_rule sanitizes the + # command line to resolve such overrides (see msvc_sanitize_cl()). + # + o = ($cxx.class == 'gcc' ? -w : $cxx.class == 'msvc' ? /w : ) + + if ($regex.match($l, '[^=]+= *\[null\] *')) + { + l = $regex.replace($l, '= *\[null\] *$', "= $o") + h = $regex.replace($h, '= *\[null\] *$', "= $o") + } + else + { + l = $regex.replace($l, '=(.*)$', "=\\1 $o") + h = $regex.replace($h, '=(.*)$', "=\\1 $o") + } + } + + if ($h != [null]) + host_config_no_warnings_lines += $h + + build2_config_no_warnings_lines += $l +} + +config/cxx{host-config}: config/in{host-config} +{ + host_config = $regex.merge($host_config_lines, '(.+)', '\1\n') + build2_config = $regex.merge($build2_config_lines, '(.+)', '\1\n') + + host_config_no_warnings = $regex.merge($host_config_no_warnings_lines, \ + '(.+)', '\1\n') + build2_config_no_warnings = $regex.merge($build2_config_no_warnings_lines, \ + '(.+)', '\1\n') } libul{build2}: dist/{hxx ixx txx cxx}{** -**.test...} @@ -169,14 +247,48 @@ if! $cross { {obja objs}{context}: cxx.poptions += \ -DBUILD2_IMPORT_PATH=\"$regex.replace($out_root, '\\', '\\\\')\" +} - # While this object file should only be linked when we are installing, it - # will be compiled even in the uninstalled case. +# Note that while the -installed object file should only be linked when we +# are installing, it will be compiled even in the uninstalled case. +# +if ($install.root != [null]) +{ + # Only if installed. + # + {obja objs}{utility-installed}: cxx.poptions += \ + -DBUILD2_INSTALL_LIB=\"$regex.replace(\ + $install.resolve($install.lib), '\\', '\\\\')\" + + # Only if configured. + # + # Note: strip the last directory component (<project>). # - if ($install.root != [null]) - {obja objs}{utility-installed}: cxx.poptions += \ - -DBUILD2_INSTALL_LIB=\"$regex.replace(\ - $install.resolve($install.lib), '\\', '\\\\')\" + # @@ TMP drop after 0.16.0 release. + # + install_buildfile = ($install.buildfile != [null] \ + ? $directory($install.resolve($install.buildfile)) \ + :) + {obja objs}{utility-installed utility-uninstalled}: cxx.poptions += \ + -DBUILD2_INSTALL_BUILDFILE=\"$regex.replace($install_buildfile, '\\', '\\\\')\" + + #\ + {obja objs}{utility-installed utility-uninstalled}: cxx.poptions += \ + -DBUILD2_INSTALL_BUILDFILE=\"$regex.replace(\ + $directory($install.resolve($install.buildfile)), '\\', '\\\\')\" + #\ + + # Data directory or src_root if not installed. + # + # Note: normalized in both cases. + # + {obja objs}{utility-installed}: cxx.poptions += \ + -DBUILD2_INSTALL_DATA=\"$regex.replace(\ + $install.resolve($install.data), '\\', '\\\\')\" + + {obja objs}{utility-uninstalled}: cxx.poptions += \ + -DBUILD2_INSTALL_DATA=\"$regex.replace(\ + $src_root, '\\', '\\\\')\" } if ($cxx.target.class != 'windows') @@ -304,11 +416,11 @@ else { # No install for the pre-generated case. # - script/hxx{builtin-options}@./ \ - script/ixx{builtin-options}@./: install = false + script/hxx{builtin-options}@script/ \ + script/ixx{builtin-options}@script/: install = false - build/script/hxx{builtin-options}@./ \ - build/script/ixx{builtin-options}@./: install = false + build/script/hxx{builtin-options}@build/script/ \ + build/script/ixx{builtin-options}@build/script/: install = false } # Install into the libbuild2/ subdirectory of, say, /usr/include/ |