From 5bc0f0f9214e14f34c5743f9881f5d8f1104dcd9 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Thu, 18 Jul 2024 17:44:10 +0100 Subject: [PATCH 01/36] Remove enable_modules build config variable, use cxx.features.modules to directly control modular build toggle. --- fmt/build/root.build | 3 --- fmt/fmt/buildfile | 13 ++++++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fmt/build/root.build b/fmt/build/root.build index 6645442..811e4e3 100644 --- a/fmt/build/root.build +++ b/fmt/build/root.build @@ -14,6 +14,3 @@ test.target = $cxx.target ############################## # Project-specific options: -# Set to true to build and provide the `fmt` C++ module. -config [bool] config.fmt.enable_modules ?= $cxx.features.modules # $($cxx.features.modules == true) - diff --git a/fmt/fmt/buildfile b/fmt/fmt/buildfile index 9f07692..48b7fd9 100644 --- a/fmt/fmt/buildfile +++ b/fmt/fmt/buildfile @@ -6,14 +6,17 @@ imp_libs = # Implementation dependencies. lib{fmt}: include/hxx{**} hxx{version} $imp_libs $int_libs -lib{fmt}: src/mxx{fmt} : include = ($config.fmt.enable_modules) # `fmt` C++ module only -lib{fmt}: src/cxx{** -fmt} : include = (!$config.fmt.enable_modules) # no modules only +# Automatically build as module if the feature is enabled +build_fmt_module = $cxx.features.modules + +lib{fmt}: src/mxx{fmt} : include = ($build_fmt_module) # `fmt` C++ module only +lib{fmt}: src/cxx{** -fmt} : include = (!$build_fmt_module) # no modules only # Meta data for users lib{fmt}: { export.metadata = 1 fmt - fmt.is_module = [bool] $config.fmt.enable_modules + fmt.is_module = [bool] $build_fmt_module } # Include the generated version header into the distribution (so that we don't @@ -33,8 +36,8 @@ hxx{version} : in{version} $src_root/manifest cxx.poptions =+ "-I$src_base/include" "-I$out_root" "-I$src_root" objs{*}: cxx.poptions += -DFMT_LIB_EXPORT -if($config.fmt.enable_modules) - cxx.poptions =+ -DFMT_MODULE=ON +if($build_fmt_module) + cxx.poptions =+ -DFMT_MODULE # Export options. # From a836c699236a9dd13d5ad61a8691a66f5ddda559 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Thu, 18 Jul 2024 17:45:04 +0100 Subject: [PATCH 02/36] Include bmis target type when setting export poptions --- fmt/fmt/buildfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmt/fmt/buildfile b/fmt/fmt/buildfile index 48b7fd9..b1e2342 100644 --- a/fmt/fmt/buildfile +++ b/fmt/fmt/buildfile @@ -34,7 +34,7 @@ hxx{version} : in{version} $src_root/manifest # Build options. # cxx.poptions =+ "-I$src_base/include" "-I$out_root" "-I$src_root" -objs{*}: cxx.poptions += -DFMT_LIB_EXPORT +{objs bmis}{*}: cxx.poptions += -DFMT_LIB_EXPORT if($build_fmt_module) cxx.poptions =+ -DFMT_MODULE From 1f146228b7afdfe6029fdaceb58cec30b9a9e79c Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Thu, 18 Jul 2024 18:30:06 +0100 Subject: [PATCH 03/36] Automatically enable FMT_ATTACH_TO_GLOBAL_MODULE when building as module, to permit #include usage. --- fmt/fmt/buildfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fmt/fmt/buildfile b/fmt/fmt/buildfile index b1e2342..b967826 100644 --- a/fmt/fmt/buildfile +++ b/fmt/fmt/buildfile @@ -36,8 +36,9 @@ hxx{version} : in{version} $src_root/manifest cxx.poptions =+ "-I$src_base/include" "-I$out_root" "-I$src_root" {objs bmis}{*}: cxx.poptions += -DFMT_LIB_EXPORT +# If building fmt module, also enable attaching to the global module in order to allow concurrent #include and import. if($build_fmt_module) - cxx.poptions =+ -DFMT_MODULE + cxx.poptions =+ -DFMT_MODULE -DFMT_ATTACH_TO_GLOBAL_MODULE # Export options. # From f808761fe44498263823ed3a405cec43a72310db Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Thu, 18 Jul 2024 18:41:09 +0100 Subject: [PATCH 04/36] Replace import std; in smoke tests with #includes, pending implementing handling of std module (build2 complains if building package with clang on Windows). --- fmt/tests/basics/driver-modules.cxx | 5 ++++- fmt/tests/basics/driver.cxx | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fmt/tests/basics/driver-modules.cxx b/fmt/tests/basics/driver-modules.cxx index 15483c3..6cdf1f5 100644 --- a/fmt/tests/basics/driver-modules.cxx +++ b/fmt/tests/basics/driver-modules.cxx @@ -1,6 +1,9 @@ #include -import std; +#include +#include +#include + import fmt; #include "tests.inl" diff --git a/fmt/tests/basics/driver.cxx b/fmt/tests/basics/driver.cxx index 88f1830..cff192d 100644 --- a/fmt/tests/basics/driver.cxx +++ b/fmt/tests/basics/driver.cxx @@ -1,4 +1,5 @@ #include +#include #include #include From 07571589b95fc2d3eb0e2384e2dadbdb9c3734f9 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 22 Jul 2024 17:35:31 +0100 Subject: [PATCH 05/36] Add package configuration variable to toggle use of import std. --- fmt/build/root.build | 1 + fmt/fmt/buildfile | 2 ++ 2 files changed, 3 insertions(+) diff --git a/fmt/build/root.build b/fmt/build/root.build index 811e4e3..6cb1c15 100644 --- a/fmt/build/root.build +++ b/fmt/build/root.build @@ -14,3 +14,4 @@ test.target = $cxx.target ############################## # Project-specific options: +config [bool] config.fmt.enable_import_std ?= false diff --git a/fmt/fmt/buildfile b/fmt/fmt/buildfile index b967826..3f5d042 100644 --- a/fmt/fmt/buildfile +++ b/fmt/fmt/buildfile @@ -39,6 +39,8 @@ cxx.poptions =+ "-I$src_base/include" "-I$out_root" "-I$src_root" # If building fmt module, also enable attaching to the global module in order to allow concurrent #include and import. if($build_fmt_module) cxx.poptions =+ -DFMT_MODULE -DFMT_ATTACH_TO_GLOBAL_MODULE + if($config.fmt.enable_import_std) + cxx.poptions =+ -DFMT_IMPORT_STD # Export options. # From a9ee48b20b5066150bd58eea4725a159eb1e7938 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 22 Jul 2024 19:40:32 +0100 Subject: [PATCH 06/36] Add config option for a modules-only mode. --- fmt/build/root.build | 1 + fmt/fmt/buildfile | 24 ++++++++++++++++-------- fmt/tests/basics/buildfile | 13 +++++++++---- fmt/tests/basics/driver-modules.cxx | 7 +++++-- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/fmt/build/root.build b/fmt/build/root.build index 6cb1c15..499fa36 100644 --- a/fmt/build/root.build +++ b/fmt/build/root.build @@ -15,3 +15,4 @@ test.target = $cxx.target # Project-specific options: config [bool] config.fmt.enable_import_std ?= false +config [bool] config.fmt.modules_only ?= false diff --git a/fmt/fmt/buildfile b/fmt/fmt/buildfile index 3f5d042..5f179c5 100644 --- a/fmt/fmt/buildfile +++ b/fmt/fmt/buildfile @@ -8,6 +8,10 @@ lib{fmt}: include/hxx{**} hxx{version} $imp_libs $int_libs # Automatically build as module if the feature is enabled build_fmt_module = $cxx.features.modules +allow_header_usage = ($build_fmt_module == false || $config.fmt.modules_only == false) + +if($build_fmt_module && $allow_header_usage) + info "Building fmt with dual module/header mode enabled" lib{fmt}: src/mxx{fmt} : include = ($build_fmt_module) # `fmt` C++ module only lib{fmt}: src/cxx{** -fmt} : include = (!$build_fmt_module) # no modules only @@ -16,7 +20,8 @@ lib{fmt}: src/cxx{** -fmt} : include = (!$build_fmt_module) # no modules only lib{fmt}: { export.metadata = 1 fmt - fmt.is_module = [bool] $build_fmt_module + fmt.has_header = [bool] $allow_header_usage + fmt.has_module = [bool] $build_fmt_module } # Include the generated version header into the distribution (so that we don't @@ -38,21 +43,24 @@ cxx.poptions =+ "-I$src_base/include" "-I$out_root" "-I$src_root" # If building fmt module, also enable attaching to the global module in order to allow concurrent #include and import. if($build_fmt_module) - cxx.poptions =+ -DFMT_MODULE -DFMT_ATTACH_TO_GLOBAL_MODULE +{ + cxx.poptions =+ -DFMT_MODULE + if($allow_header_usage) + # Support mixing consuming as both modules and headers within a single build + cxx.poptions =+ -DFMT_ATTACH_TO_GLOBAL_MODULE if($config.fmt.enable_import_std) cxx.poptions =+ -DFMT_IMPORT_STD +} # Export options. # -lib{fmt}: +lib{fmt}: cxx.export.libs = $int_libs +if($allow_header_usage) # Note: exported poptions only relevant for header consumption { - cxx.export.poptions = "-I$src_base/include" "-I$out_root" "-I$src_root" - cxx.export.libs = $int_libs + lib{fmt}: cxx.export.poptions = "-I$src_base/include" "-I$out_root" "-I$src_root" + libs{fmt}: cxx.export.poptions += -DFMT_SHARED } -libs{fmt}: cxx.export.poptions += -DFMT_SHARED - - # For pre-releases use the complete version to make sure they cannot be used # in place of another pre-release or the final version. See the version module # for details on the version.* variable values. diff --git a/fmt/tests/basics/buildfile b/fmt/tests/basics/buildfile index c66f3bc..5dab89c 100644 --- a/fmt/tests/basics/buildfile +++ b/fmt/tests/basics/buildfile @@ -1,9 +1,14 @@ import! [metadata, rule_hint=cxx.link] libs = fmt%lib{fmt} -./ : exe{driver} : {cxx}{driver} hxx{tests.inl} $libs testscript{**} - -if $($libs: fmt.is_module) +if $($libs: fmt.has_header) { - ./ : exe{driver-modules} : {cxx}{driver-modules} hxx{tests.inl} $libs testscript{**} + ./ : exe{driver} : {cxx}{driver} hxx{tests.inl} $libs testscript{**} } +if $($libs: fmt.has_module) +{ + # For purposes of verifying that fmt headers are not made available for include when in modules-only mode + cxx.poptions =+ "-DFMT_BUILD2_HAS_HEADER=($($libs: fmt.has_header) ? 1 : 0)" + + ./ : exe{driver-modules} : {cxx}{driver-modules} hxx{tests.inl} $libs testscript{**} +} diff --git a/fmt/tests/basics/driver-modules.cxx b/fmt/tests/basics/driver-modules.cxx index 6cdf1f5..4d90052 100644 --- a/fmt/tests/basics/driver-modules.cxx +++ b/fmt/tests/basics/driver-modules.cxx @@ -1,4 +1,9 @@ +// Verify that fmt headers are not available if config.fmt.modules_only is true +#if __has_include() != FMT_BUILD2_HAS_HEADER +#error fmt headers should be available for include iff config.fmt.modules_only == false +#endif + #include #include #include @@ -7,5 +12,3 @@ import fmt; #include "tests.inl" - - From b2e4c3b6b84a2ead07a63b1fd970aca659d0914c Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 26 Aug 2024 17:38:59 +0900 Subject: [PATCH 07/36] Point upstream to master branch of upstream fmt - this has merged in the module fix PRs, but they're yet to make an upstream release. --- upstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream b/upstream index b50e685..0379bf3 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit b50e685db996c167e6c831dcef582aba6e14276a +Subproject commit 0379bf3a5d52d8542aec1874677c9df5ff9ba5f9 From c271d7778a5acbf32cd87625fd325329e37c48cf Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Fri, 30 Aug 2024 18:41:10 +0900 Subject: [PATCH 08/36] Add new package for hosting upstream tests. Add gtest and gmock dependencies via build2 packages. Begun to map the logic from upstream CMake; added static library test-main and some initial tests to a basics subfolder. --- .gitattributes | 2 ++ fmt-tests/.gitignore | 25 ++++++++++++++++++++++ fmt-tests/basics/.gitignore | 5 +++++ fmt-tests/basics/buildfile | 37 +++++++++++++++++++++++++++++++++ fmt-tests/basics/test | 1 + fmt-tests/build/.gitignore | 4 ++++ fmt-tests/build/bootstrap.build | 7 +++++++ fmt-tests/build/root.build | 15 +++++++++++++ fmt-tests/buildfile | 1 + fmt-tests/manifest | 13 ++++++++++++ fmt-tests/test-main/buildfile | 13 ++++++++++++ fmt-tests/test-main/test | 1 + fmt/manifest | 3 ++- packages.manifest | 2 ++ repositories.manifest | 11 +++------- 15 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 fmt-tests/.gitignore create mode 100644 fmt-tests/basics/.gitignore create mode 100644 fmt-tests/basics/buildfile create mode 120000 fmt-tests/basics/test create mode 100644 fmt-tests/build/.gitignore create mode 100644 fmt-tests/build/bootstrap.build create mode 100644 fmt-tests/build/root.build create mode 100644 fmt-tests/buildfile create mode 100644 fmt-tests/manifest create mode 100644 fmt-tests/test-main/buildfile create mode 120000 fmt-tests/test-main/test diff --git a/.gitattributes b/.gitattributes index 6891e29..1abc10a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,3 +21,5 @@ fmt/fmt/include symlink=dir fmt/fmt/src symlink=dir fmt/doc symlink=dir +fmt-tests/basics/test symlink=dir +fmt-tests/test-main/test symlink=dir diff --git a/fmt-tests/.gitignore b/fmt-tests/.gitignore new file mode 100644 index 0000000..1c363a0 --- /dev/null +++ b/fmt-tests/.gitignore @@ -0,0 +1,25 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.i.* +*.ii +*.ii.* +*.o +*.obj +*.gcm +*.pcm +*.ifc +*.so +*.dylib +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc diff --git a/fmt-tests/basics/.gitignore b/fmt-tests/basics/.gitignore new file mode 100644 index 0000000..8521b07 --- /dev/null +++ b/fmt-tests/basics/.gitignore @@ -0,0 +1,5 @@ +basics + +# Testscript output directory (can be symlink). +# +test-basics diff --git a/fmt-tests/basics/buildfile b/fmt-tests/basics/buildfile new file mode 100644 index 0000000..bec9d56 --- /dev/null +++ b/fmt-tests/basics/buildfile @@ -0,0 +1,37 @@ +include ../test-main/ + +#test_names = +# args-test \ +# assert-test \ +# base-test +gtest_test_names = args-test assert-test base-test chrono-test color-test compile-fp-test compile-test format-test gtest-extra-test noexception-test os-test ostream-test posix-mock-test printf-test ranges-odr-test ranges-test std-test unicode-test xchar-test +# header-only-test +# scan-test + +standalone_test_names = enforce-checks-test # some way to pair these? -DFMT_ENFORCE_COMPILE_STRING + +for test_name : $gtest_test_names +{ + ./: exe{$test_name} : test/cxx{$test_name} + exe{$test_name}: ../test-main/liba{test-main}: + { + bin.whole = true + } +} + +# linker issues. +#./: exe{scan-test} : test/cxx{scan-test} ../test-main/liba{test-main} + +# @todo: cmake adds this test conditionally on NOT ( msvc AND fmt-shared ) +# in build2, i guess it's a bit different in that we can potentially build both shared and static variants within a single config? +# also not clear how fmt_shared/fmt_header_only is being configured, looks like the package doesn't do anything there. using defaults only? +# if $cxx. != msvc +#./: exe{format-impl-test} : test/cxx{format-impl-test header-only-test} ../test-main/liba{test-main} + + +import fmt = fmt%lib{fmt} + +for test_name : $standalone_test_names +{ + ./: exe{$test_name} : test/cxx{$test_name} $fmt +} diff --git a/fmt-tests/basics/test b/fmt-tests/basics/test new file mode 120000 index 0000000..18e4790 --- /dev/null +++ b/fmt-tests/basics/test @@ -0,0 +1 @@ +../../upstream/test \ No newline at end of file diff --git a/fmt-tests/build/.gitignore b/fmt-tests/build/.gitignore new file mode 100644 index 0000000..974e01d --- /dev/null +++ b/fmt-tests/build/.gitignore @@ -0,0 +1,4 @@ +/config.build +/root/ +/bootstrap/ +build/ diff --git a/fmt-tests/build/bootstrap.build b/fmt-tests/build/bootstrap.build new file mode 100644 index 0000000..70f798c --- /dev/null +++ b/fmt-tests/build/bootstrap.build @@ -0,0 +1,7 @@ +project = fmt-tests + +using version +using config +using test +using install +using dist diff --git a/fmt-tests/build/root.build b/fmt-tests/build/root.build new file mode 100644 index 0000000..6377162 --- /dev/null +++ b/fmt-tests/build/root.build @@ -0,0 +1,15 @@ +# Uncomment to suppress warnings coming from external libraries. +# +#cxx.internal.scope = current + +cxx.std = latest + +using cxx + +hxx{*}: extension = h +mxx{*}: extension = cc +cxx{*}: extension = cc + +# The test target for cross-testing (running tests under Wine, etc). +# +test.target = $cxx.target diff --git a/fmt-tests/buildfile b/fmt-tests/buildfile new file mode 100644 index 0000000..bca55a2 --- /dev/null +++ b/fmt-tests/buildfile @@ -0,0 +1 @@ +./: {*/ -build/} manifest diff --git a/fmt-tests/manifest b/fmt-tests/manifest new file mode 100644 index 0000000..a34b168 --- /dev/null +++ b/fmt-tests/manifest @@ -0,0 +1,13 @@ +: 1 +name: fmt-tests +version: 0.1.0-a.0.z +project: fmt +summary: Tests package for fmt upstream tests +license: MIT +url: https://github.com/fmtlib/fmt/ + +depends: * build2 >= 0.17.0 +depends: * bpkg >= 0.17.0 + +depends: gtest ^1.11.0 +depends: gmock ^1.11.0 diff --git a/fmt-tests/test-main/buildfile b/fmt-tests/test-main/buildfile new file mode 100644 index 0000000..e2676f0 --- /dev/null +++ b/fmt-tests/test-main/buildfile @@ -0,0 +1,13 @@ + +libs = +import libs += fmt%lib{fmt} +import libs += gtest%lib{gtest} gmock%lib{gmock} + +liba{test-main}: test/cxx{test-main gtest-extra util} test/hxx{gtest-extra} $libs + +# Export options. +# +liba{test-main}: +{ + cxx.export.libs = $libs +} diff --git a/fmt-tests/test-main/test b/fmt-tests/test-main/test new file mode 120000 index 0000000..18e4790 --- /dev/null +++ b/fmt-tests/test-main/test @@ -0,0 +1 @@ +../../upstream/test \ No newline at end of file diff --git a/fmt/manifest b/fmt/manifest index 9ac843d..3e41529 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -9,6 +9,7 @@ url: https://github.com/fmtlib/fmt/ package-url: https://github.com/build2-packaging/fmt/ package-email: mjklaim@gmail.com +tests: fmt-tests == $ + depends: * build2 >= 0.17.0 depends: * bpkg >= 0.17.0 - diff --git a/packages.manifest b/packages.manifest index 7092409..ccd3e1e 100644 --- a/packages.manifest +++ b/packages.manifest @@ -1,2 +1,4 @@ : 1 location: fmt/ +: +location: fmt-tests/ diff --git a/repositories.manifest b/repositories.manifest index cd76feb..230f8c0 100644 --- a/repositories.manifest +++ b/repositories.manifest @@ -1,11 +1,6 @@ : 1 summary: fmt project repository -#: -#role: prerequisite -#location: https://pkg.cppget.org/1/stable -#trust: ... - -#: -#role: prerequisite -#location: https://git.build2.org/hello/libhello.git +: +role: prerequisite +location: https://pkg.cppget.org/1/stable From 110906e6d01352187b6e9df54816acc639f3544e Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Fri, 30 Aug 2024 18:52:12 +0900 Subject: [PATCH 09/36] Add .vs/ folder to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 10d90d1..6d7a9f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .bdep/ +.vs/ # Local default options files. # From ab0cc5e26d13f3e67cdb74232c097c1b3f12bd3d Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Fri, 30 Aug 2024 19:29:23 +0900 Subject: [PATCH 10/36] Align the test package version number to the main package. --- fmt-tests/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmt-tests/manifest b/fmt-tests/manifest index a34b168..2b6b7fa 100644 --- a/fmt-tests/manifest +++ b/fmt-tests/manifest @@ -1,6 +1,6 @@ : 1 name: fmt-tests -version: 0.1.0-a.0.z +version: 11.0.1-a.0.z project: fmt summary: Tests package for fmt upstream tests license: MIT From 79827a31b0e952384cb8f2fb0883a70414127193 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Sat, 31 Aug 2024 17:02:04 +0900 Subject: [PATCH 11/36] Adjusted fmt-tests buildfiles to attempt to fix issues with include path failures on CI. --- fmt-tests/basics/buildfile | 8 +++++--- fmt-tests/test-main/buildfile | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fmt-tests/basics/buildfile b/fmt-tests/basics/buildfile index bec9d56..85bb4f3 100644 --- a/fmt-tests/basics/buildfile +++ b/fmt-tests/basics/buildfile @@ -4,9 +4,11 @@ include ../test-main/ # args-test \ # assert-test \ # base-test -gtest_test_names = args-test assert-test base-test chrono-test color-test compile-fp-test compile-test format-test gtest-extra-test noexception-test os-test ostream-test posix-mock-test printf-test ranges-odr-test ranges-test std-test unicode-test xchar-test -# header-only-test -# scan-test +gtest_test_names = args-test assert-test base-test chrono-test color-test compile-fp-test compile-test format-test gtest-extra-test noexception-test os-test ostream-test printf-test ranges-odr-test ranges-test std-test unicode-test xchar-test + +# header-only-test <- header only mode seemingly not supported by this build2 package? +# scan-test <- some linker issues +# posix-mock-test <- needs posix-mock.h, and has some msvc/runtime conditional logic going on standalone_test_names = enforce-checks-test # some way to pair these? -DFMT_ENFORCE_COMPILE_STRING diff --git a/fmt-tests/test-main/buildfile b/fmt-tests/test-main/buildfile index e2676f0..30b42fa 100644 --- a/fmt-tests/test-main/buildfile +++ b/fmt-tests/test-main/buildfile @@ -3,11 +3,12 @@ libs = import libs += fmt%lib{fmt} import libs += gtest%lib{gtest} gmock%lib{gmock} -liba{test-main}: test/cxx{test-main gtest-extra util} test/hxx{gtest-extra} $libs +liba{test-main}: test/cxx{test-main gtest-extra util} test/hxx{gtest-extra mock-allocator test-assert util} $libs # Export options. # liba{test-main}: { + cxx.export.poptions += "-I$src_base/test" cxx.export.libs = $libs } From b5ecdbfcad8b3adfc395c3eddf834c2f1a62a3b5 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Sat, 31 Aug 2024 17:58:35 +0900 Subject: [PATCH 12/36] Marked all executable targets in fmt-tests as tests. Removed install module from fmt-tests bootstrap.build. --- fmt-tests/build/bootstrap.build | 1 - fmt-tests/build/root.build | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fmt-tests/build/bootstrap.build b/fmt-tests/build/bootstrap.build index 70f798c..fbb1605 100644 --- a/fmt-tests/build/bootstrap.build +++ b/fmt-tests/build/bootstrap.build @@ -3,5 +3,4 @@ project = fmt-tests using version using config using test -using install using dist diff --git a/fmt-tests/build/root.build b/fmt-tests/build/root.build index 6377162..b269653 100644 --- a/fmt-tests/build/root.build +++ b/fmt-tests/build/root.build @@ -10,6 +10,10 @@ hxx{*}: extension = h mxx{*}: extension = cc cxx{*}: extension = cc +# All executables are tests +# +exe{*}: test = true + # The test target for cross-testing (running tests under Wine, etc). # test.target = $cxx.target From 6007797796ec2d8fa1468ee139ea20465d819fab Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 13:36:06 +0900 Subject: [PATCH 13/36] Tweak to ranges-test to match upstream CMake setup. --- fmt-tests/basics/buildfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fmt-tests/basics/buildfile b/fmt-tests/basics/buildfile index 85bb4f3..58fcb5b 100644 --- a/fmt-tests/basics/buildfile +++ b/fmt-tests/basics/buildfile @@ -4,7 +4,7 @@ include ../test-main/ # args-test \ # assert-test \ # base-test -gtest_test_names = args-test assert-test base-test chrono-test color-test compile-fp-test compile-test format-test gtest-extra-test noexception-test os-test ostream-test printf-test ranges-odr-test ranges-test std-test unicode-test xchar-test +gtest_test_names = args-test assert-test base-test chrono-test color-test compile-fp-test compile-test format-test gtest-extra-test noexception-test os-test ostream-test printf-test std-test unicode-test xchar-test # header-only-test <- header only mode seemingly not supported by this build2 package? # scan-test <- some linker issues @@ -21,6 +21,12 @@ for test_name : $gtest_test_names } } +./: exe{ranges-test} : test/cxx{ranges-test ranges-odr-test} +exe{ranges-test}: ../test-main/liba{test-main}: +{ + bin.whole = true +} + # linker issues. #./: exe{scan-test} : test/cxx{scan-test} ../test-main/liba{test-main} From 60423130ce74ddf8928d2e53dea8698030fb6f1b Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 13:51:34 +0900 Subject: [PATCH 14/36] Symc to latest upstream --- upstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream b/upstream index 0379bf3..bc3af51 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit 0379bf3a5d52d8542aec1874677c9df5ff9ba5f9 +Subproject commit bc3af512720da527690c58d2edab4ca1892b1f1d From 4841d772e60116074da12289dbfa7dd0751e94d2 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 18:25:26 +0900 Subject: [PATCH 15/36] Refactor smoke test buildfile to avoid conditional target dependencies. --- fmt/tests/basics/buildfile | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/fmt/tests/basics/buildfile b/fmt/tests/basics/buildfile index 5dab89c..1756471 100644 --- a/fmt/tests/basics/buildfile +++ b/fmt/tests/basics/buildfile @@ -1,14 +1,13 @@ import! [metadata, rule_hint=cxx.link] libs = fmt%lib{fmt} -if $($libs: fmt.has_header) -{ - ./ : exe{driver} : {cxx}{driver} hxx{tests.inl} $libs testscript{**} -} - -if $($libs: fmt.has_module) -{ - # For purposes of verifying that fmt headers are not made available for include when in modules-only mode - cxx.poptions =+ "-DFMT_BUILD2_HAS_HEADER=($($libs: fmt.has_header) ? 1 : 0)" - - ./ : exe{driver-modules} : {cxx}{driver-modules} hxx{tests.inl} $libs testscript{**} -} +./ : + +./ : exe{driver} : include = $($libs: fmt.has_header) +./ : exe{driver-modules} : include = $($libs: fmt.has_module) + +exe{driver} : {cxx}{driver} hxx{tests.inl} $libs testscript{**} + +# For purposes of verifying that fmt headers are not made available for include when in modules-only mode +cxx.poptions =+ "-DFMT_BUILD2_HAS_HEADER=($($libs: fmt.has_header) ? 1 : 0)" + +exe{driver-modules} : {cxx}{driver-modules} hxx{tests.inl} $libs testscript{**} From 014a3d87c35a56c61298f3c62e67da3823ead8eb Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 19:00:27 +0900 Subject: [PATCH 16/36] Experiment with package specific CI configurations. --- fmt/manifest | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fmt/manifest b/fmt/manifest index 3e41529..b832abb 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -13,3 +13,6 @@ tests: fmt-tests == $ depends: * build2 >= 0.17.0 depends: * bpkg >= 0.17.0 + +modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules +modules-only-build-config: config.cxx.features.modules=true config.fmt.modules_only=true ; Enable c++20 modules and disable header usage From 80557624f7bcbe4a5b0e8c26109c06d47b7f10ae Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 19:10:51 +0900 Subject: [PATCH 17/36] Force reproces=true on MSVC modules builds to work around compiler bug. See https://developercommunity.visualstudio.com/t/Separate-preprocessing-with-P-fails-wit/10707183 --- fmt/fmt/buildfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fmt/fmt/buildfile b/fmt/fmt/buildfile index 5f179c5..9d1192a 100644 --- a/fmt/fmt/buildfile +++ b/fmt/fmt/buildfile @@ -13,6 +13,10 @@ allow_header_usage = ($build_fmt_module == false || $config.fmt.modules_only == if($build_fmt_module && $allow_header_usage) info "Building fmt with dual module/header mode enabled" +# Workaround for MSVC bug: https://developercommunity.visualstudio.com/t/Separate-preprocessing-with-P-fails-wit/10707183 +if($build_fmt_module && $cxx.class == 'msvc') + cxx.reprocess = true + lib{fmt}: src/mxx{fmt} : include = ($build_fmt_module) # `fmt` C++ module only lib{fmt}: src/cxx{** -fmt} : include = (!$build_fmt_module) # no modules only From 1130bb67397f7d4713fc7951ea3a07f84a6e5c92 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 19:17:57 +0900 Subject: [PATCH 18/36] Fix for incorrect variable prefix. --- fmt/fmt/buildfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmt/fmt/buildfile b/fmt/fmt/buildfile index 9d1192a..98b1876 100644 --- a/fmt/fmt/buildfile +++ b/fmt/fmt/buildfile @@ -15,7 +15,7 @@ if($build_fmt_module && $allow_header_usage) # Workaround for MSVC bug: https://developercommunity.visualstudio.com/t/Separate-preprocessing-with-P-fails-wit/10707183 if($build_fmt_module && $cxx.class == 'msvc') - cxx.reprocess = true + cc.reprocess = true lib{fmt}: src/mxx{fmt} : include = ($build_fmt_module) # `fmt` C++ module only lib{fmt}: src/cxx{** -fmt} : include = (!$build_fmt_module) # no modules only From c553ca83e7284c328188c01ee5729c2fea290dc5 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 19:35:54 +0900 Subject: [PATCH 19/36] Constrain modules CI build configs to latest. --- fmt/manifest | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fmt/manifest b/fmt/manifest index b832abb..bff155d 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -14,5 +14,7 @@ tests: fmt-tests == $ depends: * build2 >= 0.17.0 depends: * bpkg >= 0.17.0 +modules-builds: latest; modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules +modules-only-builds: latest; modules-only-build-config: config.cxx.features.modules=true config.fmt.modules_only=true ; Enable c++20 modules and disable header usage From 495ab27cebae1dc242ac7a34c8affca0d10be2a5 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 19:58:03 +0900 Subject: [PATCH 20/36] Experiment constraining to clang. --- fmt/manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fmt/manifest b/fmt/manifest index bff155d..a33bfac 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -14,7 +14,7 @@ tests: fmt-tests == $ depends: * build2 >= 0.17.0 depends: * bpkg >= 0.17.0 -modules-builds: latest; +modules-builds: latest : &( +clang-18+ ) ; Modules builds only supported for latest Clang and MSVC modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules -modules-only-builds: latest; +modules-only-builds: latest : &( +clang-18+ ) ; Modules builds only supported for latest Clang and MSVC modules-only-build-config: config.cxx.features.modules=true config.fmt.modules_only=true ; Enable c++20 modules and disable header usage From c328c6c9dd8c142b26260a8c39843ba7367876b4 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 20:03:50 +0900 Subject: [PATCH 21/36] Switch from latest to experimental --- fmt/manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fmt/manifest b/fmt/manifest index a33bfac..fb102c1 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -14,7 +14,7 @@ tests: fmt-tests == $ depends: * build2 >= 0.17.0 depends: * bpkg >= 0.17.0 -modules-builds: latest : &( +clang-18+ ) ; Modules builds only supported for latest Clang and MSVC +modules-builds: experimental : &( +clang-18+ ) ; Modules builds only supported for latest Clang and MSVC modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules -modules-only-builds: latest : &( +clang-18+ ) ; Modules builds only supported for latest Clang and MSVC +modules-only-builds: experimental : &( +clang-18+ ) ; Modules builds only supported for latest Clang and MSVC modules-only-build-config: config.cxx.features.modules=true config.fmt.modules_only=true ; Enable c++20 modules and disable header usage From b3b1dcce8b5ed55c11b3f858a0e0514e1f42fd9b Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 20:06:10 +0900 Subject: [PATCH 22/36] Add msvc to CI package configs --- fmt/manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fmt/manifest b/fmt/manifest index fb102c1..0889813 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -14,7 +14,7 @@ tests: fmt-tests == $ depends: * build2 >= 0.17.0 depends: * bpkg >= 0.17.0 -modules-builds: experimental : &( +clang-18+ ) ; Modules builds only supported for latest Clang and MSVC +modules-builds: experimental : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules -modules-only-builds: experimental : &( +clang-18+ ) ; Modules builds only supported for latest Clang and MSVC +modules-only-builds: experimental : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC modules-only-build-config: config.cxx.features.modules=true config.fmt.modules_only=true ; Enable c++20 modules and disable header usage From 82e02d5226f91efb445e70c7d9ad25e562e707a9 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 20:07:10 +0900 Subject: [PATCH 23/36] Revert CI configs to latest --- fmt/manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fmt/manifest b/fmt/manifest index 0889813..6b46692 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -14,7 +14,7 @@ tests: fmt-tests == $ depends: * build2 >= 0.17.0 depends: * bpkg >= 0.17.0 -modules-builds: experimental : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC +modules-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules -modules-only-builds: experimental : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC +modules-only-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC modules-only-build-config: config.cxx.features.modules=true config.fmt.modules_only=true ; Enable c++20 modules and disable header usage From dc8fb4b95e72be70c4032719c356dc33961ebdac Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Mon, 2 Sep 2024 20:21:32 +0900 Subject: [PATCH 24/36] Change smoke test to use template parameter for format parse context, rather than format_parse_context alias which is not exported by the fmt module. --- fmt/tests/basics/tests.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fmt/tests/basics/tests.inl b/fmt/tests/basics/tests.inl index c087edb..b5de3e8 100644 --- a/fmt/tests/basics/tests.inl +++ b/fmt/tests/basics/tests.inl @@ -51,7 +51,8 @@ struct date { template <> struct fmt::formatter { - constexpr auto parse(format_parse_context& ctx) const { return ctx.begin(); } + template + constexpr auto parse(ParseContext& ctx) const { return ctx.begin(); } template constexpr auto format(const date& d, FormatContext& ctx) const { From 105613fbd26af7ec6fae9167d3347dcd31afae06 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Wed, 4 Sep 2024 09:07:05 +0900 Subject: [PATCH 25/36] Update upstream to grab latest fixes. --- upstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream b/upstream index bc3af51..15694c9 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit bc3af512720da527690c58d2edab4ca1892b1f1d +Subproject commit 15694c9a84f120e21ca3095ed0f989d5b704e796 From 780ba03ca6086f74f355685a3720e02508b014cf Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Wed, 4 Sep 2024 10:52:30 +0900 Subject: [PATCH 26/36] Upstream submodule update. --- upstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream b/upstream index 15694c9..3b9a3d2 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit 15694c9a84f120e21ca3095ed0f989d5b704e796 +Subproject commit 3b9a3d26081f473309607f07bd04bfe026fa139d From 682c69b59318dd78628195d3af1c04e2af849d6f Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Wed, 4 Sep 2024 11:50:56 +0900 Subject: [PATCH 27/36] Upstream update. --- upstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream b/upstream index 3b9a3d2..38e959d 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit 3b9a3d26081f473309607f07bd04bfe026fa139d +Subproject commit 38e959d9af1caf6fa154641684d58410d2668669 From 2922bb41fbfc95f34bcc949d2ad97fca2f349e16 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Wed, 4 Sep 2024 13:05:24 +0900 Subject: [PATCH 28/36] Upstream sync. --- upstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream b/upstream index 38e959d..916e779 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit 38e959d9af1caf6fa154641684d58410d2668669 +Subproject commit 916e779e245c0f8e4e9bca560105059956d72dfd From 3d7398ab916caf67d92af175265e853987057bff Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Wed, 4 Sep 2024 14:36:53 +0900 Subject: [PATCH 29/36] Upstream sync --- upstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream b/upstream index 916e779..38e959d 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit 916e779e245c0f8e4e9bca560105059956d72dfd +Subproject commit 38e959d9af1caf6fa154641684d58410d2668669 From c5c5ab50c6b3f9929e516d5be7d5719305ed351a Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Sat, 7 Sep 2024 21:49:04 +0900 Subject: [PATCH 30/36] Upstream sync. --- upstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream b/upstream index 38e959d..1777002 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit 38e959d9af1caf6fa154641684d58410d2668669 +Subproject commit 1777002ff3f68f2259fb00fafab5669b0cdc3f23 From 05855de698a888f180d4e9b0d03092975dbfa1fa Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Sun, 8 Sep 2024 01:38:52 +0900 Subject: [PATCH 31/36] Disable modules builds on CI. Revert upstream to master branch. --- fmt/manifest | 8 ++++---- upstream | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fmt/manifest b/fmt/manifest index 6b46692..d2606ee 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -14,7 +14,7 @@ tests: fmt-tests == $ depends: * build2 >= 0.17.0 depends: * bpkg >= 0.17.0 -modules-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC -modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules -modules-only-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC -modules-only-build-config: config.cxx.features.modules=true config.fmt.modules_only=true ; Enable c++20 modules and disable header usage +#modules-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC +#modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules +#modules-only-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC +#modules-only-build-config: config.cxx.features.modules=true config.fmt.modules_only=true ; Enable c++20 modules and disable header usage diff --git a/upstream b/upstream index 1777002..9408c2a 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit 1777002ff3f68f2259fb00fafab5669b0cdc3f23 +Subproject commit 9408c2ae8c264f2c94495db73251f75fcc35cad0 From 88412586797e054f239c8814305c19dde3ae3dae Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Tue, 10 Sep 2024 11:54:36 +0900 Subject: [PATCH 32/36] Switch upstream branch bag to latest tagged release (11.0.2) --- upstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstream b/upstream index 9408c2a..0c9fce2 160000 --- a/upstream +++ b/upstream @@ -1 +1 @@ -Subproject commit 9408c2ae8c264f2c94495db73251f75fcc35cad0 +Subproject commit 0c9fce2ffefecfdce794e1859584e25877b7b592 From 7c56c1c6064046a187d01c5112a056c202b91358 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Tue, 10 Sep 2024 13:36:39 +0900 Subject: [PATCH 33/36] Add some CI build exclusions. --- fmt/manifest | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fmt/manifest b/fmt/manifest index d2606ee..5cf740b 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -14,6 +14,11 @@ tests: fmt-tests == $ depends: * build2 >= 0.17.0 depends: * bpkg >= 0.17.0 +builds: default +builds: -freebsd ; fmt tests failing, fixed on upstream master, pending removal next package release after 11.0.2 +build-exclude: linux_debian_12-clang_17 ; clang-17 bug with libstdc++ std::tuple (https://github.com/llvm/llvm-project/issues/61415) +build-exclude: **/x86_64-w64-mingw32 ; unknown error building installed tests 'error: unable to stat path D:\a\msys64\mingw64\lib\x86_64-w64-mingw32\14.1.0\pkgconfig\: the device is not ready' + #modules-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC #modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules #modules-only-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC From 6b5d1145725f851767b663a870f5102450fd2849 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Tue, 10 Sep 2024 15:01:39 +0900 Subject: [PATCH 34/36] Update package readme with latest information on modules compatibility. --- fmt/README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fmt/README.md b/fmt/README.md index 3910761..f921b95 100644 --- a/fmt/README.md +++ b/fmt/README.md @@ -9,9 +9,18 @@ See [`{fmt}` documentation](https://fmt.dev/) for usage and details. Note: This is the source code for the build2 package of the `{fmt}` C++ library, the actual library sources snapshot can be found in the `./upstream/` submodule. -## Configuration Options: +## Configuration Options - - `config.fmt.enable_modules` : Set to `true` to build and provide the `fmt` C++ modules. If the compiler and C++ version don't support C++ modules (which is C++ > 20), this will result in a compilation failure. Set to `true` if `$cxx.features.modules == true` which means the configuration is set to enable C++ modules, `false` otherwise. +### Experimental C++20 modules support +Modules support is WIP, both in the `build2` package and also in `fmt` upstream. Latest versions of MSVC or Clang are recommended, and the most up-to-date version of the package with regards to modules compatibility can be used via git and the [modules branch](https://github.com/build2-packaging/fmt/tree/modules). For example, in project `repositories.manifest`: +``` +: +role: prerequisite +location: https://github.com/build2-packaging/fmt.git#modules +``` +Enable with `config.cxx.features.modules=true`. When enabled, by default dual mode is used meaning that the library can be consumed either through `import` or via `#include`. To enable this safely, all entities are attached to the global module (extern "C++"). See `modules_only` option for the alternative. + - `config.fmt.enable_import_std` : Set to `true` to consume the standard library as a module when building the `fmt` module. Support dependent on compiler and std lib. Defaults to `false`. + - `config.fmt.modules_only` : Set to `true` to enable modules-only mode for the package. In this mode, `fmt` entities are fully encapsulated in the `fmt` module meaning `#include`-based consumption cannot be mixed, and the package will not export headers. Defaults to `false`. From 8f3e14849973b4dca33ccc1879d3eafca2dec1cb Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Tue, 10 Sep 2024 15:04:00 +0900 Subject: [PATCH 35/36] Add comment to manifest re CI modules configs. --- fmt/manifest | 1 + 1 file changed, 1 insertion(+) diff --git a/fmt/manifest b/fmt/manifest index 5cf740b..a425587 100644 --- a/fmt/manifest +++ b/fmt/manifest @@ -19,6 +19,7 @@ builds: -freebsd ; fmt tests failing, fixed on upstream master, pending re build-exclude: linux_debian_12-clang_17 ; clang-17 bug with libstdc++ std::tuple (https://github.com/llvm/llvm-project/issues/61415) build-exclude: **/x86_64-w64-mingw32 ; unknown error building installed tests 'error: unable to stat path D:\a\msys64\mingw64\lib\x86_64-w64-mingw32\14.1.0\pkgconfig\: the device is not ready' +# Modules support still not sufficient to enable on CI #modules-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC #modules-build-config: config.cxx.features.modules=true ; Enable c++20 modules #modules-only-builds: latest : &( +clang-18+ +msvc ) ; Modules builds only supported for latest Clang and MSVC From bffc9c4f9e210aacf1165992a144388226ac4ec0 Mon Sep 17 00:00:00 2001 From: Cameron Angus Date: Wed, 11 Sep 2024 14:20:36 +0900 Subject: [PATCH 36/36] Cleanup of fmt-tests buildfile organization and comments. --- fmt-tests/basics/buildfile | 56 +++++++++++++++++++++++++++----------- fmt/tests/basics/buildfile | 2 -- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/fmt-tests/basics/buildfile b/fmt-tests/basics/buildfile index 58fcb5b..512c578 100644 --- a/fmt-tests/basics/buildfile +++ b/fmt-tests/basics/buildfile @@ -1,16 +1,31 @@ include ../test-main/ -#test_names = -# args-test \ -# assert-test \ -# base-test -gtest_test_names = args-test assert-test base-test chrono-test color-test compile-fp-test compile-test format-test gtest-extra-test noexception-test os-test ostream-test printf-test std-test unicode-test xchar-test +# NOTE: Maintaining explicit lists to match upstream, as it's not clear that there is intended to be a uniform pattern that can be reliably globbed. +# See individual invocations of add_fmt_test() in upstream/test/CMakeLists.txt -# header-only-test <- header only mode seemingly not supported by this build2 package? -# scan-test <- some linker issues -# posix-mock-test <- needs posix-mock.h, and has some msvc/runtime conditional logic going on -standalone_test_names = enforce-checks-test # some way to pair these? -DFMT_ENFORCE_COMPILE_STRING +# Tests that use gtest, and do not require any additional source/headers beyond a single cc file + +gtest_test_names = \ + args-test \ + assert-test \ + base-test \ + chrono-test \ + color-test \ + compile-fp-test \ + compile-test \ + format-test \ + gtest-extra-test \ + noexception-test \ + os-test \ + ostream-test \ + printf-test \ + std-test \ + unicode-test \ + xchar-test + +# NOTE: header-only-test - Excluded as this package does not currently provide support for FMT_HEADER_ONLY. +# TODO: scan-test - Excluded due to unresolved linker errors. for test_name : $gtest_test_names { @@ -21,21 +36,28 @@ for test_name : $gtest_test_names } } +# END [Tests that use gtest, and do not require any additional source/headers beyond a single cc file] + + +# Tests using gtest but with additional prerequisites + ./: exe{ranges-test} : test/cxx{ranges-test ranges-odr-test} exe{ranges-test}: ../test-main/liba{test-main}: { bin.whole = true } -# linker issues. -#./: exe{scan-test} : test/cxx{scan-test} ../test-main/liba{test-main} +# NOTE: format-impl-test- For whatever reason, format-impl-test is tied in upstream to header-only-test, which we do not support. Attempting to compile it alone yields errors, therefore omitted. +# TODO: posix-mock-test - Excluded pending further work. Needs posix-mock.h, and has some msvc/runtime conditional logic that needs looking into. + +# END [Tests using gtest but with additional prerequisites] -# @todo: cmake adds this test conditionally on NOT ( msvc AND fmt-shared ) -# in build2, i guess it's a bit different in that we can potentially build both shared and static variants within a single config? -# also not clear how fmt_shared/fmt_header_only is being configured, looks like the package doesn't do anything there. using defaults only? -# if $cxx. != msvc -#./: exe{format-impl-test} : test/cxx{format-impl-test header-only-test} ../test-main/liba{test-main} +# Tests which do not use gtest and therefore should link directly to fmt only and not the test-main lib + +# TODO: Is there a clean way to use a declarative list but with more structure, in order to pair names to additional options? +standalone_test_names = \ + enforce-checks-test # -DFMT_ENFORCE_COMPILE_STRING import fmt = fmt%lib{fmt} @@ -43,3 +65,5 @@ for test_name : $standalone_test_names { ./: exe{$test_name} : test/cxx{$test_name} $fmt } + +# END [Tests which do not use gtest and therefore should link directly to fmt only and not the test-main lib] diff --git a/fmt/tests/basics/buildfile b/fmt/tests/basics/buildfile index 1756471..4c6f11d 100644 --- a/fmt/tests/basics/buildfile +++ b/fmt/tests/basics/buildfile @@ -1,7 +1,5 @@ import! [metadata, rule_hint=cxx.link] libs = fmt%lib{fmt} -./ : - ./ : exe{driver} : include = $($libs: fmt.has_header) ./ : exe{driver-modules} : include = $($libs: fmt.has_module)