Skip to content

Commit

Permalink
use opend-xpack-emscripten druntime
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Dec 8, 2024
1 parent 0b26d44 commit 489e31f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
15 changes: 12 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,10 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*std.Build.Step.InstallDi
// keep all function bodies in .di files
ldc_exec.addArg("-Hkeep-all-bodies");

// automatically finds needed library files and builds
ldc_exec.addArg("-i");
// automatically finds needed modules
ldc_exec.addArg("-i=sokol");
ldc_exec.addArg("-i=shaders");
ldc_exec.addArg("-i=handmade");

// sokol include path
ldc_exec.addArg(b.fmt("-I{s}", .{b.pathJoin(&.{ rootPath(), "src" })}));
Expand Down Expand Up @@ -586,8 +588,9 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*std.Build.Step.InstallDi
.emsdk = options.emsdk.?,
.use_webgpu = backend == .wgpu,
.use_webgl2 = backend != .wgpu,
.use_emmalloc = true,
.use_emmalloc = options.betterC,
.use_filesystem = false,
.use_drt = !options.betterC and options.target.result.isWasm(),
.use_ubsan = options.artifact.?.root_module.sanitize_c orelse false,
.release_use_lto = options.artifact.?.want_lto orelse false,
.shell_file_path = b.path("src/sokol/web/shell.html"),
Expand Down Expand Up @@ -759,6 +762,7 @@ pub const EmLinkOptions = struct {
use_emmalloc: bool = false,
use_filesystem: bool = true,
use_ubsan: bool = false,
use_drt: bool = false,
shell_file_path: ?Build.LazyPath,
extra_args: []const []const u8 = &.{},
};
Expand Down Expand Up @@ -809,6 +813,11 @@ pub fn emLinkStep(b: *Build, options: EmLinkOptions) !*Build.Step.InstallDir {
emcc.addArg(arg);
}

if (options.use_drt) {
const xpack = b.dependency("xpack", .{}).path("lib").getPath(b);
emcc.addFileArg(path(b, b.fmt("{s}/libdruntime-ldc.a", .{xpack})));
emcc.addFileArg(path(b, b.fmt("{s}/libphobos2-ldc.a", .{xpack})));
}
// add the main lib, and then scan for library dependencies and add those too
emcc.addArtifactArg(options.lib_main);
var it = options.lib_main.root_module.iterateDependencies(options.lib_main, false);
Expand Down
4 changes: 4 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
.url = "git+https://github.com/floooh/sokol-tools-bin#3388e3b2c04b532a55b072d79e77c9fc44c3ca50",
.hash = "1220bd7b3c90b9b827145dfb25cf35fa2bfbb1d04ff597d5540eda06b97f3fb612a7",
},
.xpack = .{
.url = "https://github.com/opendlang/opend/releases/download/CI/opend-latest-xpack-emscripten.tar.xz",
.hash = "12207ff27668e40a4054a60bda3fd33c3d49c603a8b06c568afad536a969ccf3c410",
},
},
}
20 changes: 10 additions & 10 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/clear.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand All @@ -58,7 +58,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/sgl_context.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand All @@ -74,7 +74,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/sgl_points.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand All @@ -90,7 +90,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/debugtext.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand All @@ -106,7 +106,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/triangle.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand All @@ -122,7 +122,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/blend.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand All @@ -138,7 +138,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/saudio.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand All @@ -154,7 +154,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/mrt.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand All @@ -170,7 +170,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/cube.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand All @@ -186,7 +186,7 @@ subPackage {
targetPath "build"
sourceFiles "src/examples/user_data.d"
libs "sokol"
dflags "-preview=all" "-i"
dflags "-preview=all" "-i=sokol" "-i=shaders" "-i=handmade"
libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux"
lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx"
libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows"
Expand Down

0 comments on commit 489e31f

Please sign in to comment.