Skip to content

Commit

Permalink
Support using --cpedantic for base
Browse files Browse the repository at this point in the history
Set the env var CPEDANTIC and base will be compiled with --cpedantic
  • Loading branch information
plajjan committed Aug 15, 2023
1 parent 2ba603e commit 20e93be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ CFLAGS_DEV= -g -DDEV
LDFLAGS+=-L$(TD)/lib
LDLIBS += -lActonDeps-$(PLATFORM) -lm -lpthread

ifdef CPEDANTIC
CPEDANTIC=--cpedantic
endif

# rewrite arm64 to aarch64
ifeq ($(shell uname -m),arm64)
ARCH:=aarch64
Expand Down Expand Up @@ -326,17 +330,17 @@ dist/depsout/lib/libyyjson.a: dist/deps/libyyjson $(DIST_ZIG)
ifeq ($(ARCH),x86_64)
ZIG_ARCH_ARG=-mcpu=x86_64
endif
builder/builder: builder/build.zig $(ZIG_DEP) $(DEPS_DIRS)
builder/builder: builder/build.zig backend/build.zig base/build.zig $(ZIG_DEP) $(DEPS_DIRS)
rm -rf builder/zig-cache builder/zig-out
(echo 'const root = @import("build.zig");'; tail -n +2 dist/zig/lib/build_runner.zig) > builder/build_runner.zig
cd builder && $(ZIG) build-exe build_runner.zig -femit-bin=builder $(ZIG_ARCH_ARG)

.PHONY: base/out/rel/lib/libActon.a base/out/dev/lib/libActon.a
base/out/rel/lib/libActon.a: $(ACTONC) $(DEPS)
cd base && ../dist/bin/actonc build --auto-stub --ccmd
cd base && ../dist/bin/actonc build --auto-stub $(CPEDANTIC)

base/out/dev/lib/libActon.a: $(ACTONC) $(DEPS)
cd base && ../dist/bin/actonc build --auto-stub --dev --ccmd
cd base && ../dist/bin/actonc build --auto-stub --dev $(CPEDANTIC)

base/out/types/__builtin__.ty: $(ACTONC)
cd base && ../dist/bin/actonc src/__builtin__.act
Expand Down
4 changes: 4 additions & 0 deletions base/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn build(b: *std.build.Builder) void {
print("Acton Base Builder\nBuilding in {s}\n", .{buildroot_path});
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const cpedantic = b.option(bool, "cpedantic", "") orelse false;
const use_prebuilt = b.option(bool, "use_prebuilt", "") orelse false;
const projpath = b.option([]const u8, "projpath", "") orelse "";
const projpath_outtypes = b.option([]const u8, "projpath_outtypes", "") orelse "";
Expand Down Expand Up @@ -120,6 +121,9 @@ pub fn build(b: *std.build.Builder) void {
file_prefix_map.appendSlice(file_prefix_path_path) catch unreachable;
file_prefix_map.appendSlice("/=") catch unreachable;
flags.append(file_prefix_map.items) catch unreachable;
if (cpedantic) {
flags.append("-Werror") catch unreachable;
}

if (optimize == .Debug) {
print("Debug build\n", .{});
Expand Down
3 changes: 2 additions & 1 deletion compiler/ActonCompiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ zigBuild env opts paths tasks binTasks = do
if (C.debug opts) then " --verbose " else "" ++
" -Dtarget=" ++ (C.target opts) ++
" -Doptimize=" ++ (if (C.dev opts) then "Debug" else "ReleaseFast") ++
(if (C.cpedantic opts) then " -Dcpedantic " else " ") ++
" -Dprojpath=" ++ projPath paths ++
" -Dprojpath_outtypes=" ++ joinPath [ projPath paths, "out", "types" ] ++
" -Dsyspath=" ++ sysPath paths ++
Expand All @@ -901,7 +902,7 @@ zigBuild env opts paths tasks binTasks = do
" -Dsyspath_include=" ++ joinPath [ sysPath paths, "depsout", "include" ] ++
" -Dsyspath_lib=" ++ joinPath [ sysPath paths, "depsout", "lib" ] ++
" -Dsyspath_libreldev=" ++ joinPath [ sysPath paths, "lib", reldev ] ++
if use_prebuilt then " -Duse_prebuilt" else ""
(if use_prebuilt then " -Duse_prebuilt" else "")

runZig opts zigCmd (Just (projPath paths))
-- if we are in a temp acton project, copy the outputted binary next to the source file
Expand Down

0 comments on commit 20e93be

Please sign in to comment.