From ed4b8246ff9fc1518f373fed7ae091479c4d331e Mon Sep 17 00:00:00 2001 From: Firefly35 Date: Tue, 29 Mar 2022 22:22:01 +0200 Subject: [PATCH] feat[bazel]: parse bazel conditions file --- src/backends/BazelGeneratorBackend.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/backends/BazelGeneratorBackend.cpp b/src/backends/BazelGeneratorBackend.cpp index 99f1e33..674909c 100644 --- a/src/backends/BazelGeneratorBackend.cpp +++ b/src/backends/BazelGeneratorBackend.cpp @@ -247,8 +247,6 @@ void BazelGeneratorBackend::parseConditionsFile(const fs::path & rootFolderPath { fs::detail::utf8_codecvt_facet utf8; fs::path configureFilePath = rootFolderPath / getGeneratorFileName("configure_conditions"); - //std::map conditionsMap; - if (!fs::exists(configureFilePath)) { return; } @@ -258,18 +256,20 @@ void BazelGeneratorBackend::parseConditionsFile(const fs::path & rootFolderPath std::vector results; std::string curStr; getline(configureFile,curStr); - std::string formatRegexStr = "^[\t\s]*REMAKENDEFINES[\t\s]*=[\[]+([a-zA-Z0-9_-]*)[\]]+"; - //std::regex formatRegexr(formatRegexStr, std::regex_constants::extended); + std::string formatRegexStr = "^[\t ]*REMAKENDEFINES[\t ]*=[\t ]*[\[]+([a-zA-Z0-9_, ]*)[\]]+"; + std::regex formatRegexr(formatRegexStr, std::regex_constants::extended); std::smatch sm; - //check string format is ^[\t\s]*DEFINES[\t\s]*+=[\t\s]*[a-zA-Z0-9_-]* - // if (std::regex_search(curStr, sm, formatRegexr, std::regex_constants::match_any)) { - boost::split(results, curStr, [](char c){return c == ',';}); - if (results.size() == 2) { - std::string conditionValue = results[1]; - boost::trim(conditionValue); - conditionsMap.insert_or_assign(conditionValue, true); + if (std::regex_search(curStr, sm, formatRegexr, std::regex_constants::match_any)) { + if (sm.size() >= 2) { + std::string defines = sm[1]; + boost::split(results, defines, [](char c){return c == ',';}); + for (auto & result: results) { + std::string conditionValue = result; + boost::trim(conditionValue); + conditionsMap.insert_or_assign(conditionValue, true); + } + } } - // } } configureFile.close(); }