Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vicroms committed Dec 13, 2024
1 parent 6defa28 commit 5fe30dc
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 422 deletions.
90 changes: 76 additions & 14 deletions azure-pipelines/end-to-end-tests-dir/fetch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,104 @@ if (-not $IsMacOS -and -not $IsLinux) {
$Scripts = Join-Path $TestingRoot "scripts"
mkdir $Scripts | Out-Null

$7zip_version = "24.08"
$ninja_version = "1.11.1"
$7zip_version = "19.00"
$ninja_version = "1.10.2"

@'
[{
"name": "7zip",
"os": "windows",
"version": "19.00",
"executable": "Files\\7-Zip\\7z.exe",
"url": "https://www.7-zip.org/a/7z1900-x64.msi",
"sha512": "7837a8677a01eed9c3309923f7084bc864063ba214ee169882c5b04a7a8b198ed052c15e981860d9d7952c98f459a4fab87a72fd78e7d0303004dcb86f4324c8",
"archive": "7z1900-x64.msi"
},
{
"name": "ninja-testing",
"os": "windows",
"version": "1.10.2",
"executable": "ninja.exe",
"url": "https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip",
"sha512": "6004140d92e86afbb17b49c49037ccd0786ce238f340f7d0e62b4b0c29ed0d6ad0bab11feda2094ae849c387d70d63504393714ed0a1f4d3a1f155af7a4f1ba3",
"archive": "ninja-win-1.10.2.zip"
},
{
"name": "ninja",
"os": "windows",
"version": "1.10.2",
"executable": "ninja.exe",
"url": "https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip",
"sha512": "6004140d92e86afbb17b49c49037ccd0786ce238f340f7d0e62b4b0c29ed0d6ad0bab11feda2094ae849c387d70d63504393714ed0a1f4d3a1f155af7a4f1ba3",
"archive": "ninja-win-1.10.2.zip"
},
{
"name": "cmake",
"os": "windows",
"version": "3.22.2",
"executable": "cmake-3.22.2-windows-i386\\bin\\cmake.exe",
"url": "https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2-windows-i386.zip",
"sha512": "969d3d58d56d8fa3cc3acae2b949bf58abab945f70ae292ff20c9060d845dfc094c613c367a924abff47f307cc33af1467cdb9b75bb857868e38b2c7cdc72f79",
"archive": "cmake-3.22.2-windows-i386.zip"
},
{
"name": "cmake",
"os": "osx",
"version": "3.22.2",
"executable": "cmake-3.22.2-macos-universal/CMake.app/Contents/bin/cmake",
"url": "https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2-macos-universal.tar.gz",
"sha512": "08104f608ecb9a5cfef38e79f0957d21e425616c0677781445492f82cbfec805113e3b5eb4bc737b707bb26a00678e7bd55e17555a5611c08b0b9b44ac5136ac",
"archive": "cmake-3.22.2-macos-universal.tar.gz"
},
{
"name": "cmake",
"os": "linux",
"version": "3.22.2",
"executable": "cmake-3.22.2-linux-x86_64/bin/cmake",
"url": "https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2-linux-x86_64.tar.gz",
"sha512": "579e08b086f6903ef063697fca1dc2692f68a7341dd35998990b772b4221cdb5b1deecfa73bad9d46817ef09e58882b2adff9d64f959c01002c11448a878746b",
"archive": "cmake-3.22.2linux-x86_64.tar.gz"
},
{
"name": "cmake",
"os": "freebsd",
"version": "3.20.4",
"executable": "/usr/local/bin/cmake",
"url": "https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/All/cmake-3.20.4.txz",
"sha512": "3e5b675d7ff924f92996d912e2365582e687375109ef99c9073fb8196bb329243a406b218cf1358d7cc518988b311ce9e5bf87de4d64f2e6377b7c2bc8894475",
"archive": "cmake-3.20.4.txz"
}]
'@ | % { $_ -replace "`r","" } | Out-File -enc ascii $(Join-Path $Scripts "vcpkg-tools.json")

$env:VCPKG_DOWNLOADS = Join-Path $TestingRoot 'down loads'
$env:VCPKG_FORCE_DOWNLOADED_BINARIES = "1"
Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "7zip", "--vcpkg-root=$TestingRoot"))
Throw-IfFailed
Require-FileExists "$TestingRoot/down loads/tools/7zip-${7zip_version}-windows/7za.exe"
Require-FileExists "$env:VCPKG_DOWNLOADS/tools/7zip-19.00-windows/Files/7-Zip/7z.exe"

Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "ninja", "--vcpkg-root=$TestingRoot"))
Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "ninja-testing", "--vcpkg-root=$TestingRoot"))
Throw-IfFailed
Require-FileExists "$TestingRoot/down loads/tools/ninja-${ninja_version}-windows/ninja.exe"
Require-FileExists "$env:VCPKG_DOWNLOADS/tools/ninja-testing-1.10.2-windows/ninja.exe"

mkdir "$TestingRoot/down loads/tools/ninja-testing-${ninja_version}-windows" | Out-Null
Move-Item -Path "$TestingRoot/down loads/tools/ninja-${ninja_version}-windows/ninja.exe" -Destination "$TestingRoot/down loads/tools/ninja-testing-${ninja_version}-windows/ninja.exe"
$path = $env:PATH
Remove-Item env:VCPKG_FORCE_DOWNLOADED_BINARIES

$env:PATH = "$path;$TestingRoot/down loads/tools/ninja-testing-${ninja_version}-windows"
$env:PATH = "$path;$env:VCPKG_DOWNLOADS/tools/ninja-testing-1.10.2-windows"
Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "ninja", "--vcpkg-root=$TestingRoot"))
Throw-IfFailed
Require-FileNotExists "$TestingRoot/down loads/tools/ninja-${ninja_version}-windows/ninja.exe"
Require-FileNotExists "$env:VCPKG_DOWNLOADS/tools/ninja-1.10.2-windows/ninja.exe"

$env:VCPKG_FORCE_DOWNLOADED_BINARIES = "1"
Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "ninja", "--vcpkg-root=$TestingRoot"))
Throw-IfFailed
Require-FileExists "$TestingRoot/down loads/tools/ninja-${ninja_version}-windows/ninja.exe"
Require-FileExists "$env:VCPKG_DOWNLOADS/tools/ninja-1.10.2-windows/ninja.exe"

Remove-Item -Recurse -Force "$TestingRoot/down loads/tools/ninja-${ninja_version}-windows" -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force "$env:VCPKG_DOWNLOADS/tools/ninja-1.10.2-windows" -ErrorAction SilentlyContinue
Remove-Item env:VCPKG_FORCE_DOWNLOADED_BINARIES

$env:VCPKG_FORCE_SYSTEM_BINARIES = "1"
$env:PATH = "$PSScriptRoot\..\e2e-assets\fetch;$path"
Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "ninja", "--vcpkg-root=$TestingRoot"))
Throw-IfFailed
Require-FileNotExists "$TestingRoot/down loads/tools/ninja-${ninja_version}-windows/ninja.exe"
Require-FileNotExists "$env:VCPKG_DOWNLOADS/tools/ninja-1.10.2-windows/ninja.exe"

Remove-Item env:VCPKG_FORCE_SYSTEM_BINARIES
$out = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("fetch", "ninja", "--vcpkg-root=$TestingRoot", "--x-stderr-status"))
Expand Down
14 changes: 14 additions & 0 deletions include/vcpkg/base/jsonreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,18 @@ namespace vcpkg::Json
virtual Optional<std::string> visit_string(Json::Reader&, StringView sv) const override;
static const FeatureNameDeserializer instance;
};

struct ArchitectureDeserializer final : Json::IDeserializer<std::string>
{
virtual LocalizedString type_name() const override;
virtual Optional<std::string> visit_string(Json::Reader&, StringView sv) const override;
static const ArchitectureDeserializer instance;
};

struct Sha512Deserializer final : Json::IDeserializer<std::string>
{
virtual LocalizedString type_name() const override;
virtual Optional<std::string> visit_string(Json::Reader&, StringView sv) const override;
static const Sha512Deserializer instance;
};
}
1 change: 1 addition & 0 deletions include/vcpkg/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace vcpkg
std::unique_ptr<ToolCache> get_tool_cache(const Filesystem& fs,
std::shared_ptr<const DownloadManager> downloader,
Path downloads,
Path config_path,
Path tools,
RequireExactVersions abiToolVersionHandling);
}
55 changes: 55 additions & 0 deletions src/vcpkg/base/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <vcpkg/base/messages.h>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/unicode.h>
#include <vcpkg/base/util.h>

#include <vcpkg/documentation.h>

Expand Down Expand Up @@ -1569,4 +1570,58 @@ namespace vcpkg::Json
}

const FeatureNameDeserializer FeatureNameDeserializer::instance;

LocalizedString ArchitectureDeserializer::type_name() const
{
// TODO: Add type name
return msg::format(msgAFeatureName);
}

Optional<std::string> ArchitectureDeserializer::visit_string(Json::Reader& r, StringView sv) const
{
static const std::vector<StringLiteral> known_architectures{
"x86",
"x64",
"arm",
"arm64",
"arm64ec",
"s390x",
"ppc64le",
"riscv32",
"riscv64",
"loongarch32",
"loongarch64",
"mips64",
};

if (Util::contains(known_architectures, sv))
{
return sv.to_string();
}

r.add_generic_error(type_name(), msg::format(msgInvalidArchitecture, msg::value = sv));
return nullopt;
}

const ArchitectureDeserializer ArchitectureDeserializer::instance;

LocalizedString Sha512Deserializer::type_name() const
{
// TODO: Add type name
return msg::format(msgAFeatureName);
}

Optional<std::string> Sha512Deserializer::visit_string(Json::Reader& r, StringView sv) const
{
if (sv.size() == 128 && std::all_of(sv.begin(), sv.end(), ParserBase::is_hex_digit))
{
return sv.to_string();
}

// TODO: Add error
// r.add_generic_error(type_name(), msg::format(msgInvalidSha512Length, msg::value = sv));
return nullopt;
}

const Sha512Deserializer Sha512Deserializer::instance;
}
Loading

0 comments on commit 5fe30dc

Please sign in to comment.