Build And Test
Rule
Do not manually drive the repo with ad-hoc cmake commands for normal work.
Use morphc — the unified build system (scripts/morphc_build, invoked via morphc.bat on Windows or python3 -m scripts.morphc_build elsewhere):
morphc build :: smart incremental build
morphc build --test :: build once, then run full tests
morphc build --test "flow" :: build once, then run tests matching pattern
morphc build --test "a" --test "b" :: multiple filtered passes (one run per pattern)
morphc test :: build + run all tests
morphc test "flow" :: filtered tests (unit + behavior rules below)
morphc doctor :: diagnose environment
morphc fails :: show details of the last test failures
If a background build is already running, do not start morphc test. Wait for it to finish, or use morphc build --test ... so build and tests are serialized. (The driver detects active compiler/link processes on Windows and refuses test when they overlap the workspace.)
Optional env / flags
- Toolchain: Usually no need to set
LLVM_DIRorMORPH_TOOLCHAIN_BIN. The driver probes MSYS2 MinGW, LLVM, Ninja, and CMake. To force the MinGWbindirectory, setMORPH_TOOLCHAIN_BIN(derived fromconfig/branding.toml→MORPH_*whencanonical = "morph"). morphc build --testextras:--test-unit-only,--test-timeout,--test-stop-on-fail,--test-expose N(behavior suite).morphc test:--list,--unit-only,--timeout,--stop-on-fail,--expose,-j.
Typical auto-detected Windows paths (examples, not requirements):
C:\msys64\mingw64\bin\c++.exeC:\msys64\mingw64\bin\ninja.exeC:\msys64\mingw64\lib\cmake\llvm\LLVMConfig.cmake
Full pipeline
From repo root:
morphc build
This:
- resolves workspace under
%LOCALAPPDATA%\<vendor>\workspaces\<canonical>\(e.g.%LOCALAPPDATA%\Morph\workspaces\morph\) - auto-detects toolchain (MSYS2, LLVM, Ninja)
- hashes manifests (
morph.toml,feature.toml,block.toml,domain.toml, relevantCMakeLists.txt, etc.) and reconfigures when needed - builds with Ninja (or fallback generator) and surfaces structured errors
Targeted tests
morphc test "PackageManager"
morphc test "flow"
morphc test --list
morphc test --unit-only
Filtered morphc test "pattern": if no C++ unit test names match, the driver skips the unit binary and runs behavior tests whose .mx sources match the pattern. With no pattern, unit tests run first and the behavior suite runs only after unit tests succeed. See scripts/morphc_build/test_runner.py for details.
Build targets
Pass CMake target names to morphc build -t (or -t "t1 t2"):
morphc build -t morphlang_unit_tests :: unit test binary only
morphc build -t morphlang :: compiler CLI only
Other targets exist in CMakeLists.txt (e.g. morphlang-lsp, domain hosts). There is no ncon executable target in the current top-level CMake; do not document it unless it returns to the tree.
morphc run
morphc run path\to\File.mx -- arg1 arg2
Ensures the morphlang target is built, then runs morph run <file> with the staged compiler under the workspace bin directory (see scripts/morphc_build/cli.py::_cmd_run). Behavior matches the morph run CLI for that file/cwd.
Command summary
| Command | Description |
|---|---|
morphc build | Incremental build |
morphc build --clean | Clean reconfigure + build |
morphc build --debug | Debug build |
morphc build -t TARGET | Build specific target(s) |
morphc build --test [PATTERN] | After build, run tests (omit pattern = full suite); repeatable |
morphc build --test --test-unit-only | Post-build: C++ unit tests only |
morphc test | Build + all tests |
morphc test PATTERN | Build + filtered tests |
morphc test --list | List tests |
morphc test --unit-only | Skip behavior suite |
morphc fails | Last failure details |
morphc configure | Configure only |
morphc configure --clean | Wipe cache + configure |
morphc clean | Remove workspace build dir + state snapshot |
morphc doctor | Environment diagnosis |
morphc status | Build state / history |
morphc watch | Watch + rebuild |
morphc run FILE | Build compiler + morph run FILE |
Aliases (examples): b → build, t → test, r → run, w → watch, cfg → configure, doc → doctor, st → status.
Smart reconfigure
The driver hashes CMake and morph manifest inputs (including under morphs/ and domains/) and triggers reconfigure when they change.
Logs
- Build logs:
%LOCALAPPDATA%\<WorkspaceVendor>\workspaces\<canonical>\logs\build_*.log - Test results:
%LOCALAPPDATA%\<WorkspaceVendor>\workspaces\<canonical>\build-mingw\test-results\ - Quick state:
morphc status
For default branding (canonical = morph, vendor dir Morph), that is %LOCALAPPDATA%\Morph\workspaces\morph\....
Anti-pattern
Avoid unless you are changing the build system itself:
cmake -S . -B build/cmake --build ...for routine work- invoking Ninja directly against ad-hoc build dirs
- relying on
n.bator rawbuild.shwhenmorphcis available
Cross-platform
| Method | Command | Notes |
|---|---|---|
| morphc | morphc.bat … or python3 -m scripts.morphc_build … | Preferred |
| Make | make / make test FILTER=… | Delegates to scripts.morphc_build |