Skip to content

Commit

Permalink
Add --clean-non-downloads-after-build switch to be used by CI to redu…
Browse files Browse the repository at this point in the history
…ce our disk consumption there. (#66)

* Add --clean-non-downloads-after-build switch to be used by CI to reduce our disk consumption there.

* Change --clean-non-downloads-after-build to separate switches for each of the 3.

* Delete Util::MoveOnlyBase and Util::ResourceBase.
  • Loading branch information
BillyONeal authored May 5, 2021
1 parent 1bc8779 commit d448a0e
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 52 deletions.
5 changes: 3 additions & 2 deletions azure-pipelines/end-to-end-tests-dir/binarycaching.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ Throw-IfFailed
Require-FileNotExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
Require-FileNotExists "$buildtreesRoot/rapidjson/src"
Require-FileExists "$TestingRoot/packages.config"
$fetchNuGetArgs = $commonArgs + @('fetch', 'nuget')
if ($IsLinux -or $IsMacOS) {
mono $(./vcpkg fetch nuget) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
mono $(./vcpkg @fetchNuGetArgs) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
} else {
& $(./vcpkg fetch nuget) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
& $(./vcpkg @fetchNuGetArgs) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
}
Throw-IfFailed
Remove-Item -Recurse -Force $NuGetRoot -ErrorAction SilentlyContinue
Expand Down
66 changes: 66 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/clean-after-build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

$CurrentTest = "Clean After Build"

$ZlibInstalledHeader = Join-Path $installRoot "$Triplet/include/zlib.h"
$ZlibDownloadTarball = Join-Path $downloadsRoot 'zlib1211.tar.gz'
$ZlibPackageRoot = Join-Path $packagesRoot "zlib_$Triplet"
$ZlibSrc = Join-Path $buildtreesRoot "zlib/src"

$installZlibArgs = @("install", "zlib", "--no-binarycaching")

Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + $installZlibArgs)
Require-FileExists $ZlibInstalledHeader
Require-FileExists $ZlibDownloadTarball
Require-FileExists $ZlibPackageRoot
Require-FileExists $ZlibSrc

Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + $installZlibArgs + @("--clean-packages-after-build"))
Require-FileExists $ZlibInstalledHeader
Require-FileExists $ZlibDownloadTarball
Require-FileNotExists $ZlibPackageRoot
Require-FileExists $ZlibSrc

Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + $installZlibArgs + @("--clean-buildtrees-after-build"))
Require-FileExists $ZlibInstalledHeader
Require-FileExists $ZlibDownloadTarball
Require-FileExists $ZlibPackageRoot
Require-FileNotExists $ZlibSrc

Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + $installZlibArgs + @("--clean-packages-after-build", "--clean-buildtrees-after-build"))
Require-FileExists $ZlibInstalledHeader
Require-FileExists $ZlibDownloadTarball
Require-FileNotExists $ZlibPackageRoot
Require-FileNotExists $ZlibSrc

Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + $installZlibArgs + @("--clean-buildtrees-after-build"))
Require-FileExists $ZlibInstalledHeader
Require-FileExists $ZlibDownloadTarball
Require-FileExists $ZlibPackageRoot
Require-FileNotExists $ZlibSrc

Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + $installZlibArgs + @("--clean-downloads-after-build", "--clean-packages-after-build", "--clean-buildtrees-after-build"))
Require-FileExists $ZlibInstalledHeader
Require-FileNotExists $ZlibDownloadTarball
Require-FileNotExists $ZlibPackageRoot
Require-FileNotExists $ZlibSrc

Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + $installZlibArgs + @("--clean-after-build"))
Require-FileExists $ZlibInstalledHeader
Require-FileNotExists $ZlibDownloadTarball
Require-FileNotExists $ZlibPackageRoot
Require-FileNotExists $ZlibSrc

Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + $installZlibArgs + @("--clean-after-build", "--clean-downloads-after-build", "--clean-packages-after-build", "--clean-buildtrees-after-build"))
Require-FileExists $ZlibInstalledHeader
Require-FileNotExists $ZlibDownloadTarball
Require-FileNotExists $ZlibPackageRoot
Require-FileNotExists $ZlibSrc
2 changes: 2 additions & 0 deletions azure-pipelines/end-to-end-tests-prelude.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $TestingRoot = Join-Path $WorkingRoot 'testing'
$buildtreesRoot = Join-Path $TestingRoot 'buildtrees'
$installRoot = Join-Path $TestingRoot 'installed'
$packagesRoot = Join-Path $TestingRoot 'packages'
$downloadsRoot = Join-Path $TestingRoot 'downloads'
$NuGetRoot = Join-Path $TestingRoot 'nuget'
$NuGetRoot2 = Join-Path $TestingRoot 'nuget2'
$ArchiveRoot = Join-Path $TestingRoot 'archives'
Expand All @@ -12,6 +13,7 @@ $commonArgs = @(
"--x-buildtrees-root=$buildtreesRoot",
"--x-install-root=$installRoot",
"--x-packages-root=$packagesRoot",
"--downloads-root=$downloadsRoot",
"--overlay-ports=$PSScriptRoot/e2e_ports/overlays",
"--overlay-triplets=$PSScriptRoot/e2e_ports/triplets"
)
Expand Down
24 changes: 0 additions & 24 deletions include/vcpkg/base/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,30 +207,6 @@ namespace vcpkg::Util
return fmap(input_map, [](auto&& p) { return p.first; });
}

struct MoveOnlyBase
{
MoveOnlyBase() = default;
MoveOnlyBase(const MoveOnlyBase&) = delete;
MoveOnlyBase(MoveOnlyBase&&) = default;

MoveOnlyBase& operator=(const MoveOnlyBase&) = delete;
MoveOnlyBase& operator=(MoveOnlyBase&&) = default;

~MoveOnlyBase() = default;
};

struct ResourceBase
{
ResourceBase() = default;
ResourceBase(const ResourceBase&) = delete;
ResourceBase(ResourceBase&&) = delete;

ResourceBase& operator=(const ResourceBase&) = delete;
ResourceBase& operator=(ResourceBase&&) = delete;

~ResourceBase() = default;
};

namespace Enum
{
template<class E>
Expand Down
5 changes: 4 additions & 1 deletion include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,15 @@ namespace vcpkg::Build
/// <summary>
/// Settings from the triplet file which impact the build environment and post-build checks
/// </summary>
struct PreBuildInfo : Util::ResourceBase
struct PreBuildInfo
{
PreBuildInfo(const VcpkgPaths& paths,
Triplet triplet,
const std::unordered_map<std::string, std::string>& cmakevars);

PreBuildInfo(const PreBuildInfo&) = delete;
PreBuildInfo& operator=(const PreBuildInfo&) = delete;

Triplet triplet;
bool load_vcvars_env = false;
std::string target_architecture;
Expand Down
20 changes: 17 additions & 3 deletions include/vcpkg/dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ namespace vcpkg::Dependencies
EXCLUDED
};

struct InstallPlanAction : Util::MoveOnlyBase
struct InstallPlanAction
{
static bool compare_by_name(const InstallPlanAction* left, const InstallPlanAction* right);

InstallPlanAction() noexcept;
InstallPlanAction(const InstallPlanAction&) = delete;
InstallPlanAction(InstallPlanAction&&) = default;
InstallPlanAction& operator=(const InstallPlanAction&) = delete;
InstallPlanAction& operator=(InstallPlanAction&&) = default;

InstallPlanAction(InstalledPackageView&& spghs, const RequestType& request_type);

Expand Down Expand Up @@ -89,11 +93,16 @@ namespace vcpkg::Dependencies
REMOVE
};

struct RemovePlanAction : Util::MoveOnlyBase
struct RemovePlanAction
{
static bool compare_by_name(const RemovePlanAction* left, const RemovePlanAction* right);

RemovePlanAction() noexcept;
RemovePlanAction(const RemovePlanAction&) = delete;
RemovePlanAction(RemovePlanAction&&) = default;
RemovePlanAction& operator=(const RemovePlanAction&) = delete;
RemovePlanAction& operator=(RemovePlanAction&&) = default;

RemovePlanAction(const PackageSpec& spec, const RemovePlanType& plan_type, const RequestType& request_type);

PackageSpec spec;
Expand All @@ -118,11 +127,16 @@ namespace vcpkg::Dependencies
ALREADY_BUILT
};

struct ExportPlanAction : Util::MoveOnlyBase
struct ExportPlanAction
{
static bool compare_by_name(const ExportPlanAction* left, const ExportPlanAction* right);

ExportPlanAction() noexcept;
ExportPlanAction(const ExportPlanAction&) = delete;
ExportPlanAction(ExportPlanAction&&) = default;
ExportPlanAction& operator=(const ExportPlanAction&) = delete;
ExportPlanAction& operator=(ExportPlanAction&&) = default;

ExportPlanAction(const PackageSpec& spec,
InstalledPackageView&& installed_package,
const RequestType& request_type);
Expand Down
6 changes: 5 additions & 1 deletion include/vcpkg/metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@

namespace vcpkg::Metrics
{
struct Metrics : Util::ResourceBase
struct Metrics
{
Metrics() = default;
Metrics(const Metrics&) = delete;
Metrics& operator=(const Metrics&) = delete;

void set_send_metrics(bool should_send_metrics);
void set_print_metrics(bool should_print_metrics);
void set_disabled(bool disabled);
Expand Down
8 changes: 6 additions & 2 deletions include/vcpkg/portfileprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ namespace vcpkg::PortFileProvider
virtual std::vector<const SourceControlFileLocation*> load_all_control_files() const = 0;
};

struct MapPortFileProvider : Util::ResourceBase, PortFileProvider
struct MapPortFileProvider : PortFileProvider
{
explicit MapPortFileProvider(const std::unordered_map<std::string, SourceControlFileLocation>& map);
MapPortFileProvider(const MapPortFileProvider&) = delete;
MapPortFileProvider& operator=(const MapPortFileProvider&) = delete;
ExpectedS<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const override;
std::vector<const SourceControlFileLocation*> load_all_control_files() const override;

Expand Down Expand Up @@ -51,9 +53,11 @@ namespace vcpkg::PortFileProvider
virtual void load_all_control_files(std::map<std::string, const SourceControlFileLocation*>& out) const = 0;
};

struct PathsPortFileProvider : Util::ResourceBase, PortFileProvider
struct PathsPortFileProvider : PortFileProvider
{
explicit PathsPortFileProvider(const vcpkg::VcpkgPaths& paths, const std::vector<std::string>& overlay_ports);
PathsPortFileProvider(const PathsPortFileProvider&) = delete;
PathsPortFileProvider& operator=(const PathsPortFileProvider&) = delete;
ExpectedS<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const override;
std::vector<const SourceControlFileLocation*> load_all_control_files() const override;

Expand Down
6 changes: 5 additions & 1 deletion include/vcpkg/vcpkgpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace vcpkg
struct PackageSpec;
struct Triplet;

struct VcpkgPaths : Util::MoveOnlyBase
struct VcpkgPaths
{
struct TripletFile
{
Expand All @@ -71,6 +71,10 @@ namespace vcpkg
};

VcpkgPaths(Files::Filesystem& filesystem, const VcpkgCmdArguments& args);
VcpkgPaths(const VcpkgPaths&) = delete;
VcpkgPaths(VcpkgPaths&&) = default;
VcpkgPaths& operator=(const VcpkgPaths&) = delete;
VcpkgPaths& operator=(VcpkgPaths&&) = default;
~VcpkgPaths();

fs::path package_dir(const PackageSpec& spec) const;
Expand Down
14 changes: 10 additions & 4 deletions src/vcpkg-test/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,21 @@ static const PackageSpec& toplevel_spec()
return ret;
}

struct MockOverlayProvider : PortFileProvider::IOverlayProvider, Util::ResourceBase
struct MockOverlayProvider : PortFileProvider::IOverlayProvider
{
MockOverlayProvider() = default;
MockOverlayProvider(const MockOverlayProvider&) = delete;
MockOverlayProvider& operator=(const MockOverlayProvider&) = delete;

virtual Optional<const SourceControlFileLocation&> get_control_file(StringView name) const override
{
auto it = mappings.find(name);
if (it != mappings.end())
return it->second;
else
if (it == mappings.end())
{
return nullopt;
}

return it->second;
}

SourceControlFileLocation& emplace(const std::string& name,
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/base/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ namespace vcpkg::Files

struct remove
{
struct ErrorInfo : Util::ResourceBase
struct ErrorInfo
{
std::error_code ec;
fs::path failure_point;
Expand Down
4 changes: 3 additions & 1 deletion src/vcpkg/cmakevars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ namespace vcpkg::CMakeVars

namespace
{
struct TripletCMakeVarProvider : Util::ResourceBase, CMakeVarProvider
struct TripletCMakeVarProvider : CMakeVarProvider
{
explicit TripletCMakeVarProvider(const vcpkg::VcpkgPaths& paths) : paths(paths) { }
TripletCMakeVarProvider(const TripletCMakeVarProvider&) = delete;
TripletCMakeVarProvider& operator=(const TripletCMakeVarProvider&) = delete;

void load_generic_triplet_vars(Triplet triplet) const override;

Expand Down
20 changes: 17 additions & 3 deletions src/vcpkg/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace vcpkg::Dependencies
/// <summary>
/// Representation of a package and its features in a ClusterGraph.
/// </summary>
struct Cluster : Util::MoveOnlyBase
struct Cluster
{
Cluster(const InstalledPackageView& ipv, ExpectedS<const SourceControlFileLocation&>&& scfl)
: m_spec(ipv.spec()), m_scfl(std::move(scfl)), m_installed(ipv)
Expand All @@ -58,6 +58,11 @@ namespace vcpkg::Dependencies

Cluster(const PackageSpec& spec, const SourceControlFileLocation& scfl) : m_spec(spec), m_scfl(scfl) { }

Cluster(const Cluster&) = delete;
Cluster(Cluster&&) = default;
Cluster& operator=(const Cluster&) = delete;
Cluster& operator=(Cluster&&) = default;

bool has_feature_installed(const std::string& feature) const
{
if (const ClusterInstalled* inst = m_installed.get())
Expand Down Expand Up @@ -260,13 +265,16 @@ namespace vcpkg::Dependencies
/// <summary>
/// Directional graph representing a collection of packages with their features connected by their dependencies.
/// </summary>
struct ClusterGraph : Util::ResourceBase
struct ClusterGraph
{
explicit ClusterGraph(const PortFileProvider::PortFileProvider& port_provider, Triplet host_triplet)
: m_port_provider(port_provider), m_host_triplet(host_triplet)
{
}

ClusterGraph(const ClusterGraph&) = delete;
ClusterGraph& operator=(const ClusterGraph&) = delete;

/// <summary>
/// Find the cluster associated with spec or if not found, create it from the PortFileProvider.
/// </summary>
Expand Down Expand Up @@ -1259,7 +1267,7 @@ namespace vcpkg::Dependencies
bool is_less_than(const Versions::Version& new_ver) const;
};

struct PackageNode : Util::MoveOnlyBase
struct PackageNode
{
std::map<Versions::Version, VersionSchemeInfo*, VersionTMapLess> vermap;
std::map<std::string, VersionSchemeInfo> exacts;
Expand All @@ -1272,6 +1280,12 @@ namespace vcpkg::Dependencies
VersionSchemeInfo* get_node(const Versions::Version& ver);
VersionSchemeInfo& emplace_node(Versions::Scheme scheme, const Versions::Version& ver);

PackageNode() = default;
PackageNode(const PackageNode&) = delete;
PackageNode(PackageNode&&) = default;
PackageNode& operator=(const PackageNode&) = delete;
PackageNode& operator=(PackageNode&&) = default;

template<class F>
void foreach_vsi(F f)
{
Expand Down
Loading

0 comments on commit d448a0e

Please sign in to comment.