Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Add languages manifest field #1314

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/vcpkg/base/message-data.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")
1 change: 1 addition & 0 deletions include/vcpkg/binaryparagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace vcpkg
Version version;
std::vector<std::string> description;
std::vector<std::string> maintainers;
std::vector<std::string> languages;
std::string feature;
std::vector<std::string> default_features;
std::vector<PackageSpec> dependencies;
Expand Down
6 changes: 4 additions & 2 deletions include/vcpkg/commands.build.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>& languages);
const CompilerInfo& get_compiler_info(const VcpkgPaths& paths,
const PreBuildInfo& pre_build_info,
const Toolset& toolset);
const Toolset& toolset,
const std::set<std::string>& languages);

private:
struct TripletMapEntry
Expand Down
2 changes: 2 additions & 0 deletions include/vcpkg/sourceparagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ namespace vcpkg
{
std::string name;
std::vector<std::string> description;
std::vector<std::string> languages;
std::vector<Dependency> dependencies;
PlatformExpression::Expr supports_expression;
// there are two distinct "empty" states here
Expand All @@ -114,6 +115,7 @@ namespace vcpkg
std::vector<std::string> description;
std::vector<std::string> summary;
std::vector<std::string> maintainers;
std::vector<std::string> languages;
std::string homepage;
std::string documentation;
std::vector<Dependency> dependencies;
Expand Down
4 changes: 2 additions & 2 deletions include/vcpkg/vcpkgpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>& languages) const;
const CompilerInfo& get_compiler_info(const PreBuildInfo& pre_build_info, const Toolset& toolset, const std::set<std::string>& languages) const;

const FeatureFlagSettings& get_feature_flags() const;

Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/binarycaching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
19 changes: 18 additions & 1 deletion src/vcpkg/binaryparagraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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))
Expand All @@ -118,6 +121,7 @@ namespace vcpkg
, version()
, description(fpgh.description)
, maintainers()
, languages(fpgh.languages)
, feature(fpgh.name)
, default_features()
, dependencies(std::move(deps))
Expand All @@ -133,6 +137,7 @@ namespace vcpkg
};

Util::sort_unique_erase(this->dependencies);
Util::sort_unique_erase(this->languages);

for (auto& maintainer : this->maintainers)
{
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
49 changes: 41 additions & 8 deletions src/vcpkg/commands.build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>& languages);

static const std::string& get_toolchain_cache(Cache<Path, std::string>& cache,
const Path& tcfile,
Expand All @@ -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<std::string>& languages)
{
if (!m_compiler_tracking || pre_build_info.disable_compiler_tracking)
{
Expand All @@ -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
{
Expand All @@ -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<std::string>& languages)
{
const auto& fs = paths.get_filesystem();
const auto& triplet_file_path = paths.get_triplet_db().get_triplet_file_path(pre_build_info.triplet);
Expand All @@ -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);
});
}
Expand Down Expand Up @@ -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<std::string>& 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<CMakeVariable> 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);

Expand Down Expand Up @@ -1118,6 +1131,7 @@ namespace vcpkg
static void populate_abi_tag(const VcpkgPaths& paths,
InstallPlanAction& action,
std::unique_ptr<PreBuildInfo>&& proto_pre_build_info,
const std::set<std::string>& langs,
Span<const AbiEntry> dependency_abis,
Cache<Path, Optional<std::string>>& grdk_cache)
{
Expand All @@ -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())
Expand All @@ -1155,7 +1169,7 @@ namespace vcpkg

std::vector<AbiEntry> 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);
Expand Down Expand Up @@ -1283,6 +1297,24 @@ namespace vcpkg
const StatusParagraphs& status_db)
{
Cache<Path, Optional<std::string>> grdk_cache;

std::set<std::string> 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;
Expand Down Expand Up @@ -1323,6 +1355,7 @@ namespace vcpkg
std::make_unique<PreBuildInfo>(paths,
action.spec.triplet(),
var_provider.get_tag_vars(action.spec).value_or_exit(VCPKG_LINE_INFO)),
languages,
dependency_abis,
grdk_cache);
}
Expand Down
Loading
Loading