diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index d69b10cca3..1257d9f5c1 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -3094,3 +3094,5 @@ DECLARE_MESSAGE(WhileParsingVersionsForPort, DECLARE_MESSAGE(WhileValidatingVersion, (msg::version), "", "while validating version: {version}") DECLARE_MESSAGE(WindowsOnlyCommand, (), "", "This command only supports Windows.") DECLARE_MESSAGE(WroteNuGetPkgConfInfo, (msg::path), "", "Wrote NuGet package config information to {path}") +DECLARE_MESSAGE(AProgrammingLanguage, (), "", "a string representing a programming languages") +DECLARE_MESSAGE(AnArrayOfProgrammingLanguages, (), "", "an array of strings containing programming languages") diff --git a/include/vcpkg/binaryparagraph.h b/include/vcpkg/binaryparagraph.h index 08280c2f77..6cd53a9421 100644 --- a/include/vcpkg/binaryparagraph.h +++ b/include/vcpkg/binaryparagraph.h @@ -36,6 +36,7 @@ namespace vcpkg Version version; std::vector description; std::vector maintainers; + std::vector languages; std::string feature; std::vector default_features; std::vector dependencies; diff --git a/include/vcpkg/commands.build.h b/include/vcpkg/commands.build.h index 8929386791..bf74416c66 100644 --- a/include/vcpkg/commands.build.h +++ b/include/vcpkg/commands.build.h @@ -291,10 +291,12 @@ namespace vcpkg const Toolset& toolset); const std::string& get_triplet_info(const VcpkgPaths& paths, const PreBuildInfo& pre_build_info, - const Toolset& toolset); + const Toolset& toolset, + const std::set& languages); const CompilerInfo& get_compiler_info(const VcpkgPaths& paths, const PreBuildInfo& pre_build_info, - const Toolset& toolset); + const Toolset& toolset, + const std::set& languages); private: struct TripletMapEntry diff --git a/include/vcpkg/sourceparagraph.h b/include/vcpkg/sourceparagraph.h index 45bb97e118..115ce58498 100644 --- a/include/vcpkg/sourceparagraph.h +++ b/include/vcpkg/sourceparagraph.h @@ -90,6 +90,7 @@ namespace vcpkg { std::string name; std::vector description; + std::vector languages; std::vector dependencies; PlatformExpression::Expr supports_expression; // there are two distinct "empty" states here @@ -114,6 +115,7 @@ namespace vcpkg std::vector description; std::vector summary; std::vector maintainers; + std::vector languages; std::string homepage; std::string documentation; std::vector dependencies; diff --git a/include/vcpkg/vcpkgpaths.h b/include/vcpkg/vcpkgpaths.h index 90fd4d093c..9980b75855 100644 --- a/include/vcpkg/vcpkgpaths.h +++ b/include/vcpkg/vcpkgpaths.h @@ -143,8 +143,8 @@ namespace vcpkg const Toolset& get_toolset(const PreBuildInfo& prebuildinfo) const; const Environment& get_action_env(const PreBuildInfo& pre_build_info, const Toolset& toolset) const; - const std::string& get_triplet_info(const PreBuildInfo& pre_build_info, const Toolset& toolset) const; - const CompilerInfo& get_compiler_info(const PreBuildInfo& pre_build_info, const Toolset& toolset) const; + const std::string& get_triplet_info(const PreBuildInfo& pre_build_info, const Toolset& toolset, const std::set& languages) const; + const CompilerInfo& get_compiler_info(const PreBuildInfo& pre_build_info, const Toolset& toolset, const std::set& languages) const; const FeatureFlagSettings& get_feature_flags() const; diff --git a/src/vcpkg/binarycaching.cpp b/src/vcpkg/binarycaching.cpp index ab702db54a..ddd641b7c4 100644 --- a/src/vcpkg/binarycaching.cpp +++ b/src/vcpkg/binarycaching.cpp @@ -2424,9 +2424,9 @@ std::string vcpkg::generate_nuspec(const Path& package_dir, version, "\nTriplet: ", spec.triplet().to_string(), - "\nCXX Compiler id: ", + "\nCompiler id: ", compiler_info.id, - "\nCXX Compiler version: ", + "\nCompiler version: ", compiler_info.version, "\nTriplet/Compiler hash: ", abi_info.triplet_abi.value_or_exit(VCPKG_LINE_INFO), diff --git a/src/vcpkg/binaryparagraph.cpp b/src/vcpkg/binaryparagraph.cpp index a6211ca2d0..be7cf5c3d7 100644 --- a/src/vcpkg/binaryparagraph.cpp +++ b/src/vcpkg/binaryparagraph.cpp @@ -13,6 +13,7 @@ namespace vcpkg static constexpr StringLiteral PACKAGE = "Package"; static constexpr StringLiteral VERSION = "Version"; static constexpr StringLiteral PORT_VERSION = "Port-Version"; + static constexpr StringLiteral LANGUAGES = "Languages"; static constexpr StringLiteral ARCHITECTURE = "Architecture"; static constexpr StringLiteral MULTI_ARCH = "Multi-Arch"; } @@ -52,6 +53,7 @@ namespace vcpkg parser.add_error(pv_position, msgPortVersionControlMustBeANonNegativeInteger); } } + this->languages = Strings::split(parser.optional_field(Fields::LANGUAGES), '\n'); this->feature = parser.optional_field(Fields::FEATURE); this->description = Strings::split(parser.optional_field(Fields::DESCRIPTION), '\n'); @@ -103,6 +105,7 @@ namespace vcpkg , version(spgh.version) , description(spgh.description) , maintainers(spgh.maintainers) + , languages(spgh.languages) , feature() , default_features(default_features) , dependencies(std::move(deps)) @@ -118,6 +121,7 @@ namespace vcpkg , version() , description(fpgh.description) , maintainers() + , languages(fpgh.languages) , feature(fpgh.name) , default_features() , dependencies(std::move(deps)) @@ -133,6 +137,7 @@ namespace vcpkg }; Util::sort_unique_erase(this->dependencies); + Util::sort_unique_erase(this->languages); for (auto& maintainer : this->maintainers) { @@ -143,6 +148,11 @@ namespace vcpkg this->maintainers.clear(); } + if (all_empty(this->languages)) + { + this->languages.clear(); + } + for (auto& desc : this->description) { Strings::inplace_trim(desc); @@ -176,6 +186,7 @@ namespace vcpkg if (lhs.version != rhs.version) return false; if (lhs.description != rhs.description) return false; if (lhs.maintainers != rhs.maintainers) return false; + if (lhs.languages != rhs.languages) return false; if (lhs.feature != rhs.feature) return false; if (lhs.default_features != rhs.default_features) return false; if (lhs.dependencies != rhs.dependencies) return false; @@ -240,6 +251,11 @@ namespace vcpkg fmt::format_to(std::back_inserter(out_str), "{}: {}\n", Fields::PORT_VERSION, pgh.version.port_version); } + if (!pgh.languages.empty()) + { + serialize_array(Fields::LANGUAGES, pgh.languages, out_str); + } + if (pgh.is_feature()) { serialize_string(Fields::FEATURE, pgh.feature, out_str); @@ -291,11 +307,12 @@ namespace vcpkg { static constexpr StringLiteral join_str = R"(", ")"; return fmt::format( - "\nspec: \"{}\"\nversion: \"{}\"\nport_version: {}\ndescription: [\"{}\"]\nmaintainers: [\"{}\"]\nfeature: " + "\nspec: \"{}\"\nversion: \"{}\"\nport_version: {}\nlanguages: [\"{}\"]\ndescription: [\"{}\"]\nmaintainers: [\"{}\"]\nfeature: " "\"{}\"\ndefault_features: [\"{}\"]\ndependencies: [\"{}\"]\nabi: \"{}\"", paragraph.spec.to_string(), paragraph.version.text, paragraph.version.port_version, + Strings::join(join_str, paragraph.languages), Strings::join(join_str, paragraph.description), Strings::join(join_str, paragraph.maintainers), paragraph.feature, diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index bee75ac440..d184a8245e 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -487,7 +487,8 @@ namespace vcpkg static CompilerInfo load_compiler_info(const VcpkgPaths& paths, const PreBuildInfo& pre_build_info, - const Toolset& toolset); + const Toolset& toolset, + const std::set& languages); static const std::string& get_toolchain_cache(Cache& cache, const Path& tcfile, @@ -507,7 +508,8 @@ namespace vcpkg const CompilerInfo& EnvCache::get_compiler_info(const VcpkgPaths& paths, const PreBuildInfo& pre_build_info, - const Toolset& toolset) + const Toolset& toolset, + const std::set& languages) { if (!m_compiler_tracking || pre_build_info.disable_compiler_tracking) { @@ -526,7 +528,7 @@ namespace vcpkg return triplet_entry.compiler_info.get_lazy(toolchain_hash, [&]() -> CompilerInfo { if (m_compiler_tracking) { - return load_compiler_info(paths, pre_build_info, toolset); + return load_compiler_info(paths, pre_build_info, toolset, languages); } else { @@ -537,7 +539,8 @@ namespace vcpkg const std::string& EnvCache::get_triplet_info(const VcpkgPaths& paths, const PreBuildInfo& pre_build_info, - const Toolset& toolset) + const Toolset& toolset, + const std::set& languages) { const auto& fs = paths.get_filesystem(); const auto& triplet_file_path = paths.get_triplet_db().get_triplet_file_path(pre_build_info.triplet); @@ -549,7 +552,7 @@ namespace vcpkg if (m_compiler_tracking && !pre_build_info.disable_compiler_tracking) { return triplet_entry.triplet_infos.get_lazy(toolchain_hash, [&]() -> std::string { - auto& compiler_info = get_compiler_info(paths, pre_build_info, toolset); + auto& compiler_info = get_compiler_info(paths, pre_build_info, toolset, languages); return Strings::concat(triplet_entry.hash, '-', toolchain_hash, '-', compiler_info.hash); }); } @@ -664,18 +667,28 @@ namespace vcpkg static CompilerInfo load_compiler_info(const VcpkgPaths& paths, const PreBuildInfo& pre_build_info, - const Toolset& toolset) + const Toolset& toolset, + const std::set& languages) { auto& triplet = pre_build_info.triplet; msg::println(msgDetectCompilerHash, msg::triplet = triplet); auto buildpath = paths.buildtrees() / "detect_compiler"; + std::string languages_list {""}; + for(const auto& language: languages) { + if(!languages_list.empty()) { + languages_list.append(";"); + } + languages_list.append(language); + } + std::vector cmake_args{ {"CURRENT_PORT_DIR", paths.scripts / "detect_compiler"}, {"CURRENT_BUILDTREES_DIR", buildpath}, {"CURRENT_PACKAGES_DIR", paths.packages() / ("detect_compiler_" + triplet.canonical_name())}, // The detect_compiler "port" doesn't depend on the host triplet, so always natively compile {"_HOST_TRIPLET", triplet.canonical_name()}, + {"USED_LANGUAGES", languages_list}, }; get_generic_cmake_build_args(paths, triplet, toolset, cmake_args); @@ -1118,6 +1131,7 @@ namespace vcpkg static void populate_abi_tag(const VcpkgPaths& paths, InstallPlanAction& action, std::unique_ptr&& proto_pre_build_info, + const std::set& langs, Span dependency_abis, Cache>& grdk_cache) { @@ -1139,7 +1153,7 @@ namespace vcpkg return; } - abi_info.compiler_info = paths.get_compiler_info(*abi_info.pre_build_info, toolset); + abi_info.compiler_info = paths.get_compiler_info(*abi_info.pre_build_info, toolset, langs); for (auto&& dep_abi : dependency_abis) { if (dep_abi.value.empty()) @@ -1155,7 +1169,7 @@ namespace vcpkg std::vector abi_tag_entries(dependency_abis.begin(), dependency_abis.end()); - const auto& triplet_abi = paths.get_triplet_info(pre_build_info, toolset); + const auto& triplet_abi = paths.get_triplet_info(pre_build_info, toolset, langs); abi_info.triplet_abi.emplace(triplet_abi); const auto& triplet_canonical_name = action.spec.triplet().canonical_name(); abi_tag_entries.emplace_back("triplet", triplet_canonical_name); @@ -1283,6 +1297,24 @@ namespace vcpkg const StatusParagraphs& status_db) { Cache> grdk_cache; + + std::set languages; + for(const auto& action: action_plan.install_actions) + { + const auto& scfl = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO); + const auto& scf = scfl.source_control_file; + const auto langs = scf->core_paragraph->languages; + if(!langs.empty()) + { + languages.insert(langs.begin(),langs.end()); + } + } + if(languages.empty()) + { + languages.emplace("C"); + languages.emplace("CXX"); + } + for (auto it = action_plan.install_actions.begin(); it != action_plan.install_actions.end(); ++it) { auto& action = *it; @@ -1323,6 +1355,7 @@ namespace vcpkg std::make_unique(paths, action.spec.triplet(), var_provider.get_tag_vars(action.spec).value_or_exit(VCPKG_LINE_INFO)), + languages, dependency_abis, grdk_cache); } diff --git a/src/vcpkg/sourceparagraph.cpp b/src/vcpkg/sourceparagraph.cpp index af1989c4af..d913f511da 100644 --- a/src/vcpkg/sourceparagraph.cpp +++ b/src/vcpkg/sourceparagraph.cpp @@ -109,6 +109,7 @@ namespace vcpkg if (lhs.version != rhs.version) return false; if (!paragraph_equal(lhs.description, rhs.description)) return false; if (!paragraph_equal(lhs.maintainers, rhs.maintainers)) return false; + if (!paragraph_equal(lhs.languages, rhs.languages)) return false; if (lhs.homepage != rhs.homepage) return false; if (lhs.documentation != rhs.documentation) return false; if (lhs.dependencies != rhs.dependencies) return false; @@ -150,6 +151,7 @@ namespace vcpkg static constexpr StringLiteral DESCRIPTION = "Description"; static constexpr StringLiteral FEATURE = "Feature"; static constexpr StringLiteral MAINTAINERS = "Maintainer"; + static constexpr StringLiteral LANGUAGES = "Languages"; static constexpr StringLiteral NAME = "Source"; static constexpr StringLiteral VERSION = "Version"; static constexpr StringLiteral PORT_VERSION = "Port-Version"; @@ -315,6 +317,9 @@ namespace vcpkg } } + spgh->languages = Strings::split(parser.optional_field(SourceParagraphFields::LANGUAGES), '\n'); + trim_all(spgh->languages); + spgh->description = Strings::split(parser.optional_field(SourceParagraphFields::DESCRIPTION), '\n'); trim_all(spgh->description); @@ -1025,10 +1030,11 @@ namespace vcpkg constexpr static StringLiteral DEPENDENCIES = "dependencies"; constexpr static StringLiteral SUPPORTS = "supports"; constexpr static StringLiteral LICENSE = "license"; + constexpr static StringLiteral LANGUAGES = "languages"; virtual Span valid_fields() const override { - static constexpr StringView t[] = {DESCRIPTION, DEPENDENCIES, SUPPORTS, LICENSE}; + static constexpr StringView t[] = {DESCRIPTION, DEPENDENCIES, SUPPORTS, LICENSE, LANGUAGES}; return t; } @@ -1112,6 +1118,24 @@ namespace vcpkg const FeaturesFieldDeserializer FeaturesFieldDeserializer::instance; + struct ProgrammingLanguageStringDeserializer final : Json::StringDeserializer + { + LocalizedString type_name() const override { return msg::format(msgAProgrammingLanguage); } + + static const ProgrammingLanguageStringDeserializer instance; + }; + + const ProgrammingLanguageStringDeserializer ProgrammingLanguageStringDeserializer::instance; + + struct ProgrammingLanguageArrayDeserializer final : Json::ArrayDeserializer + { + LocalizedString type_name() const override { return msg::format(msgAnArrayOfProgrammingLanguages); } + + static const ProgrammingLanguageArrayDeserializer instance; + }; + + const ProgrammingLanguageArrayDeserializer ProgrammingLanguageArrayDeserializer::instance; + struct ContactsDeserializer final : Json::IDeserializer { virtual LocalizedString type_name() const override { return msg::format(msgADictionaryOfContacts); } @@ -1161,6 +1185,7 @@ namespace vcpkg constexpr static StringLiteral OVERRIDES = "overrides"; constexpr static StringLiteral BUILTIN_BASELINE = "builtin-baseline"; constexpr static StringLiteral VCPKG_CONFIGURATION = "vcpkg-configuration"; + constexpr static StringLiteral LANGUAGES = "languages"; virtual Span valid_fields() const override { @@ -1180,6 +1205,7 @@ namespace vcpkg OVERRIDES, BUILTIN_BASELINE, VCPKG_CONFIGURATION, + LANGUAGES, }; static const auto t = Util::Vectors::concat(schemed_deserializer_fields(), u); @@ -1201,6 +1227,7 @@ namespace vcpkg } r.optional_object_field(obj, MAINTAINERS, spgh.maintainers, Json::ParagraphDeserializer::instance); + r.optional_object_field(obj, LANGUAGES, spgh.languages, ProgrammingLanguageArrayDeserializer::instance); r.optional_object_field(obj, CONTACTS, spgh.contacts, ContactsDeserializer::instance); r.optional_object_field(obj, SUMMARY, spgh.summary, Json::ParagraphDeserializer::instance); r.optional_object_field(obj, DESCRIPTION, spgh.description, Json::ParagraphDeserializer::instance); @@ -1213,6 +1240,12 @@ namespace vcpkg spgh.license = {std::move(license)}; } + std::vector languages; + if (r.optional_object_field(obj, LANGUAGES, languages, ProgrammingLanguageArrayDeserializer::instance)) + { + spgh.languages = std::move(languages); + } + r.optional_object_field(obj, DEPENDENCIES, spgh.dependencies, DependencyArrayDeserializer::instance); r.optional_object_field(obj, OVERRIDES, spgh.overrides, DependencyOverrideArrayDeserializer::instance); @@ -1267,6 +1300,7 @@ namespace vcpkg constexpr StringLiteral ManifestDeserializer::OVERRIDES; constexpr StringLiteral ManifestDeserializer::BUILTIN_BASELINE; constexpr StringLiteral ManifestDeserializer::VCPKG_CONFIGURATION; + constexpr StringLiteral ManifestDeserializer::LANGUAGES; struct ProjectManifestDeserializer final : ManifestDeserializer { @@ -1778,6 +1812,10 @@ namespace vcpkg serialize_schemed_version(obj, version_scheme, scf.to_version()); } + if(!scf.core_paragraph->languages.empty()) + { + serialize_paragraph(obj, ManifestDeserializer::LANGUAGES, scf.core_paragraph->languages); + } serialize_paragraph(obj, ManifestDeserializer::MAINTAINERS, scf.core_paragraph->maintainers); if (scf.core_paragraph->contacts.size() > 0) { diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 9c8888f248..0207b9ef30 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -1339,14 +1339,14 @@ namespace vcpkg return m_pimpl->m_env_cache.get_action_env(*this, pre_build_info, toolset); } - const std::string& VcpkgPaths::get_triplet_info(const PreBuildInfo& pre_build_info, const Toolset& toolset) const + const std::string& VcpkgPaths::get_triplet_info(const PreBuildInfo& pre_build_info, const Toolset& toolset, const std::set& languages) const { - return m_pimpl->m_env_cache.get_triplet_info(*this, pre_build_info, toolset); + return m_pimpl->m_env_cache.get_triplet_info(*this, pre_build_info, toolset, languages); } - const CompilerInfo& VcpkgPaths::get_compiler_info(const PreBuildInfo& pre_build_info, const Toolset& toolset) const + const CompilerInfo& VcpkgPaths::get_compiler_info(const PreBuildInfo& pre_build_info, const Toolset& toolset, const std::set& languages) const { - return m_pimpl->m_env_cache.get_compiler_info(*this, pre_build_info, toolset); + return m_pimpl->m_env_cache.get_compiler_info(*this, pre_build_info, toolset, languages); } const FeatureFlagSettings& VcpkgPaths::get_feature_flags() const { return m_pimpl->m_ff_settings; }