Skip to content

Commit c78bf7f

Browse files
committed
Merge remote-tracking branch 'origin/main' into process-stdin
2 parents f5767f8 + 9a4e2ef commit c78bf7f

File tree

95 files changed

+1562
-2230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1562
-2230
lines changed
118 Bytes
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
. $PSScriptRoot/../end-to-end-tests-prelude.ps1
2+
3+
$out = Join-Path $TestingRoot "a-tar-with-execute"
4+
Run-Vcpkg z-extract "$PSScriptRoot/../e2e-assets/extract/a-tar-with-plus-x.tar.gz" $out
5+
Throw-IfFailed
6+
7+
$extractedFilePath = Join-Path $out "myExe"
8+
if (-Not (Test-Path $extractedFilePath)) {
9+
throw "Extraction Failed"
10+
}
11+
12+
if (-Not $IsWindows) {
13+
$unixMode = (Get-Item $extractedFilePath).UnixMode
14+
if ($unixMode -ne "-rwxr-xr-x") {
15+
throw "File does not have +x permission. UnixMode: $unixMode"
16+
}
17+
}

docs/vcpkg-schema-definitions.schema.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
"features": {
212212
"type": "array",
213213
"items": {
214-
"$ref": "#/definitions/identifier"
214+
"$ref": "#/definitions/dependency-feature"
215215
}
216216
},
217217
"host": {
@@ -239,6 +239,33 @@
239239
},
240240
"additionalProperties": false
241241
},
242+
"dependency-feature-object": {
243+
"description": "Expanded form of a dependency feature with platform expression.",
244+
"type": "object",
245+
"properties": {
246+
"name": {
247+
"$ref": "#/definitions/identifier"
248+
},
249+
"platform": {
250+
"$ref": "#/definitions/platform-expression"
251+
}
252+
},
253+
"required": [
254+
"name"
255+
],
256+
"additionalProperties": false
257+
},
258+
"dependency-feature": {
259+
"description": "A feature",
260+
"oneOf": [
261+
{
262+
"$ref": "#/definitions/identifier"
263+
},
264+
{
265+
"$ref": "#/definitions/dependency-feature-object"
266+
}
267+
]
268+
},
242269
"description-field": {
243270
"description": "A string or array of strings containing the description of a package or feature.",
244271
"$ref": "#/definitions/string-or-strings"

docs/vcpkg.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"description": "Features enabled by default with the package.",
8585
"type": "array",
8686
"items": {
87-
"$ref": "vcpkg-schema-definitions.schema.json#/definitions/identifier"
87+
"$ref": "vcpkg-schema-definitions.schema.json#/definitions/dependency-feature"
8888
}
8989
},
9090
"supports": {

include/vcpkg-test/util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ namespace Catch
7575
{
7676
static const std::string convert(const vcpkg::Path& value) { return "\"" + value.native() + "\""; }
7777
};
78+
79+
template<>
80+
struct StringMaker<std::pair<vcpkg::Path, vcpkg::Path>>
81+
{
82+
static const std::string convert(const std::pair<vcpkg::Path, vcpkg::Path>& value)
83+
{
84+
return "{\"" + value.first.native() + "\", \"" + value.second.native() + "\"}";
85+
}
86+
};
7887
}
7988

8089
namespace vcpkg

include/vcpkg/archives.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,38 @@
1313

1414
namespace vcpkg
1515
{
16+
enum class ExtractionType
17+
{
18+
Unknown,
19+
Tar,
20+
Zip,
21+
Nupkg,
22+
Msi,
23+
Exe
24+
};
25+
1626
// Extract `archive` to `to_path` using `tar_tool`.
1727
void extract_tar(const Path& tar_tool, const Path& archive, const Path& to_path);
1828
// Extract `archive` to `to_path` using `cmake_tool`. (CMake's built in tar)
1929
void extract_tar_cmake(const Path& cmake_tool, const Path& archive, const Path& to_path);
20-
// Extract `archive` to `to_path`, deleting `to_path` first.
2130
void extract_archive(const Filesystem& fs,
2231
const ToolCache& tools,
2332
MessageSink& status_sink,
2433
const Path& archive,
2534
const Path& to_path);
35+
// set `to_path` to `archive` contents.
36+
void set_directory_to_archive_contents(const Filesystem& fs,
37+
const ToolCache& tools,
38+
MessageSink& status_sink,
39+
const Path& archive,
40+
const Path& to_path);
41+
Path extract_archive_to_temp_subdirectory(const Filesystem& fs,
42+
const ToolCache& tools,
43+
MessageSink& status_sink,
44+
const Path& archive,
45+
const Path& to_path);
2646

47+
ExtractionType guess_extraction_type(const Path& archive);
2748
#ifdef _WIN32
2849
// Extract the 7z archive part of a self extracting 7z installer
2950
void win32_extract_self_extracting_7z(const Filesystem& fs, const Path& archive, const Path& to_path);

include/vcpkg/base/files.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ namespace vcpkg
4040
std::error_code ec;
4141
};
4242

43+
struct IsSlash
44+
{
45+
bool operator()(const char c) const noexcept
46+
{
47+
return c == '/'
48+
#if defined(_WIN32)
49+
|| c == '\\'
50+
#endif // _WIN32
51+
;
52+
}
53+
};
54+
4355
bool is_symlink(FileType s);
4456
bool is_regular_file(FileType s);
4557
bool is_directory(FileType s);

include/vcpkg/base/message-data.inc.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ DECLARE_MESSAGE(ABoolean, (), "", "a boolean")
44
DECLARE_MESSAGE(ABuiltinRegistry, (), "", "a builtin registry")
55
DECLARE_MESSAGE(AConfigurationObject, (), "", "a configuration object")
66
DECLARE_MESSAGE(ADependency, (), "", "a dependency")
7+
DECLARE_MESSAGE(ADependencyFeature, (), "", "a feature in a dependency")
78
DECLARE_MESSAGE(ADemandObject,
89
(),
910
"'demands' are a concept in the schema of a JSON file the user can edit",
@@ -124,6 +125,7 @@ DECLARE_MESSAGE(AnArtifactsGitRegistryUrl, (), "", "an artifacts git registry UR
124125
DECLARE_MESSAGE(AnArtifactsRegistry, (), "", "an artifacts registry")
125126
DECLARE_MESSAGE(AnArrayOfDependencies, (), "", "an array of dependencies")
126127
DECLARE_MESSAGE(AnArrayOfDependencyOverrides, (), "", "an array of dependency overrides")
128+
DECLARE_MESSAGE(AnArrayOfFeatures, (), "", "an array of features")
127129
DECLARE_MESSAGE(AnArrayOfIdentifers, (), "", "an array of identifiers")
128130
DECLARE_MESSAGE(AnArrayOfOverlayPaths, (), "", "an array of overlay paths")
129131
DECLARE_MESSAGE(AnArrayOfOverlayTripletsPaths, (), "", "an array of overlay triplets paths")
@@ -858,6 +860,10 @@ DECLARE_MESSAGE(ErrorRequirePackagesList,
858860
(),
859861
"",
860862
"`vcpkg install` requires a list of packages to install in classic mode.")
863+
DECLARE_MESSAGE(ErrorInvalidExtractOption,
864+
(msg::option, msg::value),
865+
"The keyword 'AUTO' should not be localized",
866+
"--{option} must be set to a nonnegative integer or 'AUTO'.")
861867
DECLARE_MESSAGE(ErrorsFound, (), "", "Found the following errors:")
862868
DECLARE_MESSAGE(ErrorUnableToDetectCompilerInfo,
863869
(),
@@ -929,6 +935,7 @@ DECLARE_MESSAGE(ExportUnsupportedInManifest,
929935
"vcpkg export does not support manifest mode, in order to allow for future design considerations. "
930936
"You may use export in classic mode by running vcpkg outside of a manifest-based project.")
931937
DECLARE_MESSAGE(ExtendedDocumentationAtUrl, (msg::url), "", "Extended documentation available at '{url}'.")
938+
DECLARE_MESSAGE(ExtractHelp, (), "", "Extracts an archive.")
932939
DECLARE_MESSAGE(ExtractingTool, (msg::tool_name), "", "Extracting {tool_name}...")
933940
DECLARE_MESSAGE(FailedPostBuildChecks,
934941
(msg::count, msg::path),
@@ -2360,6 +2367,10 @@ DECLARE_MESSAGE(StoredBinariesToDestinations,
23602367
"",
23612368
"Stored binaries in {count} destinations in {elapsed}.")
23622369
DECLARE_MESSAGE(StoreOptionMissingSha, (), "", "--store option is invalid without a sha512")
2370+
DECLARE_MESSAGE(StripOption,
2371+
(msg::option),
2372+
"--{option} is a setting that can be passed to z-extract command.",
2373+
"--{option} specifies the number of leading directories to strip from all paths.")
23632374
DECLARE_MESSAGE(SuccessfulyExported, (msg::package_name, msg::path), "", "Exported {package_name} to {path}")
23642375
DECLARE_MESSAGE(SuggestGitPull, (), "", "The result may be outdated. Run `git pull` to get the latest results.")
23652376
DECLARE_MESSAGE(SuggestResolution,

include/vcpkg/binaryparagraph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace vcpkg
1414
BinaryParagraph();
1515
explicit BinaryParagraph(Paragraph fields);
1616
BinaryParagraph(const SourceParagraph& spgh,
17+
const std::vector<std::string>& default_features,
1718
Triplet triplet,
1819
const std::string& abi_tag,
1920
std::vector<PackageSpec> deps);

include/vcpkg/commands.extract.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#pragma once
2+
3+
#include <vcpkg/fwd/vcpkgcmdarguments.h>
4+
#include <vcpkg/fwd/vcpkgpaths.h>
5+
6+
#include <vcpkg/base/expected.h>
7+
#include <vcpkg/base/path.h>
8+
9+
#include <stddef.h>
10+
11+
#include <utility>
12+
#include <vector>
13+
namespace vcpkg::Commands
14+
{
15+
enum class StripMode
16+
{
17+
Manual,
18+
Automatic
19+
};
20+
21+
struct StripSetting
22+
{
23+
StripMode mode;
24+
int count;
25+
26+
// A constructor to enforce the relationship between mode and count
27+
StripSetting(StripMode mode, int count) : mode(mode), count(count)
28+
{
29+
// If mode is Automatic, enforce count to be -1
30+
if (mode == StripMode::Automatic) this->count = -1;
31+
}
32+
33+
// Equality comparison
34+
bool operator==(const StripSetting& other) const
35+
{
36+
return this->mode == other.mode && this->count == other.count;
37+
}
38+
};
39+
40+
ExpectedL<StripSetting> get_strip_setting(std::map<std::string, std::string, std::less<>> settings);
41+
42+
struct ExtractedArchive
43+
{
44+
Path temp_path;
45+
Path base_path;
46+
std::vector<Path> proximate_to_temp;
47+
};
48+
49+
// Returns athe set of move operations required to deploy an archive after applying a strip operation. Each .first
50+
// should be move to .second. If .second is empty, the file should not be deployed.
51+
std::vector<std::pair<Path, Path>> get_archive_deploy_operations(const ExtractedArchive& archive,
52+
StripSetting strip_setting);
53+
// Returns the number of leading directories that are common to all paths, excluding their last path element.
54+
// Pre: There are no duplicate entries in paths.
55+
// Pre: Every entry in paths is lexically_normal.
56+
// Both conditions are usually met by calling this function with the result of
57+
// get_regular_files_recursive_lexically_proximate.
58+
size_t get_common_directories_count(std::vector<Path> paths);
59+
void command_extract_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
60+
}

0 commit comments

Comments
 (0)