diff --git a/Makefile b/Makefile index 662c785dd..054306394 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/base/build.zig b/base/build.zig index 3a5b58636..0477a0aad 100644 --- a/base/build.zig +++ b/base/build.zig @@ -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 ""; @@ -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", .{}); diff --git a/compiler/ActonCompiler.hs b/compiler/ActonCompiler.hs index 7781c5565..cac80491e 100644 --- a/compiler/ActonCompiler.hs +++ b/compiler/ActonCompiler.hs @@ -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 ++ @@ -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