Skip to content

Commit

Permalink
build-system: only write version.txt once per dir (#36162)
Browse files Browse the repository at this point in the history
* build-system: only write version.txt once

* output full set of

* sort the paths

* write files...not directories

* succinct format
  • Loading branch information
samouri authored Sep 27, 2021
1 parent 2a85ef7 commit 4377f31
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
24 changes: 24 additions & 0 deletions build-system/tasks/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const {
const {
displayLifecycleDebugging,
} = require('../compile/debug-compilation-lifecycle');
const {
VERSION: internalRuntimeVersion,
} = require('../compile/internal-version');
const {buildCompiler} = require('../compile/build-compiler');
const {buildExtensions, parseExtensionFlags} = require('./extension-helpers');
const {buildVendorConfigs} = require('./3p-vendor-helpers');
Expand Down Expand Up @@ -118,6 +121,7 @@ async function dist() {
await compileCoreRuntime(options);
} else {
await Promise.all([
writeVersionFiles(),
buildExperiments(),
buildLoginDone('0.1'),
buildWebPushPublisherFiles(),
Expand Down Expand Up @@ -147,6 +151,26 @@ async function dist() {
}
}

/**
* Writes the verion.txt file.
* @return {!Promise}
*/
async function writeVersionFiles() {
// TODO: determine which of these are necessary and trim the rest via an I2D.
const paths = [
'dist',
'dist/v0',
'dist/v0/examples',
'dist.tools/experiments',
`dist.3p/${internalRuntimeVersion}`,
`dist.3p/${internalRuntimeVersion}/vendor`,
].map((p) => path.join(...p.split('/'), 'version.txt'));

return Promise.all(
paths.map((p) => fs.outputFile(p, internalRuntimeVersion))
);
}

/**
* Build AMP experiments.js.
* @return {Promise<void>}
Expand Down
9 changes: 0 additions & 9 deletions build-system/tasks/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ async function compileMinifiedJs(srcDir, srcFilename, destDir, options) {

const destPath = path.join(destDir, minifiedName);
combineWithCompiledFile(srcFilename, destPath, options);
fs.writeFileSync(path.join(destDir, 'version.txt'), internalRuntimeVersion);
if (options.latestName) {
fs.copySync(
destPath,
Expand Down Expand Up @@ -403,14 +402,6 @@ async function esbuildCompile(srcDir, srcFilename, destDir, options) {
return watchedTargets.get(entryPoint).rebuild();
}

// TODO(36162): Only write this once as part of the dist() function.
if (options.minify) {
fs.outputFileSync(
path.join(destDir, 'version.txt'),
internalRuntimeVersion
);
}

/**
* Splits up the wrapper to compute the banner and footer
* @return {Object}
Expand Down

0 comments on commit 4377f31

Please sign in to comment.