basisu: pass CrossTarget to static libs
If we don't do that, we risk generating an invalid archive format for the cross-target.
This commit is contained in:
parent
8026526b99
commit
6ce4110bac
1 changed files with 8 additions and 6 deletions
|
|
@ -23,7 +23,7 @@ pub fn testStep(b: *Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget
|
||||||
main_tests.setBuildMode(mode);
|
main_tests.setBuildMode(mode);
|
||||||
main_tests.setTarget(target);
|
main_tests.setTarget(target);
|
||||||
main_tests.main_pkg_path = thisDir();
|
main_tests.main_pkg_path = thisDir();
|
||||||
link(b, main_tests, .{
|
link(b, main_tests, target, .{
|
||||||
.encoder = .{},
|
.encoder = .{},
|
||||||
.transcoder = .{},
|
.transcoder = .{},
|
||||||
});
|
});
|
||||||
|
|
@ -31,24 +31,25 @@ pub fn testStep(b: *Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget
|
||||||
return main_tests.run();
|
return main_tests.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
|
pub fn link(b: *Builder, step: *std.build.LibExeObjStep, target: std.zig.CrossTarget, options: Options) void {
|
||||||
if (options.encoder) |encoder_options| {
|
if (options.encoder) |encoder_options| {
|
||||||
step.linkLibrary(buildEncoder(b, encoder_options));
|
step.linkLibrary(buildEncoder(b, target, encoder_options));
|
||||||
step.addCSourceFile(comptime thisDir() ++ "/src/encoder/wrapper.cpp", &.{});
|
step.addCSourceFile(comptime thisDir() ++ "/src/encoder/wrapper.cpp", &.{});
|
||||||
step.addIncludePath(basisu_root ++ "/encoder");
|
step.addIncludePath(basisu_root ++ "/encoder");
|
||||||
}
|
}
|
||||||
if (options.transcoder) |transcoder_options| {
|
if (options.transcoder) |transcoder_options| {
|
||||||
step.linkLibrary(buildTranscoder(b, transcoder_options));
|
step.linkLibrary(buildTranscoder(b, target, transcoder_options));
|
||||||
step.addCSourceFile(comptime thisDir() ++ "/src/transcoder/wrapper.cpp", &.{});
|
step.addCSourceFile(comptime thisDir() ++ "/src/transcoder/wrapper.cpp", &.{});
|
||||||
step.addIncludePath(basisu_root ++ "/transcoder");
|
step.addIncludePath(basisu_root ++ "/transcoder");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buildEncoder(b: *Builder, options: EncoderOptions) *std.build.LibExeObjStep {
|
pub fn buildEncoder(b: *Builder, target: std.zig.CrossTarget, options: EncoderOptions) *std.build.LibExeObjStep {
|
||||||
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
|
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
|
||||||
ensureDependencySubmodule(b.allocator, "upstream") catch unreachable;
|
ensureDependencySubmodule(b.allocator, "upstream") catch unreachable;
|
||||||
|
|
||||||
const encoder = b.addStaticLibrary("basisu-encoder", null);
|
const encoder = b.addStaticLibrary("basisu-encoder", null);
|
||||||
|
encoder.setTarget(target);
|
||||||
encoder.linkLibCpp();
|
encoder.linkLibCpp();
|
||||||
encoder.addCSourceFiles(
|
encoder.addCSourceFiles(
|
||||||
encoder_sources,
|
encoder_sources,
|
||||||
|
|
@ -62,11 +63,12 @@ pub fn buildEncoder(b: *Builder, options: EncoderOptions) *std.build.LibExeObjSt
|
||||||
return encoder;
|
return encoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buildTranscoder(b: *Builder, options: TranscoderOptions) *std.build.LibExeObjStep {
|
pub fn buildTranscoder(b: *Builder, target: std.zig.CrossTarget, options: TranscoderOptions) *std.build.LibExeObjStep {
|
||||||
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
|
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
|
||||||
ensureDependencySubmodule(b.allocator, "upstream") catch unreachable;
|
ensureDependencySubmodule(b.allocator, "upstream") catch unreachable;
|
||||||
|
|
||||||
const transcoder = b.addStaticLibrary("basisu-transcoder", null);
|
const transcoder = b.addStaticLibrary("basisu-transcoder", null);
|
||||||
|
transcoder.setTarget(target);
|
||||||
transcoder.linkLibCpp();
|
transcoder.linkLibCpp();
|
||||||
transcoder.addCSourceFiles(
|
transcoder.addCSourceFiles(
|
||||||
transcoder_sources,
|
transcoder_sources,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue