Skip to content

Instantly share code, notes, and snippets.

@thosakwe
Created October 30, 2018 14:34
Show Gist options
  • Select an option

  • Save thosakwe/1507cc117fd8c6cc804390d05bd8785d to your computer and use it in GitHub Desktop.

Select an option

Save thosakwe/1507cc117fd8c6cc804390d05bd8785d to your computer and use it in GitHub Desktop.
Simple build pipeline...
// Glob up C++ sources
var srcs = combine([
glob("src/*{.h,.cpp}")
])
// Exclude some sources
srcs = exclude(srcs, [glob("test/**")])
// Grab all the object files, creates multiple targets
var objects = compile_cpp(srcs).outputs
// Next, add a linking step that creates libfoo.a
var linkStep = link_cpp("foo", objects)
// We can make it a shared library
linkStep.shared = true
macro compile_wat_to_wasm(source) {
var name = extension(source, ".wasm")
return process(["wat2wasm", "-o", name, source])
}
// Globs many sources through wat2wasm
macro compile_wasm(sources) {
return multi_target(sources, compile_wat_to_wasm)
}
// Call it. Produces foo.wasm, hello.wasm
compile_wasm(["foo.wat", "hello.wat"])
import "../wasm.tmake"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment