-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: auto generate electron_version.h from the version file
- Loading branch information
1 parent
d581160
commit 8e5e10c
Showing
15 changed files
with
128 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import json | ||
import sys | ||
from string import Template | ||
|
||
inpath = sys.argv[1] | ||
outpath = sys.argv[2] | ||
argpaths = sys.argv[3:] | ||
|
||
with open(inpath, 'r') as infile, open(outpath, 'w') as outfile: | ||
data = {} | ||
for argpath in argpaths: | ||
with open(argpath, 'r') as argfile: | ||
data.update(json.load(argfile)) | ||
|
||
s = Template(''.join(infile.readlines())).safe_substitute(data) | ||
outfile.write(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
template("templated_file") { | ||
assert(defined(invoker.template), "Need template file to run") | ||
assert(defined(invoker.output), "Need output file to run") | ||
assert(defined(invoker.values)) | ||
|
||
args_path = "$target_gen_dir/$target_name.args" | ||
write_file(args_path, invoker.values, "json") | ||
|
||
action(target_name) { | ||
forward_variables_from(invoker, | ||
[ | ||
"deps", | ||
"public_deps", | ||
"inputs", | ||
"outputs", | ||
]) | ||
inputs = [ | ||
invoker.template, | ||
] | ||
outputs = [ | ||
invoker.output, | ||
] | ||
script = "//electron/build/generate-template.py" | ||
args = [ | ||
rebase_path(invoker.template), | ||
rebase_path(invoker.output), | ||
rebase_path(args_path), | ||
] | ||
|
||
if (defined(invoker.extra_args)) { | ||
args += rebase_path(invoker.extra_args) | ||
inputs += invoker.extra_args | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const semver = require('semver') | ||
|
||
const outputPath = process.argv[2] | ||
|
||
const currentVersion = fs.readFileSync(path.resolve(__dirname, '../ELECTRON_VERSION'), 'utf8').trim() | ||
|
||
const parsed = semver.parse(currentVersion) | ||
|
||
let prerelease = '' | ||
if (parsed.prerelease && parsed.prerelease.length > 0) { | ||
prerelease = parsed.prerelease.join('.') | ||
} | ||
|
||
const { | ||
major, | ||
minor, | ||
patch | ||
} = parsed | ||
|
||
fs.writeFileSync(outputPath, JSON.stringify({ | ||
major, | ||
minor, | ||
patch, | ||
prerelease, | ||
has_prerelease: prerelease === '' ? 0 : 1 | ||
}, null, 2)) |