Skip to content

Commit 41ca7c5

Browse files
committed
Initial parallel bom.
1 parent c58a43d commit 41ca7c5

4 files changed

Lines changed: 141 additions & 4 deletions

File tree

src/client/main.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <boost/algorithm/string.hpp>
3737
#include <boost/nowide/args.hpp>
38+
#include <primitives/command.h>
3839
#include <primitives/pack.h>
3940
#include <primitives/templates.h>
4041
#include <primitives/executor.h>
@@ -727,6 +728,32 @@ optional<int> internal(const Strings &args)
727728
return 0;
728729
}
729730

731+
if (args[1] == "internal-parallel-moc")
732+
{
733+
if (args.size() != 3)
734+
{
735+
std::cout << "invalid number of arguments: " << args.size() << "\n";
736+
std::cout << "usage: cppan internal-parallel-moc moc.list\n";
737+
return 1;
738+
}
739+
740+
path file = trim_double_quotes(args[2]);
741+
auto lines = read_lines(file);
742+
auto &e = getExecutor();
743+
for (auto &line : lines)
744+
{
745+
// maybe read in stream with std::quoted
746+
auto ss = split_string(line, " ");
747+
primitives::Command c;
748+
c.working_directory = ss[0];
749+
c.args.assign(ss.begin() + 1, ss.end());
750+
e.push([c]() mutable { c.execute(); });
751+
}
752+
e.wait();
753+
754+
return 0;
755+
}
756+
730757
if (args[1] == "internal-self-upgrade-copy")
731758
{
732759
self_upgrade_copy(args[2]);

src/common/package_store.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ PackageStore::read_packages_from_file(path p, const String &config_name, bool di
359359

360360
auto read_from_cpp = [&conf, &config_name](const path &fn)
361361
{
362-
auto s = read_file(fn);
362+
auto s = read_file_without_bom(fn);
363363
auto comments = extract_comments(s);
364364

365365
std::vector<size_t> load_ok;

src/inserts/functions.cmake

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,4 +957,114 @@ function(set_once_var variable)
957957
set(CPPAN_ONCE_VARIABLES ${CPPAN_ONCE_VARIABLES} ${variable} CACHE STRING "" FORCE)
958958
endfunction()
959959

960+
########################################
961+
# FUNCTION cppan_QT5_MAKE_OUTPUT_FILE
962+
########################################
963+
964+
# macro used to create the names of output files preserving relative dirs
965+
macro(cppan_QT5_MAKE_OUTPUT_FILE infile prefix ext outfile )
966+
string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
967+
string(LENGTH ${infile} _infileLength)
968+
set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
969+
if(_infileLength GREATER _binlength)
970+
string(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
971+
if(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
972+
file(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
973+
else()
974+
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
975+
endif()
976+
else()
977+
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
978+
endif()
979+
if(WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$") # absolute path
980+
set(rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
981+
endif()
982+
set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
983+
string(REPLACE ".." "__" _outfile ${_outfile})
984+
get_filename_component(outpath ${_outfile} PATH)
985+
get_filename_component(_outfile ${_outfile} NAME_WE)
986+
file(MAKE_DIRECTORY ${outpath})
987+
set(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
988+
endmacro()
989+
990+
########################################
991+
# FUNCTION cppan_QT5_CREATE_MOC_COMMAND
992+
########################################
993+
994+
# helper macro to set up a moc rule
995+
function(cppan_QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target moc_depends)
996+
# Pass the parameters in a file. Set the working directory to
997+
# be that containing the parameters file and reference it by
998+
# just the file name. This is necessary because the moc tool on
999+
# MinGW builds does not seem to handle spaces in the path to the
1000+
# file given with the @ syntax.
1001+
get_filename_component(_moc_outfile_name "${outfile}" NAME)
1002+
get_filename_component(_moc_outfile_dir "${outfile}" PATH)
1003+
if(_moc_outfile_dir)
1004+
set(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
1005+
endif()
1006+
set (_moc_parameters_file ${outfile}_parameters)
1007+
set (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
1008+
string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
1009+
1010+
if(moc_target)
1011+
set(_moc_parameters_file ${_moc_parameters_file}$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>)
1012+
set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>")
1013+
set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>")
1014+
1015+
set(targetincludes "$<$<BOOL:${targetincludes}>:-I$<JOIN:${targetincludes},\n-I>\n>")
1016+
set(targetdefines "$<$<BOOL:${targetdefines}>:-D$<JOIN:${targetdefines},\n-D>\n>")
1017+
1018+
file (GENERATE
1019+
OUTPUT ${_moc_parameters_file}
1020+
CONTENT "${targetdefines}${targetincludes}${_moc_parameters}\n"
1021+
)
1022+
1023+
set(targetincludes)
1024+
set(targetdefines)
1025+
else()
1026+
file(WRITE ${_moc_parameters_file} "${_moc_parameters}\n")
1027+
endif()
1028+
1029+
set(_moc_extra_parameters_file @${_moc_parameters_file})
1030+
file(APPEND ${BDIR}/moc.list "\"${_moc_working_dir}\" \"${Qt5Core_MOC_EXECUTABLE}\" \"${_moc_extra_parameters_file}\"\n")
1031+
set_source_files_properties(${infile} PROPERTIES SKIP_AUTOMOC ON)
1032+
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON)
1033+
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON)
1034+
endfunction()
1035+
1036+
########################################
1037+
# FUNCTION cppan_QT5_WRAP_CPP
1038+
########################################
1039+
1040+
function(cppan_QT5_WRAP_CPP outfiles )
1041+
# get include dirs
1042+
qt5_get_moc_flags(moc_flags)
1043+
1044+
set(options)
1045+
set(oneValueArgs TARGET)
1046+
set(multiValueArgs OPTIONS DEPENDS)
1047+
1048+
cmake_parse_arguments(_WRAP_CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
1049+
1050+
set(moc_files ${_WRAP_CPP_UNPARSED_ARGUMENTS})
1051+
set(moc_options ${_WRAP_CPP_OPTIONS})
1052+
set(moc_target ${_WRAP_CPP_TARGET})
1053+
set(moc_depends ${_WRAP_CPP_DEPENDS})
1054+
1055+
if (moc_target AND CMAKE_VERSION VERSION_LESS 2.8.12)
1056+
message(FATAL_ERROR "The TARGET parameter to qt5_wrap_cpp is only available when using CMake 2.8.12 or later.")
1057+
endif()
1058+
foreach(it ${moc_files})
1059+
get_filename_component(it ${it} ABSOLUTE)
1060+
cppan_qt5_make_output_file(${it} moc_ cpp outfile)
1061+
cppan_qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
1062+
list(APPEND ${outfiles} ${outfile})
1063+
endforeach()
1064+
add_custom_command(OUTPUT ${outfiles}
1065+
COMMAND ${CPPAN_COMMAND} internal-parallel-moc ${BDIR}/moc.list
1066+
DEPENDS ${moc_files} ${moc_depends})
1067+
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
1068+
endfunction()
1069+
9601070
################################################################################

src/printers/cmake.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ void CMakePrinter::print_references(CMakeContext &ctx) const
15011501
ScopedDependencyCondition sdc(ctx, dd);
15021502
ctx.addLine("set(" + dd.reference + " " + rd[d].dependencies[dd.ppath.toString()].target_name + ")");
15031503
if (dd.ppath.is_loc())
1504-
ctx.addLine("set(" + dd.reference + "_SDIR " + normalize_path(rd.get_local_package_dir(dd.ppath.toString())) + ")");
1504+
ctx.addLine("set(" + dd.reference + "_SDIR " + normalize_path(rd.get_local_package_dir(dd.ppath)) + ")");
15051505
else
15061506
ctx.addLine("set(" + dd.reference + "_SDIR " + normalize_path(rd[d].dependencies[dd.ppath.toString()].getDirSrc()) + ")");
15071507
ctx.addLine("set(" + dd.reference + "_BDIR " + normalize_path(rd[d].dependencies[dd.ppath.toString()].getDirObj()) + ")");
@@ -2450,8 +2450,8 @@ void CMakePrinter::print_src_actions_file(const path &fn) const
24502450
ctx.addLine();
24512451
print_bs_insertion(ctx, p, "post sources", &BuildSystemConfigInsertions::post_sources);
24522452
ctx.addLine();
2453-
print_bs_insertion(ctx, p, "post target", &BuildSystemConfigInsertions::post_target);
2454-
ctx.addLine();
2453+
//print_bs_insertion(ctx, p, "post target", &BuildSystemConfigInsertions::post_target);
2454+
//ctx.addLine();
24552455
print_bs_insertion(ctx, p, "post alias", &BuildSystemConfigInsertions::post_alias);
24562456
ctx.addLine();
24572457
ctx.addLine("set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR_OLD})");

0 commit comments

Comments
 (0)