Skip to content

kassane/anotherBuildStep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

anotherBuildStep [WiP]

Overview

anotherBuildStep is a project designed to leverage the Zig build system (build.zig) for building projects with various other toolchains. This allows developers to use Zig as a unified build system across different environments and toolsets.

TODO

  • ldc2 support
  • rustc (no cargo) support
  • rustc (cargo) support (need to figure out how to get the cargo build system to work)

Required

  • zig v0.12.0 or master

Supported

  • ldc2 v1.36.0 or latest-CI
  • rustc stable or nightly

Usage

Make new project or add to existing project:

In project folder, add this package, as dependency on your build.zig.zon

$ zig fetch --save git+https://github.com/kassane/anotherBuildStep#{commit-tag}
  • add @import("anotherBuildStep") to build.zig
const std = @import("std");
// get build.zig from pkg to extend your build.zig project (only pub content module)
const abs = @import("anotherBuildStep"); 

pub fn build(b: *std.Build) !void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});
    const exe = try abs.ldcBuildStep(b, .{
        .name = "helloD",
        .target = target,
        .optimize = optimize,
        .sources = &.{"src/main.d"},
        .dflags = &.{
            "-w",
        },
    });
    b.default_step.dependOn(&exe.step);

    // or

    const exeRust = try abs.rustcBuildStep(b, .{
        .name = "helloRust",
        .target = target,
        .optimize = optimize,
        .source = "src/main.rs",
        .rflags = &.{
            "-C",
            "panic=abort",
        },
    });
    b.default_step.dependOn(&exeRust.step);
}

Languages