fix cell toml and add documentation for tools
This commit is contained in:
@@ -228,11 +228,105 @@ var d = vector.dot(1, 0, 0, 1) // 0
|
||||
C files are automatically compiled when you run:
|
||||
|
||||
```bash
|
||||
pit build
|
||||
pit update
|
||||
cell --dev build
|
||||
```
|
||||
|
||||
Each C file is compiled into a per-file dynamic library at `~/.pit/lib/<pkg>/<stem>.dylib`.
|
||||
Each C file is compiled into a per-file dynamic library at `.cell/lib/<pkg>/<stem>.dylib`.
|
||||
|
||||
## Compilation Flags (cell.toml)
|
||||
|
||||
Use the `[compilation]` section in `cell.toml` to pass compiler and linker flags:
|
||||
|
||||
```toml
|
||||
[compilation]
|
||||
CFLAGS = "-Isrc -Ivendor/include"
|
||||
LDFLAGS = "-lz -lm"
|
||||
```
|
||||
|
||||
### Include paths
|
||||
|
||||
Relative `-I` paths are resolved from the package root:
|
||||
|
||||
```toml
|
||||
CFLAGS = "-Isdk/public"
|
||||
```
|
||||
|
||||
If your package is at `/path/to/mypkg`, this becomes `-I/path/to/mypkg/sdk/public`.
|
||||
|
||||
Absolute paths are passed through unchanged.
|
||||
|
||||
### Library paths
|
||||
|
||||
Relative `-L` paths work the same way:
|
||||
|
||||
```toml
|
||||
LDFLAGS = "-Lsdk/lib -lmylib"
|
||||
```
|
||||
|
||||
### Target-specific flags
|
||||
|
||||
Add sections named `[compilation.<target>]` for platform-specific flags:
|
||||
|
||||
```toml
|
||||
[compilation]
|
||||
CFLAGS = "-Isdk/public"
|
||||
|
||||
[compilation.macos_arm64]
|
||||
LDFLAGS = "-Lsdk/lib/osx -lmylib"
|
||||
|
||||
[compilation.linux]
|
||||
LDFLAGS = "-Lsdk/lib/linux64 -lmylib"
|
||||
|
||||
[compilation.windows]
|
||||
LDFLAGS = "-Lsdk/lib/win64 -lmylib64"
|
||||
```
|
||||
|
||||
Available targets: `macos_arm64`, `macos_x86_64`, `linux`, `linux_arm64`, `windows`.
|
||||
|
||||
### Sigils
|
||||
|
||||
Use `$LOCAL` in flags to refer to the `.cell/local` directory (for prebuilt libraries):
|
||||
|
||||
```toml
|
||||
LDFLAGS = "-L$LOCAL -lmyprebuilt"
|
||||
```
|
||||
|
||||
### Example: vendored SDK
|
||||
|
||||
A package wrapping an external SDK with platform-specific shared libraries:
|
||||
|
||||
```
|
||||
mypkg/
|
||||
├── cell.toml
|
||||
├── wrapper.cpp
|
||||
└── sdk/
|
||||
├── public/
|
||||
│ └── mylib/
|
||||
│ └── api.h
|
||||
└── lib/
|
||||
├── osx/
|
||||
│ └── libmylib.dylib
|
||||
└── linux64/
|
||||
└── libmylib.so
|
||||
```
|
||||
|
||||
```toml
|
||||
[compilation]
|
||||
CFLAGS = "-Isdk/public"
|
||||
|
||||
[compilation.macos_arm64]
|
||||
LDFLAGS = "-Lsdk/lib/osx -lmylib"
|
||||
|
||||
[compilation.linux]
|
||||
LDFLAGS = "-Lsdk/lib/linux64 -lmylib"
|
||||
```
|
||||
|
||||
```cpp
|
||||
// wrapper.cpp
|
||||
#include "cell.h"
|
||||
#include <mylib/api.h>
|
||||
// ...
|
||||
```
|
||||
|
||||
## Platform-Specific Code
|
||||
|
||||
|
||||
Reference in New Issue
Block a user