Skip to content

Commit

Permalink
clean up tsc build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Jan 19, 2024
1 parent 38aa25b commit 7f4508c
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 890 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
"unpkg.com"
],
"files.readonlyInclude": {
"**/ts/gen/*": true,
"**/dist/*": true,
"**/aici-types.d.ts": true
}
Expand Down
1 change: 1 addition & 0 deletions jsctrl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "aici_jsctrl"
version = "0.1.0"
edition = "2021"
build = "build.rs"

[dependencies]
aici_abi = { path = "../aici_abi" }
Expand Down
24 changes: 24 additions & 0 deletions jsctrl/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::process::Command;

fn run(cmd: &mut Command, msg: &str) {
let status = cmd.status().expect(&format!("failed to execute: {msg}"));
if !status.success() {
panic!("process exited with status: {}; {}", status, msg);
}
}

fn main() {
if Command::new("tsc").arg("--version").status().is_err() {
println!("cargo:warning=typescript not found, installing...");
run(
Command::new("npm")
.arg("install")
.arg("-g")
.arg("typescript"),
"npm install failed",
);
}

run(Command::new("tsc").arg("-p").arg("ts"), "build failed");
run(Command::new("node").arg("gen-dts.mjs"), "gen-dts failed");
}
6 changes: 0 additions & 6 deletions jsctrl/build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion jsctrl/gen-dts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs';
function gen() {
const ts = "./ts/"
const native = fs.readFileSync(ts + '/native.d.ts', 'utf8')
let aici = fs.readFileSync(ts + '/gen/aici.d.ts', 'utf8')
let aici = fs.readFileSync(ts + '/dist/aici.d.ts', 'utf8')
aici = aici.replace(/<reference path=".*/g, "")
aici = aici.replace(/ declare /g, " ")
aici = aici.replace(/^declare /mg, "")
Expand Down
3 changes: 3 additions & 0 deletions jsctrl/samples/aici-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ import { TokenSet, tokenize, detokenize, regexConstraint, cfgConstraint, substrC
export { TokenSet, tokenize, detokenize, getVar, setVar, appendVar, eosToken };
export type SeqId = number;
type int = number;
/**
* Return debug representation of the argument, suitable for printing in the console.
*/
export function inspect(v: any): string;
export function log(...args: any[]): void;
export class AssertionError extends Error {
Expand Down
2 changes: 1 addition & 1 deletion jsctrl/src/jsctrl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl Runner {
context: Context::full(&rt).unwrap(),
};

let aici_js = include_str!("../ts/gen/aici.js");
let aici_js = include_str!("../ts/dist/aici.js");

s.with_cb("_new", |ctx| {
let global = ctx.globals();
Expand Down
3 changes: 3 additions & 0 deletions jsctrl/ts/aici.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ function dbgArg(arg: any, depth: number): string {
}
}

/**
* Return debug representation of the argument, suitable for printing in the console.
*/
export function inspect(v: any) {
return dbgArg(v, 0);
}
Expand Down
225 changes: 0 additions & 225 deletions jsctrl/ts/gen/aici.d.ts

This file was deleted.

Loading

0 comments on commit 7f4508c

Please sign in to comment.