@shd101wyy/yo 0.0.27 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/out/cjs/index.cjs +513 -513
- package/out/cjs/yo-cli.cjs +677 -552
- package/out/esm/index.mjs +478 -478
- package/out/types/src/build-runner.d.ts +22 -0
- package/out/types/src/cache.d.ts +3 -0
- package/out/types/src/codegen/codegen-c.d.ts +3 -0
- package/out/types/src/codegen/index.d.ts +4 -0
- package/out/types/src/codegen/utils/index.d.ts +3 -0
- package/out/types/src/evaluator/builtins/build.d.ts +135 -0
- package/out/types/src/expr.d.ts +17 -0
- package/out/types/src/fetch-command.d.ts +6 -0
- package/out/types/src/fetch.d.ts +10 -0
- package/out/types/src/init.d.ts +5 -0
- package/out/types/src/install-command.d.ts +6 -0
- package/out/types/src/lock-file.d.ts +16 -0
- package/out/types/src/module-manager.d.ts +3 -1
- package/out/types/src/pkg-config.d.ts +11 -0
- package/out/types/src/target.d.ts +28 -0
- package/out/types/src/tests/build-system.test.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/build.yo +287 -0
- package/std/crypto/random.yo +2 -2
- package/std/fs/dir.yo +1 -1
- package/std/fs/temp.yo +1 -1
- package/std/os/env.yo +5 -5
- package/std/os/signal.yo +8 -8
- package/std/path.yo +2 -2
- package/std/process.yo +23 -43
- package/std/regex/compiler.yo +355 -0
- package/std/regex/flags.yo +104 -0
- package/std/regex/match.yo +83 -0
- package/std/regex/node.yo +283 -0
- package/std/regex/parser.yo +847 -0
- package/std/regex/regex.yo +714 -0
- package/std/regex/unicode.yo +365 -0
- package/std/regex/vm.yo +737 -0
- package/std/sys/clock.yo +1 -1
- package/std/sys/constants.yo +3 -3
- package/std/sys/mmap.yo +2 -2
- package/std/sys/signals.yo +4 -4
- package/std/sys/socket.yo +25 -25
- package/std/sys/sysinfo.yo +4 -4
- package/std/time/sleep.yo +18 -0
- package/std/time.yo +0 -13
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BuildRegistry } from "./evaluator/builtins/build";
|
|
2
|
+
export interface BuildOptions {
|
|
3
|
+
buildFile: string;
|
|
4
|
+
targetTriple?: string;
|
|
5
|
+
verbose?: boolean;
|
|
6
|
+
dryRun?: boolean;
|
|
7
|
+
listSteps?: boolean;
|
|
8
|
+
steps?: string[];
|
|
9
|
+
defines?: Record<string, string>;
|
|
10
|
+
cCompiler?: string;
|
|
11
|
+
sysroot?: string;
|
|
12
|
+
summary?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function runBuild(options: BuildOptions): Promise<void>;
|
|
15
|
+
export interface DAGNode {
|
|
16
|
+
name: string;
|
|
17
|
+
kind: "artifact" | "test" | "run" | "step";
|
|
18
|
+
dependsOn: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare function buildDAG(registry: BuildRegistry, rootStepName: string): DAGNode[];
|
|
21
|
+
export declare function detectCycle(dag: DAGNode[]): string[] | null;
|
|
22
|
+
export declare function computeDependencyHash(registry: BuildRegistry, depName: string, projectDir: string): string;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { ModuleValue } from "../value";
|
|
2
2
|
export declare class CodeGeneratorC {
|
|
3
3
|
private emitter;
|
|
4
|
+
private exportedFunctionNames;
|
|
4
5
|
constructor();
|
|
5
6
|
compileModule(modulePath: string, moduleValue: ModuleValue, options?: {
|
|
6
7
|
debugGc?: boolean;
|
|
7
8
|
debugParallelism?: boolean;
|
|
8
9
|
debugAsyncAwait?: boolean;
|
|
9
10
|
allocator?: "mimalloc" | "libc";
|
|
11
|
+
isLibrary?: boolean;
|
|
10
12
|
}): void;
|
|
11
13
|
print(): string;
|
|
14
|
+
getExportedFunctionNames(): Set<string>;
|
|
12
15
|
}
|
|
@@ -5,6 +5,8 @@ export declare class CodeGenerator {
|
|
|
5
5
|
output: string;
|
|
6
6
|
cCompiler: string;
|
|
7
7
|
target: "c";
|
|
8
|
+
targetTriple?: string;
|
|
9
|
+
sysroot?: string;
|
|
8
10
|
extern: string[];
|
|
9
11
|
includePaths?: string[];
|
|
10
12
|
libraryPaths?: string[];
|
|
@@ -23,6 +25,8 @@ export declare class CodeGenerator {
|
|
|
23
25
|
debugSymbols?: boolean;
|
|
24
26
|
strip?: boolean;
|
|
25
27
|
static?: boolean;
|
|
28
|
+
shared?: boolean;
|
|
29
|
+
staticLibrary?: boolean;
|
|
26
30
|
cflags?: string;
|
|
27
31
|
}): void;
|
|
28
32
|
}
|
|
@@ -77,6 +77,9 @@ export interface CodeGenContext {
|
|
|
77
77
|
currentContinueLabel?: string;
|
|
78
78
|
insideMatch?: boolean;
|
|
79
79
|
typeIdStatics?: Map<string, string>;
|
|
80
|
+
isLibrary?: boolean;
|
|
81
|
+
currentModuleId?: string;
|
|
82
|
+
exportedFunctionLabels?: Map<FuncValueId, string>;
|
|
80
83
|
}
|
|
81
84
|
export declare function sanitizeForCIdentifier(str: string, isExternC?: boolean): string;
|
|
82
85
|
export declare function shouldAvoidConst(type: Type): boolean;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { Environment } from "../../env";
|
|
2
|
+
import { type FnCallExpr } from "../../expr";
|
|
3
|
+
import type { EvaluatorContext } from "../context";
|
|
4
|
+
export interface BuildProject {
|
|
5
|
+
name: string;
|
|
6
|
+
root: string;
|
|
7
|
+
}
|
|
8
|
+
export interface BuildArtifact {
|
|
9
|
+
kind: "executable" | "static_library" | "shared_library";
|
|
10
|
+
name: string;
|
|
11
|
+
root: string;
|
|
12
|
+
target: string;
|
|
13
|
+
optimize: string;
|
|
14
|
+
allocator: string;
|
|
15
|
+
sanitize: string;
|
|
16
|
+
linkLibraries: string[];
|
|
17
|
+
includePaths: string[];
|
|
18
|
+
libraryPaths: string[];
|
|
19
|
+
cSources: string[];
|
|
20
|
+
cFlags: string[];
|
|
21
|
+
defines: string[];
|
|
22
|
+
strip: boolean;
|
|
23
|
+
staticLink: boolean;
|
|
24
|
+
linkedArtifacts: string[];
|
|
25
|
+
linkedSystemLibraries: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface BuildTestSuite {
|
|
28
|
+
name: string;
|
|
29
|
+
root: string;
|
|
30
|
+
target: string;
|
|
31
|
+
verbose: boolean;
|
|
32
|
+
bail: boolean;
|
|
33
|
+
parallel: number;
|
|
34
|
+
}
|
|
35
|
+
export interface BuildRunStep {
|
|
36
|
+
name: string;
|
|
37
|
+
artifactName: string;
|
|
38
|
+
args: string[];
|
|
39
|
+
}
|
|
40
|
+
export interface BuildStep {
|
|
41
|
+
name: string;
|
|
42
|
+
description: string;
|
|
43
|
+
dependencyNames: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface BuildGitDependency {
|
|
46
|
+
name: string;
|
|
47
|
+
url: string;
|
|
48
|
+
ref: string;
|
|
49
|
+
path: string;
|
|
50
|
+
}
|
|
51
|
+
export interface BuildPathDependency {
|
|
52
|
+
name: string;
|
|
53
|
+
path: string;
|
|
54
|
+
}
|
|
55
|
+
export interface BuildSystemLibrary {
|
|
56
|
+
name: string;
|
|
57
|
+
pkgConfig: string;
|
|
58
|
+
fallbackInclude: string;
|
|
59
|
+
fallbackLib: string;
|
|
60
|
+
fallbackLink: string;
|
|
61
|
+
}
|
|
62
|
+
export interface DependencyArtifactRef {
|
|
63
|
+
dependencyName: string;
|
|
64
|
+
artifactName: string;
|
|
65
|
+
}
|
|
66
|
+
export declare class BuildRegistry {
|
|
67
|
+
project: BuildProject | undefined;
|
|
68
|
+
artifacts: BuildArtifact[];
|
|
69
|
+
testSuites: BuildTestSuite[];
|
|
70
|
+
runSteps: BuildRunStep[];
|
|
71
|
+
steps: BuildStep[];
|
|
72
|
+
dependencies: BuildGitDependency[];
|
|
73
|
+
pathDependencies: BuildPathDependency[];
|
|
74
|
+
systemLibraries: BuildSystemLibrary[];
|
|
75
|
+
dependencyArtifacts: DependencyArtifactRef[];
|
|
76
|
+
cliOptions: Map<string, string>;
|
|
77
|
+
declaredOptions: Map<string, {
|
|
78
|
+
description: string;
|
|
79
|
+
defaultValue: string;
|
|
80
|
+
}>;
|
|
81
|
+
setCliOptions(options: Map<string, string>): void;
|
|
82
|
+
registerProject(name: string, root: string): void;
|
|
83
|
+
registerExecutable(config: Omit<BuildArtifact, "kind">): void;
|
|
84
|
+
registerStaticLibrary(config: Omit<BuildArtifact, "kind">): void;
|
|
85
|
+
registerSharedLibrary(config: Omit<BuildArtifact, "kind">): void;
|
|
86
|
+
registerTest(config: BuildTestSuite): void;
|
|
87
|
+
registerRun(artifactName: string, args: string[]): void;
|
|
88
|
+
registerStep(name: string, description: string, dependencyNames?: string[]): void;
|
|
89
|
+
addStepDependency(stepName: string, depName: string): void;
|
|
90
|
+
registerDependency(dep: BuildGitDependency): void;
|
|
91
|
+
registerPathDependency(dep: BuildPathDependency): void;
|
|
92
|
+
registerSystemLibrary(lib: BuildSystemLibrary): void;
|
|
93
|
+
registerDependencyArtifact(ref: DependencyArtifactRef): void;
|
|
94
|
+
registerLink(artifactName: string, libraryName: string): void;
|
|
95
|
+
findArtifact(name: string): BuildArtifact | undefined;
|
|
96
|
+
findTest(name: string): BuildTestSuite | undefined;
|
|
97
|
+
findRunStep(name: string): BuildRunStep | undefined;
|
|
98
|
+
findStep(name: string): BuildStep | undefined;
|
|
99
|
+
findDependency(name: string): BuildGitDependency | undefined;
|
|
100
|
+
findPathDependency(name: string): BuildPathDependency | undefined;
|
|
101
|
+
findSystemLibrary(name: string): BuildSystemLibrary | undefined;
|
|
102
|
+
getStepNames(): string[];
|
|
103
|
+
resolveDependency(name: string): {
|
|
104
|
+
kind: "artifact";
|
|
105
|
+
value: BuildArtifact;
|
|
106
|
+
} | {
|
|
107
|
+
kind: "test";
|
|
108
|
+
value: BuildTestSuite;
|
|
109
|
+
} | {
|
|
110
|
+
kind: "run";
|
|
111
|
+
value: BuildRunStep;
|
|
112
|
+
} | {
|
|
113
|
+
kind: "step";
|
|
114
|
+
value: BuildStep;
|
|
115
|
+
} | undefined;
|
|
116
|
+
resolveDependencies(step: BuildStep): {
|
|
117
|
+
artifacts: BuildArtifact[];
|
|
118
|
+
tests: BuildTestSuite[];
|
|
119
|
+
runs: BuildRunStep[];
|
|
120
|
+
};
|
|
121
|
+
clear(): void;
|
|
122
|
+
}
|
|
123
|
+
export declare function getRootBuildProjectDir(): string | undefined;
|
|
124
|
+
export declare function setRootBuildProjectDir(dir: string | undefined): void;
|
|
125
|
+
export declare function getDependencyProjectRoot(depDir: string): string | undefined;
|
|
126
|
+
export declare function setDependencyProjectRoot(depDir: string, root: string): void;
|
|
127
|
+
export declare function clearDependencyProjectRoots(): void;
|
|
128
|
+
export declare function getBuildRegistry(): BuildRegistry;
|
|
129
|
+
export declare function clearBuildRegistry(): void;
|
|
130
|
+
export declare function swapBuildRegistry(newRegistry: BuildRegistry | undefined): BuildRegistry | undefined;
|
|
131
|
+
export declare function evaluateYoBuildFunctions({ expr, env, }: {
|
|
132
|
+
expr: FnCallExpr;
|
|
133
|
+
env: Environment;
|
|
134
|
+
context: EvaluatorContext;
|
|
135
|
+
}): FnCallExpr;
|
package/out/types/src/expr.d.ts
CHANGED
|
@@ -531,6 +531,23 @@ export declare const BuiltinFunctions: {
|
|
|
531
531
|
__yo_maybe_uninit_assume_init: string[];
|
|
532
532
|
__yo_process_platform: string[];
|
|
533
533
|
__yo_process_arch: string[];
|
|
534
|
+
__yo_build_project: string[];
|
|
535
|
+
__yo_build_executable: string[];
|
|
536
|
+
__yo_build_static_library: string[];
|
|
537
|
+
__yo_build_shared_library: string[];
|
|
538
|
+
__yo_build_test: string[];
|
|
539
|
+
__yo_build_run: string[];
|
|
540
|
+
__yo_build_step: string[];
|
|
541
|
+
__yo_build_step_depend_on: string[];
|
|
542
|
+
__yo_build_link: string[];
|
|
543
|
+
__yo_build_link_system_library: string[];
|
|
544
|
+
__yo_build_target_host: string[];
|
|
545
|
+
__yo_build_target_parse: string[];
|
|
546
|
+
__yo_build_dependency: string[];
|
|
547
|
+
__yo_build_path_dependency: string[];
|
|
548
|
+
__yo_build_system_library: string[];
|
|
549
|
+
__yo_build_option: string[];
|
|
550
|
+
__yo_build_dep_artifact: string[];
|
|
534
551
|
};
|
|
535
552
|
export declare function exprIsInfixOperatorFunctionCall(expr: Expr): boolean;
|
|
536
553
|
export interface ExprToStringConfig {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BuildGitDependency } from "./evaluator/builtins/build";
|
|
2
|
+
import { type LockFile } from "./lock-file";
|
|
3
|
+
export declare function getCacheDir(_projectDir?: string): string;
|
|
4
|
+
export interface FetchResult {
|
|
5
|
+
resolvedPaths: Map<string, string>;
|
|
6
|
+
lockFile: LockFile;
|
|
7
|
+
}
|
|
8
|
+
export declare function fetchAllDependencies(projectDir: string, dependencies: BuildGitDependency[], verbose?: boolean, update?: boolean): FetchResult;
|
|
9
|
+
export declare function areDependenciesCached(projectDir: string, dependencies: BuildGitDependency[]): boolean;
|
|
10
|
+
export declare function resolveDependencyPath(projectDir: string, depName: string, depPath?: string): string | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface LockEntry {
|
|
2
|
+
name: string;
|
|
3
|
+
url: string;
|
|
4
|
+
ref: string;
|
|
5
|
+
commit: string;
|
|
6
|
+
hash: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LockFile {
|
|
9
|
+
dependencies: LockEntry[];
|
|
10
|
+
}
|
|
11
|
+
export declare function parseLockFile(content: string): LockFile;
|
|
12
|
+
export declare function writeLockFileContent(lockFile: LockFile): string;
|
|
13
|
+
export declare function readLockFile(projectDir: string): LockFile;
|
|
14
|
+
export declare function saveLockFile(projectDir: string, lockFile: LockFile): void;
|
|
15
|
+
export declare function findLockEntry(lockFile: LockFile, name: string): LockEntry | undefined;
|
|
16
|
+
export declare function upsertLockEntry(lockFile: LockFile, entry: LockEntry): LockFile;
|
|
@@ -28,12 +28,14 @@ export declare class ModuleManager {
|
|
|
28
28
|
moduleError: Error | undefined;
|
|
29
29
|
};
|
|
30
30
|
deleteModule(modulePath: string): void;
|
|
31
|
-
compileModule(modulePath: string, { emitC, debugGc, debugParallelism, debugAsyncAwait, allocator, }?: {
|
|
31
|
+
compileModule(modulePath: string, { emitC, debugGc, debugParallelism, debugAsyncAwait, allocator, isLibrary, }?: {
|
|
32
32
|
emitC?: boolean;
|
|
33
33
|
debugGc?: boolean;
|
|
34
34
|
debugParallelism?: boolean;
|
|
35
35
|
debugAsyncAwait?: boolean;
|
|
36
36
|
allocator?: "mimalloc" | "libc";
|
|
37
|
+
isLibrary?: boolean;
|
|
37
38
|
}): void;
|
|
38
39
|
getGeneratedCode(): string;
|
|
40
|
+
getExportedFunctionNames(): Set<string>;
|
|
39
41
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BuildSystemLibrary } from "./evaluator/builtins/build";
|
|
2
|
+
export interface PkgConfigResult {
|
|
3
|
+
cFlags: string[];
|
|
4
|
+
ldFlags: string[];
|
|
5
|
+
includePaths: string[];
|
|
6
|
+
libraryPaths: string[];
|
|
7
|
+
linkLibraries: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function isPkgConfigAvailable(): boolean;
|
|
10
|
+
export declare function resolveSystemLibrary(lib: BuildSystemLibrary, verbose?: boolean): PkgConfigResult;
|
|
11
|
+
export declare function resolveAllSystemLibraries(libraries: BuildSystemLibrary[], verbose?: boolean): PkgConfigResult;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type Arch = "x86_64" | "aarch64" | "x86" | "arm" | "wasm32";
|
|
2
|
+
export type Os = "linux" | "macos" | "windows" | "freebsd" | "wasi";
|
|
3
|
+
export type Abi = "gnu" | "musl" | "msvc" | "none" | "wasm";
|
|
4
|
+
export interface TargetInfo {
|
|
5
|
+
arch: Arch;
|
|
6
|
+
os: Os;
|
|
7
|
+
abi: Abi | undefined;
|
|
8
|
+
pointerSizeBits: 32 | 64;
|
|
9
|
+
triple: string;
|
|
10
|
+
}
|
|
11
|
+
export interface HostInfo {
|
|
12
|
+
platform: Os;
|
|
13
|
+
arch: Arch;
|
|
14
|
+
}
|
|
15
|
+
export declare function pointerSizeForArch(arch: Arch): 32 | 64;
|
|
16
|
+
export declare function detectHost(): HostInfo;
|
|
17
|
+
export declare function hostTarget(): TargetInfo;
|
|
18
|
+
export declare function parseTarget(triple: string): TargetInfo;
|
|
19
|
+
export declare function clangTriple(target: TargetInfo): string;
|
|
20
|
+
export declare function setCurrentTarget(target: TargetInfo): void;
|
|
21
|
+
export declare function getCurrentTarget(): TargetInfo;
|
|
22
|
+
export declare function targetOsToYoString(os: Os): string;
|
|
23
|
+
export declare function targetArchToYoString(arch: Arch): string;
|
|
24
|
+
export declare function isTargetWindows(target: TargetInfo): boolean;
|
|
25
|
+
export declare function isTargetLinux(target: TargetInfo): boolean;
|
|
26
|
+
export declare function isTargetMacos(target: TargetInfo): boolean;
|
|
27
|
+
export declare function isTargetMSVC(target: TargetInfo): boolean;
|
|
28
|
+
export declare function isTargetWasm(target: TargetInfo): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|