chore: stop using electron.gyp for branding and version (#14559)
* chore: stop using electron.gyp for version info * chore: remove branding info from electron.gyp * Use get_electron_branding instead of gn read * Flip project_name/product_name
This commit is contained in:
parent
6be69048e6
commit
77fb9cf416
12 changed files with 60 additions and 86 deletions
31
BUILD.gn
31
BUILD.gn
|
@ -25,13 +25,12 @@ if (is_linux) {
|
|||
}
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
electron_project_name = "electron"
|
||||
electron_product_name = "Electron"
|
||||
electron_company_name = "GitHub, Inc"
|
||||
electron_company_abbr = "github"
|
||||
electron_version = "0.0.0-dev"
|
||||
branding = read_file("atom/app/BRANDING.json", "json")
|
||||
electron_project_name = branding.project_name
|
||||
electron_product_name = branding.product_name
|
||||
electron_mac_bundle_id = branding.mac_bundle_id
|
||||
|
||||
declare_args() {
|
||||
enable_desktop_capturer = true
|
||||
enable_run_as_node = true
|
||||
enable_osr = true
|
||||
|
@ -462,11 +461,10 @@ electron_paks("packed_resources") {
|
|||
}
|
||||
|
||||
if (is_mac) {
|
||||
electron_framework_name = electron_product_name + " Framework"
|
||||
electron_helper_name = electron_product_name + " Helper"
|
||||
electron_login_helper_name = electron_product_name + " Login Helper"
|
||||
electron_framework_name = "$electron_product_name Framework"
|
||||
electron_helper_name = "$electron_product_name Helper"
|
||||
electron_login_helper_name = "$electron_product_name Login Helper"
|
||||
electron_framework_version = "A"
|
||||
electron_mac_bundle_id = "com.$electron_company_abbr.$electron_project_name"
|
||||
|
||||
mac_xib_bundle_data("electron_xibs") {
|
||||
sources = [
|
||||
|
@ -545,6 +543,8 @@ if (is_mac) {
|
|||
deps += [ ":electron_crashpad_helper" ]
|
||||
}
|
||||
info_plist = "atom/common/resources/mac/Info.plist"
|
||||
|
||||
electron_version = read_file("VERSION", "trim string")
|
||||
extra_substitutions = [
|
||||
"ATOM_BUNDLE_ID=$electron_mac_bundle_id.framework",
|
||||
"ELECTRON_VERSION=$electron_version",
|
||||
|
@ -881,12 +881,13 @@ group("licenses") {
|
|||
]
|
||||
}
|
||||
|
||||
action("electron_version") {
|
||||
script = "build/write_version.py"
|
||||
outputs = [
|
||||
"$root_build_dir/version",
|
||||
copy("electron_version") {
|
||||
sources = [
|
||||
"VERSION"
|
||||
]
|
||||
outputs = [
|
||||
"$root_build_dir/version"
|
||||
]
|
||||
args = rebase_path(outputs, root_build_dir) + [ electron_version ]
|
||||
}
|
||||
|
||||
dist_zip("electron_dist_zip") {
|
||||
|
|
1
VERSION
Normal file
1
VERSION
Normal file
|
@ -0,0 +1 @@
|
|||
4.0.0-nightly.20180823
|
5
atom/app/BRANDING.json
Normal file
5
atom/app/BRANDING.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"project_name": "electron",
|
||||
"product_name": "Electron",
|
||||
"mac_bundle_id": "com.github.Electron"
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
import sys
|
||||
|
||||
|
||||
def main(argv):
|
||||
out_file, version = argv
|
||||
with open(out_file, 'w') as f:
|
||||
f.write(version)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
'variables': {
|
||||
'project_name%': 'electron',
|
||||
'product_name%': 'Electron',
|
||||
'version%': '4.0.0-nightly.20180823',
|
||||
}
|
||||
}
|
|
@ -96,7 +96,7 @@ def main():
|
|||
return 0
|
||||
|
||||
with scoped_cwd(SOURCE_ROOT):
|
||||
update_electron_gyp(version, suffix)
|
||||
update_version(version, suffix)
|
||||
update_win_rc(version, versions)
|
||||
update_version_h(versions, suffix)
|
||||
update_info_plist(version)
|
||||
|
@ -115,20 +115,9 @@ def increase_version(versions, index):
|
|||
return versions
|
||||
|
||||
|
||||
def update_electron_gyp(version, suffix):
|
||||
assert False, "electron.gyp must not be used anymore. We build with GN now."
|
||||
|
||||
pattern = re.compile(" *'version%' *: *'[0-9.]+(-beta[0-9.]*)?(-dev)?"
|
||||
+ "(-nightly[0-9.]*)?'")
|
||||
with open('electron.gyp', 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
for i in range(0, len(lines)):
|
||||
if pattern.match(lines[i]):
|
||||
lines[i] = " 'version%': '{0}',\n".format(version + suffix)
|
||||
with open('electron.gyp', 'w') as f:
|
||||
f.write(''.join(lines))
|
||||
return
|
||||
def update_version(version, suffix):
|
||||
with open('VERSION', 'w') as f:
|
||||
f.write(version + suffix)
|
||||
|
||||
|
||||
def update_win_rc(version, versions):
|
||||
|
|
|
@ -5,8 +5,7 @@ import os
|
|||
import sys
|
||||
|
||||
from lib.config import PLATFORM, enable_verbose_mode, is_verbose_mode
|
||||
from lib.gn import gn
|
||||
from lib.util import execute, rm_rf
|
||||
from lib.util import get_electron_branding, execute, rm_rf
|
||||
|
||||
ELECTRON_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(ELECTRON_ROOT))
|
||||
|
@ -19,8 +18,7 @@ def main():
|
|||
rm_rf(args.destination)
|
||||
source_root = os.path.abspath(args.source_root)
|
||||
build_path = os.path.join(source_root, args.build_dir)
|
||||
product_name = gn(build_path).args().get_string('electron_product_name')
|
||||
project_name = gn(build_path).args().get_string('electron_project_name')
|
||||
(project_name, product_name) = get_names_from_branding()
|
||||
|
||||
if PLATFORM in ['darwin', 'linux']:
|
||||
|
||||
|
@ -50,6 +48,10 @@ def main():
|
|||
]
|
||||
execute([sys.executable, generate_breakpad_symbols] + args)
|
||||
|
||||
def get_names_from_branding():
|
||||
variables = get_electron_branding()
|
||||
return (variables['project_name'], variables['product_name'])
|
||||
|
||||
def generate_posix_symbols(binary, source_root, build_dir, destination):
|
||||
generate_breakpad_symbols = os.path.join(source_root, 'components', 'crash',
|
||||
'content', 'tools',
|
||||
|
|
|
@ -4,6 +4,8 @@ import atexit
|
|||
import contextlib
|
||||
import datetime
|
||||
import errno
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
|
@ -14,7 +16,6 @@ import sys
|
|||
import tarfile
|
||||
import tempfile
|
||||
import urllib2
|
||||
import os
|
||||
import zipfile
|
||||
|
||||
from lib.config import is_verbose_mode, PLATFORM
|
||||
|
@ -171,17 +172,17 @@ def execute_stdout(argv, env=None, cwd=None):
|
|||
else:
|
||||
execute(argv, env, cwd)
|
||||
|
||||
def electron_gyp():
|
||||
# FIXME(alexeykuzmin): Use data from //BUILD.gn.
|
||||
# electron.gyp is not used during the build.
|
||||
def get_electron_branding():
|
||||
SOURCE_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
|
||||
gyp = os.path.join(SOURCE_ROOT, 'electron.gyp')
|
||||
with open(gyp) as f:
|
||||
obj = eval(f.read());
|
||||
return obj['variables']
|
||||
branding_file_path = os.path.join(SOURCE_ROOT, 'atom', 'app', 'BRANDING.json')
|
||||
with open(branding_file_path) as f:
|
||||
return json.load(f)
|
||||
|
||||
def get_electron_version():
|
||||
return 'v' + electron_gyp()['version%']
|
||||
SOURCE_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
|
||||
version_file = os.path.join(SOURCE_ROOT, 'VERSION')
|
||||
with open(version_file) as f:
|
||||
return 'v' + f.read().strip()
|
||||
|
||||
def boto_path_dirs():
|
||||
return [
|
||||
|
|
|
@ -8,8 +8,8 @@ import subprocess
|
|||
import sys
|
||||
|
||||
from lib.config import enable_verbose_mode
|
||||
from lib.util import get_electron_branding, execute_stdout, rm_rf
|
||||
import lib.dbus_mock
|
||||
from lib.util import electron_gyp, execute_stdout, rm_rf
|
||||
|
||||
|
||||
if sys.platform == 'linux2':
|
||||
|
@ -29,8 +29,8 @@ if sys.platform == 'linux2':
|
|||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
|
||||
PROJECT_NAME = electron_gyp()['project_name%']
|
||||
PRODUCT_NAME = electron_gyp()['product_name%']
|
||||
PROJECT_NAME = get_electron_branding()['project_name']
|
||||
PRODUCT_NAME = get_electron_branding()['product_name']
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -5,15 +5,16 @@ import glob
|
|||
import sys
|
||||
|
||||
from lib.config import PLATFORM, s3_config, enable_verbose_mode
|
||||
from lib.util import electron_gyp, execute, rm_rf, safe_mkdir, s3put
|
||||
from lib.util import get_electron_branding, execute, rm_rf, safe_mkdir, s3put
|
||||
|
||||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
|
||||
RELEASE_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
|
||||
|
||||
PROJECT_NAME = electron_gyp()['project_name%']
|
||||
PRODUCT_NAME = electron_gyp()['product_name%']
|
||||
|
||||
PROJECT_NAME = get_electron_branding()['project_name']
|
||||
PRODUCT_NAME = get_electron_branding()['product_name']
|
||||
|
||||
if PLATFORM == 'win32':
|
||||
SYMBOLS_DIR = os.path.join(DIST_DIR, 'symbols')
|
||||
|
|
|
@ -13,15 +13,15 @@ import tempfile
|
|||
from io import StringIO
|
||||
from lib.config import PLATFORM, get_target_arch, get_env_var, s3_config, \
|
||||
get_zip_name
|
||||
from lib.util import electron_gyp, execute, get_electron_version, \
|
||||
from lib.util import get_electron_branding, execute, get_electron_version, \
|
||||
parse_version, scoped_cwd, s3put
|
||||
|
||||
|
||||
ELECTRON_REPO = 'electron/electron'
|
||||
ELECTRON_VERSION = get_electron_version()
|
||||
|
||||
PROJECT_NAME = electron_gyp()['project_name%']
|
||||
PRODUCT_NAME = electron_gyp()['product_name%']
|
||||
PROJECT_NAME = get_electron_branding()['project_name']
|
||||
PRODUCT_NAME = get_electron_branding()['product_name']
|
||||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
|
||||
|
|
|
@ -5,13 +5,12 @@ import shutil
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
from lib.gn import gn
|
||||
from lib.util import rm_rf
|
||||
|
||||
from lib.util import get_electron_branding, rm_rf
|
||||
|
||||
PROJECT_NAME = get_electron_branding()['project_name']
|
||||
PRODUCT_NAME = get_electron_branding()['product_name']
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
|
@ -19,23 +18,18 @@ def main():
|
|||
initial_app_path = os.path.join(source_root, args.build_dir)
|
||||
app_path = create_app_copy(initial_app_path)
|
||||
|
||||
# Those are the same in the original app and its copy.
|
||||
# So it is ok to get them from the original build dir and use in the copy.
|
||||
product_name = gn(initial_app_path).args().get_string('electron_product_name')
|
||||
project_name = gn(initial_app_path).args().get_string('electron_project_name')
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
electron = os.path.join(app_path, 'Contents', 'MacOS', product_name)
|
||||
electron = os.path.join(app_path, 'Contents', 'MacOS', PRODUCT_NAME)
|
||||
ffmpeg_name = 'libffmpeg.dylib'
|
||||
ffmpeg_app_path = os.path.join(app_path, 'Contents', 'Frameworks',
|
||||
'{0} Framework.framework'.format(product_name),
|
||||
'{0} Framework.framework'.format(PRODUCT_NAME),
|
||||
'Libraries')
|
||||
elif sys.platform == 'win32':
|
||||
electron = os.path.join(app_path, '{0}.exe'.format(project_name))
|
||||
electron = os.path.join(app_path, '{0}.exe'.format(PROJECT_NAME))
|
||||
ffmpeg_app_path = app_path
|
||||
ffmpeg_name = 'ffmpeg.dll'
|
||||
else:
|
||||
electron = os.path.join(app_path, project_name)
|
||||
electron = os.path.join(app_path, PROJECT_NAME)
|
||||
ffmpeg_app_path = app_path
|
||||
ffmpeg_name = 'libffmpeg.so'
|
||||
|
||||
|
@ -65,9 +59,7 @@ def create_app_copy(initial_app_path):
|
|||
+ '-no-proprietary-codecs')
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
product_name = gn(initial_app_path).args().get_string(
|
||||
'electron_product_name')
|
||||
app_name = '{0}.app'.format(product_name)
|
||||
app_name = '{0}.app'.format(PRODUCT_NAME)
|
||||
initial_app_path = os.path.join(initial_app_path, app_name)
|
||||
app_path = os.path.join(app_path, app_name)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue