-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use OUT_DIR env variable if defined as prefix path for location of te…
- Loading branch information
Showing
2 changed files
with
16 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import { ensureDir } from "https://deno.land/[email protected]/fs/ensure_dir.ts"; | ||
import { parse } from "https://deno.land/[email protected]/flags/mod.ts"; | ||
import { join } from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { codegen } from "./codegen.ts"; | ||
|
||
const flags = parse(Deno.args, { "--": true }); | ||
|
@@ -11,6 +12,8 @@ const fetchPrefix = typeof flags.release == "string" | |
? flags.release | ||
: "../target/" + (release ? "release" : "debug"); | ||
|
||
const metafile = join(Deno.env.get("OUT_DIR") || "", "bindings.json"); | ||
|
||
async function build() { | ||
const cmd = ["cargo", "build"]; | ||
if (release) cmd.push("--release"); | ||
|
@@ -23,7 +26,7 @@ let source = null; | |
async function generate() { | ||
let conf; | ||
try { | ||
conf = JSON.parse(await Deno.readTextFile("bindings.json")); | ||
conf = JSON.parse(await Deno.readTextFile(metafile)); | ||
} catch (_) { | ||
// Nothing to update. | ||
return; | ||
|
@@ -44,16 +47,16 @@ async function generate() { | |
}, | ||
); | ||
|
||
await Deno.remove("bindings.json"); | ||
await Deno.remove(metafile); | ||
} | ||
|
||
try { | ||
await Deno.remove("bindings.json"); | ||
await Deno.remove(metafile); | ||
} catch (e) { | ||
// no op | ||
} | ||
|
||
const status = await build().catch((_) => Deno.removeSync("bindings.json")); | ||
const status = await build().catch((_) => Deno.removeSync(metafile)); | ||
if (status?.success || typeof flags.release == "string") { | ||
await generate(); | ||
if (source) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters