sonar

Scan files at memory bandwidth speed.
Log | Files | Refs

commit babaf2f99e3fc420d2eac85fb37ace10d1455a48
parent 91d48e5ecf812c99605f6667ee983a4b5a1edd5c
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date:   Wed, 16 Sep 2026 21:22:50 -0400

build: replace build.cmd with a Makefile writing to build/

A Makefile works from any shell on Windows, macOS, and Linux, which matters
because the parser is meant to go cross-platform. Debug and release binaries
land in build/debug and build/release so both can exist at once, and the
source tree stays free of compiler output. Targets rebuild only when a source
file changes. Odin does not create output directories, so each output has an
order-only prerequisite that makes its directory.

Diffstat:
AMakefile | 45+++++++++++++++++++++++++++++++++++++++++++++
Dbuild.cmd | 24------------------------
2 files changed, 45 insertions(+), 24 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,45 @@ +# sonar build +# +# make debug build -> build/debug/sonar.exe +# make release optimised build -> build/release/sonar.exe +# make test run the ntfs tests -> build/test/ntfs.exe +# make check type-check both modes without producing a binary +# make clean remove build/ +# +# GNU Make runs recipes through sh even on Windows (scoop's make finds sh.exe), so +# the recipes use POSIX commands. Odin does not create output directories, hence the +# order-only directory prerequisites. + +ODIN ?= odin +BUILD := build +FLAGS := -vet -strict-style +EXE := $(if $(filter Windows_NT,$(OS)),.exe,) + +SRC := $(wildcard *.odin) $(wildcard ntfs/*.odin) $(wildcard lifetime/*.odin) + +.PHONY: all debug release test check clean + +all: debug + +debug: $(BUILD)/debug/sonar$(EXE) + +release: $(BUILD)/release/sonar$(EXE) + +$(BUILD)/debug/sonar$(EXE): $(SRC) | $(BUILD)/debug + $(ODIN) build . -debug $(FLAGS) -out:$@ + +$(BUILD)/release/sonar$(EXE): $(SRC) | $(BUILD)/release + $(ODIN) build . -o:speed $(FLAGS) -out:$@ + +test: | $(BUILD)/test + $(ODIN) test ntfs $(FLAGS) -out:$(BUILD)/test/ntfs$(EXE) + +check: + $(ODIN) check . $(FLAGS) + $(ODIN) check . -debug $(FLAGS) + +$(BUILD)/debug $(BUILD)/release $(BUILD)/test: + mkdir -p $@ + +clean: + rm -rf $(BUILD) diff --git a/build.cmd b/build.cmd @@ -1,24 +0,0 @@ -@echo off -setlocal -set "MODE=%~1" -if "%MODE%"=="" set "MODE=debug" - -if /i "%MODE%"=="debug" ( - odin build . -debug -vet -strict-style -out:sonar.exe - exit /b %errorlevel% -) -if /i "%MODE%"=="release" ( - odin build . -o:speed -vet -strict-style -out:sonar.exe - exit /b %errorlevel% -) -if /i "%MODE%"=="test" ( - odin test ntfs -vet -strict-style - exit /b %errorlevel% -) -if /i "%MODE%"=="check" ( - odin check . -vet -strict-style - exit /b %errorlevel% -) - -echo usage: build [debug^|release^|test^|check] -exit /b 1