Skip to content

Commit

Permalink
Native/Vulkan Loader: Build for linux-arm64, osx-arm64, and win-x86.
Browse files Browse the repository at this point in the history
Also clean up the build script.
  • Loading branch information
alexrp committed Apr 13, 2024
1 parent 15d84c8 commit f98f3f4
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 40 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/vulkan-loader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,37 @@ jobs:
fail-fast: false
matrix:
env:
- os: ubuntu-latest
- os: ubuntu-22.04
name: Linux
nuke_invoke: ./build.sh
extras: |
sudo apt-get update
sudo apt-get install -y build-essential libx11-xcb-dev libxkbcommon-dev libwayland-dev libxrandr-dev
- os: windows-latest
sudo tee /etc/apt/sources.list << EOF
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy main multiverse restricted universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-backports main multiverse restricted universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-security main multiverse restricted universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-updates main multiverse restricted universe
deb [arch=arm64,armhf] http://ports.ubuntu.com jammy main multiverse restricted universe
deb [arch=arm64,armhf] http://ports.ubuntu.com jammy-backports main multiverse restricted universe
deb [arch=arm64,armhf] http://ports.ubuntu.com jammy-security main multiverse restricted universe
deb [arch=arm64,armhf] http://ports.ubuntu.com jammy-updates main multiverse restricted universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy main multiverse restricted universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-backports main multiverse restricted universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-security main multiverse restricted universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-updates main multiverse restricted universe
EOF
sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf
for arch in amd64 arm64 armhf; do
sudo apt install -y pkg-config:$arch
sudo apt install -y libx11-xcb-dev:$arch libxkbcommon-dev:$arch libwayland-dev:$arch libxrandr-dev:$arch
done
- os: windows-2022
name: Windows
nuke_invoke: ./build.cmd
extras: ""
- os: macos-latest
- os: macos-14
name: Darwin
nuke_invoke: ./build.sh
extras: ""
Expand All @@ -41,7 +61,7 @@ jobs:
run: |
git -c submodule.third_party/git-hooks.update=none submodule update --init --recursive --depth 0 build/submodules/Vulkan-Loader
git config --local user.email "[email protected]"
git config --local user.name "The Silk.NET Automaton"
git config --local user.name "The Silk.NET Automaton"
- name: Extra prerequisites
run: |
echo running extras
Expand Down
98 changes: 64 additions & 34 deletions build/nuke/Native/VulkanLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,69 @@ partial class Build {
Target VulkanLoader => CommonTarget
(
x => x.Before(Compile)
.After(Clean)
.Executes
(
() =>
{
var @out = VulkanLoaderPath / "build";
EnsureCleanDirectory(@out);
var abi = OperatingSystem.IsWindows() ? " -DCMAKE_GENERATOR_PLATFORM=Win32" : string.Empty;
InheritedShell
(
$"cmake -S. -Bbuild -DUPDATE_DEPS=On -DCMAKE_BUILD_TYPE=Release{abi}",
VulkanLoaderPath
)
.AssertZeroExitCode();
InheritedShell($"cmake --build build --config Release{JobsArg}", VulkanLoaderPath)
.AssertZeroExitCode();
var runtimes = RootDirectory / "src" / "Native" / "Silk.NET.Vulkan.Loader.Native" / "runtimes";
if (OperatingSystem.IsWindows())
{
CopyAll(@out.GlobFiles("loader/Release/vulkan-1.dll"), runtimes / "win-x64" / "native");
CopyAll(@out.GlobFiles("loader/Release/vulkan-1.dll"), runtimes / "win-x86" / "native");
}
else
{
CopyAll
(
@out.GlobFiles("loader/libvulkan.so", "loader/libvulkan.dylib"),
runtimes / (OperatingSystem.IsMacOS() ? "osx-x64" : "linux-x64") / "native"
);
}
.After(Clean)
.Executes
(
() =>
{
var buildDir = VulkanLoaderPath / "build";
var runtimes = RootDirectory / "src" / "Native" / "Silk.NET.Vulkan.Loader.Native" / "runtimes";
PrUpdatedNativeBinary("Vulkan Loader");
}
)
var prepare = "cmake .. -DCMAKE_BUILD_TYPE=Release -DUPDATE_DEPS=ON";
var build = $"cmake --build . --config Release{JobsArg}";
if (OperatingSystem.IsWindows())
{
foreach (var (platform, rid) in new[]
{
("Win32", "win-x86"),
("x64", "win-x64"),
})
{
EnsureCleanDirectory(buildDir);
InheritedShell($"{prepare} -A {platform}", buildDir).AssertZeroExitCode();
InheritedShell(build, buildDir).AssertZeroExitCode();
CopyAll((buildDir / "loader" / "Release").GlobFiles("vulkan-1.dll"), runtimes / rid / "native");
}
}
else if (OperatingSystem.IsLinux())
{
foreach (var (triple, rid) in new[]
{
("x86_64-linux-gnu", "linux-x64"),
("aarch64-linux-gnu", "linux-arm64"),
})
{
EnsureCleanDirectory(buildDir);
InheritedShell($"{prepare} {GetCMakeToolchainFlag(triple)}", buildDir).AssertZeroExitCode();
InheritedShell(build, buildDir).AssertZeroExitCode();
CopyAll((buildDir / "loader").GlobFiles("libvulkan.so"), runtimes / rid / "native");
}
}
else if (OperatingSystem.IsMacOS())
{
foreach (var (arch, rid) in new[]
{
("x86_64", "osx-x64"),
("arm64", "osx-arm64"),
})
{
EnsureCleanDirectory(buildDir);
InheritedShell($"{prepare} -DCMAKE_OSX_ARCHITECTURES={arch}", buildDir).AssertZeroExitCode();
InheritedShell(build, buildDir).AssertZeroExitCode();
CopyAll((buildDir / "loader").GlobFiles("libvulkan.dylib"), runtimes / rid / "native");
}
}
PrUpdatedNativeBinary("Vulkan Loader");
}
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
</PropertyGroup>
<ItemGroup>
<Content Include="build\net461\$(PackageId).targets" PackagePath="build\net461\$(PackageId).targets" />
<Content Include="runtimes\linux-arm64\native\libvulkan.so" PackagePath="runtimes\linux-arm64\native\libvulkan.so" />
<Content Include="runtimes\linux-x64\native\libvulkan.so" PackagePath="runtimes\linux-x64\native\libvulkan.so" />
<Content Include="runtimes\osx-arm64\native\libvulkan.dylib" PackagePath="runtimes\osx-arm64\native\libvulkan.dylib" />
<Content Include="runtimes\osx-x64\native\libvulkan.dylib" PackagePath="runtimes\osx-x64\native\libvulkan.dylib" />
<Content Include="runtimes\win-x64\native\vulkan-1.dll" PackagePath="runtimes\win-x64\native\vulkan-1.dll" />
<Content Include="runtimes\win-x86\native\vulkan-1.dll" PackagePath="runtimes\win-x86\native\vulkan-1.dll" />
Expand Down

0 comments on commit f98f3f4

Please sign in to comment.