44
55#include < boost/process/system.hpp>
66#include < gsl/narrow>
7+ #include < range/v3/algorithm/all_of.hpp>
78#include < range/v3/range/conversion.hpp>
89#include < range/v3/view.hpp>
910#include < spdlog/spdlog.h>
1011
1112#include " cppship/cmake/msvc.h"
1213#include " cppship/cmake/naming.h"
1314#include " cppship/cmd/build.h"
14- #include " cppship/core/manifest.h"
1515#include " cppship/core/workspace.h"
1616#include " cppship/util/fs.h"
1717#include " cppship/util/log.h"
@@ -34,20 +34,19 @@ int run_one_bench(const cmd::BuildContext& ctx, const std::string_view bench)
3434
3535int cmd::run_bench (const BenchOptions& options)
3636{
37- BuildContext ctx (options.profile );
38- Manifest manifest (ctx.metafile );
39-
40- const auto & layout = enforce_default_package (ctx.workspace );
41-
4237 NameTargetMapper mapper;
38+
39+ BuildContext ctx (options.profile );
4340 BuildOptions build_options { .profile = options.profile };
4441 if (options.target ) {
45- if (!layout.bench (*options.target )) {
42+ if (ranges::all_of (
43+ ctx.workspace .layouts (), [&](const auto & layout) { return !layout.bench (*options.target ); })) {
4644 throw Error { fmt::format (" bench `{}` not found" , *options.target ) };
4745 }
4846
49- build_options.target = mapper.bench (*options.target );
47+ build_options.cmake_target = mapper.bench (*options.target );
5048 } else {
49+ build_options.package = options.package ;
5150 build_options.groups .insert (BuildGroup::benches);
5251 }
5352
@@ -56,14 +55,16 @@ int cmd::run_bench(const BenchOptions& options)
5655 return EXIT_FAILURE;
5756 }
5857
59- if (build_options.target ) {
60- return run_one_bench (ctx, *build_options.target );
58+ if (build_options.cmake_target ) {
59+ return run_one_bench (ctx, *build_options.cmake_target );
6160 }
6261
63- for (const auto & bench : layout.benches ()) {
64- const int res = run_one_bench (ctx, mapper.bench (bench.name ));
65- if (res != 0 ) {
66- result = res;
62+ for (const auto & layout : ctx.workspace .layouts ()) {
63+ for (const auto & bench : layout.benches ()) {
64+ const int res = run_one_bench (ctx, mapper.bench (bench.name ));
65+ if (res != 0 ) {
66+ result = res;
67+ }
6768 }
6869 }
6970
0 commit comments