@dbx-tools/projen 0.6.148 → 0.6.149
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/index.ts +2 -2
- package/package.json +4 -4
- package/src/project-rs.ts +91 -20
package/index.ts
CHANGED
|
@@ -45,8 +45,8 @@ export { PackageIdentifier, PROJEN_VERSION, DBXToolsNodeProject, ROOT_INSTALL_ON
|
|
|
45
45
|
export type { DBXToolsJavaScriptProject, DBXToolsJavaScriptProjectOptions, DBXToolsTypeScriptProjectOptions } from "./src/project-js.ts";
|
|
46
46
|
export { DBXToolsPythonProject, DBXToolsPythonWorkspace } from "./src/project-py.ts";
|
|
47
47
|
export type { PythonRepositoryOptions, PythonPackageOptions, PythonTrustedPublisherOptions, DBXToolsPythonProjectOptions, PythonReleaseOptions, DBXToolsPythonWorkspaceOptions } from "./src/project-py.ts";
|
|
48
|
-
export { UNIFFI_RELEASE_TARGETS, DBXToolsRustProject, DBXToolsRustWorkspace } from "./src/project-rs.ts";
|
|
49
|
-
export type { CargoDependencyOptions, CargoDependency, RustPackageOptions, DBXToolsRustWorkspaceOptions, UniFFIReleaseTarget, RustBindingMapping, RustWorkspaceMapping } from "./src/project-rs.ts";
|
|
48
|
+
export { RustReleaseOs, RustReleaseCpu, UNIFFI_RELEASE_TARGETS, DBXToolsRustProject, DBXToolsRustWorkspace } from "./src/project-rs.ts";
|
|
49
|
+
export type { CargoDependencyOptions, CargoDependency, RustPackageOptions, DBXToolsRustWorkspaceOptions, RustReleasePlatform, UniFFIReleaseTarget, RustBindingMapping, RustWorkspaceMapping } from "./src/project-rs.ts";
|
|
50
50
|
export { COMPILED_DIR, COMPILED_COMPILER_OPTIONS } from "./src/publish.ts";
|
|
51
51
|
export { DBXToolsRelease } from "./src/release.ts";
|
|
52
52
|
export type { StandaloneRelease, DBXToolsReleaseOptions } from "./src/release.ts";
|
package/package.json
CHANGED
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@clack/prompts": "^1.7.0",
|
|
29
|
-
"@dbx-tools/core": "0.6.
|
|
30
|
-
"@dbx-tools/path": "0.6.
|
|
31
|
-
"@dbx-tools/shared-core": "0.6.
|
|
29
|
+
"@dbx-tools/core": "0.6.149",
|
|
30
|
+
"@dbx-tools/path": "0.6.149",
|
|
31
|
+
"@dbx-tools/shared-core": "0.6.149",
|
|
32
32
|
"commander": "^15.0.0",
|
|
33
33
|
"concurrently": "^10.0.3",
|
|
34
34
|
"constructs": "^10.6.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"main": "index.ts",
|
|
50
50
|
"license": "Apache-2.0",
|
|
51
|
-
"version": "0.6.
|
|
51
|
+
"version": "0.6.149",
|
|
52
52
|
"types": "index.ts",
|
|
53
53
|
"type": "module",
|
|
54
54
|
"exports": {
|
package/src/project-rs.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface RustPackageOptions {
|
|
|
32
32
|
readonly devDependencies?: Readonly<Record<string, CargoDependency>>;
|
|
33
33
|
readonly features?: Readonly<Record<string, readonly string[]>>;
|
|
34
34
|
readonly defaultFeatures?: readonly string[];
|
|
35
|
+
/** Cargo and release executable name. Defaults to the generated package name. */
|
|
35
36
|
readonly binaryName?: string;
|
|
36
37
|
readonly bindings?: readonly ("node" | "python")[];
|
|
37
38
|
readonly nodeDependencies?: readonly string[];
|
|
@@ -56,17 +57,35 @@ export interface DBXToolsRustWorkspaceOptions {
|
|
|
56
57
|
readonly release?: boolean;
|
|
57
58
|
/** Native release targets; defaults to the maintained GitHub-hosted matrix. */
|
|
58
59
|
readonly releaseTargets?: readonly UniFFIReleaseTarget[];
|
|
60
|
+
/** Maintained OS/CPU combinations to release. Defaults to every supported target. */
|
|
61
|
+
readonly releasePlatforms?: readonly RustReleasePlatform[];
|
|
59
62
|
/** Workflow name used by downstream release stages. Defaults to `rust-release`. */
|
|
60
63
|
readonly releaseWorkflowName?: string;
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
export enum RustReleaseOs {
|
|
67
|
+
DARWIN = "darwin",
|
|
68
|
+
LINUX = "linux",
|
|
69
|
+
WINDOWS = "win32",
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export enum RustReleaseCpu {
|
|
73
|
+
ARM64 = "arm64",
|
|
74
|
+
X64 = "x64",
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface RustReleasePlatform {
|
|
78
|
+
readonly os: RustReleaseOs;
|
|
79
|
+
readonly cpu: RustReleaseCpu;
|
|
80
|
+
}
|
|
81
|
+
|
|
63
82
|
export interface UniFFIReleaseTarget {
|
|
64
83
|
readonly runner: string;
|
|
65
84
|
readonly cargo: string;
|
|
66
85
|
readonly node: string;
|
|
67
86
|
readonly python: string;
|
|
68
|
-
readonly os:
|
|
69
|
-
readonly cpu:
|
|
87
|
+
readonly os: RustReleaseOs;
|
|
88
|
+
readonly cpu: RustReleaseCpu;
|
|
70
89
|
readonly libc?: "glibc";
|
|
71
90
|
}
|
|
72
91
|
|
|
@@ -77,8 +96,8 @@ export const UNIFFI_RELEASE_TARGETS: readonly UniFFIReleaseTarget[] = [
|
|
|
77
96
|
cargo: "x86_64-unknown-linux-gnu",
|
|
78
97
|
node: "linux-x64-gnu",
|
|
79
98
|
python: "manylinux_2_35_x86_64",
|
|
80
|
-
os:
|
|
81
|
-
cpu:
|
|
99
|
+
os: RustReleaseOs.LINUX,
|
|
100
|
+
cpu: RustReleaseCpu.X64,
|
|
82
101
|
libc: "glibc",
|
|
83
102
|
},
|
|
84
103
|
{
|
|
@@ -86,8 +105,8 @@ export const UNIFFI_RELEASE_TARGETS: readonly UniFFIReleaseTarget[] = [
|
|
|
86
105
|
cargo: "aarch64-unknown-linux-gnu",
|
|
87
106
|
node: "linux-arm64-gnu",
|
|
88
107
|
python: "manylinux_2_39_aarch64",
|
|
89
|
-
os:
|
|
90
|
-
cpu:
|
|
108
|
+
os: RustReleaseOs.LINUX,
|
|
109
|
+
cpu: RustReleaseCpu.ARM64,
|
|
91
110
|
libc: "glibc",
|
|
92
111
|
},
|
|
93
112
|
{
|
|
@@ -95,27 +114,59 @@ export const UNIFFI_RELEASE_TARGETS: readonly UniFFIReleaseTarget[] = [
|
|
|
95
114
|
cargo: "x86_64-apple-darwin",
|
|
96
115
|
node: "darwin-x64",
|
|
97
116
|
python: "macosx_13_0_x86_64",
|
|
98
|
-
os:
|
|
99
|
-
cpu:
|
|
117
|
+
os: RustReleaseOs.DARWIN,
|
|
118
|
+
cpu: RustReleaseCpu.X64,
|
|
100
119
|
},
|
|
101
120
|
{
|
|
102
121
|
runner: "macos-14",
|
|
103
122
|
cargo: "aarch64-apple-darwin",
|
|
104
123
|
node: "darwin-arm64",
|
|
105
124
|
python: "macosx_11_0_arm64",
|
|
106
|
-
os:
|
|
107
|
-
cpu:
|
|
125
|
+
os: RustReleaseOs.DARWIN,
|
|
126
|
+
cpu: RustReleaseCpu.ARM64,
|
|
108
127
|
},
|
|
109
128
|
{
|
|
110
129
|
runner: "windows-latest",
|
|
111
130
|
cargo: "x86_64-pc-windows-msvc",
|
|
112
131
|
node: "win32-x64-msvc",
|
|
113
132
|
python: "win_amd64",
|
|
114
|
-
os:
|
|
115
|
-
cpu:
|
|
133
|
+
os: RustReleaseOs.WINDOWS,
|
|
134
|
+
cpu: RustReleaseCpu.X64,
|
|
116
135
|
},
|
|
117
136
|
] as const;
|
|
118
137
|
|
|
138
|
+
const RUST_CACHE_ENV = {
|
|
139
|
+
RUSTC_WRAPPER: "sccache",
|
|
140
|
+
SCCACHE_GHA_ENABLED: "true",
|
|
141
|
+
} as const;
|
|
142
|
+
|
|
143
|
+
function rustCacheSteps(sharedKey: string): readonly Record<string, unknown>[] {
|
|
144
|
+
return [
|
|
145
|
+
{ name: "Setup sccache", uses: "mozilla-actions/sccache-action@v0.0.9" },
|
|
146
|
+
{
|
|
147
|
+
name: "Cache Cargo registry",
|
|
148
|
+
uses: "Swatinem/rust-cache@v2",
|
|
149
|
+
with: { "cache-targets": false, "shared-key": sharedKey },
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function releaseTargets(options: DBXToolsRustWorkspaceOptions): readonly UniFFIReleaseTarget[] {
|
|
155
|
+
if (options.releaseTargets && options.releasePlatforms) {
|
|
156
|
+
throw new Error("releaseTargets and releasePlatforms are mutually exclusive");
|
|
157
|
+
}
|
|
158
|
+
if (options.releaseTargets) return options.releaseTargets;
|
|
159
|
+
if (!options.releasePlatforms) return UNIFFI_RELEASE_TARGETS;
|
|
160
|
+
return options.releasePlatforms.map((platform) => {
|
|
161
|
+
const target = UNIFFI_RELEASE_TARGETS.find(
|
|
162
|
+
(candidate) => candidate.os === platform.os && candidate.cpu === platform.cpu,
|
|
163
|
+
);
|
|
164
|
+
if (!target)
|
|
165
|
+
throw new Error(`Unsupported Rust release platform: ${platform.os}-${platform.cpu}`);
|
|
166
|
+
return target;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
119
170
|
/** Persisted mapping consumed by the focused Rust source watcher. */
|
|
120
171
|
export interface RustBindingMapping {
|
|
121
172
|
readonly crate: string;
|
|
@@ -218,6 +269,8 @@ export class DBXToolsRustProject extends Project implements DBXToolsProject {
|
|
|
218
269
|
this.packageOptions = options;
|
|
219
270
|
this.uniffi = hasUniFFIBindings(this.outdir);
|
|
220
271
|
const library = existsSync(join(this.outdir, "src/lib.rs"));
|
|
272
|
+
const binary = existsSync(join(this.outdir, "src/main.rs"));
|
|
273
|
+
const binaryName = options.binaryName ?? crateName;
|
|
221
274
|
const manifest: Record<string, unknown> = {
|
|
222
275
|
package: {
|
|
223
276
|
name: crateName,
|
|
@@ -238,11 +291,11 @@ export class DBXToolsRustProject extends Project implements DBXToolsProject {
|
|
|
238
291
|
},
|
|
239
292
|
}
|
|
240
293
|
: {}),
|
|
241
|
-
...(this.uniffi ||
|
|
294
|
+
...(this.uniffi || binary
|
|
242
295
|
? {
|
|
243
296
|
bin: this.uniffi
|
|
244
297
|
? { name: "uniffi-bindgen", path: "uniffi-bindgen.rs" }
|
|
245
|
-
: { name:
|
|
298
|
+
: { name: binaryName, path: "src/main.rs" },
|
|
246
299
|
}
|
|
247
300
|
: {}),
|
|
248
301
|
...(options.features || options.defaultFeatures
|
|
@@ -356,9 +409,7 @@ export class DBXToolsRustWorkspace {
|
|
|
356
409
|
trustedPublisher: {
|
|
357
410
|
workflowName: options.releaseWorkflowName ?? "rust-release",
|
|
358
411
|
environment: `native-${pkg.crateName}`,
|
|
359
|
-
artifacts: `platform-specific wheels for ${(
|
|
360
|
-
options.releaseTargets ?? UNIFFI_RELEASE_TARGETS
|
|
361
|
-
)
|
|
412
|
+
artifacts: `platform-specific wheels for ${releaseTargets(options)
|
|
362
413
|
.map((target) => `${target.os}-${target.cpu}`)
|
|
363
414
|
.join(", ")}; all architectures publish to this one PyPI project`,
|
|
364
415
|
},
|
|
@@ -471,7 +522,7 @@ export class DBXToolsRustWorkspace {
|
|
|
471
522
|
(options.release ?? true) &&
|
|
472
523
|
(this.bindingMappings.length > 0 || this.packages.some((pkg) => pkg.packageOptions.release))
|
|
473
524
|
) {
|
|
474
|
-
this.addReleaseWorkflow(project, options, options
|
|
525
|
+
this.addReleaseWorkflow(project, options, releaseTargets(options));
|
|
475
526
|
}
|
|
476
527
|
}
|
|
477
528
|
|
|
@@ -506,6 +557,7 @@ export class DBXToolsRustWorkspace {
|
|
|
506
557
|
const buildJob = {
|
|
507
558
|
name: "${{ matrix.binding.crate }} / ${{ matrix.target.node }}",
|
|
508
559
|
"runs-on": "${{ matrix.target.runner }}",
|
|
560
|
+
env: RUST_CACHE_ENV,
|
|
509
561
|
strategy: {
|
|
510
562
|
"fail-fast": false,
|
|
511
563
|
matrix: { include: matrix },
|
|
@@ -523,6 +575,7 @@ export class DBXToolsRustWorkspace {
|
|
|
523
575
|
uses: "dtolnay/rust-toolchain@stable",
|
|
524
576
|
with: { targets: "${{ matrix.target.cargo }}" },
|
|
525
577
|
},
|
|
578
|
+
...rustCacheSteps("uniffi-${{ matrix.target.cargo }}"),
|
|
526
579
|
{
|
|
527
580
|
name: "Install Linux native dependencies",
|
|
528
581
|
if: "${{ matrix.target.os == 'linux' }}",
|
|
@@ -554,6 +607,7 @@ export class DBXToolsRustWorkspace {
|
|
|
554
607
|
const binaryBuildJob = {
|
|
555
608
|
name: "${{ matrix.package.crate }} / ${{ matrix.target.node }}",
|
|
556
609
|
"runs-on": "${{ matrix.target.runner }}",
|
|
610
|
+
env: RUST_CACHE_ENV,
|
|
557
611
|
strategy: { "fail-fast": false, matrix: { include: binaryMatrix } },
|
|
558
612
|
steps: [
|
|
559
613
|
{ name: "Checkout", uses: "actions/checkout@v6" },
|
|
@@ -562,6 +616,7 @@ export class DBXToolsRustWorkspace {
|
|
|
562
616
|
uses: "dtolnay/rust-toolchain@stable",
|
|
563
617
|
with: { targets: "${{ matrix.target.cargo }}" },
|
|
564
618
|
},
|
|
619
|
+
...rustCacheSteps("binary-${{ matrix.target.cargo }}"),
|
|
565
620
|
{
|
|
566
621
|
name: "Install Linux native dependencies",
|
|
567
622
|
if: "${{ matrix.target.os == 'linux' }}",
|
|
@@ -572,10 +627,18 @@ export class DBXToolsRustWorkspace {
|
|
|
572
627
|
shell: "bash",
|
|
573
628
|
run: [
|
|
574
629
|
'cargo build --release --package "${{ matrix.package.crate }}" --bin "${{ matrix.package.binary }}" --target "${{ matrix.target.cargo }}"',
|
|
575
|
-
"mkdir -p dist/rust-release",
|
|
630
|
+
"mkdir -p dist/rust-release/stage",
|
|
576
631
|
"SOURCE=\"target/${{ matrix.target.cargo }}/release/${{ matrix.package.binary }}${{ matrix.target.os == 'win32' && '.exe' || '' }}\"",
|
|
577
|
-
"DESTINATION=\"dist/rust-release/${{ matrix.package.binary }}
|
|
632
|
+
"DESTINATION=\"dist/rust-release/stage/${{ matrix.package.binary }}${{ matrix.target.os == 'win32' && '.exe' || '' }}\"",
|
|
578
633
|
'cp "$SOURCE" "$DESTINATION"',
|
|
634
|
+
'if [ "${{ matrix.target.os }}" = "win32" ]; then',
|
|
635
|
+
' ARCHIVE="dist/rust-release/${{ matrix.package.binary }}-${{ matrix.target.node }}.zip"',
|
|
636
|
+
' 7z a "$ARCHIVE" "$DESTINATION"',
|
|
637
|
+
"else",
|
|
638
|
+
' ARCHIVE="dist/rust-release/${{ matrix.package.binary }}-${{ matrix.target.node }}.tar.gz"',
|
|
639
|
+
' tar -C dist/rust-release/stage -czf "$ARCHIVE" "${{ matrix.package.binary }}"',
|
|
640
|
+
"fi",
|
|
641
|
+
"rm -rf dist/rust-release/stage",
|
|
579
642
|
].join("\n"),
|
|
580
643
|
},
|
|
581
644
|
{
|
|
@@ -665,9 +728,15 @@ export class DBXToolsRustWorkspace {
|
|
|
665
728
|
needs: [matrix.length ? "build" : "build-binaries"],
|
|
666
729
|
"runs-on": "ubuntu-latest",
|
|
667
730
|
permissions: { contents: "read" },
|
|
731
|
+
env: RUST_CACHE_ENV,
|
|
668
732
|
steps: [
|
|
669
733
|
{ name: "Checkout", uses: "actions/checkout@v6" },
|
|
670
734
|
{ name: "Setup Rust", uses: "dtolnay/rust-toolchain@stable" },
|
|
735
|
+
...rustCacheSteps("cargo-publish"),
|
|
736
|
+
{
|
|
737
|
+
name: "Install Linux native dependencies",
|
|
738
|
+
run: "sudo apt-get update && sudo apt-get install --yes libdbus-1-dev pkg-config",
|
|
739
|
+
},
|
|
671
740
|
{
|
|
672
741
|
name: "Publish public crates",
|
|
673
742
|
env: { CARGO_REGISTRY_TOKEN: "${{ secrets.CARGO_REGISTRY_TOKEN }}" },
|
|
@@ -679,6 +748,7 @@ export class DBXToolsRustWorkspace {
|
|
|
679
748
|
if: "${{ github.event_name == 'push' && vars.LOCAL_REPOSITORIES == 'true' }}",
|
|
680
749
|
"runs-on": ["self-hosted"],
|
|
681
750
|
permissions: { contents: "read" },
|
|
751
|
+
env: RUST_CACHE_ENV,
|
|
682
752
|
steps: [
|
|
683
753
|
{ name: "Checkout", uses: "actions/checkout@v6" },
|
|
684
754
|
{
|
|
@@ -688,6 +758,7 @@ export class DBXToolsRustWorkspace {
|
|
|
688
758
|
},
|
|
689
759
|
{ name: "Setup uv", uses: "astral-sh/setup-uv@v7" },
|
|
690
760
|
{ name: "Setup Rust", uses: "dtolnay/rust-toolchain@stable" },
|
|
761
|
+
...rustCacheSteps("local-${{ runner.os }}-${{ runner.arch }}"),
|
|
691
762
|
{ name: "Install", run: "bun install" },
|
|
692
763
|
{
|
|
693
764
|
name: "Build and publish host-native packages",
|