]> khamidou — GitHub mirrors - electron.git/commitdiff
Move version info to atom.gyp and discard apm dependency
authorCheng Zhao <zcbenz@gmail.com>
Sun, 12 Apr 2015 04:45:18 +0000 (12:45 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 12 Apr 2015 04:45:18 +0000 (12:45 +0800)
Fixes #1408.
Closes #1359.

atom.gyp
package.json
script/bootstrap.py
script/bump-version.py
script/dump-symbols.py
script/lib/util.py

index 5f54b0f3ca7163cb8ac8be98b8143ba13dfa370e..a05ff617e53b341018b44da0ae04482fa4fb9034 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
@@ -2,6 +2,7 @@
   'variables': {
     'project_name%': 'atom',
     'product_name%': 'Atom',
+    'version%': '0.22.3',
 
     'atom_source_root': '<!(["python", "tools/atom_source_root.py"])',
   },
index ed02691ff67bbcf061cd06373c6bd6f437edb655..e3017e0f108cabd8e887c743af895c90bfad45d9 100644 (file)
@@ -1,15 +1,7 @@
 {
   "name": "atom-shell",
-  "version": "0.22.3",
-  "licenses": [
-    {
-      "type": "MIT",
-      "url": "http://github.com/atom/atom-shell/raw/master/LICENSE.md"
-    }
-  ],
   "devDependencies": {
     "asar": "0.2.2",
-    "atom-package-manager": "0.144.0",
     "coffee-script": "~1.7.1",
     "coffeelint": "~1.3.0",
     "request": "*",
index 4ca7526b7c6d9cfa9b361dd229aed92c84031da8..2870e75ac11d891c9744faa7716215c1a9288c4d 100755 (executable)
@@ -6,7 +6,7 @@ import sys
 
 from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, PLATFORM, \
                        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__)))
@@ -32,7 +32,7 @@ def main():
   create_chrome_version_h()
   touch_config_gypi()
   update_atom_shell()
-  update_atom_modules('spec')
+  update_atom_modules('spec', args.target_arch)
 
 
 def parse_args():
@@ -82,21 +82,20 @@ def bootstrap_brightray(is_dev, url, target_arch):
   execute_stdout([sys.executable, bootstrap] + args)
 
 
-def update_node_modules(dirname):
+def update_node_modules(dirname, env=os.environ):
   with scoped_cwd(dirname):
     if is_verbose_mode():
-      execute_stdout([NPM, 'install', '--verbose'])
+      execute_stdout([NPM, 'install', '--verbose'], env)
     else:
-      execute_stdout([NPM, 'install'])
+      execute_stdout([NPM, 'install'], env)
 
 
-def update_atom_modules(dirname):
-  with scoped_cwd(dirname):
-    apm = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'apm')
-    if sys.platform in ['win32', 'cygwin']:
-      apm = os.path.join(SOURCE_ROOT, 'node_modules', 'atom-package-manager',
-                         'bin', 'apm.cmd')
-    execute_stdout([apm, 'install'])
+def update_atom_modules(dirname, target_arch):
+  env = os.environ.copy()
+  env['npm_config_arch']    = target_arch
+  env['npm_config_target']  = get_atom_shell_version()
+  env['npm_config_disturl'] = 'https://atom.io/download/atom-shell'
+  update_node_modules(dirname, env)
 
 
 def update_win32_python():
index 187f67e30b7b7e87ae294cec1291f7b007487a7b..c256fd4228d21efa744dd01103ec8fdda20aab3c 100755 (executable)
@@ -27,7 +27,7 @@ def main():
   version = '.'.join(versions[:3])
 
   with scoped_cwd(SOURCE_ROOT):
-    update_package_json(version)
+    update_atom_gyp(version)
     update_win_rc(version, versions)
     update_version_h(versions)
     update_info_plist(version)
@@ -42,15 +42,15 @@ def increase_version(versions, index):
   return versions
 
 
-def update_package_json(version):
-  pattern = re.compile(' *"version" *: *"[0-9.]+"')
-  with open('package.json', 'r') as f:
+def update_atom_gyp(version):
+  pattern = re.compile(" *'version%' *: *'[0-9.]+'")
+  with open('atom.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)
-      with open('package.json', 'w') as f:
+      lines[i] = "    'version%': '{0}',\n".format(version)
+      with open('atom.gyp', 'w') as f:
         f.write(''.join(lines))
       return
 
index ccad30227bae081ad740d6f2e541ca1400a9286b..b69754548fb17565334e13691f6f895ddc9b1270 100755 (executable)
@@ -4,7 +4,7 @@ import os
 import sys
 
 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__)))
@@ -60,10 +60,8 @@ def register_required_dll():
 
 
 def get_names_from_gyp():
-  gyp = os.path.join(SOURCE_ROOT, 'atom.gyp')
-  with open(gyp) as f:
-    o = eval(f.read());
-    return (o['variables']['project_name%'], o['variables']['product_name%'])
+  variables = atom_gyp()
+  return (variables['project_name%'], variables['product_name%'])
 
 
 if __name__ == '__main__':
index 88641589859137ce00fbf8b977e7891bf7410c40..0099c6e4307549b630fecc2b6976fdbe3f693051 100644 (file)
@@ -129,11 +129,11 @@ def safe_mkdir(path):
       raise
 
 
-def execute(argv):
+def execute(argv, env=os.environ):
   if is_verbose_mode():
     print ' '.join(argv)
   try:
-    output = subprocess.check_output(argv, stderr=subprocess.STDOUT)
+    output = subprocess.check_output(argv, stderr=subprocess.STDOUT, env=env)
     if is_verbose_mode():
       print output
     return output
@@ -142,20 +142,28 @@ def execute(argv):
     raise e
 
 
-def execute_stdout(argv):
+def execute_stdout(argv, env=os.environ):
   if is_verbose_mode():
     print ' '.join(argv)
     try:
-      subprocess.check_call(argv)
+      subprocess.check_call(argv, env=env)
     except subprocess.CalledProcessError as e:
       print e.output
       raise e
   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():
-  return subprocess.check_output(['git', 'describe', '--tags']).strip()
+  return atom_gyp()['version%']
 
 
 def get_chromedriver_version():