mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 12:28:30 +00:00
Added:
- `sharedlib` build kind (shared library output) - ASM projects (`build.language = "asm"`) - NASM and GAS backends - `build.platform` architecture hint for `-march` / `/arch` - Basic CLI integration tests
This commit is contained in:
@@ -17,10 +17,13 @@ Current DCR focuses on a simple, predictable workflow:
|
||||
- C: `*.c`
|
||||
- C++: `*.cpp`, `*.cxx`, `*.cc`
|
||||
- Compiler selection from `dcr.toml` (`clang`, `gcc`, `cl`, `clang-cl`, etc.).
|
||||
- Two build kinds:
|
||||
- ASM support via `language = "asm"` (GCC/Clang, NASM, GAS).
|
||||
- Three build kinds:
|
||||
- `bin` (default)
|
||||
- `staticlib`
|
||||
- `sharedlib`
|
||||
- Optional custom output directory via `build.target`.
|
||||
- Optional `build.platform` to pass architecture hints (`-march` / `/arch`).
|
||||
- Path dependencies with include/lib resolution and `dcr.lock` generation.
|
||||
|
||||
## Important behavior notes
|
||||
|
||||
@@ -17,7 +17,7 @@ dcr build --release
|
||||
3. Resolves path dependencies from `[dependencies]`.
|
||||
4. Creates required output directories.
|
||||
5. Recursively compiles sources from `src/`.
|
||||
6. Links final artifact (binary or static library).
|
||||
6. Links final artifact (binary or library).
|
||||
|
||||
## Config values used
|
||||
|
||||
@@ -27,6 +27,7 @@ dcr build --release
|
||||
- `build.standard`
|
||||
- `build.kind`
|
||||
- `build.target`
|
||||
- `build.platform`
|
||||
- `build.cflags`
|
||||
- `build.ldflags`
|
||||
|
||||
@@ -34,9 +35,11 @@ dcr build --release
|
||||
|
||||
- `language = "c"` -> `*.c`
|
||||
- `language = "c++" | "cpp" | "cxx"` -> `*.cpp`, `*.cxx`, `*.cc`
|
||||
- `language = "asm"` -> `*.s`, `*.S`, `*.asm`
|
||||
|
||||
## Notes
|
||||
|
||||
- The profile is selected from the first argument only.
|
||||
- Unknown profile flags return an error.
|
||||
- Incremental rebuild is based on source/object mtime comparison.
|
||||
- For `language = "asm"` with `compiler = "as"`/`"gas"`, use `.s` files (no preprocessing). For `.S`, use `gcc` or `clang`.
|
||||
|
||||
@@ -19,7 +19,7 @@ dcr run --release
|
||||
|
||||
## Restrictions
|
||||
|
||||
- If `build.kind = "staticlib"`, `run` exits with error.
|
||||
- If `build.kind = "staticlib"` or `build.kind = "sharedlib"`, `run` exits with error.
|
||||
- The profile is selected from the first argument.
|
||||
|
||||
## On build failure
|
||||
|
||||
@@ -33,7 +33,25 @@ By default:
|
||||
- `target/debug/<name>` (or `.exe` on Windows)
|
||||
- `target/release/<name>` (or `.exe` on Windows)
|
||||
|
||||
Default compiler flags:
|
||||
|
||||
GCC/Clang:
|
||||
|
||||
- `debug`: `-O0 -g -Wall -Wextra -fno-omit-frame-pointer -DDEBUG`
|
||||
- `release`: `-O3 -DNDEBUG -march=native`
|
||||
|
||||
MSVC:
|
||||
|
||||
- `debug`: `/Od /Zi /W4 /DDEBUG /Oy-`
|
||||
- `release`: `/O2 /DNDEBUG`
|
||||
|
||||
Static library mode (`kind = "staticlib"`):
|
||||
|
||||
- Linux/macOS: `lib<name>.a`
|
||||
- Windows: `<name>.lib`
|
||||
|
||||
Shared library mode (`kind = "sharedlib"`):
|
||||
|
||||
- Linux: `lib<name>.so`
|
||||
- macOS: `lib<name>.dylib`
|
||||
- Windows: `<name>.dll`
|
||||
|
||||
@@ -10,17 +10,19 @@ compiler = "clang"
|
||||
kind = "bin"
|
||||
# optional:
|
||||
# target = "./dist"
|
||||
# platform = "x86_64"
|
||||
# cflags = ["-Wall"]
|
||||
# ldflags = ["-lm"]
|
||||
```
|
||||
|
||||
## Fields
|
||||
|
||||
- `language` (string, required): `c`, `c++`, `cpp`, or `cxx`.
|
||||
- `language` (string, required): `c`, `c++`, `cpp`, `cxx`, or `asm`.
|
||||
- `standard` (string, required): language standard passed to compiler.
|
||||
- `compiler` (string, required): compiler command (for example `clang`, `gcc`, `cl`).
|
||||
- `kind` (string, required): `bin` or `staticlib`.
|
||||
- `kind` (string, required): `bin`, `staticlib`, or `sharedlib`.
|
||||
- `target` (string, optional): custom output directory for final artifact.
|
||||
- `platform` (string, optional): architecture hint for compiler (used for `-march` or `/arch`).
|
||||
- `cflags` (string array, optional): extra compile flags.
|
||||
- `ldflags` (string array, optional): extra link flags.
|
||||
|
||||
@@ -28,4 +30,4 @@ kind = "bin"
|
||||
|
||||
- Compiler backend is selected by compiler string (`gcc`, `clang`, `cl`, `clang-cl`).
|
||||
- Empty or unknown compiler value falls back to clang-like build path.
|
||||
- `run` is not allowed for `kind = "staticlib"`.
|
||||
- `run` is not allowed for library kinds (`staticlib`, `sharedlib`).
|
||||
|
||||
@@ -35,7 +35,7 @@ kind = "bin"
|
||||
- `build.compiler`
|
||||
- `build.kind`
|
||||
|
||||
`build.kind` must be either `bin` or `staticlib`.
|
||||
`build.kind` must be either `bin`, `staticlib`, or `sharedlib`.
|
||||
|
||||
## Optional keys
|
||||
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
DCR picks a backend from `build.compiler`:
|
||||
|
||||
- contains `clang-cl` -> MSVC backend
|
||||
- equals `as` or contains `gas` -> GAS backend (standalone assembler)
|
||||
- contains `gcc` or `g++` -> GCC backend
|
||||
- contains `clang` or `clang++` -> Clang backend
|
||||
- equals `cl` or contains `msvc` -> MSVC backend
|
||||
- contains `nasm` -> NASM backend
|
||||
- otherwise -> Clang backend fallback
|
||||
|
||||
## Compilation model
|
||||
@@ -16,6 +18,27 @@ DCR picks a backend from `build.compiler`:
|
||||
- Each source is compiled to `target/<profile>/obj/<relative-path>.o` (`.obj` on MSVC).
|
||||
- Recompile happens when source mtime is newer than object mtime.
|
||||
|
||||
## Default build flags
|
||||
|
||||
These flags are applied automatically based on profile and compiler backend.
|
||||
|
||||
GCC/Clang:
|
||||
|
||||
- `debug`: `-O0 -g -Wall -Wextra -fno-omit-frame-pointer -DDEBUG`
|
||||
- `release`: `-O3 -DNDEBUG -march=native`
|
||||
|
||||
MSVC:
|
||||
|
||||
- `debug`: `/Od /Zi /W4 /DDEBUG /Oy-`
|
||||
- `release`: `/O2 /DNDEBUG`
|
||||
|
||||
## Platform hint
|
||||
|
||||
If `build.platform` is set, DCR passes it as an architecture hint:
|
||||
|
||||
- GCC/Clang: `-march=<platform>`
|
||||
- MSVC: maps to `/arch:*` for known values (`x86`, `i386`, `i486`, `i586`, `i686`, `sse2`, `avx`, `avx2`)
|
||||
|
||||
## Linking
|
||||
|
||||
For `kind = "bin"`:
|
||||
@@ -28,3 +51,9 @@ For `kind = "staticlib"`:
|
||||
|
||||
- Linux/macOS (GCC/Clang): `ar rcs` creates `.a` archive.
|
||||
- Windows (MSVC): `lib` creates `.lib` archive.
|
||||
|
||||
For `kind = "sharedlib"`:
|
||||
|
||||
- Linux (GCC/Clang): `-shared` with output `.so`.
|
||||
- macOS (Clang): `-dynamiclib` with output `.dylib`.
|
||||
- Windows (MSVC): `/LD` with output `.dll`.
|
||||
|
||||
@@ -41,6 +41,6 @@ dcr clean --release
|
||||
|
||||
## Notes
|
||||
|
||||
- `run` is unavailable for `build.kind = "staticlib"`.
|
||||
- `run` is unavailable for `build.kind = "staticlib"` and `build.kind = "sharedlib"`.
|
||||
- Build profile flag is parsed from the first command argument.
|
||||
- Unknown profile flags produce an error.
|
||||
|
||||
@@ -35,5 +35,6 @@ project/
|
||||
- `target/<profile>/deps/`: synchronized copies of path dependencies.
|
||||
- `target/<profile>/<name>` (or `.exe` on Windows): output for `kind = "bin"`.
|
||||
- `target/<profile>/lib<name>.a` (or `<name>.lib` on Windows): output for `kind = "staticlib"`.
|
||||
- `target/<profile>/lib<name>.so` (or `.dylib` on macOS, `<name>.dll` on Windows): output for `kind = "sharedlib"`.
|
||||
|
||||
If `build.target` is set, the final artifact is written to that custom directory, while object cache still stays in `target/<profile>/obj`.
|
||||
|
||||
@@ -8,11 +8,12 @@ name = "string" # required
|
||||
version = "string" # required
|
||||
|
||||
[build]
|
||||
language = "c|c++|cpp|cxx" # required
|
||||
language = "c|c++|cpp|cxx|asm" # required
|
||||
standard = "string" # required
|
||||
compiler = "string" # required
|
||||
kind = "bin|staticlib" # required
|
||||
kind = "bin|staticlib|sharedlib" # required
|
||||
target = "string" # optional
|
||||
platform = "string" # optional
|
||||
cflags = ["string", "..."] # optional
|
||||
ldflags = ["string", "..."] # optional
|
||||
|
||||
@@ -29,7 +30,7 @@ name = {
|
||||
|
||||
- `[package]`, `[build]`, `[dependencies]` must exist.
|
||||
- Required string fields must be non-empty.
|
||||
- `build.kind` must be `bin` or `staticlib`.
|
||||
- `build.kind` must be `bin`, `staticlib`, or `sharedlib`.
|
||||
- Dependency fields `include/lib/libs` must be string arrays when provided.
|
||||
|
||||
## Generated defaults (`dcr new` / `dcr init`)
|
||||
|
||||
Reference in New Issue
Block a user