Skip to content

Commit d3beea5

Browse files
committed
add MSRV to manifest
1 parent d1ec300 commit d3beea5

1 file changed

Lines changed: 47 additions & 35 deletions

File tree

lib/update-v8/updateCrates.js

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export default function updateCrates() {
1414
return task.newListr([
1515
enumerateTemporalDependencies(),
1616
removeExistingCrates(),
17-
buildManifest(),
1817
vendorCrates(),
18+
buildManifest(),
1919
generateLockfile(),
2020
updateGYP(),
2121
commitChanges()
@@ -57,40 +57,6 @@ function removeExistingCrates() {
5757
};
5858
}
5959

60-
function buildManifest() {
61-
return {
62-
title: 'Build new manifest',
63-
task: async(ctx) => {
64-
const sourceManifest = TOML.parse(
65-
await fs.readFile(path.join(ctx.nodeDir, chromiumCratesDir, 'Cargo.toml'), 'utf8')
66-
);
67-
68-
const header =
69-
'# This manifest is generated by node-core-utils. Do not modify it directly.\n\n';
70-
const manifest = {
71-
package: {
72-
edition: sourceManifest.package.edition,
73-
name: 'node_crates',
74-
version: `${ctx.newVersion.major}.${ctx.newVersion.minor}.${ctx.newVersion.build}`
75-
},
76-
lib: {
77-
'crate-type': ['staticlib']
78-
},
79-
dependencies: {}
80-
};
81-
for (const crate of ctx.temporalCrates) {
82-
const name = crate.split('@', 1)[0];
83-
if (name === 'temporal_capi' || typeof sourceManifest.dependencies[name] === 'object') {
84-
manifest.dependencies[name] = sourceManifest.dependencies[name];
85-
}
86-
}
87-
88-
const cargoTOML = header + TOML.stringify(manifest);
89-
await fs.writeFile(path.join(ctx.nodeDir, nodeCratesDir, 'Cargo.toml'), cargoTOML);
90-
},
91-
};
92-
}
93-
9460
// Note that the crates vendored in third_party/rust/chromium_crates_io already have any custom
9561
// Chromium patches applied by gnrt, so we don't need to worry about patching them ourselves.
9662
function vendorCrates() {
@@ -102,12 +68,16 @@ function vendorCrates() {
10268
await fs.mkdir(nodeVendor);
10369

10470
const subtasks = [];
71+
const rustVersions = [];
10572
for (const dir of await fs.readdir(chromiumVendor)) {
10673
const crate = await getCrateInfo(dir);
10774
if (!crate || !ctx.temporalCrates.has(`${crate.name}@${crate.version}`)) continue;
10875
if (crate.name === 'temporal_capi') {
10976
ctx.temporalCAPIDirectory = dir;
11077
}
78+
if (crate['rust-version']) {
79+
rustVersions.push(crate['rust-version']);
80+
}
11181
subtasks.push({
11282
title: dir,
11383
task: async(ctx) => {
@@ -120,6 +90,11 @@ function vendorCrates() {
12090
});
12191
}
12292

93+
if (rustVersions.length) {
94+
const msrv = rustVersions.map(semver.coerce).reduce((a, b) => (semver.gt(a, b) ? a : b));
95+
ctx.msrv = `${msrv.major}.${msrv.minor}`;
96+
}
97+
12398
return task.newListr(subtasks, { concurrent: ctx.concurrent });
12499

125100
async function getCrateInfo(crate) {
@@ -136,6 +111,43 @@ function vendorCrates() {
136111
};
137112
}
138113

114+
function buildManifest() {
115+
return {
116+
title: 'Build new manifest',
117+
task: async(ctx) => {
118+
const sourceManifest = TOML.parse(
119+
await fs.readFile(path.join(ctx.nodeDir, chromiumCratesDir, 'Cargo.toml'), 'utf8')
120+
);
121+
122+
const header =
123+
'# This manifest is generated by node-core-utils. Do not modify it directly.\n\n';
124+
const manifest = {
125+
package: {
126+
edition: sourceManifest.package.edition,
127+
name: 'node_crates',
128+
version: `${ctx.newVersion.major}.${ctx.newVersion.minor}.${ctx.newVersion.build}`
129+
},
130+
lib: {
131+
'crate-type': ['staticlib']
132+
},
133+
dependencies: {}
134+
};
135+
if (ctx.msrv) {
136+
manifest.package['rust-version'] = ctx.msrv;
137+
}
138+
for (const crate of ctx.temporalCrates) {
139+
const name = crate.split('@', 1)[0];
140+
if (name === 'temporal_capi' || typeof sourceManifest.dependencies[name] === 'object') {
141+
manifest.dependencies[name] = sourceManifest.dependencies[name];
142+
}
143+
}
144+
145+
const cargoTOML = header + TOML.stringify(manifest);
146+
await fs.writeFile(path.join(ctx.nodeDir, nodeCratesDir, 'Cargo.toml'), cargoTOML);
147+
},
148+
};
149+
}
150+
139151
function generateLockfile() {
140152
return {
141153
title: 'Generate lockfile',

0 commit comments

Comments
 (0)