-
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
00d1891
commit 95bccf8
Showing
16 changed files
with
143 additions
and
62 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 was deleted.
Oops, something went wrong.
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(infile.read()).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,39 @@ | ||
template("templated_file") { | ||
assert(defined(invoker.template), "Need template file to run") | ||
assert(defined(invoker.output), "Need output file to run") | ||
|
||
if (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), | ||
] | ||
|
||
if (defined(invoker.values)) { | ||
args += rebase_path(args_path) | ||
} | ||
|
||
if (defined(invoker.args_files)) { | ||
args += rebase_path(invoker.args_files) | ||
inputs += invoker.args_files | ||
} | ||
} | ||
} |
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,23 @@ | ||
// Copyright (c) 2019 Slack Technologies, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ELECTRON_ELECTRON_VERSION_H | ||
#define ELECTRON_ELECTRON_VERSION_H | ||
|
||
#define ELECTRON_MAJOR_VERSION $major | ||
#define ELECTRON_MINOR_VERSION $minor | ||
#define ELECTRON_PATCH_VERSION $patch | ||
#if $has_prerelease | ||
#define ELECTRON_PRE_RELEASE_VERSION -$prerelease | ||
#endif | ||
|
||
#ifndef ELECTRON_PRE_RELEASE_VERSION | ||
#define ELECTRON_VERSION_STRING "$major.$minor.$patch" | ||
#else | ||
#define ELECTRON_VERSION_STRING "$major.$minor.$patch-$prerelease" | ||
#endif | ||
|
||
#define ELECTRON_VERSION "v" ELECTRON_VERSION_STRING | ||
|
||
#endif // ELECTRON_ELECTRON_VERSION_H |
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)) |