Skip to content

Commit

Permalink
updates wasmc config to enable several emcc debug features in debug m…
Browse files Browse the repository at this point in the history
…ode and updated build product config
rsms committed Oct 15, 2020
1 parent dc0823c commit ecc956f
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions wasmc.js
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@ const package = require("./package.json")
const outdir = debug ? builddir : "dist"

const m = {
name: "markdown",
out: outdir + "/markdown.js",
jsentry: "src/md.js",
sources: [
"src/wlib.c",
@@ -13,31 +11,49 @@ const m = {
"src/fmt_html.c",
// "src/fmt_json.c",
],
cflags: debug ? ["-DDEBUG=1"] : [],
cflags: [
"-DMD4C_USE_UTF8",
].concat(debug ? [
// debug flags
"-DDEBUG=1",
"-DASSERTIONS=1", // emcc
"-DSAFE_HEAP=1", // emcc
"-DSTACK_OVERFLOW_CHECK=1", // emcc
"-DDEMANGLE_SUPPORT=1", // emcc
] : [
// release flags
]),
constants: {
VERSION: package.version,
},
}

// —————————————————————————————————————————————————
// products

// embedded wasm, ES module, nodejs-specific compression
// Suitable for using or bundling as a library targeting nodejs only
module({ ...m,
name: "markdown-node",
out: outdir + "/markdown.node.js",
target: "node",
embed: true,
})

if (!debug) {
// generic js module
module({...m})
// sideloaded wasm, universal js library, exports API at global["markdown"] as a fallback
// Suitable as a runtime library in browsers
module({ ...m,
name: "markdown",
out: outdir + "/markdown.js",
})

// node cjs module
// embedded wasm, ES module
// Suitable for bundling as a library intended for browsers
module({ ...m,
name: "markdown-node",
out: outdir + "/markdown.node.js",
target: "node",
embed: true,
name: "markdown-es",
out: outdir + "/markdown.es.js",
outwasm: outdir + "/markdown.wasm",
format: "es",
})
}

// node es module
module({ ...m,
name: "markdown-es",
out: outdir + "/markdown.es.js",
format: "es",
target: "node",
embed: true,
})

0 comments on commit ecc956f

Please sign in to comment.