Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve hak & build ia32 again by default #369

Merged
merged 11 commits into from
May 26, 2022
1 change: 1 addition & 0 deletions scripts/hak/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default async function copy(hakEnv: HakEnv, moduleInfo: DependencyInfo):
// (and if you set glob.cwd it just breaks because it can't find the files)
const oldCwd = process.cwd();
try {
await mkdirp(moduleInfo.moduleOutDir);
process.chdir(moduleInfo.moduleOutDir);
await new Promise<void>((resolve, reject) => {
rimraf(moduleInfo.cfg.prune, {}, err => {
Expand Down
14 changes: 5 additions & 9 deletions scripts/hak/hakEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,21 @@ async function getRuntimeVersion(projectRoot: string): Promise<string> {
}

export default class HakEnv {
public target: Target;
public projectRoot: string;
public readonly target: Target;
public runtime: string;
public runtimeVersion: string;
public dotHakDir: string;

constructor(prefix: string, targetId: TargetId) {
let target;
constructor(public readonly projectRoot: string, targetId: TargetId | null) {
if (targetId) {
target = TARGETS[targetId];
this.target = TARGETS[targetId];
} else {
target = getHost();
this.target = getHost();
}

if (!target) {
if (!this.target) {
throw new Error(`Unknown target ${targetId}!`);
}
this.target = target;
this.projectRoot = prefix;
this.dotHakDir = path.join(this.projectRoot, '.hak');
}

Expand Down
8 changes: 4 additions & 4 deletions scripts/hak/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function main() {
process.exit(1);
}

const targetIds = [] as TargetId[];
const targetIds: TargetId[] = [];
// Apply `--target <target>` option if specified
// Can be specified multiple times for the copy command to bundle
// multiple archs into a single universal output module)
Expand All @@ -84,13 +84,13 @@ async function main() {
}
const hakEnv = hakEnvs[0];

const deps = {} as Record<string, DependencyInfo>;
const deps: Record<string, DependencyInfo> = {};

const hakDepsCfg = packageJson.hakDependencies || {};

for (const dep of Object.keys(hakDepsCfg)) {
const hakJsonPath = path.join(prefix, 'hak', dep, 'hak.json');
let hakJson;
let hakJson: Record<string, any>;
try {
hakJson = await require(hakJsonPath);
} catch (e) {
Expand Down Expand Up @@ -125,7 +125,7 @@ async function main() {
}
}

let cmds;
let cmds: string[];
if (process.argv.length < 3) {
cmds = ['check', 'fetch', 'fetchDeps', 'build', 'copy', 'link'];
} else if (METACOMMANDS[process.argv[2]]) {
Expand Down
1 change: 1 addition & 0 deletions scripts/hak/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const ENABLED_TARGETS: Target[] = [
TARGETS['universal-apple-darwin'],
TARGETS['x86_64-unknown-linux-gnu'],
TARGETS['x86_64-pc-windows-msvc'],
TARGETS['i686-pc-windows-msvc'],
];

export function getHost(): Target {
Expand Down