commit
3a609e9133
29 changed files with 678 additions and 407 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,6 +6,8 @@ dist/
|
|||
frameworks/
|
||||
node/
|
||||
node_modules/
|
||||
out/
|
||||
vendor/
|
||||
*.xcodeproj
|
||||
*.swp
|
||||
*.pyc
|
||||
|
|
32
atom.gyp
32
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
|
||||
],
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
<string>com.github.atom</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>atom.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
|
42
common.gypi
Normal file
42
common.gypi
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
'variables': {
|
||||
'clang': 0,
|
||||
'source_root': '<!(python tools/mac/source_root.py)',
|
||||
'conditions': [
|
||||
['OS=="mac"', {
|
||||
'clang': 1,
|
||||
'mac_sdk%': '<!(python tools/mac/find_sdk.py 10.8)',
|
||||
}],
|
||||
],
|
||||
},
|
||||
'conditions': [
|
||||
['clang==1', {
|
||||
'make_global_settings': [
|
||||
['CC', '/usr/bin/clang'],
|
||||
['CXX', '/usr/bin/clang++'],
|
||||
['LINK', '$(CXX)'],
|
||||
['CC.host', '$(CC)'],
|
||||
['CXX.host', '$(CXX)'],
|
||||
['LINK.host', '$(LINK)'],
|
||||
],
|
||||
'target_defaults': {
|
||||
'cflags_cc': [
|
||||
'-std=c++11',
|
||||
],
|
||||
'xcode_settings': {
|
||||
'CC': '/usr/bin/clang',
|
||||
'LDPLUSPLUS': '/usr/bin/clang++',
|
||||
'OTHER_CPLUSPLUSFLAGS': [
|
||||
'$(inherited)', '-std=gnu++11'
|
||||
],
|
||||
'OTHER_CFLAGS': [
|
||||
'-fcolor-diagnostics',
|
||||
],
|
||||
|
||||
'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
|
||||
'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
|
||||
},
|
||||
},
|
||||
}], # clang==1
|
||||
],
|
||||
}
|
|
@ -6,6 +6,8 @@
|
|||
<string>com.github.atom.helper</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>LSUIElement</key>
|
||||
<true/>
|
||||
</dict>
|
||||
|
|
|
@ -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"
|
60
script/bootstrap.py
Executable file
60
script/bootstrap.py
Executable file
|
@ -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())
|
12
script/build
12
script/build
|
@ -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
|
30
script/build.py
Executable file
30
script/build.py
Executable file
|
@ -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())
|
|
@ -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"
|
23
script/compile-coffee.py
Executable file
23
script/compile-coffee.py
Executable file
|
@ -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())
|
|
@ -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
|
45
script/cpplint.py
vendored
Executable file
45
script/cpplint.py
vendored
Executable file
|
@ -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())
|
|
@ -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())
|
43
script/create-dist.py
Executable file
43
script/create-dist.py
Executable file
|
@ -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())
|
103
script/download
103
script/download
|
@ -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())
|
0
script/lib/__init__.py
Normal file
0
script/lib/__init__.py
Normal file
85
script/lib/util.py
Normal file
85
script/lib/util.py
Normal file
|
@ -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
|
|
@ -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
|
|
@ -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
|
41
script/update-frameworks.py
Executable file
41
script/update-frameworks.py
Executable file
|
@ -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())
|
|
@ -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"
|
81
script/update-node.py
Executable file
81
script/update-node.py
Executable file
|
@ -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())
|
34
script/update.py
Executable file
34
script/update.py
Executable file
|
@ -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())
|
|
@ -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())
|
77
script/upload.py
Executable file
77
script/upload.py
Executable file
|
@ -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())
|
82
tools/mac/find_sdk.py
Executable file
82
tools/mac/find_sdk.py
Executable file
|
@ -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()
|
10
tools/mac/source_root.py
Executable file
10
tools/mac/source_root.py
Executable file
|
@ -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)
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 1143359bed70f5c2d4f6fc998a1d8cedb7ecff87
|
||||
Subproject commit 6d893b1f5001c94d1ace0bc3d976f6e83a922e81
|
Loading…
Reference in a new issue