First pass at port settings

This commit is contained in:
Curtis.Bezault 2019-07-16 15:34:13 -07:00
parent a22242e837
commit 44dcc3d4f3
4 changed files with 52 additions and 29 deletions

View File

@ -1,4 +1,7 @@
include(${CMAKE_TRIPLET_FILE}) include(${CMAKE_TRIPLET_FILE})
if (DEFINED CMAKE_PORTFILE_SETTINGS)
include(${CMAKE_PORTFILE_SETTINGS} OPTIONAL)
endif()
# GUID used as a flag - "cut here line" # GUID used as a flag - "cut here line"
message("c35112b6-d1ba-415b-aa5d-81de856ef8eb") message("c35112b6-d1ba-415b-aa5d-81de856ef8eb")

View File

@ -140,29 +140,6 @@ namespace vcpkg::Build
{"VCPKG_ENV_PASSTHROUGH", VcpkgTripletVar::ENV_PASSTHROUGH}, {"VCPKG_ENV_PASSTHROUGH", VcpkgTripletVar::ENV_PASSTHROUGH},
}; };
/// <summary>
/// Settings from the triplet file which impact the build environment and post-build checks
/// </summary>
struct PreBuildInfo
{
/// <summary>
/// Runs the triplet file in a "capture" mode to create a PreBuildInfo
/// </summary>
static PreBuildInfo from_triplet_file(const VcpkgPaths& paths, const Triplet& triplet);
std::string triplet_abi_tag;
std::string target_architecture;
std::string cmake_system_name;
std::string cmake_system_version;
Optional<std::string> platform_toolset;
Optional<fs::path> visual_studio_path;
Optional<std::string> external_toolchain_file;
Optional<ConfigurationType> build_type;
std::vector<std::string> passthrough_env_vars;
};
std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
struct ExtendedBuildResult struct ExtendedBuildResult
{ {
ExtendedBuildResult(BuildResult code); ExtendedBuildResult(BuildResult code);
@ -200,6 +177,31 @@ namespace vcpkg::Build
const BuildPackageConfig& config, const BuildPackageConfig& config,
const StatusParagraphs& status_db); const StatusParagraphs& status_db);
/// <summary>
/// Settings from the triplet file which impact the build environment and post-build checks
/// </summary>
struct PreBuildInfo
{
/// <summary>
/// Runs the triplet file in a "capture" mode to create a PreBuildInfo
/// </summary>
static PreBuildInfo from_triplet_file(const VcpkgPaths& paths,
const Triplet& triplet,
Optional<const std::string&> port = nullopt);
std::string triplet_abi_tag;
std::string target_architecture;
std::string cmake_system_name;
std::string cmake_system_version;
Optional<std::string> platform_toolset;
Optional<fs::path> visual_studio_path;
Optional<std::string> external_toolchain_file;
Optional<ConfigurationType> build_type;
std::vector<std::string> passthrough_env_vars;
};
std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
enum class BuildPolicy enum class BuildPolicy
{ {
EMPTY_PACKAGE, EMPTY_PACKAGE,

View File

@ -782,7 +782,8 @@ namespace vcpkg::Build
AbiEntry{status_it->get()->package.spec.name(), status_it->get()->package.abi}); AbiEntry{status_it->get()->package.spec.name(), status_it->get()->package.abi});
} }
const auto pre_build_info = PreBuildInfo::from_triplet_file(paths, triplet); const auto pre_build_info =
PreBuildInfo::from_triplet_file(paths, triplet, config.scf.core_paragraph->name);
auto maybe_abi_tag_and_file = compute_abi_tag(paths, config, pre_build_info, dependency_abis); auto maybe_abi_tag_and_file = compute_abi_tag(paths, config, pre_build_info, dependency_abis);
@ -997,7 +998,9 @@ namespace vcpkg::Build
return inner_create_buildinfo(*pghs.get()); return inner_create_buildinfo(*pghs.get());
} }
PreBuildInfo PreBuildInfo::from_triplet_file(const VcpkgPaths& paths, const Triplet& triplet) PreBuildInfo PreBuildInfo::from_triplet_file(const VcpkgPaths& paths,
const Triplet& triplet,
Optional<const std::string&> port)
{ {
static constexpr CStringView FLAG_GUID = "c35112b6-d1ba-415b-aa5d-81de856ef8eb"; static constexpr CStringView FLAG_GUID = "c35112b6-d1ba-415b-aa5d-81de856ef8eb";
@ -1005,11 +1008,19 @@ namespace vcpkg::Build
const fs::path ports_cmake_script_path = paths.scripts / "get_triplet_environment.cmake"; const fs::path ports_cmake_script_path = paths.scripts / "get_triplet_environment.cmake";
const fs::path triplet_file_path = paths.get_triplet_file_path(triplet); const fs::path triplet_file_path = paths.get_triplet_file_path(triplet);
std::vector<System::CMakeVariable> args{{"CMAKE_TRIPLET_FILE", triplet_file_path}};
if (port)
{
args.emplace_back(
"CMAKE_PORT_SETTINGS",
paths.ports / port.value_or_exit(VCPKG_LINE_INFO) / "port_settings.cmake");
}
const auto cmd_launch_cmake = System::make_cmake_cmd(cmake_exe_path, const auto cmd_launch_cmake = System::make_cmake_cmd(cmake_exe_path,
ports_cmake_script_path, ports_cmake_script_path,
{ args);
{"CMAKE_TRIPLET_FILE", triplet_file_path},
});
const auto ec_data = System::cmd_execute_and_capture_output(cmd_launch_cmake); const auto ec_data = System::cmd_execute_and_capture_output(cmd_launch_cmake);
Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, ec_data.output); Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, ec_data.output);

View File

@ -254,7 +254,14 @@ namespace vcpkg::Commands::CI
return {spec.name(), it->second}; return {spec.name(), it->second};
}); });
const auto& pre_build_info = pre_build_info_cache.get_lazy( const auto& pre_build_info = pre_build_info_cache.get_lazy(
triplet, [&]() { return Build::PreBuildInfo::from_triplet_file(paths, triplet); }); triplet,
[&]() {
return Build::PreBuildInfo::from_triplet_file(
paths,
triplet,
scfl->source_control_file->core_paragraph->name);
}
);
auto maybe_tag_and_file = auto maybe_tag_and_file =
Build::compute_abi_tag(paths, build_config, pre_build_info, dependency_abis); Build::compute_abi_tag(paths, build_config, pre_build_info, dependency_abis);