Skip to content

Commit

Permalink
Merge pull request #22 from pierrelgol/enhancements
Browse files Browse the repository at this point in the history
Various enhancements / update of the std.builtin.Type enum usage
  • Loading branch information
andrewCodeDev authored Sep 7, 2024
2 parents f365786 + 50253e4 commit b702076
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 206 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file is for zig-specific build artifacts.
# If you have OS-specific or editor-specific files to ignore,
# such as *.swp or .DS_Store, put those in your global
# ~/.gitignore and put this in your ~/.gitconfig:
#
# [core]
# excludesfile = ~/.gitignore
#
# Cheers!
# -andrewrk

.zig-cache/
zig-out/
/release/
/debug/
/build/
/build-*/
/docgen_tmp/

# Although this was renamed to .zig-cache, let's leave it here for a few
# releases to make it less annoying to work with multiple branches.
zig-cache/

38 changes: 21 additions & 17 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
const std = @import("std");

// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});

// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});

const lib = b.addStaticLibrary(.{
.name = "Fluent",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = b.path("fluent.zig"),
.target = target,
.optimize = optimize,
});

// This declares intent for the library to be installed into the standard
// location when the user invokes the "install" step (the default step when
// running `zig build`).
b.installArtifact(lib);

// Export as module to be available for @import("Fluent") on user site
const check = b.addStaticLibrary(.{
.name = "Fluent",
.root_source_file = b.path("fluent.zig"),
.target = target,
.optimize = optimize,
.use_llvm = false,
.use_lld = false,
});
const check_step = b.step("check", "check if the code compiles");
check_step.dependOn(&check.step);

const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("fluent.zig"),
.target = target,
.optimize = optimize,
});

const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);

_ = b.addModule("Fluent", .{
.root_source_file = b.path("fluent.zig"),
.target = target,
Expand Down
Loading

0 comments on commit b702076

Please sign in to comment.