Skip to content

Commit 9f89d1a

Browse files
committed
Implement parallel moc.
1 parent dac5f98 commit 9f89d1a

2 files changed

Lines changed: 30 additions & 19 deletions

File tree

src/client/main.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -738,15 +738,19 @@ optional<int> internal(const Strings &args)
738738
}
739739

740740
path file = trim_double_quotes(args[2]);
741-
auto lines = read_lines(file);
741+
std::istringstream f(read_file(file));
742742
auto &e = getExecutor();
743-
for (auto &line : lines)
743+
while (1)
744744
{
745-
// maybe read in stream with std::quoted
746-
auto ss = split_string(line, " ");
745+
std::string wd, prog, arg;
746+
f >> std::quoted(wd);
747+
if (!f)
748+
break;
749+
f >> std::quoted(prog) >> std::quoted(arg);
747750
primitives::Command c;
748-
c.working_directory = ss[0];
749-
c.args.assign(ss.begin() + 1, ss.end());
751+
c.working_directory = wd;
752+
c.program = prog;
753+
c.args.push_back(arg);
750754
e.push([c]() mutable { c.execute(); });
751755
}
752756
e.wait();

src/inserts/functions.cmake

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -958,11 +958,11 @@ function(set_once_var variable)
958958
endfunction()
959959

960960
########################################
961-
# FUNCTION cppan_QT5_MAKE_OUTPUT_FILE
961+
# FUNCTION cppan_qt5_make_output_file
962962
########################################
963963

964964
# macro used to create the names of output files preserving relative dirs
965-
macro(cppan_QT5_MAKE_OUTPUT_FILE infile prefix ext outfile )
965+
macro(cppan_qt5_make_output_file infile prefix ext outfile )
966966
string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
967967
string(LENGTH ${infile} _infileLength)
968968
set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
@@ -988,11 +988,11 @@ macro(cppan_QT5_MAKE_OUTPUT_FILE infile prefix ext outfile )
988988
endmacro()
989989

990990
########################################
991-
# FUNCTION cppan_QT5_CREATE_MOC_COMMAND
991+
# FUNCTION cppan_qt5_create_moc_command
992992
########################################
993993

994994
# 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)
995+
function(cppan_qt5_create_moc_command infile outfile moc_flags moc_options moc_target moc_depends)
996996
# Pass the parameters in a file. Set the working directory to
997997
# be that containing the parameters file and reference it by
998998
# just the file name. This is necessary because the moc tool on
@@ -1001,7 +1001,7 @@ function(cppan_QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_t
10011001
get_filename_component(_moc_outfile_name "${outfile}" NAME)
10021002
get_filename_component(_moc_outfile_dir "${outfile}" PATH)
10031003
if(_moc_outfile_dir)
1004-
set(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
1004+
set(_moc_working_dir ${_moc_outfile_dir})
10051005
endif()
10061006
set (_moc_parameters_file ${outfile}_parameters)
10071007
set (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
@@ -1027,17 +1027,17 @@ function(cppan_QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_t
10271027
endif()
10281028

10291029
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")
1030+
file(APPEND ${BDIR}/moc.list "\"${_moc_working_dir}\" \"$<TARGET_FILE:${Qt5Core_MOC_EXECUTABLE}>\" \"${_moc_extra_parameters_file}\"\n")
10311031
set_source_files_properties(${infile} PROPERTIES SKIP_AUTOMOC ON)
10321032
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON)
10331033
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON)
10341034
endfunction()
10351035

10361036
########################################
1037-
# FUNCTION cppan_QT5_WRAP_CPP
1037+
# FUNCTION cppan_qt5_wrap_cpp
10381038
########################################
10391039

1040-
function(cppan_QT5_WRAP_CPP outfiles )
1040+
function(cppan_qt5_wrap_cpp outfiles)
10411041
# get include dirs
10421042
qt5_get_moc_flags(moc_flags)
10431043

@@ -1055,16 +1055,23 @@ function(cppan_QT5_WRAP_CPP outfiles )
10551055
if (moc_target AND CMAKE_VERSION VERSION_LESS 2.8.12)
10561056
message(FATAL_ERROR "The TARGET parameter to qt5_wrap_cpp is only available when using CMake 2.8.12 or later.")
10571057
endif()
1058+
file(WRITE ${BDIR}/moc.list "")
1059+
set(lst)
10581060
foreach(it ${moc_files})
10591061
get_filename_component(it ${it} ABSOLUTE)
10601062
cppan_qt5_make_output_file(${it} moc_ cpp outfile)
10611063
cppan_qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
1062-
list(APPEND ${outfiles} ${outfile})
1064+
list(APPEND lst ${outfile})
10631065
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)
1066+
file(READ ${BDIR}/moc.list f)
1067+
file(GENERATE OUTPUT ${BDIR}/moc_$<CONFIGURATION>.list CONTENT "${f}")
1068+
list(LENGTH lst N)
1069+
if (${N} GREATER 0)
1070+
add_custom_command(OUTPUT ${lst}
1071+
COMMAND ${CPPAN_COMMAND} internal-parallel-moc ${BDIR}/moc_$<CONFIGURATION>.list
1072+
DEPENDS ${moc_files} ${moc_depends})
1073+
set(${outfiles} ${lst} PARENT_SCOPE)
1074+
endif()
10681075
endfunction()
10691076

10701077
################################################################################

0 commit comments

Comments
 (0)