From 3f307ea8a6b38eae99f6f0150434cabab8d36fc2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 29 Dec 2014 09:35:08 -0800 Subject: [PATCH 1/7] Revert #898 --- atom.gyp | 1 + atom/app/atom_main_delegate.h | 4 ++++ atom/app/atom_main_delegate_mac.mm | 37 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 atom/app/atom_main_delegate_mac.mm diff --git a/atom.gyp b/atom.gyp index 345474b5b6de..3a0f8cbb7331 100644 --- a/atom.gyp +++ b/atom.gyp @@ -60,6 +60,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', diff --git a/atom/app/atom_main_delegate.h b/atom/app/atom_main_delegate.h index 9f74386304a1..8cd4a28ee1c0 100644 --- a/atom/app/atom_main_delegate.h +++ b/atom/app/atom_main_delegate.h @@ -26,6 +26,10 @@ class AtomMainDelegate : public brightray::MainDelegate { scoped_ptr 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_; diff --git a/atom/app/atom_main_delegate_mac.mm b/atom/app/atom_main_delegate_mac.mm new file mode 100644 index 000000000000..37fdf0664796 --- /dev/null +++ b/atom/app/atom_main_delegate_mac.mm @@ -0,0 +1,37 @@ +// 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("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 From 22d5d40a66f6fff229f2fc509760be87ba039e52 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 29 Dec 2014 09:39:21 -0800 Subject: [PATCH 2/7] Define PRODUCT_NAME --- atom.gyp | 1 + 1 file changed, 1 insertion(+) diff --git a/atom.gyp b/atom.gyp index 3a0f8cbb7331..e5be6835144f 100644 --- a/atom.gyp +++ b/atom.gyp @@ -528,6 +528,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. From 9bd517e623c46a886b7daa2085ddc4dd7989424c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 29 Dec 2014 09:44:34 -0800 Subject: [PATCH 3/7] Use PRODUCT_NAME as application name --- atom/app/atom_main_delegate_mac.mm | 11 ++++++----- atom/browser/atom_browser_main_parts_mac.mm | 7 +------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/atom/app/atom_main_delegate_mac.mm b/atom/app/atom_main_delegate_mac.mm index 37fdf0664796..7232817c94ff 100644 --- a/atom/app/atom_main_delegate_mac.mm +++ b/atom/app/atom_main_delegate_mac.mm @@ -23,14 +23,15 @@ base::FilePath GetFrameworksPath() { void AtomMainDelegate::OverrideFrameworkBundlePath() { base::mac::SetOverrideFrameworkBundlePath( - GetFrameworksPath().Append("Atom Framework.framework")); + GetFrameworksPath().Append(PRODUCT_NAME " Framework.framework")); } void AtomMainDelegate::OverrideChildProcessPath() { - base::FilePath helper_path = GetFrameworksPath().Append("Atom Helper.app") - .Append("Contents") - .Append("MacOS") - .Append("Atom Helper"); + 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); } diff --git a/atom/browser/atom_browser_main_parts_mac.mm b/atom/browser/atom_browser_main_parts_mac.mm index c1a9eae3147f..3e80eac223a5 100644 --- a/atom/browser/atom_browser_main_parts_mac.mm +++ b/atom/browser/atom_browser_main_parts_mac.mm @@ -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" From a9d67e97151fa8e52cbba70e8bc02276a6197d4a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 29 Dec 2014 09:49:10 -0800 Subject: [PATCH 4/7] Discard "framework_name" We are using "'product_name' Framework" directly in C++, so we should keep the name consistent in C++ and gyp --- atom.gyp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/atom.gyp b/atom.gyp index e5be6835144f..8f0e9b04026b 100644 --- a/atom.gyp +++ b/atom.gyp @@ -5,7 +5,6 @@ ], 'project_name': 'atom', 'product_name': 'Atom', - 'framework_name': 'Atom Framework', 'app_sources': [ 'atom/app/atom_main.cc', 'atom/app/atom_main.h', @@ -420,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', @@ -786,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', @@ -822,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', ], @@ -832,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', @@ -851,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', ], From de55d8c2922bf87e999551d4ac3dab03455be1c5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 29 Dec 2014 09:51:47 -0800 Subject: [PATCH 5/7] Make product_name and project_name configurable Now users can make use of GYP_DEFINES to custom application name: export GYP_DEFINES="product_name=MyApp project_name=myapp" ./script/update.py ./script/build.py -C Release -t myapp --- atom.gyp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atom.gyp b/atom.gyp index 8f0e9b04026b..0caf2f227f3d 100644 --- a/atom.gyp +++ b/atom.gyp @@ -3,8 +3,8 @@ 'includes': [ 'vendor/native_mate/native_mate_files.gypi', ], - 'project_name': 'atom', - 'product_name': 'Atom', + 'project_name%': 'atom', + 'product_name%': 'Atom', 'app_sources': [ 'atom/app/atom_main.cc', 'atom/app/atom_main.h', From 5c65f037b09dab9174594cf5ac85c7b057d0b33d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 29 Dec 2014 10:46:15 -0800 Subject: [PATCH 6/7] docs: Update Application Distribution --- docs/tutorial/application-distribution.md | 102 ++++++++++++++-------- 1 file changed, 68 insertions(+), 34 deletions(-) diff --git a/docs/tutorial/application-distribution.md b/docs/tutorial/application-distribution.md index ff1030bbf7d5..4b24a536ed27 100644 --- a/docs/tutorial/application-distribution.md +++ b/docs/tutorial/application-distribution.md @@ -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,76 @@ 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 +## Renaming atom-shell for your app -If you build your application with `grunt` there is a grunt task that can -download atom-shell for your current platform automatically: +### Renaming by rebuilding + +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 two lines: + +``` +'project_name': 'atom', +'product_name': 'Atom', +``` + +Once you make the change, re-run `script/bootstrap.py` then run the command: + +```sh +script/build.py -c Release -t whatever_you_chose_for_project_name +``` + +### Renaming with 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. + +### Renaming the downloaded binaries + +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 atom-shell 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). + +#### 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 the 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. From 45c2cda6bb3b12d8fce20a5d1c856fb0ec353511 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 29 Dec 2014 12:12:04 -0800 Subject: [PATCH 7/7] docs: Mention the GYP_DEFINES way of rebranding --- docs/tutorial/application-distribution.md | 78 +++++++++++++---------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/docs/tutorial/application-distribution.md b/docs/tutorial/application-distribution.md index 4b24a536ed27..2a48993fec92 100644 --- a/docs/tutorial/application-distribution.md +++ b/docs/tutorial/application-distribution.md @@ -53,57 +53,67 @@ atom-shell/resources/ More details can be found in [Application packaging](application-packaging.md). -## Renaming atom-shell for your app +## Rebranding with downloaded binaries -### Renaming by rebuilding - -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 two lines: - -``` -'project_name': 'atom', -'product_name': 'Atom', -``` - -Once you make the change, re-run `script/bootstrap.py` then run the command: - -```sh -script/build.py -c Release -t whatever_you_chose_for_project_name -``` - -### Renaming with 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. - -### Renaming the downloaded binaries +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 atom-shell for your current platform automatically, +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 +### 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). -#### OS X +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 the keys: +following manifest files if they have these keys: * `Atom.app/Contents/Info.plist` * `Atom.app/Contents/Frameworks/Atom Helper.app/Contents/Info.plist` -#### Linux +### 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.