Move version info to atom.gyp and discard apm dependency
Fixes #1408. Closes #1359.
This commit is contained in:
		
					parent
					
						
							
								6b1dd0d413
							
						
					
				
			
			
				commit
				
					
						b9b7928e7d
					
				
			
		
					 6 changed files with 35 additions and 37 deletions
				
			
		
							
								
								
									
										1
									
								
								atom.gyp
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								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"])',
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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": "*",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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():
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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__':
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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():
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue