mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-27 20:27:12 +09:00
Backport CI fixes from stable
This commit is contained in:
@@ -17,21 +17,21 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: buildbase.bat
|
||||
run: buildbase.bat ..\vs2022\libsodium.sln 17
|
||||
run: buildbase.bat ..\vs2026\libsodium.sln 18
|
||||
working-directory: builds/msvc/build/
|
||||
shell: cmd
|
||||
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
with:
|
||||
name: build-win-x64
|
||||
path: bin/x64/Release/v143/dynamic/libsodium.dll
|
||||
path: bin/x64/Release/v145/dynamic/libsodium.dll
|
||||
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
with:
|
||||
name: build-win-x86
|
||||
path: bin/Win32/Release/v143/dynamic/libsodium.dll
|
||||
path: bin/Win32/Release/v145/dynamic/libsodium.dll
|
||||
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
with:
|
||||
name: build-win-arm64
|
||||
path: bin/ARM64/Release/v143/dynamic/libsodium.dll
|
||||
path: bin/ARM64/Release/v145/dynamic/libsodium.dll
|
||||
|
||||
build-others:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
+3
-6
@@ -11,7 +11,7 @@ jobs:
|
||||
steps:
|
||||
- powershell: |
|
||||
cd builds\msvc\build
|
||||
& .\buildbase.bat ..\vs2026\libsodium.sln 18
|
||||
& .\buildbase.bat ..\vs2022\libsodium.sln 17
|
||||
displayName: Compile it all
|
||||
- powershell: |
|
||||
mkdir bin\include\sodium
|
||||
@@ -19,7 +19,6 @@ jobs:
|
||||
Copy-Item "src\libsodium\include\*.h" -Destination "bin\include\"
|
||||
displayName: Copy header files
|
||||
- task: PublishBuildArtifacts@1
|
||||
condition: not(canceled())
|
||||
inputs:
|
||||
pathToPublish: bin
|
||||
artifactName: libsodium
|
||||
@@ -38,7 +37,6 @@ jobs:
|
||||
Copy-Item "src\libsodium\include\*.h" -Destination "bin\include\"
|
||||
displayName: Copy header files
|
||||
- task: PublishBuildArtifacts@1
|
||||
condition: not(canceled())
|
||||
inputs:
|
||||
pathToPublish: bin
|
||||
artifactName: libsodium
|
||||
@@ -60,7 +58,6 @@ jobs:
|
||||
Copy-Item "src\libsodium\include\*.h" -Destination "bin\include\"
|
||||
displayName: Copy header files
|
||||
- task: PublishBuildArtifacts@1
|
||||
condition: not(canceled())
|
||||
inputs:
|
||||
pathToPublish: bin
|
||||
artifactName: libsodium
|
||||
@@ -70,7 +67,7 @@ jobs:
|
||||
vmImage: "windows-2022"
|
||||
steps:
|
||||
- powershell: |
|
||||
(New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2026-03-22/msys2-base-x86_64-20260322.sfx.exe", "sfx.exe")
|
||||
(New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2026-06-11/msys2-base-x86_64-20260611.sfx.exe", "sfx.exe")
|
||||
.\sfx.exe -y -o\
|
||||
del sfx.exe
|
||||
displayName: Install MSYS2
|
||||
@@ -109,7 +106,7 @@ jobs:
|
||||
vmImage: "windows-2022"
|
||||
steps:
|
||||
- powershell: |
|
||||
(New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2026-03-22/msys2-base-x86_64-20260322.sfx.exe", "sfx.exe")
|
||||
(New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2026-06-11/msys2-base-x86_64-20260611.sfx.exe", "sfx.exe")
|
||||
.\sfx.exe -y -o\
|
||||
del sfx.exe
|
||||
displayName: Install MSYS2
|
||||
|
||||
@@ -5,10 +5,11 @@ const mem = std.mem;
|
||||
const Compile = std.Build.Step.Compile;
|
||||
const Target = std.Target;
|
||||
|
||||
// Zig 0.16+ uses std.Io.Dir, 0.15 uses std.fs
|
||||
const is_zig_16 = @hasDecl(std, "Io") and @hasDecl(std.Io, "Dir");
|
||||
const Dir = if (is_zig_16) std.Io.Dir else std.fs.Dir;
|
||||
const Io = if (is_zig_16) std.Io else void;
|
||||
const pre_zig17 = @hasDecl(std, "Io") and @hasDecl(std.Io, "Dir");
|
||||
const Dir = if (pre_zig17) std.Io.Dir else std.fs.Dir;
|
||||
const Io = if (pre_zig17) std.Io else void;
|
||||
|
||||
const has_build_root_handle = @hasField(std.Build, "build_root");
|
||||
|
||||
const wasm_libc_path = "builds/wasm32-freestanding";
|
||||
|
||||
@@ -159,15 +160,17 @@ fn initLibConfig(b: *std.Build, target: std.Build.ResolvedTarget, lib: *Compile)
|
||||
}
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const io: Io = if (is_zig_16) b.graph.io else {};
|
||||
const cwd = if (is_zig_16)
|
||||
try b.root.openDir(io, ".", .{})
|
||||
const io: Io = if (pre_zig17) b.graph.io else {};
|
||||
const cwd: Dir = if (!pre_zig17)
|
||||
try std.fs.cwd().openDir(b.build_root.path orelse ".", .{})
|
||||
else if (has_build_root_handle)
|
||||
b.build_root.handle
|
||||
else
|
||||
try std.fs.cwd().openDir(b.build_root.path orelse ".", .{});
|
||||
try b.root.openDir(io, ".", .{});
|
||||
|
||||
const src_path = "src/libsodium";
|
||||
const src_dir = if (is_zig_16)
|
||||
try b.root.openDir(io, src_path, .{ .iterate = true })
|
||||
const src_dir = if (pre_zig17)
|
||||
try cwd.openDir(io, src_path, .{ .iterate = true })
|
||||
else if (@hasField(Dir.OpenOptions, "follow_symlinks"))
|
||||
try cwd.openDir(src_path, .{ .iterate = true, .follow_symlinks = false })
|
||||
else
|
||||
@@ -204,7 +207,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.aarch64, .aarch64_be => {
|
||||
// ARM CPUs supported by Windows are assumed to have NEON support
|
||||
if (target.result.isMinGW()) {
|
||||
target.query.cpu_features_add.addFeature(@backingInt(Target.aarch64.Feature.neon));
|
||||
target.query.cpu_features_add.addFeatureSet(Target.aarch64.featureSet(&.{.neon}));
|
||||
}
|
||||
},
|
||||
else => {},
|
||||
@@ -239,20 +242,18 @@ pub fn build(b: *std.Build) !void {
|
||||
try libs.append(heap.page_allocator, shared_lib);
|
||||
}
|
||||
|
||||
const prebuilt_version_file_path = "builds/msvc/version.h";
|
||||
const version_file_path = "include/sodium/version.h";
|
||||
|
||||
if (is_zig_16) {
|
||||
try Dir.copyFile(cwd, prebuilt_version_file_path, src_dir, version_file_path, io, .{});
|
||||
} else {
|
||||
try cwd.copyFile(prebuilt_version_file_path, src_dir, version_file_path, .{});
|
||||
}
|
||||
const version_files = b.addWriteFiles();
|
||||
const version_file = version_files.addCopyFile(b.path("builds/msvc/version.h"), "sodium/version.h");
|
||||
|
||||
for (libs.items) |lib| {
|
||||
b.installArtifact(lib);
|
||||
lib.installHeader(b.path(src_path ++ "/include/sodium.h"), "sodium.h");
|
||||
lib.installHeadersDirectory(b.path(src_path ++ "/include/sodium"), "sodium", .{});
|
||||
lib.installHeadersDirectory(b.path(src_path ++ "/include/sodium"), "sodium", .{
|
||||
.exclude_extensions = &.{"version.h"},
|
||||
});
|
||||
lib.installHeader(version_file, "sodium/version.h");
|
||||
|
||||
lib.root_module.addIncludePath(version_file.dirname());
|
||||
initLibConfig(b, target, lib);
|
||||
|
||||
const flags = &.{
|
||||
@@ -274,7 +275,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const allocator = heap.page_allocator;
|
||||
|
||||
var walker = try src_dir.walk(allocator);
|
||||
while (if (is_zig_16) try walker.next(io) else try walker.next()) |entry| {
|
||||
while (if (pre_zig17) try walker.next(io) else try walker.next()) |entry| {
|
||||
const name = entry.basename;
|
||||
if (mem.endsWith(u8, name, ".c")) {
|
||||
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ src_path, entry.path });
|
||||
@@ -291,29 +292,14 @@ pub fn build(b: *std.Build) !void {
|
||||
}
|
||||
|
||||
const test_path = "test/default";
|
||||
const out_bin_path = "zig-out/bin";
|
||||
const test_dir = if (is_zig_16)
|
||||
const test_dir = if (pre_zig17)
|
||||
try cwd.openDir(io, test_path, .{ .iterate = true })
|
||||
else if (@hasField(Dir.OpenOptions, "follow_symlinks"))
|
||||
try cwd.openDir(test_path, .{ .iterate = true, .follow_symlinks = false })
|
||||
else
|
||||
try cwd.openDir(test_path, .{ .iterate = true, .no_follow = true });
|
||||
|
||||
if (is_zig_16) {
|
||||
cwd.createDirPath(io, out_bin_path) catch {};
|
||||
} else {
|
||||
cwd.makePath(out_bin_path) catch {};
|
||||
}
|
||||
const out_bin_dir = if (is_zig_16)
|
||||
try cwd.openDir(io, out_bin_path, .{})
|
||||
else
|
||||
try cwd.openDir(out_bin_path, .{});
|
||||
|
||||
if (is_zig_16) {
|
||||
try Dir.copyFile(test_dir, "run.sh", out_bin_dir, "run.sh", io, .{});
|
||||
} else {
|
||||
try test_dir.copyFile("run.sh", out_bin_dir, "run.sh", .{});
|
||||
}
|
||||
b.installBinFile(test_path ++ "/run.sh", "run.sh");
|
||||
|
||||
const allocator = heap.page_allocator;
|
||||
var walker = try test_dir.walk(allocator);
|
||||
@@ -321,14 +307,11 @@ pub fn build(b: *std.Build) !void {
|
||||
const test_step = b.step("test", "Run all libsodium tests");
|
||||
|
||||
if (build_tests) {
|
||||
while (if (is_zig_16) try walker.next(io) else try walker.next()) |entry| {
|
||||
while (if (pre_zig17) try walker.next(io) else try walker.next()) |entry| {
|
||||
const name = entry.basename;
|
||||
if (mem.endsWith(u8, name, ".exp")) {
|
||||
if (is_zig_16) {
|
||||
try Dir.copyFile(test_dir, name, out_bin_dir, name, io, .{});
|
||||
} else {
|
||||
try test_dir.copyFile(name, out_bin_dir, name, .{});
|
||||
}
|
||||
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ test_path, entry.path });
|
||||
b.installBinFile(full_path, name);
|
||||
continue;
|
||||
}
|
||||
if (!mem.endsWith(u8, name, ".c")) {
|
||||
@@ -378,6 +361,8 @@ pub fn build(b: *std.Build) !void {
|
||||
.link_libc = true,
|
||||
});
|
||||
translate_c.addIncludePath(b.path("src/libsodium/include"));
|
||||
translate_c.addIncludePath(b.path("src/libsodium/include/sodium"));
|
||||
translate_c.addIncludePath(version_files.getDirectory());
|
||||
const c_mod = translate_c.createModule();
|
||||
|
||||
const tv_mod = b.createModule(.{
|
||||
|
||||
@@ -6,58 +6,30 @@ SETLOCAL enabledelayedexpansion
|
||||
SET solution=%1
|
||||
SET version=%2
|
||||
SET log=build_%version%.log
|
||||
SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat
|
||||
SET environment=
|
||||
SET vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
IF NOT EXIST !vswhere! SET vswhere="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
SET /A next_version=version + 1
|
||||
SET version_range=[%version%.0,!next_version!.0)
|
||||
SET required_components=Microsoft.VisualStudio.Component.VC.Tools.x86.x64
|
||||
IF %version% GEQ 17 SET required_components=!required_components! Microsoft.VisualStudio.Component.VC.Tools.ARM64
|
||||
|
||||
IF %version% == 18 (
|
||||
SET tools=Microsoft Visual Studio\2026\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
|
||||
SET environment="%programfiles%\!tools!"
|
||||
IF NOT EXIST !environment! (
|
||||
SET environment="%programfiles(x86)%\!tools!"
|
||||
IF NOT EXIST !environment! (
|
||||
SET tools=Microsoft Visual Studio\2026\Community\VC\Auxiliary\Build\vcvarsall.bat
|
||||
IF %version% GEQ 15 (
|
||||
IF EXIST !vswhere! (
|
||||
FOR /F "usebackq tokens=*" %%I IN (`!vswhere! -latest -prerelease -products * -version !version_range! -requires !required_components! -property installationPath`) DO (
|
||||
SET environment="%%I\VC\Auxiliary\Build\vcvarsall.bat"
|
||||
)
|
||||
)
|
||||
) ELSE (
|
||||
SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat
|
||||
SET environment="%ProgramFiles%\!tools!"
|
||||
IF NOT EXIST !environment! SET environment="%ProgramFiles(x86)%\!tools!"
|
||||
)
|
||||
|
||||
IF %version% == 17 (
|
||||
SET tools=Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
|
||||
SET environment="%programfiles%\!tools!"
|
||||
IF NOT EXIST !environment! (
|
||||
SET environment="%programfiles(x86)%\!tools!"
|
||||
IF NOT EXIST !environment! (
|
||||
SET tools=Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
IF %version% == 16 (
|
||||
SET tools=Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
|
||||
SET environment="%programfiles%\!tools!"
|
||||
IF NOT EXIST !environment! (
|
||||
SET environment="%programfiles(x86)%\!tools!"
|
||||
IF NOT EXIST !environment! (
|
||||
SET tools=Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
IF %version% == 15 (
|
||||
SET tools=Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
|
||||
SET environment="%programfiles%\!tools!"
|
||||
IF NOT EXIST !environment! (
|
||||
SET environment="%programfiles(x86)%\!tools!"
|
||||
IF NOT EXIST !environment! (
|
||||
SET tools=Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
|
||||
)
|
||||
)
|
||||
)
|
||||
SET environment="%programfiles%\!tools!"
|
||||
IF NOT EXIST !environment! SET environment="%programfiles(x86)%\!tools!"
|
||||
|
||||
ECHO Environment: !environment!
|
||||
|
||||
IF NOT DEFINED environment GOTO no_tools
|
||||
IF NOT EXIST !environment! GOTO no_tools
|
||||
|
||||
ECHO Environment: !environment!
|
||||
ECHO Building: %solution%
|
||||
|
||||
CALL !environment! x86 > nul 2>&1
|
||||
@@ -82,7 +54,7 @@ ECHO Configuration=StaticRelease
|
||||
msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=Win32 %solution% >> %log%
|
||||
IF errorlevel 1 GOTO error
|
||||
|
||||
ENDLOCAL & SET solution=%solution% & SET version=%version% & SET log=%log% & SET tools=%tools% & SET environment=%environment%
|
||||
ENDLOCAL & SET solution=%solution% & SET version=%version% & SET log=%log% & SET environment=%environment%
|
||||
SETLOCAL enabledelayedexpansion
|
||||
|
||||
CALL !environment! x86_amd64 > nul 2>&1
|
||||
@@ -107,12 +79,12 @@ ECHO Configuration=StaticRelease
|
||||
msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=x64 %solution% >> %log%
|
||||
IF errorlevel 1 GOTO error
|
||||
|
||||
@REM Build ARM64 packages only for Visual studio 2019 and later
|
||||
IF %version% GEQ 16 (
|
||||
ENDLOCAL & SET solution=%solution% & SET version=%version% & SET log=%log% & SET tools=%tools% & SET environment=%environment%
|
||||
@REM Build ARM64 packages only for Visual Studio 2022 and later
|
||||
IF %version% GEQ 17 (
|
||||
ENDLOCAL & SET solution=%solution% & SET version=%version% & SET log=%log% & SET environment=%environment%
|
||||
SETLOCAL enabledelayedexpansion
|
||||
|
||||
CALL !environment! ARM64 > nul 2>&1
|
||||
CALL !environment! amd64_arm64 > nul 2>&1
|
||||
ECHO Platform=ARM64
|
||||
|
||||
ECHO Configuration=DynDebug
|
||||
@@ -136,7 +108,7 @@ IF %version% GEQ 16 (
|
||||
)
|
||||
|
||||
ECHO Complete: %solution%
|
||||
GOTO end
|
||||
EXIT /B 0
|
||||
|
||||
:error
|
||||
ECHO *** ERROR, build terminated early, see: %log%
|
||||
@@ -144,10 +116,8 @@ ECHO.
|
||||
ECHO === Last errors from %log% ===
|
||||
findstr /i /c:"error " /c:"error:" /c:"fatal error" %log%
|
||||
ECHO.
|
||||
GOTO end
|
||||
EXIT /B 1
|
||||
|
||||
:no_tools
|
||||
ECHO *** ERROR, build tools not found: !tools!
|
||||
|
||||
:end
|
||||
|
||||
ECHO *** ERROR, Visual Studio %version% C++ build tools not found
|
||||
EXIT /B 1
|
||||
|
||||
Reference in New Issue
Block a user