Replace syncqt arguments with rsp file
syncqt arguments contain full paths and may exceed the supported command line size on some platforms. Use a single rsp file to pass all arguments to syncqt. Added the missing end-of-line terminators for error messages. Change-Id: I60ad0f6770458d5256e67f042a63a3c16cd5ecb5 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 947dd880cc2c1fc7973c0439ff8393e0f63f96a0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e9479d2a22
commit
80f9966c90
@ -134,34 +134,33 @@ function(qt_internal_target_sync_headers target module_headers module_headers_ge
|
||||
list(FILTER module_headers EXCLUDE REGEX
|
||||
"(.+/(ui_)[^/]+\\.h|${CMAKE_CURRENT_SOURCE_DIR}(/.+)?/doc/+\\.h)")
|
||||
|
||||
set(module_headers_rsp "${binary_dir_real}/${target}_module_headers")
|
||||
list(JOIN module_headers "\n" module_headers_string)
|
||||
qt_configure_file_v2(OUTPUT "${module_headers_rsp}" CONTENT "${module_headers_string}")
|
||||
|
||||
set(module_headers_generated_rsp "${binary_dir_real}/${target}_module_headers_generated")
|
||||
list(JOIN module_headers_generated "\n" module_headers_generated_string)
|
||||
qt_configure_file_v2(OUTPUT "${module_headers_generated_rsp}" CONTENT
|
||||
"${module_headers_generated_string}")
|
||||
|
||||
set(syncqt_staging_dir "${module_build_interface_include_dir}/.syncqt_staging")
|
||||
|
||||
set(syncqt_args "${common_syncqt_arguments}")
|
||||
list(APPEND syncqt_args
|
||||
${common_syncqt_arguments}
|
||||
-headers ${module_headers}
|
||||
-generatedHeaders ${module_headers_generated}
|
||||
-stagingDir "${syncqt_staging_dir}"
|
||||
-knownModules ${known_modules}
|
||||
${framework_args}
|
||||
${version_script_args}
|
||||
)
|
||||
list(JOIN syncqt_args "\n" syncqt_args_string)
|
||||
set(syncqt_args_rsp "${binary_dir_real}/${target}_syncqt_args")
|
||||
qt_configure_file_v2(OUTPUT "${syncqt_args_rsp}" CONTENT "${syncqt_args_string}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${syncqt_outputs}
|
||||
COMMAND
|
||||
${QT_CMAKE_EXPORT_NAMESPACE}::syncqt
|
||||
${common_syncqt_arguments}
|
||||
"@${syncqt_args_rsp}"
|
||||
${build_time_syncqt_arguments}
|
||||
-headers "@${module_headers_rsp}"
|
||||
-generatedHeaders "@${module_headers_generated_rsp}"
|
||||
-stagingDir "${syncqt_staging_dir}"
|
||||
-knownModules ${known_modules}
|
||||
${framework_args}
|
||||
${version_script_args}
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E touch "${syncqt_timestamp}"
|
||||
DEPENDS
|
||||
${module_headers_rsp}
|
||||
${module_headers_generated_rsp}
|
||||
${syncqt_args_rsp}
|
||||
${module_headers}
|
||||
${QT_CMAKE_EXPORT_NAMESPACE}::syncqt
|
||||
COMMENT
|
||||
@ -178,13 +177,17 @@ function(qt_internal_target_sync_headers target module_headers module_headers_ge
|
||||
# available for qdoc.
|
||||
# ${target}_sync_headers is added as dependency to make sure that
|
||||
# ${target}_sync_all_public_headers is running after ${target}_sync_headers, when building docs.
|
||||
set(syncqt_all_args "${common_syncqt_arguments};-all")
|
||||
list(JOIN syncqt_all_args "\n" syncqt_all_args_string)
|
||||
set(syncqt_all_args_rsp "${binary_dir_real}/${target}_syncqt_all_args")
|
||||
qt_configure_file_v2(OUTPUT "${syncqt_all_args_rsp}" CONTENT "${syncqt_all_args_string}")
|
||||
add_custom_target(${target}_sync_all_public_headers
|
||||
COMMAND
|
||||
${QT_CMAKE_EXPORT_NAMESPACE}::syncqt
|
||||
${common_syncqt_arguments}
|
||||
-all
|
||||
"@${syncqt_all_args_rsp}"
|
||||
DEPENDS
|
||||
${module_headers}
|
||||
${syncqt_all_args_rsp}
|
||||
${QT_CMAKE_EXPORT_NAMESPACE}::syncqt
|
||||
${target}_sync_headers
|
||||
VERBATIM
|
||||
@ -223,12 +226,7 @@ function(qt_internal_target_sync_headers target module_headers module_headers_ge
|
||||
execute_process(
|
||||
COMMAND
|
||||
${syncqt_location}
|
||||
${common_syncqt_arguments}
|
||||
-headers "@${module_headers_rsp}"
|
||||
-generatedHeaders "@${module_headers_generated_rsp}"
|
||||
-stagingDir "${syncqt_staging_dir}"
|
||||
-knownModules ${known_modules}
|
||||
${framework_args}
|
||||
"@${syncqt_args_rsp}"
|
||||
RESULT_VARIABLE syncqt_result
|
||||
OUTPUT_VARIABLE syncqt_output
|
||||
ERROR_VARIABLE syncqt_output
|
||||
|
@ -264,7 +264,6 @@ private:
|
||||
std::string qpaHeadersFilter;
|
||||
std::string privateHeadersFilter;
|
||||
std::string publicNamespaceFilter;
|
||||
std::set<std::string> generatedHeaders;
|
||||
static std::unordered_map<std::string, CommandLineOption<std::string>> stringArgumentMap = {
|
||||
{ "-module", { &m_moduleName } },
|
||||
{ "-sourceDir", { &m_sourceDir } },
|
||||
@ -283,7 +282,7 @@ private:
|
||||
static const std::unordered_map<std::string, CommandLineOption<std::set<std::string>>>
|
||||
listArgumentMap = {
|
||||
{ "-headers", { &m_headers, true } },
|
||||
{ "-generatedHeaders", { &generatedHeaders, true } },
|
||||
{ "-generatedHeaders", { &m_generatedHeaders, true } },
|
||||
{ "-knownModules", { &m_knownModules, true } },
|
||||
};
|
||||
|
||||
@ -298,11 +297,8 @@ private:
|
||||
|
||||
std::string *currentValue = nullptr;
|
||||
std::set<std::string> *currentListValue = nullptr;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::string arg(argv[i]);
|
||||
if (arg.empty())
|
||||
continue;
|
||||
|
||||
auto parseArgument = [¤tValue, ¤tListValue](const std::string &arg) -> bool {
|
||||
if (arg[0] == '-') {
|
||||
currentValue = nullptr;
|
||||
currentListValue = nullptr;
|
||||
@ -314,7 +310,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
currentValue = it->second.value;
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,7 +322,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
*(it->second.value) = true;
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,22 +334,50 @@ private:
|
||||
return false;
|
||||
}
|
||||
currentListValue = it->second.value;
|
||||
continue;
|
||||
currentListValue->insert(""); // Indicate that argument is provided
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << "Unknown argument: " << arg << std::endl;
|
||||
return false;
|
||||
} else {
|
||||
if (currentValue != nullptr) {
|
||||
*currentValue = arg;
|
||||
currentValue = nullptr;
|
||||
} else if (currentListValue != nullptr) {
|
||||
currentListValue->insert(arg);
|
||||
} else {
|
||||
std::cerr << "Unknown argument: " << arg << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentValue != nullptr) {
|
||||
*currentValue = arg;
|
||||
currentValue = nullptr;
|
||||
} else if (currentListValue != nullptr) {
|
||||
currentListValue->insert(arg);
|
||||
} else {
|
||||
std::cerr << "Unknown argument: " << arg << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::string arg(argv[i]);
|
||||
if (arg.empty())
|
||||
continue;
|
||||
|
||||
if (arg[0] == '@') {
|
||||
std::ifstream ifs(arg.substr(1), std::ifstream::in);
|
||||
if (!ifs.is_open()) {
|
||||
std::cerr << "Unable to open rsp file: " << arg[0] << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::string argFromFile;
|
||||
while (std::getline(ifs, argFromFile)) {
|
||||
if (argFromFile.empty())
|
||||
continue;
|
||||
if (!parseArgument(argFromFile))
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!parseArgument(arg))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_printHelpOnly)
|
||||
@ -369,32 +393,18 @@ private:
|
||||
m_publicNamespaceRegex = std::regex(publicNamespaceFilter);
|
||||
|
||||
if (m_headers.empty() && !m_scanAllMode) {
|
||||
std::cerr << "You need to specify either -headers or -all option.";
|
||||
std::cerr << "You need to specify either -headers or -all option." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_headers.empty() && m_scanAllMode) {
|
||||
std::cerr << "Both -headers and -all are specified. Need to choose only one"
|
||||
"operational mode.";
|
||||
"operational mode." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto &header : generatedHeaders) {
|
||||
if (header.empty())
|
||||
continue;
|
||||
if (header[0] == '@') {
|
||||
std::ifstream ifs(header.substr(1), std::ifstream::in);
|
||||
if (ifs.is_open()) {
|
||||
std::string headerFromFile;
|
||||
while (std::getline(ifs, headerFromFile)) {
|
||||
if (!headerFromFile.empty())
|
||||
m_generatedHeaders.insert(headerFromFile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_generatedHeaders.insert(header);
|
||||
}
|
||||
}
|
||||
for (const auto &argument : listArgumentMap)
|
||||
argument.second.value->erase("");
|
||||
|
||||
bool ret = true;
|
||||
ret &= checkRequiredArguments(stringArgumentMap);
|
||||
@ -566,16 +576,7 @@ public:
|
||||
const auto &headers = m_commandLineArgs->headers();
|
||||
for (auto it = headers.begin(); it != headers.end(); ++it) {
|
||||
const auto &header = *it;
|
||||
if (!header.empty() && header[0] == '@') {
|
||||
std::ifstream ifs(header.substr(1), std::ifstream::in);
|
||||
if (ifs.is_open()) {
|
||||
std::string headerFromFile;
|
||||
while (std::getline(ifs, headerFromFile)) {
|
||||
if (!headerFromFile.empty())
|
||||
rspHeaders.insert(headerFromFile);
|
||||
}
|
||||
}
|
||||
} else if (!processHeader(makeHeaderAbsolute(header))) {
|
||||
if (!processHeader(makeHeaderAbsolute(header))) {
|
||||
error = SyncFailed;
|
||||
}
|
||||
}
|
||||
@ -734,7 +735,7 @@ public:
|
||||
|
||||
// Check if a directory is passed as argument. That shouldn't happen, print error and exit.
|
||||
if (m_currentFilename.empty()) {
|
||||
std::cerr << "Header file name of " << m_currentFileString << "is empty";
|
||||
std::cerr << "Header file name of " << m_currentFileString << "is empty" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user