Cleanup vcpkg.json generation a little

main
cursey 3 years ago
parent b4b0f533a9
commit 084cbd6159
No known key found for this signature in database
GPG Key ID: A6A7163A1B8FD42C

@ -611,24 +611,25 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
const auto &packages = project.vcpkg.packages; const auto &packages = project.vcpkg.packages;
for (size_t i = 0; i < packages.size(); i++) { for (size_t i = 0; i < packages.size(); i++) {
const auto &package = packages[i]; const auto &package = packages[i];
const auto &features = package.features;
if (!vcpkg_valid_identifier(package.name)) { if (!vcpkg_valid_identifier(package.name)) {
throw std::runtime_error("Invalid vcpkg package name '" + package.name + "'"); throw std::runtime_error("Invalid vcpkg package name '" + package.name + "'");
} }
for (const auto &feature : package.features) { for (const auto &feature : features) {
if (!vcpkg_valid_identifier(feature)) { if (!vcpkg_valid_identifier(feature)) {
throw std::runtime_error("Invalid vcpkg package feature '" + feature + "'"); throw std::runtime_error("Invalid vcpkg package feature '" + feature + "'");
} }
} }
if (package.features.empty()) { if (features.empty()) {
ofs << " \"" << package.name << '\"'; ofs << " \"" << package.name << '\"';
} else { } else {
ofs << " {\n"; ofs << " {\n";
ofs << " \"name\": \"" << package.name << "\",\n"; ofs << " \"name\": \"" << package.name << "\",\n";
ofs << " \"features\": ["; ofs << " \"features\": [";
for (size_t j = 0; j < package.features.size(); j++) { for (size_t j = 0; j < features.size(); j++) {
const auto &feature = package.features[j]; const auto &feature = features[j];
ofs << '\"' << feature << '\"'; ofs << '\"' << feature << '\"';
if (j + 1 < package.features.size()) { if (j + 1 < features.size()) {
ofs << ','; ofs << ',';
} }
} }

Loading…
Cancel
Save