diff --git a/.gitignore b/.gitignore index 7eb2ff83c723..062b94e24e53 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ dist/ frameworks/ node/ node_modules/ +out/ vendor/ *.xcodeproj *.swp +*.pyc diff --git a/atom.gyp b/atom.gyp index e7488016a15f..9430bb740f21 100644 --- a/atom.gyp +++ b/atom.gyp @@ -148,11 +148,10 @@ '${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}' ], }, - 'includes': [ - 'vendor/brightray/brightray.gypi' - ], 'target_defaults': { - 'mac_framework_dirs': [ 'frameworks' ], + 'mac_framework_dirs': [ + '<(source_root)/frameworks', + ], }, 'targets': [ { @@ -184,7 +183,9 @@ ], 'xcode_settings': { 'INFOPLIST_FILE': 'browser/mac/Info.plist', - 'LD_RUNPATH_SEARCH_PATHS': '@executable_path/../Frameworks', + 'LD_RUNPATH_SEARCH_PATHS': [ + '@executable_path/../Frameworks', + ], }, 'copies': [ { @@ -263,14 +264,14 @@ 'rule_name': 'coffee', 'extension': 'coffee', 'inputs': [ - 'script/compile-coffee', + 'script/compile-coffee.py', ], 'outputs': [ '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js', ], 'action': [ - 'sh', - 'script/compile-coffee', + 'python', + 'script/compile-coffee.py', '<(RULE_INPUT_PATH)', '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js', ], @@ -309,11 +310,12 @@ '<(libchromiumcontent_resources_dir)/content_shell.pak', ], 'xcode_settings': { - 'LIBRARY_SEARCH_PATHS': '<(libchromiumcontent_library_dir)', + 'LIBRARY_SEARCH_PATHS': [ + '<(libchromiumcontent_library_dir)', + ], 'LD_DYLIB_INSTALL_NAME': '@rpath/<(product_name).framework/<(product_name)', - 'LD_RUNPATH_SEARCH_PATHS': '@loader_path/Libraries', - 'OTHER_LDFLAGS': [ - '-ObjC', + 'LD_RUNPATH_SEARCH_PATHS': [ + '@loader_path/Libraries', ], }, 'copies': [ @@ -350,7 +352,9 @@ 'mac_bundle': 1, 'xcode_settings': { 'INFOPLIST_FILE': 'renderer/mac/Info.plist', - 'LD_RUNPATH_SEARCH_PATHS': '@executable_path/../../..', + 'LD_RUNPATH_SEARCH_PATHS': [ + '@executable_path/../../..', + ], }, 'postbuilds': [ { @@ -362,6 +366,6 @@ ], }, # target helper ], - }], + }], # OS==Mac ], } diff --git a/browser/mac/Info.plist b/browser/mac/Info.plist index 971fd379af0a..7ad4ab7f4b50 100644 --- a/browser/mac/Info.plist +++ b/browser/mac/Info.plist @@ -6,6 +6,8 @@ com.github.atom CFBundleName ${PRODUCT_NAME} + CFBundlePackageType + APPL CFBundleIconFile atom.icns CFBundleVersion diff --git a/common.gypi b/common.gypi new file mode 100644 index 000000000000..9dd0ead9c6fe --- /dev/null +++ b/common.gypi @@ -0,0 +1,42 @@ +{ + 'variables': { + 'clang': 0, + 'source_root': 'com.github.atom.helper CFBundleName ${PRODUCT_NAME} + CFBundlePackageType + APPL LSUIElement diff --git a/script/bootstrap b/script/bootstrap deleted file mode 100755 index 5af504d5c8b1..000000000000 --- a/script/bootstrap +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -#/ Usage: bootstrap https://base.url.com/from/libchromiumcontent/script/upload -#/ Bootstrap this project. - -set -e - -usage() { - grep '^#/' <"$0"| cut -c4- -} - -BASE_URL="${1}" - -if [ -z "${BASE_URL}" ]; then - BASE_URL="https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent" -fi - -cd "$(dirname "$0")/.." -SOURCE_ROOT=$(pwd -P) -VENDOR_DIR="${SOURCE_ROOT}/vendor" -BRIGHTRAY_DIR="${VENDOR_DIR}/brightray" - -git submodule sync --quiet -git submodule update --init --recursive - -npm install npm --silent -./node_modules/.bin/npm install --silent - -"${BRIGHTRAY_DIR}/script/bootstrap" "${BASE_URL}" - -"${SOURCE_ROOT}/script/update" diff --git a/script/bootstrap.py b/script/bootstrap.py new file mode 100755 index 000000000000..73a5492bd36f --- /dev/null +++ b/script/bootstrap.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +import argparse +import errno +import os +import subprocess +import sys + + +SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor') +BASE_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent' + + +def main(): + os.chdir(SOURCE_ROOT) + + args = parse_args() + update_submodules() + update_npm() + bootstrap_brightray(args.url) + update_atom_shell() + + +def parse_args(): + parser = argparse.ArgumentParser(description='Bootstrap this project') + parser.add_argument('--url', + help='The base URL from which to download ' + 'libchromiumcontent (i.e., the URL you passed to ' + 'libchromiumcontent\'s script/upload script', + default=BASE_URL, + required=False) + return parser.parse_args() + + +def update_submodules(): + subprocess.check_call(['git', 'submodule', 'sync', '--quiet']) + subprocess.check_call(['git', 'submodule', 'update', '--init', + '--recursive']) + + +def update_npm(): + subprocess.check_call(['npm', 'install', 'npm', '--silent']) + + npm = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'npm') + subprocess.check_call([npm, 'install', '--silent']) + + +def bootstrap_brightray(url): + bootstrap = os.path.join(VENDOR_DIR, 'brightray', 'script', 'bootstrap') + subprocess.check_call([sys.executable, bootstrap, url]) + + +def update_atom_shell(): + update = os.path.join(SOURCE_ROOT, 'script', 'update.py') + subprocess.check_call([sys.executable, update]) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/build b/script/build deleted file mode 100755 index 06a34af1a18a..000000000000 --- a/script/build +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -MODE=Release -if [ ! -z $1 ]; then - MODE=$1 -fi - -cd "$(dirname "$0")/.." - -xcodebuild -configuration ${MODE} -target atom diff --git a/script/build.py b/script/build.py new file mode 100755 index 000000000000..2403401fd3ab --- /dev/null +++ b/script/build.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import argparse +import os +import subprocess +import sys + + +CONFIGURATIONS = ['Release', 'Debug'] + + +def main(): + args = parse_args() + for config in args.configuration: + build_path = os.path.join('out', config) + subprocess.call(['ninja', '-C', build_path]) + + +def parse_args(): + parser = argparse.ArgumentParser(description='Build atom-shell') + parser.add_argument('-c', '--configuration', + help='Build with Release or Debug configuration', + nargs='+', + default=CONFIGURATIONS, + required=False) + return parser.parse_args() + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/compile-coffee b/script/compile-coffee deleted file mode 100755 index 2c15358c9d78..000000000000 --- a/script/compile-coffee +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -set -e - -# Because of the way xcodebuild invokes external scripts we need to load -# The Setup's environment ourselves. If this isn't done, things like the -# node shim won't be able to find the stuff they need. - -node --version > /dev/null 2>&1 || { - if [ -e /opt/github/env.sh ]; then - source /opt/github/env.sh - else - # Try Constructicon's PATH. - export PATH="/usr/local/Cellar/node/0.8.21/bin:${PATH}" - fi -} - -INPUT_FILE="${1}" -OUTPUT_DIR=`dirname "$2"` - -node_modules/.bin/coffee -c -o "$OUTPUT_DIR" "$INPUT_FILE" diff --git a/script/compile-coffee.py b/script/compile-coffee.py new file mode 100755 index 000000000000..35642c90e544 --- /dev/null +++ b/script/compile-coffee.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import os +import subprocess +import sys + +from lib.util import * + + +SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) + + +def main(): + input_file = sys.argv[1] + output_dir = os.path.dirname(sys.argv[2]) + + node = get_node_path() + coffee = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'coffee') + subprocess.check_call([node, coffee, '-c', '-o', output_dir, input_file]) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/cpplint b/script/cpplint deleted file mode 100755 index ba9ba9e31836..000000000000 --- a/script/cpplint +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -cd "`dirname $0`/.." - -# List all Objective-C headers here, should not cpplint them. -OBJC_HEADERS=' -browser/atom_event_processing_window.h -browser/atom_application_mac.h -browser/atom_application_delegate_mac.h -browser/native_window_mac.h -browser/nsalert_synchronous_sheet.h -common/api/api_messages.cc -common/api/api_messages.h' - -FILES=`find app browser common renderer -type f -name '*.h' -or -name '*.cc'` -FILTERED_FILES= - -while read file; do - if ! echo "$OBJC_HEADERS" | grep "$file" > /dev/null ; then - FILTERED_FILES="$FILTERED_FILES $file" - fi -done <<< "$FILES" - -python ./vendor/cpplint.py \ - --filter=-build/header_guard,-build/include_what_you_use \ - $FILTERED_FILES diff --git a/script/cpplint.py b/script/cpplint.py new file mode 100755 index 000000000000..9ebf5e64f9dd --- /dev/null +++ b/script/cpplint.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import fnmatch +import os +import subprocess +import sys + +OBJC_HEADERS = [ + 'browser/atom_event_processing_window.h', + 'browser/atom_application_mac.h', + 'browser/atom_application_delegate_mac.h', + 'browser/native_window_mac.h', + 'browser/nsalert_synchronous_sheet.h', + 'common/api/api_messages.cc', + 'common/api/api_messages.h', +] + +SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) + + +def main(): + os.chdir(SOURCE_ROOT) + files = list_files(['app', 'browser', 'common', 'renderer'], + ['*.cc', '*.h']) + call_cpplint(list(set(files) - set(OBJC_HEADERS))) + + +def list_files(directories, filters): + matches = [] + for directory in directories: + for root, dirs, filenames, in os.walk(directory): + for f in filters: + for filename in fnmatch.filter(filenames, f): + matches.append(os.path.join(root, filename)) + return matches + + +def call_cpplint(files): + cpplint = os.path.join(SOURCE_ROOT, 'vendor', 'cpplint.py') + rules = '--filter=-build/header_guard,-build/include_what_you_use' + subprocess.call([sys.executable, cpplint, rules] + files) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/create-dist b/script/create-dist deleted file mode 100755 index 975833aff36f..000000000000 --- a/script/create-dist +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python - -import errno -import os -import shutil -import subprocess - - -SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) -DIST_DIR = os.path.join(SOURCE_ROOT, 'dist') -BUNDLE_NAME = 'Atom.app' -BUNDLE_DIR = os.path.join(SOURCE_ROOT, 'build', 'Release', BUNDLE_NAME) - - -def main(): - rm_rf(DIST_DIR) - os.makedirs(DIST_DIR) - - copy_binaries() - create_zip() - - -def copy_binaries(): - shutil.copytree(BUNDLE_DIR, os.path.join(DIST_DIR, BUNDLE_NAME), symlinks=True) - - -def create_zip(): - print "Zipping distribution..." - zip_file = os.path.join(SOURCE_ROOT, 'atom-shell.zip') - safe_unlink(zip_file) - - cwd = os.getcwd() - os.chdir(DIST_DIR) - subprocess.check_call(['zip', '-r', '-y', zip_file, 'Atom.app']) - os.chdir(cwd) - - -def rm_rf(path): - try: - shutil.rmtree(path) - except OSError as e: - if e.errno != errno.ENOENT: - raise - - -def safe_unlink(path): - try: - os.unlink(path) - except OSError as e: - if e.errno != errno.ENOENT: - raise - - -if __name__ == '__main__': - import sys - sys.exit(main()) diff --git a/script/create-dist.py b/script/create-dist.py new file mode 100755 index 000000000000..af9f47ea4492 --- /dev/null +++ b/script/create-dist.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +import errno +import os +import shutil +import subprocess +import sys + +from lib.util import * + + +SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +DIST_DIR = os.path.join(SOURCE_ROOT, 'dist') +BUNDLE_NAME = 'Atom.app' +BUNDLE_DIR = os.path.join(SOURCE_ROOT, 'out', 'Release', BUNDLE_NAME) + + +def main(): + rm_rf(DIST_DIR) + os.makedirs(DIST_DIR) + + copy_binaries() + create_zip() + + +def copy_binaries(): + shutil.copytree(BUNDLE_DIR, os.path.join(DIST_DIR, BUNDLE_NAME), + symlinks=True) + + +def create_zip(): + print "Zipping distribution..." + zip_file = os.path.join(SOURCE_ROOT, 'atom-shell.zip') + safe_unlink(zip_file) + + cwd = os.getcwd() + os.chdir(DIST_DIR) + subprocess.check_call(['zip', '-r', '-y', zip_file, 'Atom.app']) + os.chdir(cwd) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/download b/script/download deleted file mode 100755 index 8a53163d7ffa..000000000000 --- a/script/download +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python - -import argparse -import contextlib -import errno -import os -import shutil -import subprocess -import sys -import tempfile -import urllib2 -import zipfile - - -SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) - - -class ProgramError(Exception): - pass - - -def main(): - try: - args = parse_args() - commit = head_commit() - download_if_needed(args.path, args.url, commit, force=args.force) - except ProgramError as e: - return e.message - - -def parse_args(): - parser = argparse.ArgumentParser(description='Download and extract ' - 'atom-shell') - parser.add_argument('-f', '--force', action='store_true', - help='Overwrite destination if it already exists.') - parser.add_argument('url', help='The base URL from which to download ' - '(i.e., the URL you passed to script/upload)') - parser.add_argument('path', help='The path to extract to') - return parser.parse_args() - - -def head_commit(): - args = [ - 'git', - '--git-dir', - os.path.join(SOURCE_ROOT, '.git'), - 'rev-parse', - 'HEAD', - ] - return subprocess.check_output(args).strip() - - -def download_if_needed(destination, base_url, commit, force): - version_file = os.path.join(destination, '.version') - existing_version = '' - try: - with open(version_file, 'r') as f: - existing_version = f.readline().strip() - except IOError as e: - if e.errno != errno.ENOENT: - raise - if existing_version == commit: - return - - if force: - rm_rf(destination) - elif os.path.exists(destination): - raise ProgramError('Error: {0} already exists. Pass --force if you ' - 'want to overwrite it.'.format(destination)) - sys.stderr.write('Downloading atom-shell {0}...\n'.format(commit)) - sys.stderr.flush() - download_and_extract(destination, '{0}/{1}/atom-shell.zip'.format(base_url, commit)) - with open(version_file, 'w') as f: - f.write('{0}\n'.format(commit)) - - -def download_and_extract(destination, url): - print url - with tempfile.TemporaryFile() as t: - with contextlib.closing(urllib2.urlopen(url)) as u: - while True: - chunk = u.read(1024*1024) - if not len(chunk): - break - sys.stderr.write('.') - sys.stderr.flush() - t.write(chunk) - sys.stderr.write('\nExtracting...\n') - sys.stderr.flush() - with zipfile.ZipFile(t) as z: - z.extractall(destination) - - -def rm_rf(path): - try: - shutil.rmtree(path) - except OSError as e: - if e.errno != errno.ENOENT: - raise - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/script/lib/__init__.py b/script/lib/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/script/lib/util.py b/script/lib/util.py new file mode 100644 index 000000000000..acbaca30288b --- /dev/null +++ b/script/lib/util.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +import atexit +import errno +import shutil +import subprocess +import sys +import tarfile +import tempfile +import urllib2 +import os +import zipfile + + +def tempdir(prefix=''): + directory = tempfile.mkdtemp(prefix=prefix) + atexit.register(shutil.rmtree, directory) + return directory + + +def download(text, url, path): + with open(path, 'w') as local_file: + web_file = urllib2.urlopen(url) + file_size = int(web_file.info().getheaders("Content-Length")[0]) + downloaded_size = 0 + block_size = 128 + + while True: + buf = web_file.read(block_size) + if not buf: + break + + downloaded_size += len(buf) + local_file.write(buf) + + percent = downloaded_size * 100. / file_size + status = "\r%s %10d [%3.1f%%]" % (text, downloaded_size, percent) + print status, + + print + + +def extract_tarball(tarball_path, member, destination): + with tarfile.open(tarball_path) as tarball: + tarball.extract(member, destination) + + +def extract_zip(zip_path, destination): + if sys.platform == 'darwin': + # Use unzip command on Mac to keep symbol links in zip file work. + subprocess.check_call(['unzip', zip_path, '-d', destination]) + else: + with zipfile.ZipFile(zip_path) as z: + z.extractall(destination) + + +def rm_rf(path): + try: + shutil.rmtree(path) + except OSError as e: + if e.errno != errno.ENOENT: + raise + + +def safe_unlink(path): + try: + os.unlink(path) + except OSError as e: + if e.errno != errno.ENOENT: + raise + + +def safe_mkdir(path): + try: + os.makedirs(path) + except OSError as e: + if e.errno != errno.EEXIST: + raise + + +def get_node_path(): + node = os.path.join(os.path.dirname(__file__), '..', '..', 'node', 'node') + if sys.platform == 'win32' or sys.platform == 'cygwin': + node += '.exe' + return node diff --git a/script/update b/script/update deleted file mode 100755 index 4688600e2e05..000000000000 --- a/script/update +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e - -cd "$(dirname "$0")/.." - -./script/update-frameworks -./script/update-node v0.10.12 - -gyp --depth . atom.gyp \ - -Ivendor/brightray/brightray.gypi \ - -Dtarget_arch=ia32 \ - -Dlibrary=static_library diff --git a/script/update-frameworks b/script/update-frameworks deleted file mode 100755 index 38656af8e99f..000000000000 --- a/script/update-frameworks +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -cd "$(dirname $0)/.." - -. script/lib/polite-curl - -[ -d frameworks ] || mkdir frameworks -cd frameworks - -FRAMEWORKS_URL='https://gh-contractor-zcbenz.s3.amazonaws.com/frameworks' - -trap 'rm -f *.zip' EXIT - -function download_and_unzip() { - if ! [ -d $1.framework ]; then - echo "Downloading $1..." - polite_curl "$FRAMEWORKS_URL/$1.framework.zip" > $1.framework.zip - unzip $1.framework.zip - fi -} - -download_and_unzip Quincy -download_and_unzip Sparkle diff --git a/script/update-frameworks.py b/script/update-frameworks.py new file mode 100755 index 000000000000..55f2fc955712 --- /dev/null +++ b/script/update-frameworks.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +import sys +import os + +from lib.util import * + + +SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) +FRAMEWORKS_URL='https://gh-contractor-zcbenz.s3.amazonaws.com/frameworks' + + +def main(): + os.chdir(SOURCE_ROOT) + safe_mkdir('frameworks') + download_and_unzip('Quincy') + download_and_unzip('Sparkle') + + +def download_and_unzip(framework): + zip_path = download_framework(framework) + if zip_path: + extract_zip(zip_path, 'frameworks') + + +def download_framework(framework): + framework_path = os.path.join('frameworks', framework) + '.framework' + if os.path.exists(framework_path): + return + + filename = framework + '.framework.zip' + url = FRAMEWORKS_URL + '/' + filename + download_dir = tempdir(prefix='atom-shell-') + path = os.path.join(download_dir, filename) + + download('Download ' + framework, url, path) + return path + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/update-node b/script/update-node deleted file mode 100755 index 54edd321ce82..000000000000 --- a/script/update-node +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -set -e - -cd "$(dirname $0)/.." - -NODE_VERSION=v0.10.5 -[ -z $1 ] || NODE_VERSION=$1 - -# Test whether we need update. -if [ -f "node/node" ] && [[ `node/node --version` == $NODE_VERSION ]] ; then - exit 0 -fi - -case $OSTYPE in - darwin*) NODE_PLATFORM=darwin ;; - linux*) NODE_PLATFORM=linux ;; - *) echo "Unsupported platform $OSTYPE" && exit 1 ;; -esac - -NODE_DIST_NAME="node-$NODE_VERSION-$NODE_PLATFORM-x86" - -# Download node and untar -NODE_TARBALL_URL="https://gh-contractor-zcbenz.s3.amazonaws.com/node/dist/$NODE_DIST_NAME.tar.gz" -TARGET_DIR='node' -[ -d "$TARGET_DIR" ] || mkdir "$TARGET_DIR" -cd "$TARGET_DIR" -curl -fsSkL $NODE_TARBALL_URL | tar -zx || exit 1 - -cp "$NODE_DIST_NAME/bin/node" . -rm -rf "$NODE_DIST_NAME" diff --git a/script/update-node.py b/script/update-node.py new file mode 100755 index 000000000000..caadb3c8ff8c --- /dev/null +++ b/script/update-node.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python + +import argparse +import errno +import subprocess +import sys +import os + +from lib.util import * + + +SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) +NODE_VERSION = 'v0.10.9' +NODE_DIST_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/node/dist' +IS_POSIX = (sys.platform != 'win32') and (sys.platform != 'cygwin') + + +def main(): + os.chdir(SOURCE_ROOT) + + args = parse_args() + if not node_needs_update(args.version): + return 0 + + url, filename = get_node_url(args.url, args.version) + directory = tempdir(prefix='atom-shell-') + path = os.path.join(directory, filename) + download('Download node', url, path) + + if IS_POSIX: + root_name = 'node-{0}-{1}-x86'.format(args.version, sys.platform) + member = os.path.join(root_name, 'bin', 'node') + extract_tarball(path, member, directory) + node_path = os.path.join(directory, member) + + copy_node(node_path) + + +def parse_args(): + parser = argparse.ArgumentParser(description='Update node binary') + parser.add_argument('--version', + help='Version of node', + default=NODE_VERSION, + required=False) + parser.add_argument('--url', + help='URL to download node', + default=NODE_DIST_URL, + required=False) + return parser.parse_args() + + +def node_needs_update(target_version): + try: + node = os.path.join('node', 'node') + if not IS_POSIX: + node += '.exe' + version = subprocess.check_output([node, '--version']) + return version.strip() != target_version + except OSError as e: + if e.errno != errno.ENOENT: + raise + return True + + +def get_node_url(base_url, target_version): + if IS_POSIX: + distname = 'node-{0}-{1}-x86.tar.gz'.format(target_version, sys.platform) + else: + distname = 'node-{0}.exe'.format(target_version) + return '{0}/{1}'.format(base_url, distname), distname + + +def copy_node(node_path): + safe_mkdir('node') + node = os.path.join('node', 'node') + safe_unlink(node) + os.rename(node_path, node) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/update.py b/script/update.py new file mode 100755 index 000000000000..790c58adcf68 --- /dev/null +++ b/script/update.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import subprocess +import sys + +from lib.util import * + + +SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) +NODE_VERSION = 'v0.10.12' + + +def main(): + os.chdir(SOURCE_ROOT) + + update_frameworks_and_node(NODE_VERSION) + update_gyp() + + +def update_frameworks_and_node(version): + uf = os.path.join(SOURCE_ROOT, 'script', 'update-frameworks.py') + un = os.path.join(SOURCE_ROOT, 'script', 'update-node.py') + subprocess.check_call([sys.executable, uf]) + subprocess.check_call([sys.executable, un, '--version', version]) + + +def update_gyp(): + subprocess.check_call(['gyp', '-f', 'ninja', '--depth', '.', 'atom.gyp', + '-Icommon.gypi', '-Ivendor/brightray/brightray.gypi', + '-Dtarget_arch=ia32', '-Dlibrary=static_library']) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/upload b/script/upload deleted file mode 100755 index f9bb20b097a2..000000000000 --- a/script/upload +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python - -import errno -import glob -import os -import subprocess -import tempfile - - -SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) - - -def main(): - try: - ensure_s3put() - upload() - except AssertionError as e: - return e.message - - -def ensure_s3put(): - output = '' - try: - output = subprocess.check_output(['s3put', '--help']) - except OSError as e: - if e.errno != errno.ENOENT: - raise - assert 'multipart' in output, 'Error: Please install boto and filechunkio' - - -def upload(): - os.chdir(SOURCE_ROOT) - bucket, access_key, secret_key = s3_config() - commit = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip() - - s3put(bucket, access_key, secret_key, 'atom-shell/{0}'.format(commit), glob.glob('atom-shell*.zip')) - - update_version(bucket, access_key, secret_key, commit) - - -def s3_config(): - config = (os.environ.get('ATOM_SHELL_S3_BUCKET', ''), - os.environ.get('ATOM_SHELL_S3_ACCESS_KEY', ''), - os.environ.get('ATOM_SHELL_S3_SECRET_KEY', '')) - message = ('Error: Please set the $ATOM_SHELL_S3_BUCKET, ' - '$ATOM_SHELL_S3_ACCESS_KEY, and ' - '$ATOM_SHELL_S3_SECRET_KEY environment variables') - assert all(len(c) for c in config), message - return config - - -def update_version(bucket, access_key, secret_key, commit): - version_path = os.path.join(SOURCE_ROOT, 'version') - with open(version_path, 'w') as version_file: - version_file.write(commit) - - # Upload after file is closed, it's required under Windows. - s3put(bucket, access_key, secret_key, 'atom-shell', [ version_path ]) - - -def s3put(bucket, access_key, secret_key, key_prefix, files): - args = [ - 's3put', - '--bucket', bucket, - '--access_key', access_key, - '--secret_key', secret_key, - '--prefix', SOURCE_ROOT, - '--key_prefix', key_prefix, - '--grant', 'public-read' - ] + files - - subprocess.check_call(args) - - -if __name__ == '__main__': - import sys - sys.exit(main()) diff --git a/script/upload.py b/script/upload.py new file mode 100755 index 000000000000..a73f8de454de --- /dev/null +++ b/script/upload.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +import errno +import glob +import os +import subprocess +import tempfile + + +SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + + +def main(): + try: + ensure_s3put() + upload() + except AssertionError as e: + return e.message + + +def ensure_s3put(): + output = '' + try: + output = subprocess.check_output(['s3put', '--help']) + except OSError as e: + if e.errno != errno.ENOENT: + raise + assert 'multipart' in output, 'Error: Please install boto and filechunkio' + + +def upload(): + os.chdir(SOURCE_ROOT) + bucket, access_key, secret_key = s3_config() + commit = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip() + + s3put(bucket, access_key, secret_key, 'atom-shell/{0}'.format(commit), glob.glob('atom-shell*.zip')) + + update_version(bucket, access_key, secret_key, commit) + + +def s3_config(): + config = (os.environ.get('ATOM_SHELL_S3_BUCKET', ''), + os.environ.get('ATOM_SHELL_S3_ACCESS_KEY', ''), + os.environ.get('ATOM_SHELL_S3_SECRET_KEY', '')) + message = ('Error: Please set the $ATOM_SHELL_S3_BUCKET, ' + '$ATOM_SHELL_S3_ACCESS_KEY, and ' + '$ATOM_SHELL_S3_SECRET_KEY environment variables') + assert all(len(c) for c in config), message + return config + + +def update_version(bucket, access_key, secret_key, commit): + version_path = os.path.join(SOURCE_ROOT, 'version') + with open(version_path, 'w') as version_file: + version_file.write(commit) + + # Upload after file is closed, it's required under Windows. + s3put(bucket, access_key, secret_key, 'atom-shell', [ version_path ]) + + +def s3put(bucket, access_key, secret_key, key_prefix, files): + args = [ + 's3put', + '--bucket', bucket, + '--access_key', access_key, + '--secret_key', secret_key, + '--prefix', SOURCE_ROOT, + '--key_prefix', key_prefix, + '--grant', 'public-read' + ] + files + + subprocess.check_call(args) + + +if __name__ == '__main__': + import sys + sys.exit(main()) diff --git a/tools/mac/find_sdk.py b/tools/mac/find_sdk.py new file mode 100755 index 000000000000..067be638d21c --- /dev/null +++ b/tools/mac/find_sdk.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import re +import subprocess +import sys + +"""Prints the lowest locally available SDK version greater than or equal to a +given minimum sdk version to standard output. + +Usage: + python find_sdk.py 10.6 # Ignores SDKs < 10.6 +""" + +from optparse import OptionParser + + +def parse_version(version_str): + """'10.6' => [10, 6]""" + return map(int, re.findall(r'(\d+)', version_str)) + + +def main(): + parser = OptionParser() + parser.add_option("--verify", + action="store_true", dest="verify", default=False, + help="return the sdk argument and warn if it doesn't exist") + parser.add_option("--sdk_path", + action="store", type="string", dest="sdk_path", default="", + help="user-specified SDK path; bypasses verification") + (options, args) = parser.parse_args() + min_sdk_version = args[0] + + job = subprocess.Popen(['xcode-select', '-print-path'], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + out, err = job.communicate() + if job.returncode != 0: + print >>sys.stderr, out + print >>sys.stderr, err + raise Exception(('Error %d running xcode-select, you might have to run ' + '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| ' + 'if you are using Xcode 4.') % job.returncode) + # The Developer folder moved in Xcode 4.3. + xcode43_sdk_path = os.path.join( + out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs') + if os.path.isdir(xcode43_sdk_path): + sdk_dir = xcode43_sdk_path + else: + sdk_dir = os.path.join(out.rstrip(), 'SDKs') + sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)] + sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6'] + sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6'] + if parse_version(s) >= parse_version(min_sdk_version)] + if not sdks: + raise Exception('No %s+ SDK found' % min_sdk_version) + best_sdk = sorted(sdks, key=parse_version)[0] + + if options.verify and best_sdk != min_sdk_version and not options.sdk_path: + print >>sys.stderr, '' + print >>sys.stderr, ' vvvvvvv' + print >>sys.stderr, '' + print >>sys.stderr, \ + 'This build requires the %s SDK, but it was not found on your system.' \ + % min_sdk_version + print >>sys.stderr, \ + 'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.' + print >>sys.stderr, '' + print >>sys.stderr, ' ^^^^^^^' + print >>sys.stderr, '' + return min_sdk_version + + return best_sdk + + +if __name__ == '__main__': + if sys.platform != 'darwin': + raise Exception("This script only runs on Mac") + print main() diff --git a/tools/mac/source_root.py b/tools/mac/source_root.py new file mode 100755 index 000000000000..73ac5eb0c493 --- /dev/null +++ b/tools/mac/source_root.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +import os + +"""Prints the absolute path of the root of atom-shell's source tree. +""" + + +relative_source_root = os.path.join(__file__, '..', '..', '..') +print os.path.abspath(relative_source_root) diff --git a/vendor/brightray b/vendor/brightray index 1143359bed70..6d893b1f5001 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 1143359bed70f5c2d4f6fc998a1d8cedb7ecff87 +Subproject commit 6d893b1f5001c94d1ace0bc3d976f6e83a922e81