Skip to content

Commit

Permalink
fix build for zig 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Nov 29, 2024
1 parent ef3330d commit 0f76171
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ omg-cli
*.dylib
/.vagrant
.DS_Store
zig-cache
.zig-cache
zig-out
.env
.project
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zig 0.13.0
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ memcheck:
$(SO_FILE): $(EMACS_HEADERS) $(EMACS_OBJECTS)
$(CC) -shared $(EMACS_OBJECTS) $(LDFLAGS) -o $(SO_FILE)

emacs-dyn: $(SO_FILE)
@echo "Emacs dynamic module saved to $(SO_FILE)"
emacs-dyn:
zig build -Doptimize=ReleaseFast
mv zig-out/lib/libomg-dyn.* emacs/omg-dyn.so

install-deps:
ifeq ($(uname_S), Darwin)
Expand Down
35 changes: 17 additions & 18 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ const OptimizeMode = std.builtin.OptimizeMode;
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const verbose = b.option(bool, "verbose", "Enable verbose log");
const quick = b.option(bool, "quick", "Enable quick mode");
const verbose = b.option(bool, "verbose", "Enable verbose log") orelse false;
const quick = b.option(bool, "quick", "Enable quick mode") orelse false;
const build_cli = b.option(bool, "build_cli", "Whether build cli") orelse false;
const core_lib = b.addStaticLibrary(.{
.name = "omg-core",
.root_source_file = .{ .path = "core/omg.zig" },
.root_source_file = b.path("core/omg.zig"),
.target = target,
.optimize = optimize,
});
Expand All @@ -24,15 +25,11 @@ pub fn build(b: *std.Build) !void {
try cflags.append("-Wno-unused-parameter");
try cflags.append("-Wno-gnu");
try cflags.append("-Wimplicit-fallthrough");
if (verbose) |v| {
if (v) {
try cflags.append("-DVERBOSE");
}
if (verbose) {
try cflags.append("-DVERBOSE");
}
if (quick) |v| {
if (v) {
try cflags.append("-DOMG_TEST");
}
if (quick) {
try cflags.append("-DOMG_TEST");
}
core_lib.addIncludePath(b.path("core"));
core_lib.addCSourceFile(.{
Expand All @@ -46,12 +43,14 @@ pub fn build(b: *std.Build) !void {
core_lib.linkLibC();

buildEmacsModule(b, core_lib, target, optimize, cflags.items);
buildCliTool(
b,
core_lib,
target,
optimize,
);
if (build_cli) {
buildCliTool(
b,
core_lib,
target,
optimize,
);
}

inline for (.{ "core", "discussion" }) |name| {
buildTest(
Expand Down Expand Up @@ -94,7 +93,7 @@ fn buildCliTool(
.optimize = optimize,
});

const zigcli_dep = b.dependency("zigcli", .{});
const zigcli_dep = b.lazyDependency("zigcli", .{}) orelse return {};
exe.root_module.addImport("simargs", zigcli_dep.module("simargs"));
exe.root_module.addImport("pretty-table", zigcli_dep.module("pretty-table"));

Expand Down
1 change: 1 addition & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
.zigcli = .{
.url = "https://github.com/jiacai2050/zigcli/archive/c0c48df7567ea02458e9fc1f35c4088271b8d4a6.tar.gz",
.hash = "12206260a09f871fcd3726540c139d1801beeda788ca593a1bdb6eb0da671d3c3522",
.lazy = true,
},
},
}
2 changes: 1 addition & 1 deletion emacs/omg.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
;; Public main API

;;;###autoload
(defun omg-setup()
(defun omg-setup ()
"Setup oh-my-github"
(unless omg-username
(when-let ((user (omg--execute "config" "github.user")))
Expand Down

0 comments on commit 0f76171

Please sign in to comment.