Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // (C) 2023 Terminal Click - All Rights Reserved
- //
- // Zig Build File (expects zig v0.10.0)
- //
- // @author: Abner Coimbre <abner@terminal.click>
- //
- const std = @import("std");
- const bld = @import("std").build.Builder;
- pub fn build(b: *bld) void {
- b.setPreferredReleaseMode(.Debug);
- const mode = b.standardReleaseOptions();
- const target = b.standardTargetOptions(.{});
- const exe = b.addExecutable("TerminalClick", null);
- exe.setTarget(target);
- exe.setBuildMode(mode);
- const win_args = &[_][]const u8{
- "-Iinc",
- "",
- "-DSOKOL_D3D11",
- "-O0",
- "-ggdb3",
- "-fno-sanitize=undefined",
- "-std=c99",
- };
- const macos_args = &[_][]const u8{
- "-Iinc",
- "-ObjC",
- "-DSOKOL_METAL",
- "-O0",
- "-ggdb3",
- "-fno-sanitize=undefined",
- "-std=c99",
- };
- const linux_args = &[_][]const u8{
- "-Iinc",
- "-D_GNU_SOURCE",
- "-DSOKOL_GLCORE33",
- "-O0",
- "-ggdb3",
- "-fno-sanitize=undefined",
- "-std=c99",
- };
- var c_args: []const []const u8 = undefined;
- const tag = exe.target.getOs().tag;
- if (tag == .windows) {
- c_args = win_args;
- } else if (tag == .macos) {
- c_args = macos_args;
- } else if (tag == .linux) {
- c_args = linux_args;
- } else {
- std.debug.print("Error: Unsupported operating system! Contact Abner\n", .{});
- std.process.exit(1);
- }
- exe.addCSourceFile("src/main.c", c_args); // Unity build.
- exe.linkLibC();
- if (tag == .windows) {
- exe.linkSystemLibrary("kernel32");
- exe.linkSystemLibrary("gdi32");
- exe.linkSystemLibrary("d3d11");
- } else if (tag == .macos) {
- exe.linkFramework("MetalKit");
- exe.linkFramework("Metal");
- exe.linkFramework("Cocoa");
- exe.linkFramework("QuartzCore");
- } else if (tag == .linux) {
- // On a fresh Pop OS install it seems we needed the following commands:
- // sudo apt install libgl-dev
- // sudo apt install libxi-dev
- // sudo apt install libxcursor-dev
- exe.linkSystemLibrary("GL");
- exe.linkSystemLibrary("X11");
- exe.linkSystemLibrary("Xi");
- exe.linkSystemLibrary("Xcursor");
- } else {
- std.debug.print("[TC] Unsupported operating system! Contact Abner\n", .{});
- std.process.exit(1);
- }
- exe.install();
- const run_cmd = exe.run();
- run_cmd.step.dependOn(b.getInstallStep());
- if (b.args) |args| {
- run_cmd.addArgs(args);
- }
- const run_step = b.step("run", "Run the app");
- run_step.dependOn(&run_cmd.step);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement