Merge branch 'master' into chrome39

Conflicts:
	vendor/brightray
This commit is contained in:
Cheng Zhao 2014-12-09 15:49:06 -08:00
commit da3a988c8c
11 changed files with 80 additions and 66 deletions

View file

@ -60,7 +60,6 @@
'atom/app/atom_content_client.h', 'atom/app/atom_content_client.h',
'atom/app/atom_main_delegate.cc', 'atom/app/atom_main_delegate.cc',
'atom/app/atom_main_delegate.h', 'atom/app/atom_main_delegate.h',
'atom/app/atom_main_delegate_mac.mm',
'atom/browser/api/atom_api_app.cc', 'atom/browser/api/atom_api_app.cc',
'atom/browser/api/atom_api_app.h', 'atom/browser/api/atom_api_app.h',
'atom/browser/api/atom_api_auto_updater.cc', 'atom/browser/api/atom_api_auto_updater.cc',

View file

@ -26,10 +26,6 @@ class AtomMainDelegate : public brightray::MainDelegate {
scoped_ptr<brightray::ContentClient> CreateContentClient() override; scoped_ptr<brightray::ContentClient> CreateContentClient() override;
void AddDataPackFromPath( void AddDataPackFromPath(
ui::ResourceBundle* bundle, const base::FilePath& pak_dir) override; ui::ResourceBundle* bundle, const base::FilePath& pak_dir) override;
#if defined(OS_MACOSX)
void OverrideChildProcessPath() override;
void OverrideFrameworkBundlePath() override;
#endif
private: private:
brightray::ContentClient content_client_; brightray::ContentClient content_client_;

View file

@ -1,37 +0,0 @@
// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/app/atom_main_delegate.h"
#include "base/mac/bundle_locations.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "brightray/common/mac/main_application_bundle.h"
#include "content/public/common/content_paths.h"
namespace atom {
namespace {
base::FilePath GetFrameworksPath() {
return brightray::MainApplicationBundlePath().Append("Contents")
.Append("Frameworks");
}
} // namespace
void AtomMainDelegate::OverrideFrameworkBundlePath() {
base::mac::SetOverrideFrameworkBundlePath(
GetFrameworksPath().Append("Atom Framework.framework"));
}
void AtomMainDelegate::OverrideChildProcessPath() {
base::FilePath helper_path = GetFrameworksPath().Append("Atom Helper.app")
.Append("Contents")
.Append("MacOS")
.Append("Atom Helper");
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
}
} // namespace atom

View file

@ -13,6 +13,11 @@
namespace atom { namespace atom {
std::string GetApplicationName() {
std::string name = brightray::MainApplicationBundlePath().BaseName().AsUTF8Unsafe();
return name.substr(0, name.length() - 4/*.app*/);
}
void AtomBrowserMainParts::PreMainMessageLoopStart() { void AtomBrowserMainParts::PreMainMessageLoopStart() {
// Initialize locale setting. // Initialize locale setting.
l10n_util::OverrideLocaleWithCocoaLocale(); l10n_util::OverrideLocaleWithCocoaLocale();
@ -26,7 +31,7 @@ void AtomBrowserMainParts::PreMainMessageLoopStart() {
base::FilePath frameworkPath = brightray::MainApplicationBundlePath() base::FilePath frameworkPath = brightray::MainApplicationBundlePath()
.Append("Contents") .Append("Contents")
.Append("Frameworks") .Append("Frameworks")
.Append("Atom Framework.framework"); .Append(GetApplicationName() + " Framework.framework");
NSBundle* frameworkBundle = [NSBundle NSBundle* frameworkBundle = [NSBundle
bundleWithPath:base::mac::FilePathToNSString(frameworkPath)]; bundleWithPath:base::mac::FilePathToNSString(frameworkPath)];
NSNib* mainNib = [[NSNib alloc] initWithNibNamed:@"MainMenu" NSNib* mainNib = [[NSNib alloc] initWithNibNamed:@"MainMenu"

View file

@ -38,7 +38,7 @@ there is no `Makefile` generated.
```bash ```bash
$ cd atom-shell $ cd atom-shell
$ ./script/bootstrap.py $ ./script/bootstrap.py -v
``` ```
## Building ## Building

View file

@ -25,7 +25,7 @@ there is no Xcode project generated.
```bash ```bash
$ cd atom-shell $ cd atom-shell
$ ./script/bootstrap.py $ ./script/bootstrap.py -v
``` ```
## Building ## Building

View file

@ -35,7 +35,7 @@ there is no Visual Studio project generated.
```powershell ```powershell
cd atom-shell cd atom-shell
python script\bootstrap.py python script\bootstrap.py -v
``` ```
## Building ## Building

View file

@ -27,6 +27,35 @@ Then execute `Atom.app` (or `atom` on Linux, and `atom.exe` on Windows), and
atom-shell will start as your app. The `atom-shell` directory would then be atom-shell will start as your app. The `atom-shell` directory would then be
your distribution that should be delivered to final users. your distribution that should be delivered to final users.
## Renaming Atom Shell for your app
The best way to rename Atom Shell is to change the `atom.gyp` file, then build
from source. Open up `atom.gyp` and change the first lines:
```
'project_name': 'atom',
'product_name': 'Atom',
'framework_name': 'Atom Framework',
```
Once you make the change, re-run `script/bootstrap` then run the command:
```sh
script/build.py -c Release -t $whatever_you_chose_for_project_name
```
If your app is OS X / Linux-only, you can also simply rename the "Atom.app"
folder as well as the names under "Framework" (i.e. "Atom Framework.framework"
=> "MyApp Framework.framework"), but this will break loading native Node
modules on Windows.
Fixing this is complicated, but a Grunt task has been created that will handle
this automatically,
[grunt-build-atom-shell](https://github.com/paulcbetts/grunt-build-atom-shell).
This task will automatically handle editing the .gyp file, building from
source, then rebuilding your app's native Node modules to match the new
executable name.
## Packaging your app into a file ## Packaging your app into a file
Apart from shipping your app by copying all its sources files, you can also Apart from shipping your app by copying all its sources files, you can also

View file

@ -4,8 +4,9 @@ import argparse
import os import os
import sys import sys
from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, \
from lib.util import execute, scoped_cwd, enable_verbose_execute enable_verbose_mode, is_verbose_mode
from lib.util import execute_stdout, 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__)))
@ -19,7 +20,7 @@ def main():
args = parse_args() args = parse_args()
if args.verbose: if args.verbose:
enable_verbose_execute() enable_verbose_mode()
update_submodules() update_submodules()
update_node_modules('.') update_node_modules('.')
update_atom_modules('spec') update_atom_modules('spec')
@ -49,19 +50,22 @@ def parse_args():
def update_submodules(): def update_submodules():
execute(['git', 'submodule', 'sync']) execute_stdout(['git', 'submodule', 'sync'])
execute(['git', 'submodule', 'update', '--init', '--recursive']) execute_stdout(['git', 'submodule', 'update', '--init', '--recursive'])
def bootstrap_brightray(url): def bootstrap_brightray(url):
bootstrap = os.path.join(VENDOR_DIR, 'brightray', 'script', 'bootstrap') bootstrap = os.path.join(VENDOR_DIR, 'brightray', 'script', 'bootstrap')
execute([sys.executable, bootstrap, '--commit', LIBCHROMIUMCONTENT_COMMIT, execute_stdout([sys.executable, bootstrap, '--commit',
url]) LIBCHROMIUMCONTENT_COMMIT, url])
def update_node_modules(dirname): def update_node_modules(dirname):
with scoped_cwd(dirname): with scoped_cwd(dirname):
execute([NPM, 'install']) if is_verbose_mode():
execute_stdout([NPM, 'install', '--verbose'])
else:
execute_stdout([NPM, 'install'])
def update_atom_modules(dirname): def update_atom_modules(dirname):
@ -70,20 +74,20 @@ def update_atom_modules(dirname):
if sys.platform in ['win32', 'cygwin']: if sys.platform in ['win32', 'cygwin']:
apm = os.path.join(SOURCE_ROOT, 'node_modules', 'atom-package-manager', apm = os.path.join(SOURCE_ROOT, 'node_modules', 'atom-package-manager',
'bin', 'apm.cmd') 'bin', 'apm.cmd')
execute([apm, 'install']) execute_stdout([apm, 'install'])
def update_win32_python(): def update_win32_python():
with scoped_cwd(VENDOR_DIR): with scoped_cwd(VENDOR_DIR):
if not os.path.exists('python_26'): if not os.path.exists('python_26'):
execute(['git', 'clone', PYTHON_26_URL]) execute_stdout(['git', 'clone', PYTHON_26_URL])
def install_runas(): def install_runas():
# TODO This is needed by the tools/win/register_msdia80_dll.js, should move # TODO This is needed by the tools/win/register_msdia80_dll.js, should move
# this to a better place. # this to a better place.
with scoped_cwd(os.path.join(SOURCE_ROOT, 'tools', 'win')): with scoped_cwd(os.path.join(SOURCE_ROOT, 'tools', 'win')):
execute([NPM, 'install', 'runas']) execute_stdout([NPM, 'install', 'runas'])
def create_chrome_version_h(): def create_chrome_version_h():
@ -112,7 +116,7 @@ def touch_config_gypi():
def update_atom_shell(): def update_atom_shell():
update = os.path.join(SOURCE_ROOT, 'script', 'update.py') update = os.path.join(SOURCE_ROOT, 'script', 'update.py')
execute([sys.executable, update]) execute_stdout([sys.executable, update])
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -23,3 +23,13 @@ TARGET_PLATFORM = {
'linux2': 'linux', 'linux2': 'linux',
'win32': 'win32', 'win32': 'win32',
}[sys.platform] }[sys.platform]
verbose_mode = False
def enable_verbose_mode():
print 'Running in verbose mode'
global verbose_mode
verbose_mode = True
def is_verbose_mode():
return verbose_mode

View file

@ -12,7 +12,7 @@ import urllib2
import os import os
import zipfile import zipfile
verbose_mode = False from config import is_verbose_mode
def tempdir(prefix=''): def tempdir(prefix=''):
directory = tempfile.mkdtemp(prefix=prefix) directory = tempfile.mkdtemp(prefix=prefix)
@ -20,12 +20,6 @@ def tempdir(prefix=''):
return directory return directory
def enable_verbose_execute():
print 'Running in verbose mode'
global verbose_mode
verbose_mode = True
@contextlib.contextmanager @contextlib.contextmanager
def scoped_cwd(path): def scoped_cwd(path):
cwd = os.getcwd() cwd = os.getcwd()
@ -132,9 +126,11 @@ def safe_mkdir(path):
def execute(argv): def execute(argv):
if is_verbose_mode():
print ' '.join(argv)
try: try:
output = subprocess.check_output(argv, stderr=subprocess.STDOUT) output = subprocess.check_output(argv, stderr=subprocess.STDOUT)
if verbose_mode: if is_verbose_mode():
print output print output
return output return output
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
@ -142,6 +138,18 @@ def execute(argv):
raise e raise e
def execute_stdout(argv):
if is_verbose_mode():
print ' '.join(argv)
try:
subprocess.check_call(argv)
except subprocess.CalledProcessError as e:
print e.output
raise e
else:
execute(argv)
def get_atom_shell_version(): def get_atom_shell_version():
return subprocess.check_output(['git', 'describe', '--tags']).strip() return subprocess.check_output(['git', 'describe', '--tags']).strip()