Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lockieluke/swift-precompiler
🚀 A precompiler for Swift that allows you to use additional macros, include files, and more.
https://github.com/lockieluke/swift-precompiler
macros precompiler rust swift
Last synced: 21 days ago
JSON representation
🚀 A precompiler for Swift that allows you to use additional macros, include files, and more.
- Host: GitHub
- URL: https://github.com/lockieluke/swift-precompiler
- Owner: lockieluke
- License: mit
- Created: 2024-01-13T00:12:57.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-03-09T17:47:39.000Z (10 months ago)
- Last Synced: 2024-10-29T23:43:30.565Z (about 2 months ago)
- Topics: macros, precompiler, rust, swift
- Language: Rust
- Homepage: https://crates.io/crates/swift-precompiler
- Size: 44.9 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swift Precompiler
âš¡ A fast, lightweight precompiler for Swift
### Features
- Add Rust's `includeStr!` like functionality to Swift with the `precompileIncludeStr` function
### Installation
Cargo:
```shell
cargo install swift-precompiler
```### Configuration
Run `swift-precompiler init` to initialise a config file `swift-precompiled.toml` with the default values
Available options:
- `dirs` - An array of directories to search for Swift source files that require precompilation
- `path_aliases` - A dictionary of path aliases to use in precompile callsExample:
```toml
dirs = ["Cider/", "CiderPlaybackAgent/"][path_aliases]
# "@" as a path alias refers to the current working directory in most cases
"@" = "./"
```### Usage
Including a file as a string literal at compile time:
```swift
let javaScript = precompileIncludeStr("path/to/file.js")
```Include a file as a Data at compile time:
```swift
let image = precompileIncludeData("path/to/image.png")
```Run `swift-precompiler` to precompile all Swift files in the directories specified in the config file
```shell
swift-precompiler precompile
```You should add `Precompiled.swift` to your `.gitignore`
Swift Precompiler encodes your strings with Base64, you can add [swift-extras-base64](https://github.com/swift-extras/swift-extras-base64) to your project using SPM to enable faster Base64 decode.