Rew Building
Rew comes with a simple builder to manage how your app is supposed to act when installed or just when you build it.
To build a simple file from coffee to brew, you can do so with rew:
rew brew input.coffee output.brewWhat is a brew file?
A brew file is just a bundle of all modules in an app, with externals unbundled. .brew files have a built in support to run as entries, be imported/exported, or just ran.
Building
To build, you need a build field in your app.yaml.
build:
- input: entry.coffee
output: output.brew
using: brew
cleanup: entry.coffee
- input: another.coffee
output: another.brew
using: brew
cleanup:
- another.coffee
- somefolderExplanation: So, basically you take an input from your app root entry.coffee, and build it to output output.brew at the root of your app. This uses brew to build, then after it finishes, it deletes entry.coffee.
Builders
As of now, rew only supports these builders:
brewqrewmakerustccc | clang | gcczig
qrew is a binary executable that uses a brew file to render your brew to an executable qrew that runs without needing to install rew.
To use builders, just add a using: BUILDER_NAME in your build entry.
Prefetch URLs
Before build starts, you can prefetch a set of URLs and add output them to a file into the current app.
prefetch:
- url: https://example.com/path/to/file
output: .artifacts/file
# you can also use the file+ schema here
- url: file+.+sha(SHA-AAA)+https://example.com/path/to/file-with-sha
output: file.with.sha
# platform specific
- url: https://example.com/path/to/file-for-unix
system: unix # unix|linux|macos|windows|...
output: file.for.unixUsing unarchiver with prefetch
You can download and extract archives with:
prefetch:
- url: file+zip+sha(SHA)+https://example.com/path/to/file.zip
output: file.zip
extract: output_folder
# If this is an app, you can do this to build it:
build: trueCargo Crates
You can build cargo crates in your app, this whole process simplifies the use of FFI in your app. To register crates all you need to do is add crates field in your app.yaml as follows:
crates:
- name: demo_crate
path: ./demo_crate
build: true
files:
- input: ./demo_crate/target/release/libdemo_crate.dll
output: .artifacts/libdemo_crate.dll
system: windows
# Fallback prefetches are prefetch entries that
# are only applied when cargo is not found
fallback_prefetch:
url: https://example.com/files/libdemo_crate.dll
output: .artifacts/libdemo_crate.dll
- input: ./demo_crate/target/release/libdemo_crate.so
output: .artifacts/libdemo_crate.so
system: unix
cleanup: ./demo_crate
# You can also use fallback prefetches here, but here it should be an array
fallback_prefetch:
- url: https://example.com/files/libdemo_crate.dll
output: .artifacts/libdemo_crate.dllCrate triggers
If you want a crate to build let's say for example after main.brew has been built, you can do this:
crates:
- name: demo_crate
path: ./demo_crate
build: true
trigger: my_trigger_id
build:
- input: main.coffee
output: main.brew
id: my_trigger_idCMods (C Module Configs)
Just like crates, you can define CMods in your app.yaml. They work the same way: you provide a path, files to use, build flags, cleanup, and optional fallback downloads.
cmods:
- name: demo_cmod
path: ./demo_cmod
build: true
flags: "-o libdemo.so main.c"
files:
- input: ./demo_cmod/libdemo.so
output: .artifacts/libdemo.so
system: unix
cleanup: ./demo_cmod
fallback_prefetch:
- url: https://example.com/files/libdemo.so
output: .artifacts/libdemo.soThis works almost exactly like crates, so if you’re familiar with crates, using cmods is just as easy.