Merge pull request #962 from atom/fix-rename-bundle
Fix renaming application bundle on Mac
This commit is contained in:
commit
b94375c794
5 changed files with 131 additions and 49 deletions
19
atom.gyp
19
atom.gyp
|
@ -3,9 +3,8 @@
|
|||
'includes': [
|
||||
'vendor/native_mate/native_mate_files.gypi',
|
||||
],
|
||||
'project_name': 'atom',
|
||||
'product_name': 'Atom',
|
||||
'framework_name': 'Atom Framework',
|
||||
'project_name%': 'atom',
|
||||
'product_name%': 'Atom',
|
||||
'app_sources': [
|
||||
'atom/app/atom_main.cc',
|
||||
'atom/app/atom_main.h',
|
||||
|
@ -60,6 +59,7 @@
|
|||
'atom/app/atom_content_client.h',
|
||||
'atom/app/atom_main_delegate.cc',
|
||||
'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.h',
|
||||
'atom/browser/api/atom_api_auto_updater.cc',
|
||||
|
@ -419,7 +419,7 @@
|
|||
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Frameworks',
|
||||
'files': [
|
||||
'<(PRODUCT_DIR)/<(product_name) Helper.app',
|
||||
'<(PRODUCT_DIR)/<(framework_name).framework',
|
||||
'<(PRODUCT_DIR)/<(product_name) Framework.framework',
|
||||
'external_binaries/Squirrel.framework',
|
||||
'external_binaries/ReactiveCocoa.framework',
|
||||
'external_binaries/Mantle.framework',
|
||||
|
@ -527,6 +527,7 @@
|
|||
'vendor/node/node.gyp:node_lib',
|
||||
],
|
||||
'defines': [
|
||||
'PRODUCT_NAME="<(product_name)"',
|
||||
# This is defined in skia/skia_common.gypi.
|
||||
'SK_SUPPORT_LEGACY_GETTOPDEVICE',
|
||||
# Disable warnings for g_settings_list_schemas.
|
||||
|
@ -784,7 +785,7 @@
|
|||
'targets': [
|
||||
{
|
||||
'target_name': '<(project_name)_framework',
|
||||
'product_name': '<(framework_name)',
|
||||
'product_name': '<(product_name) Framework',
|
||||
'type': 'shared_library',
|
||||
'dependencies': [
|
||||
'<(project_name)_lib',
|
||||
|
@ -820,7 +821,7 @@
|
|||
'LIBRARY_SEARCH_PATHS': [
|
||||
'<(libchromiumcontent_library_dir)',
|
||||
],
|
||||
'LD_DYLIB_INSTALL_NAME': '@rpath/<(framework_name).framework/<(framework_name)',
|
||||
'LD_DYLIB_INSTALL_NAME': '@rpath/<(product_name) Framework.framework/<(product_name) Framework',
|
||||
'LD_RUNPATH_SEARCH_PATHS': [
|
||||
'@loader_path/Libraries',
|
||||
],
|
||||
|
@ -830,14 +831,14 @@
|
|||
},
|
||||
'copies': [
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)/<(framework_name).framework/Versions/A/Libraries',
|
||||
'destination': '<(PRODUCT_DIR)/<(product_name) Framework.framework/Versions/A/Libraries',
|
||||
'files': [
|
||||
'<(libchromiumcontent_library_dir)/ffmpegsumo.so',
|
||||
'<(libchromiumcontent_library_dir)/libchromiumcontent.dylib',
|
||||
],
|
||||
},
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)/<(framework_name).framework/Versions/A/Resources',
|
||||
'destination': '<(PRODUCT_DIR)/<(product_name) Framework.framework/Versions/A/Resources',
|
||||
'files': [
|
||||
'<(PRODUCT_DIR)/Inspector',
|
||||
'<(PRODUCT_DIR)/crash_report_sender.app',
|
||||
|
@ -849,7 +850,7 @@
|
|||
'postbuild_name': 'Add symlinks for framework subdirectories',
|
||||
'action': [
|
||||
'tools/mac/create-framework-subdir-symlinks.sh',
|
||||
'<(framework_name)',
|
||||
'<(project_name) Framework',
|
||||
'Libraries',
|
||||
'Frameworks',
|
||||
],
|
||||
|
|
|
@ -26,6 +26,10 @@ class AtomMainDelegate : public brightray::MainDelegate {
|
|||
scoped_ptr<brightray::ContentClient> CreateContentClient() override;
|
||||
void AddDataPackFromPath(
|
||||
ui::ResourceBundle* bundle, const base::FilePath& pak_dir) override;
|
||||
#if defined(OS_MACOSX)
|
||||
void OverrideChildProcessPath() override;
|
||||
void OverrideFrameworkBundlePath() override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
brightray::ContentClient content_client_;
|
||||
|
|
38
atom/app/atom_main_delegate_mac.mm
Normal file
38
atom/app/atom_main_delegate_mac.mm
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) 2014 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(PRODUCT_NAME " Framework.framework"));
|
||||
}
|
||||
|
||||
void AtomMainDelegate::OverrideChildProcessPath() {
|
||||
base::FilePath helper_path =
|
||||
GetFrameworksPath().Append(PRODUCT_NAME " Helper.app")
|
||||
.Append("Contents")
|
||||
.Append("MacOS")
|
||||
.Append(PRODUCT_NAME " Helper");
|
||||
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
||||
}
|
||||
|
||||
} // namespace atom
|
|
@ -13,11 +13,6 @@
|
|||
|
||||
namespace atom {
|
||||
|
||||
std::string GetApplicationName() {
|
||||
std::string name = brightray::MainApplicationBundlePath().BaseName().AsUTF8Unsafe();
|
||||
return name.substr(0, name.length() - 4/*.app*/);
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PreMainMessageLoopStart() {
|
||||
// Initialize locale setting.
|
||||
l10n_util::OverrideLocaleWithCocoaLocale();
|
||||
|
@ -31,7 +26,7 @@ void AtomBrowserMainParts::PreMainMessageLoopStart() {
|
|||
base::FilePath frameworkPath = brightray::MainApplicationBundlePath()
|
||||
.Append("Contents")
|
||||
.Append("Frameworks")
|
||||
.Append(GetApplicationName() + " Framework.framework");
|
||||
.Append(PRODUCT_NAME " Framework.framework");
|
||||
NSBundle* frameworkBundle = [NSBundle
|
||||
bundleWithPath:base::mac::FilePathToNSString(frameworkPath)];
|
||||
NSNib* mainNib = [[NSNib alloc] initWithNibNamed:@"MainMenu"
|
||||
|
|
|
@ -27,35 +27,6 @@ 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
|
||||
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
|
||||
|
||||
Apart from shipping your app by copying all its sources files, you can also
|
||||
|
@ -63,13 +34,86 @@ package your app into an [asar](https://github.com/atom/asar) archive to avoid
|
|||
exposing your app's source code to users.
|
||||
|
||||
To use an `asar` archive to replace the `app` folder, you need to rename the
|
||||
archive to `app.asar`, and put it under atom-shell's resources directory,
|
||||
atom-shell will then try read the archive and start from it.
|
||||
archive to `app.asar`, and put it under atom-shell's resources directory like
|
||||
bellow, and atom-shell will then try read the archive and start from it.
|
||||
|
||||
On Mac OS X:
|
||||
|
||||
```text
|
||||
atom-shell/Atom.app/Contents/Resources/
|
||||
└── app.asar
|
||||
```
|
||||
|
||||
On Windows and Linux:
|
||||
|
||||
```text
|
||||
atom-shell/resources/
|
||||
└── app.asar
|
||||
```
|
||||
|
||||
More details can be found in [Application packaging](application-packaging.md).
|
||||
|
||||
## Building with grunt
|
||||
## Rebranding with downloaded binaries
|
||||
|
||||
If you build your application with `grunt` there is a grunt task that can
|
||||
download atom-shell for your current platform automatically:
|
||||
After bundling your app into atom-shell, you will want to rebrand atom-shell
|
||||
before distributing it to users.
|
||||
|
||||
If you don't care about the executable name on Windows or the helper process
|
||||
name on OS X, you can simply rename the downloaded binaries, and there is also a
|
||||
grunt task that can download prebuilt atom-shell binaries for your current
|
||||
platform automatically:
|
||||
[grunt-download-atom-shell](https://github.com/atom/grunt-download-atom-shell).
|
||||
|
||||
### Windows
|
||||
|
||||
You can not rename the `atom.exe` otherwise native modules will not load. But
|
||||
you can edit the executable's icon and other information with tools like
|
||||
[rcedit](https://github.com/atom/rcedit) or [ResEdit](http://www.resedit.net).
|
||||
|
||||
If you don't use any native Node module, it is fine to rename `atom.exe` to any
|
||||
name you want.
|
||||
|
||||
### OS X
|
||||
|
||||
You can rename `Atom.app` to whatever you want, and you also have to rename the
|
||||
`CFBundleDisplayName`, `CFBundleIdentifier` and `CFBundleName` fields in
|
||||
following manifest files if they have these keys:
|
||||
|
||||
* `Atom.app/Contents/Info.plist`
|
||||
* `Atom.app/Contents/Frameworks/Atom Helper.app/Contents/Info.plist`
|
||||
|
||||
### Linux
|
||||
|
||||
You can rename the `atom` executable to whatever you want.
|
||||
|
||||
## Rebranding by rebuilding atom-shell from source
|
||||
|
||||
The best way to rename atom-shell is to change the product name and then build
|
||||
from source. To do this you need to override the `GYP_DEFINES` environment
|
||||
variable and have a clean rebuild:
|
||||
|
||||
__Windows__
|
||||
|
||||
```cmd
|
||||
> set GYP_DEFINES="project_name=myapp product_name=MyApp"
|
||||
> python script\bootstrap.py
|
||||
> python script\build.py -c Release -t myapp
|
||||
```
|
||||
|
||||
__Bash__
|
||||
|
||||
```bash
|
||||
$ export GYP_DEFINES="project_name=myapp product_name=MyApp"
|
||||
$ script/bootstrap.py
|
||||
$ script/build.py -c Release -t myapp
|
||||
```
|
||||
|
||||
### grunt-build-atom-shell
|
||||
|
||||
Manually checking out atom-shell's code and rebuilding could be complicated, so
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue