Skip to content

Commit 5fdca4f

Browse files
committed
Better ninja support.
1 parent 1d45f32 commit 5fdca4f

6 files changed

Lines changed: 39 additions & 26 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/bin*
55
cppan
66
.cppan*
7-
.vs
7+
.vs*
88

99
*.kdev*
1010

@@ -13,7 +13,7 @@ cppan
1313
/*.bat
1414

1515
*~
16-
*.user
16+
*.user*
1717

1818
*.lnk
1919

cppan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ projects:
6161
- pvt.cppan.demo.boost.optional: 1
6262
- pvt.cppan.demo.boost.property_tree: 1
6363
- pvt.cppan.demo.boost.variant: 1
64-
- pvt.cppan.demo.jbeder.yaml_cpp: master
6564
- pvt.cppan.demo.sqlite3: 3
6665

6766
- pvt.egorpugin.primitives.string: master
@@ -75,6 +74,7 @@ projects:
7574
- pvt.egorpugin.primitives.log: master
7675
- pvt.egorpugin.primitives.pack: master
7776
- pvt.egorpugin.primitives.command: master
77+
- pvt.egorpugin.primitives.yaml: master
7878

7979
options:
8080
any:

src/client/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ try
367367
c.load_current_config();
368368
Projects &projects = c.getProjects();
369369
const auto cwd = fs::current_path();
370-
for (auto &p : projects)
370+
for (auto &ps : projects)
371371
{
372-
auto &project = p.second;
372+
auto &project = ps.second;
373373

374374
auto p = cwd;
375375
if (par)

src/common/checks.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -709,38 +709,39 @@ void Checks::read_parallel_checks_for_workers(const path &dir)
709709

710710
void Checks::write_definitions(CMakeContext &ctx, const Package &d, const StringSet &prefixes) const
711711
{
712-
String m = "INTERFACE";
713-
if (!d.flags[pfHeaderOnly])
714-
m = "PUBLIC";
715-
if (d.flags[pfExecutable])
716-
m = "PRIVATE";
717-
718-
auto print_def = [&ctx, &m, &prefixes](const String &value, auto &&s)
712+
const auto m = [&d]
713+
{
714+
if (!d.flags[pfHeaderOnly])
715+
return "PUBLIC"s;
716+
if (d.flags[pfExecutable])
717+
return "PRIVATE"s;
718+
return "INTERFACE"s;
719+
}();
720+
721+
auto print_def = [&ctx, &m, &prefixes](const auto &value, const auto &s)
719722
{
720-
ctx << m << " " << s << "=" << value << CMakeContext::eol;
723+
ctx.addLine(m + " " + s + "=" + value);
721724
for (const auto &p : prefixes)
722-
ctx << m << " " << p + s << "=" << value << CMakeContext::eol;
725+
ctx.addLine(m + " " + p + s + "=" + value);
723726
return 0;
724727
};
725728

726-
auto add_if_definition = [&ctx, &print_def](const String &s, const String &value, auto && ... defs)
729+
auto add_if_definition = [&ctx, &print_def](const String &s, const String &value, const std::vector<String> &defs = std::vector<String>())
727730
{
728-
ctx.addLine("if (" + s + ")");
729-
ctx.increaseIndent();
731+
ctx.if_(s);
730732
ctx.addLine("target_compile_definitions(${this}");
731733
ctx.increaseIndent();
732734
print_def(value, s);
733-
using expand_type = int[];
734-
expand_type{ 0, print_def(value, std::forward<decltype(defs)>(defs))... };
735+
for (auto &def : defs)
736+
print_def(value, def);
735737
ctx.decreaseIndent();
736738
ctx.addLine(")");
737-
ctx.decreaseIndent();
738-
ctx.addLine("endif()");
739+
ctx.endif();
739740
ctx.addLine();
740741
};
741742

742743
// aliases
743-
add_if_definition("WORDS_BIGENDIAN", "1", "BIGENDIAN", "BIG_ENDIAN", "HOST_BIG_ENDIAN");
744+
add_if_definition("WORDS_BIGENDIAN", "1", {"BIGENDIAN", "BIG_ENDIAN", "HOST_BIG_ENDIAN"});
744745

745746
for (auto &c : checks)
746747
{

src/inserts/build.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@ if (MULTICORE)
7878
#set(parallel "-j ${N_CORES}") # temporary
7979
endif()
8080

81-
if (CONFIG)
81+
if (NINJA)
82+
cppan_debug_message("COMMAND ninja -C ${BUILD_DIR}")
83+
execute_process(
84+
COMMAND ninja -C ${BUILD_DIR}
85+
${OUTPUT_QUIET}
86+
${ERROR_QUIET}
87+
RESULT_VARIABLE ret
88+
)
89+
elseif (CONFIG)
8290
if (NOT DEFINED make OR
8391
"${make}" STREQUAL "" OR
8492
"${make}" STREQUAL "make-NOTFOUND" OR
@@ -131,7 +139,7 @@ if (CONFIG)
131139
RESULT_VARIABLE ret
132140
)
133141
endif()
134-
else(CONFIG)
142+
else()
135143
if ("${make}" STREQUAL "make-NOTFOUND")
136144
cppan_debug_message("COMMAND ${CMAKE_COMMAND}
137145
--build ${BUILD_DIR}")
@@ -151,7 +159,7 @@ else(CONFIG)
151159
RESULT_VARIABLE ret
152160
)
153161
endif()
154-
endif(CONFIG)
162+
endif()
155163

156164
check_result_variable(${ret})
157165

src/printers/cmake.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,11 @@ set(file ${BDIR}/cppan_build_deps_$<CONFIG>.${ext}))");
614614
local.addText("-DMULTICORE=1 ");
615615
local.addText("${rest} ");
616616

617-
local.addText("-P " + normalize_path(p.getDirObj()) + "/" + cmake_obj_build_filename + "\")");
617+
local.addText("-P " + normalize_path(p.getDirObj()) + "/" + cmake_obj_build_filename);
618+
#ifndef _WIN32
619+
local.addText(" &");
620+
#endif
621+
local.addText("\")");
618622
}
619623
local.emptyLines();
620624

0 commit comments

Comments
 (0)