Move version info to atom.gyp and discard apm dependency

Fixes #1408.
Closes #1359.
This commit is contained in:
Cheng Zhao 2015-04-12 12:45:18 +08:00
parent 6b1dd0d413
commit b9b7928e7d
6 changed files with 35 additions and 37 deletions

View file

@ -2,6 +2,7 @@
'variables': { 'variables': {
'project_name%': 'atom', 'project_name%': 'atom',
'product_name%': 'Atom', 'product_name%': 'Atom',
'version%': '0.22.3',
'atom_source_root': '<!(["python", "tools/atom_source_root.py"])', 'atom_source_root': '<!(["python", "tools/atom_source_root.py"])',
}, },

View file

@ -1,15 +1,7 @@
{ {
"name": "atom-shell", "name": "atom-shell",
"version": "0.22.3",
"licenses": [
{
"type": "MIT",
"url": "http://github.com/atom/atom-shell/raw/master/LICENSE.md"
}
],
"devDependencies": { "devDependencies": {
"asar": "0.2.2", "asar": "0.2.2",
"atom-package-manager": "0.144.0",
"coffee-script": "~1.7.1", "coffee-script": "~1.7.1",
"coffeelint": "~1.3.0", "coffeelint": "~1.3.0",
"request": "*", "request": "*",

View file

@ -6,7 +6,7 @@ import sys
from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, PLATFORM, \ from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, PLATFORM, \
enable_verbose_mode, is_verbose_mode, get_target_arch enable_verbose_mode, is_verbose_mode, get_target_arch
from lib.util import execute_stdout, scoped_cwd from lib.util import execute_stdout, get_atom_shell_version, scoped_cwd
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
@ -32,7 +32,7 @@ def main():
create_chrome_version_h() create_chrome_version_h()
touch_config_gypi() touch_config_gypi()
update_atom_shell() update_atom_shell()
update_atom_modules('spec') update_atom_modules('spec', args.target_arch)
def parse_args(): def parse_args():
@ -82,21 +82,20 @@ def bootstrap_brightray(is_dev, url, target_arch):
execute_stdout([sys.executable, bootstrap] + args) execute_stdout([sys.executable, bootstrap] + args)
def update_node_modules(dirname): def update_node_modules(dirname, env=os.environ):
with scoped_cwd(dirname): with scoped_cwd(dirname):
if is_verbose_mode(): if is_verbose_mode():
execute_stdout([NPM, 'install', '--verbose']) execute_stdout([NPM, 'install', '--verbose'], env)
else: else:
execute_stdout([NPM, 'install']) execute_stdout([NPM, 'install'], env)
def update_atom_modules(dirname): def update_atom_modules(dirname, target_arch):
with scoped_cwd(dirname): env = os.environ.copy()
apm = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'apm') env['npm_config_arch'] = target_arch
if sys.platform in ['win32', 'cygwin']: env['npm_config_target'] = get_atom_shell_version()
apm = os.path.join(SOURCE_ROOT, 'node_modules', 'atom-package-manager', env['npm_config_disturl'] = 'https://atom.io/download/atom-shell'
'bin', 'apm.cmd') update_node_modules(dirname, env)
execute_stdout([apm, 'install'])
def update_win32_python(): def update_win32_python():

View file

@ -27,7 +27,7 @@ def main():
version = '.'.join(versions[:3]) version = '.'.join(versions[:3])
with scoped_cwd(SOURCE_ROOT): with scoped_cwd(SOURCE_ROOT):
update_package_json(version) update_atom_gyp(version)
update_win_rc(version, versions) update_win_rc(version, versions)
update_version_h(versions) update_version_h(versions)
update_info_plist(version) update_info_plist(version)
@ -42,15 +42,15 @@ def increase_version(versions, index):
return versions return versions
def update_package_json(version): def update_atom_gyp(version):
pattern = re.compile(' *"version" *: *"[0-9.]+"') pattern = re.compile(" *'version%' *: *'[0-9.]+'")
with open('package.json', 'r') as f: with open('atom.gyp', 'r') as f:
lines = f.readlines() lines = f.readlines()
for i in range(0, len(lines)): for i in range(0, len(lines)):
if pattern.match(lines[i]): if pattern.match(lines[i]):
lines[i] = ' "version": "{0}",\n'.format(version) lines[i] = " 'version%': '{0}',\n".format(version)
with open('package.json', 'w') as f: with open('atom.gyp', 'w') as f:
f.write(''.join(lines)) f.write(''.join(lines))
return return

View file

@ -4,7 +4,7 @@ import os
import sys import sys
from lib.config import PLATFORM from lib.config import PLATFORM
from lib.util import execute, rm_rf from lib.util import atom_gyp, execute, rm_rf
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
@ -60,10 +60,8 @@ def register_required_dll():
def get_names_from_gyp(): def get_names_from_gyp():
gyp = os.path.join(SOURCE_ROOT, 'atom.gyp') variables = atom_gyp()
with open(gyp) as f: return (variables['project_name%'], variables['product_name%'])
o = eval(f.read());
return (o['variables']['project_name%'], o['variables']['product_name%'])
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -129,11 +129,11 @@ def safe_mkdir(path):
raise raise
def execute(argv): def execute(argv, env=os.environ):
if is_verbose_mode(): if is_verbose_mode():
print ' '.join(argv) print ' '.join(argv)
try: try:
output = subprocess.check_output(argv, stderr=subprocess.STDOUT) output = subprocess.check_output(argv, stderr=subprocess.STDOUT, env=env)
if is_verbose_mode(): if is_verbose_mode():
print output print output
return output return output
@ -142,20 +142,28 @@ def execute(argv):
raise e raise e
def execute_stdout(argv): def execute_stdout(argv, env=os.environ):
if is_verbose_mode(): if is_verbose_mode():
print ' '.join(argv) print ' '.join(argv)
try: try:
subprocess.check_call(argv) subprocess.check_call(argv, env=env)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print e.output print e.output
raise e raise e
else: else:
execute(argv) execute(argv, env)
def atom_gyp():
SOURCE_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
gyp = os.path.join(SOURCE_ROOT, 'atom.gyp')
with open(gyp) as f:
obj = eval(f.read());
return obj['variables']
def get_atom_shell_version(): def get_atom_shell_version():
return subprocess.check_output(['git', 'describe', '--tags']).strip() return atom_gyp()['version%']
def get_chromedriver_version(): def get_chromedriver_version():