Skip to content

Commit

Permalink
Replace hack with a better hack
Browse files Browse the repository at this point in the history
  • Loading branch information
mlafeldt committed Jan 22, 2025
1 parent 0dd56b1 commit abfac56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
version: "0.13.0"
- uses: astral-sh/setup-uv@v5
- run: zig build -Dduckdb-version=${{ matrix.duckdb_version }} -Dinstall-headers --verbose --summary new
- run: DUCKDB_METADATA_PLATFORM=linux_amd64_gcc4 zig build test -Dduckdb-version=${{ matrix.duckdb_version }} --summary none
- run: zig build test -Dduckdb-version=${{ matrix.duckdb_version }} -Dplatform-suffix=gcc4 --summary none
9 changes: 3 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const duckdb_version = b.option(DuckDBVersion, "duckdb-version", b.fmt("DuckDB version to build for (default: {s})", .{@tagName(DuckDBVersion.default)})) orelse DuckDBVersion.default;
const platforms = b.option([]const Platform, "platform", "DuckDB platform(s) to build for (default: all)") orelse std.enums.values(Platform);
const platform_suffix = b.option([]const u8, "platform-suffix", "Add suffix to platform name, e.g. gcc4");
const install_headers = b.option(bool, "install-headers", "Install DuckDB C headers") orelse false;

const ext_version = v: {
Expand All @@ -52,6 +53,7 @@ pub fn build(b: *std.Build) !void {
.windows_amd64 => .{ .os_tag = .windows, .cpu_arch = .x86_64, .abi = .gnu },
.windows_arm64 => .{ .os_tag = .windows, .cpu_arch = .aarch64, .abi = .gnu },
});
const platform_name = if (platform_suffix) |suffix| b.fmt("{s}_{s}", .{ @tagName(platform), suffix }) else @tagName(platform);

const duckdb = b.lazyDependency(b.fmt("duckdb-{s}", .{@tagName(duckdb_version)}), .{}) orelse continue;

Expand All @@ -74,9 +76,6 @@ pub fn build(b: *std.Build) !void {

// TODO: Rewrite the metadata script in Zig
const ext_path = out: {
// HACK: Allow to override platform for GitHub Actions where linux_amd64_gcc4 is used
const platform_name = std.process.getEnvVarOwned(b.allocator, "DUCKDB_METADATA_PLATFORM") catch @tagName(platform);

const cmd = b.addSystemCommand(&.{ "uv", "run", "--python=3", metadata_script });
cmd.addArgs(&.{ "--extension-name", ext.name });
cmd.addArgs(&.{ "--extension-version", ext_version });
Expand All @@ -88,11 +87,9 @@ pub fn build(b: *std.Build) !void {
break :out cmd.addOutputFileArg(filename);
};

const install_dir = @tagName(platform);

b.getInstallStep().dependOn(&b.addInstallFileWithDir(
ext_path,
.{ .custom = install_dir },
.{ .custom = platform_name },
filename,
).step);

Expand Down

0 comments on commit abfac56

Please sign in to comment.