Skip to content

Commit

Permalink
Fix the use of vcpkg (#2257)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow authored Sep 28, 2022
1 parent 482e6ee commit 9ce587d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
1 change: 1 addition & 0 deletions native/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
xcuserdata/
project.xcworkspace/
uwp/ANGLE/triplets
44 changes: 23 additions & 21 deletions native/uwp/build.cake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
bool SKIP_ANGLE = Argument ("skipAngle", false);
bool SKIP_ANGLE = Argument("skipAngle", false);
string VC_TOOLSET_VERSION = Argument("vcToolsetVersion", "14.2");

DirectoryPath ROOT_PATH = MakeAbsolute(Directory("../.."));
DirectoryPath VCPKG_PATH = MakeAbsolute(ROOT_PATH.Combine("externals/vcpkg"));
DirectoryPath VCPKG_PATH = EnvironmentVariable("VCPKG_ROOT") ?? MakeAbsolute(ROOT_PATH.Combine("externals/vcpkg"));
DirectoryPath OUTPUT_PATH = MakeAbsolute(ROOT_PATH.Combine("output/native/uwp"));

#load "../../cake/native-shared.cake"
Expand Down Expand Up @@ -102,12 +102,12 @@ Task("ANGLE")
if (SKIP_ANGLE)
return;
if (!DirectoryExists (VCPKG_PATH))
RunProcess ("git", $"clone --depth 1 https://github.com/microsoft/vcpkg.git --branch master --single-branch {VCPKG_PATH}");
if (!DirectoryExists(VCPKG_PATH))
RunProcess("git", $"clone --depth 1 https://github.com/microsoft/vcpkg.git --branch master --single-branch {VCPKG_PATH}");
var vcpkg = VCPKG_PATH.CombineWithFilePath ("vcpkg.exe");
if (!FileExists (vcpkg))
RunProcess (VCPKG_PATH.CombineWithFilePath ("bootstrap-vcpkg.bat"));
var vcpkg = VCPKG_PATH.CombineWithFilePath("vcpkg.exe");
if (!FileExists(vcpkg))
RunProcess(VCPKG_PATH.CombineWithFilePath("bootstrap-vcpkg.bat"));
var platform_toolset = string.IsNullOrEmpty(VC_TOOLSET_VERSION) ? "" : $"v{VC_TOOLSET_VERSION.Replace(".", "")}";
var toolset_suffix = string.IsNullOrEmpty(VC_TOOLSET_VERSION) ? "" : $"-{platform_toolset}";
Expand All @@ -122,16 +122,18 @@ Task("ANGLE")
if (Skip(arch)) return;
var triplet = $"{arch}-uwp{toolset_suffix}";
var tripletsRoot = MakeAbsolute((DirectoryPath)"ANGLE/triplets");
// make the versioned triplets
if (!string.IsNullOrEmpty(VC_TOOLSET_VERSION)) {
var cmake = VCPKG_PATH.CombineWithFilePath ($"triplets/community/{triplet}.cmake");
if (!FileExists (cmake)) {
var src = VCPKG_PATH.CombineWithFilePath ($"triplets/{arch}-uwp.cmake");
if (!FileExists (src))
src = VCPKG_PATH.CombineWithFilePath ($"triplets/community/{arch}-uwp.cmake");
CopyFile (src, cmake);
System.IO.File.AppendAllLines (cmake.FullPath, new [] {
var cmake = tripletsRoot.CombineWithFilePath($"{triplet}.cmake");
if (!FileExists(cmake)) {
EnsureDirectoryExists(tripletsRoot);
var src = VCPKG_PATH.CombineWithFilePath($"triplets/{arch}-uwp.cmake");
if (!FileExists(src))
src = VCPKG_PATH.CombineWithFilePath($"triplets/community/{arch}-uwp.cmake");
CopyFile(src, cmake);
System.IO.File.AppendAllLines(cmake.FullPath, new [] {
$"set(VCPKG_PLATFORM_TOOLSET \"{platform_toolset}\")",
$"set(VCPKG_DEP_INFO_OVERRIDE_VARS \"{platform_toolset}\")",
});
Expand All @@ -141,16 +143,16 @@ Task("ANGLE")
var d = CONFIGURATION.ToLower() == "release" ? "" : "debug/";
var zd = CONFIGURATION.ToLower() == "release" ? "" : "d";
RunProcess (vcpkg, $"install angle:{triplet}");
RunProcess(vcpkg, $"install angle:{triplet} --overlay-triplets=\"{tripletsRoot}\"");
var outDir = OUTPUT_PATH.Combine(arch);
EnsureDirectoryExists(outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{triplet}/{d}bin/libEGL.dll"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{triplet}/{d}bin/libEGL.pdb"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{triplet}/{d}bin/libGLESv2.dll"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{triplet}/{d}bin/libGLESv2.pdb"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{triplet}/{d}bin/zlib{zd}1.dll"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{triplet}/{d}bin/zlib{zd}.pdb"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath($"installed/{triplet}/{d}bin/libEGL.dll"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath($"installed/{triplet}/{d}bin/libEGL.pdb"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath($"installed/{triplet}/{d}bin/libGLESv2.dll"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath($"installed/{triplet}/{d}bin/libGLESv2.pdb"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath($"installed/{triplet}/{d}bin/zlib{zd}1.dll"), outDir);
CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath($"installed/{triplet}/{d}bin/zlib{zd}.pdb"), outDir);
}
});

Expand Down

0 comments on commit 9ce587d

Please sign in to comment.