diff options
Diffstat (limited to 'Source/cmExportCommand.cxx')
-rw-r--r-- | Source/cmExportCommand.cxx | 106 |
1 files changed, 103 insertions, 3 deletions
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 7e44210..7d23c91 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -8,6 +8,7 @@ #include <cm/memory> #include <cm/optional> +#include <cmext/algorithm> #include <cmext/string_view> #include "cmsys/RegularExpression.hxx" @@ -24,10 +25,12 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmValue.h" #if defined(__HAIKU__) # include <FindDirectory.h> @@ -66,6 +69,11 @@ bool cmExportCommand(std::vector<std::string> const& args, std::string CxxModulesDirectory; bool Append = false; bool ExportOld = false; + + std::vector<std::vector<std::string>> PackageDependencyArgs; + bool ExportPackageDependencies = false; + + std::vector<std::vector<std::string>> TargetArgs; }; auto parser = @@ -75,7 +83,13 @@ bool cmExportCommand(std::vector<std::string> const& args, .Bind("CXX_MODULES_DIRECTORY"_s, &Arguments::CxxModulesDirectory); if (args[0] == "EXPORT") { - parser.Bind("EXPORT"_s, &Arguments::ExportSetName); + parser.Bind("EXPORT"_s, &Arguments::ExportSetName) + .Bind("EXPORT_PACKAGE_DEPENDENCIES"_s, + &Arguments::ExportPackageDependencies); + } else if (args[0] == "SETUP") { + parser.Bind("SETUP"_s, &Arguments::ExportSetName); + parser.Bind("PACKAGE_DEPENDENCY"_s, &Arguments::PackageDependencyArgs); + parser.Bind("TARGET"_s, &Arguments::TargetArgs); } else { parser.Bind("TARGETS"_s, &Arguments::Targets); parser.Bind("ANDROID_MK"_s, &Arguments::AndroidMKFile); @@ -91,6 +105,91 @@ bool cmExportCommand(std::vector<std::string> const& args, return false; } + if (args[0] == "SETUP") { + cmMakefile& mf = status.GetMakefile(); + cmGlobalGenerator* gg = mf.GetGlobalGenerator(); + + cmExportSetMap& setMap = gg->GetExportSets(); + auto& exportSet = setMap[arguments.ExportSetName]; + + struct PackageDependencyArguments + { + std::string Enabled; + ArgumentParser::MaybeEmpty<std::vector<std::string>> ExtraArgs; + }; + + auto packageDependencyParser = + cmArgumentParser<PackageDependencyArguments>{} + .Bind("ENABLED"_s, &PackageDependencyArguments::Enabled) + .Bind("EXTRA_ARGS"_s, &PackageDependencyArguments::ExtraArgs); + + for (auto const& packageDependencyArgs : arguments.PackageDependencyArgs) { + if (packageDependencyArgs.empty()) { + continue; + } + + PackageDependencyArguments const packageDependencyArguments = + packageDependencyParser.Parse( + cmMakeRange(packageDependencyArgs).advance(1), &unknownArgs); + + if (!unknownArgs.empty()) { + status.SetError("Unknown argument: \"" + unknownArgs.front() + "\"."); + return false; + } + + auto& packageDependency = + exportSet.GetPackageDependencyForSetup(packageDependencyArgs.front()); + + if (!packageDependencyArguments.Enabled.empty()) { + if (packageDependencyArguments.Enabled == "AUTO") { + packageDependency.Enabled = + cmExportSet::PackageDependencyExportEnabled::Auto; + } else if (cmIsOff(packageDependencyArguments.Enabled)) { + packageDependency.Enabled = + cmExportSet::PackageDependencyExportEnabled::Off; + } else if (cmIsOn(packageDependencyArguments.Enabled)) { + packageDependency.Enabled = + cmExportSet::PackageDependencyExportEnabled::On; + } else { + status.SetError( + cmStrCat("Invalid enable setting for package dependency: \"", + packageDependencyArguments.Enabled, "\"")); + return false; + } + } + + cm::append(packageDependency.ExtraArguments, + packageDependencyArguments.ExtraArgs); + } + + struct TargetArguments + { + std::string XcFrameworkLocation; + }; + + auto targetParser = cmArgumentParser<TargetArguments>{}.Bind( + "XCFRAMEWORK_LOCATION"_s, &TargetArguments::XcFrameworkLocation); + + for (auto const& targetArgs : arguments.TargetArgs) { + if (targetArgs.empty()) { + continue; + } + + TargetArguments const targetArguments = + targetParser.Parse(cmMakeRange(targetArgs).advance(1), &unknownArgs); + + if (!unknownArgs.empty()) { + status.SetError("Unknown argument: \"" + unknownArgs.front() + "\"."); + return false; + } + + exportSet.SetXcFrameworkLocation(targetArgs.front(), + targetArguments.XcFrameworkLocation); + } + + return true; + } + std::string fname; bool android = false; if (!arguments.AndroidMKFile.empty()) { @@ -133,7 +232,7 @@ bool cmExportCommand(std::vector<std::string> const& args, fname = dir + "/" + fname; } - std::vector<std::string> targets; + std::vector<cmExportBuildFileGenerator::TargetExport> targets; cmGlobalGenerator* gg = mf.GetGlobalGenerator(); @@ -171,7 +270,7 @@ bool cmExportCommand(std::vector<std::string> const& args, status.SetError(e.str()); return false; } - targets.push_back(currentTarget); + targets.emplace_back(currentTarget, std::string{}); } if (arguments.Append) { if (cmExportBuildFileGenerator* ebfg = @@ -224,6 +323,7 @@ bool cmExportCommand(std::vector<std::string> const& args, ebfg->SetTargets(targets); } ebfg->SetExportOld(arguments.ExportOld); + ebfg->SetExportPackageDependencies(arguments.ExportPackageDependencies); // Compute the set of configurations exported. std::vector<std::string> configurationTypes = |