Remove unused parts of the hak build system (#2174)

This commit is contained in:
Michael Telatynski 2025-02-28 15:15:32 +00:00 committed by GitHub
parent 7847e53adc
commit 1496f3d64c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 4 additions and 40 deletions

View File

@ -67,14 +67,14 @@ Hak is divided into lifecycle stages, in order:
# hak.json # hak.json
The scripts section contains scripts used for lifecycle stages that need them (fetch, fetchDeps, build). The scripts section contains scripts used for lifecycle stages that need them (fetch, build).
It also contains 'prune' and 'copy' which are globs of files to delete from the output module directory It also contains 'prune' and 'copy' which are globs of files to delete from the output module directory
and copy over from the module build directory to the output module directory, respectively. and copy over from the module build directory to the output module directory, respectively.
# Shortcomings # Shortcomings
Hak doesn't know about dependencies between lifecycle stages, ie. it doesn't know that you need to Hak doesn't know about dependencies between lifecycle stages, ie. it doesn't know that you need to
'fetch' and 'fetchDeps' before you can 'build', etc. You get to run each individually, and remember 'fetch' before you can 'build', etc. You get to run each individually, and remember
the right order. the right order.
There is also a _lot_ of duplication in the command execution: we should abstract away There is also a _lot_ of duplication in the command execution: we should abstract away

View File

@ -10,7 +10,5 @@ import type { DependencyInfo } from "./dep.js";
import type HakEnv from "./hakEnv.js"; import type HakEnv from "./hakEnv.js";
export default async function check(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> { export default async function check(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
if (moduleInfo.scripts.check) { await moduleInfo.scripts.check?.(hakEnv, moduleInfo);
await moduleInfo.scripts.check(hakEnv, moduleInfo);
}
} }

View File

@ -9,7 +9,6 @@ Please see LICENSE files in the repository root for full details.
import path from "node:path"; import path from "node:path";
import fsProm from "node:fs/promises"; import fsProm from "node:fs/promises";
import childProcess from "node:child_process"; import childProcess from "node:child_process";
import { rimraf } from "rimraf";
import { glob } from "glob"; import { glob } from "glob";
import { mkdirp } from "mkdirp"; import { mkdirp } from "mkdirp";
@ -17,20 +16,6 @@ import type HakEnv from "./hakEnv.js";
import type { DependencyInfo } from "./dep.js"; import type { DependencyInfo } from "./dep.js";
export default async function copy(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> { export default async function copy(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
if (moduleInfo.cfg.prune) {
console.log("Removing " + moduleInfo.cfg.prune + " from " + moduleInfo.moduleOutDir);
// rimraf doesn't have a 'cwd' option: it always uses process.cwd()
// (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 rimraf(moduleInfo.cfg.prune);
} finally {
process.chdir(oldCwd);
}
}
if (moduleInfo.cfg.copy) { if (moduleInfo.cfg.copy) {
// If there are multiple moduleBuildDirs, singular moduleBuildDir // If there are multiple moduleBuildDirs, singular moduleBuildDir
// is the same as moduleBuildDirs[0], so we're just listing the contents // is the same as moduleBuildDirs[0], so we're just listing the contents

View File

@ -1,19 +0,0 @@
/*
Copyright 2024 New Vector Ltd.
Copyright 2020 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { mkdirp } from "mkdirp";
import type { DependencyInfo } from "./dep.js";
import type HakEnv from "./hakEnv.js";
export default async function fetchDeps(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
await mkdirp(moduleInfo.moduleDotHakDir);
if (moduleInfo.scripts.fetchDeps) {
await moduleInfo.scripts.fetchDeps(hakEnv, moduleInfo);
}
}

View File

@ -19,7 +19,7 @@ import packageJson from "../../package.json";
const MODULECOMMANDS = ["check", "fetch", "link", "build", "copy", "clean"]; const MODULECOMMANDS = ["check", "fetch", "link", "build", "copy", "clean"];
// Shortcuts for multiple commands at once (useful for building universal binaries // Shortcuts for multiple commands at once (useful for building universal binaries
// because you can run the fetch/fetchDeps/build for each arch and then copy/link once) // because you can run the fetch/build for each arch and then copy/link once)
const METACOMMANDS: Record<string, string[]> = { const METACOMMANDS: Record<string, string[]> = {
fetchandbuild: ["check", "fetch", "build"], fetchandbuild: ["check", "fetch", "build"],
copyandlink: ["copy", "link"], copyandlink: ["copy", "link"],