Merge pull request #326 from github/framework

Move all code and resources into Atom.framework
This commit is contained in:
Adam Roben 2013-03-04 06:10:27 -08:00
commit c96e9acb64
9 changed files with 167 additions and 136 deletions

View File

@ -42,7 +42,7 @@ task :install => [:clean, :build] do
# Install Atom.app
dest_path = "/Applications/#{File.basename(path)}"
`rm -rf #{dest_path}`
`cp -r #{path} #{File.expand_path(dest_path)}`
`cp -a #{path} #{File.expand_path(dest_path)}`
# Install atom cli
if File.directory?("/opt/boxen")

233
atom.gyp
View File

@ -16,6 +16,22 @@
'toolkit_uses_gtk%': 0,
}],
],
'fix_framework_link_command': [
'install_name_tool',
'-change',
'@executable_path/libcef.dylib',
'@rpath/Chromium Embedded Framework.framework/Libraries/libcef.dylib',
'-change',
'@executable_path/../Frameworks/CocoaOniguruma.framework/Versions/A/CocoaOniguruma',
'@rpath/CocoaOniguruma.framework/Versions/A/CocoaOniguruma',
'-change',
'@loader_path/../Frameworks/Sparkle.framework/Versions/A/Sparkle',
'@rpath/Sparkle.framework/Versions/A/Sparkle',
'-change',
'@executable_path/libgit2.0.17.0.dylib',
'@rpath/libgit2.framework/Libraries/libgit2.0.17.0.dylib',
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
],
},
'includes': [
'cef/cef_paths2.gypi',
@ -45,39 +61,20 @@
'mac_bundle': 1,
'msvs_guid': 'D22C6F51-AA2D-457C-B579-6C97A96C724D',
'dependencies': [
'libcef_dll_wrapper',
'atom_framework',
],
'defines': [
'USING_CEF_SHARED',
],
'include_dirs': [ '.', 'cef', 'git2' ],
'mac_framework_dirs': [ 'native/frameworks' ],
'libraries': [ 'native/frameworks/CocoaOniguruma.framework', 'native/frameworks/Sparkle.framework'],
'sources': [
'<@(includes_common)',
'<@(includes_wrapper)',
'native/main_mac.mm',
'native/atom_application.h',
'native/atom_application.mm',
'native/atom_cef_app.h',
'native/atom_window_controller.h',
'native/atom_window_controller.mm',
'native/atom_cef_client_mac.mm',
'native/atom_cef_client.cpp',
'native/atom_cef_client.h',
'native/message_translation.cpp',
'native/message_translation.h',
'native/main.cpp',
],
'mac_bundle_resources': [
'native/mac/atom.icns',
'native/mac/file.icns',
'native/mac/speakeasy.pem',
'native/mac/English.lproj/MainMenu.xib',
'native/mac/English.lproj/AtomWindow.xib',
],
'xcode_settings': {
'INFOPLIST_FILE': 'native/mac/info.plist',
'OTHER_LDFLAGS': ['-Wl,-headerpad_max_install_names'], # Necessary to avoid an "install_name_tool: changing install names or rpaths can't be redone" error.
'LD_RUNPATH_SEARCH_PATHS': '@executable_path/../Frameworks',
},
'conditions': [
['CODE_SIGN' , {
@ -142,6 +139,8 @@
{
'destination': '<(PRODUCT_DIR)/Atom.app/Contents/Frameworks',
'files': [
'<(PRODUCT_DIR)/Atom Helper.app',
'<(PRODUCT_DIR)/Atom.framework',
'native/frameworks/CocoaOniguruma.framework',
'native/frameworks/Sparkle.framework',
],
@ -152,40 +151,18 @@
'git2/frameworks/libgit2.0.17.0.dylib',
],
},
{
'destination': '<(PRODUCT_DIR)/Atom.app/Contents/Frameworks/Chromium Embedded Framework.framework',
'files': [
'cef/Resources',
],
},
],
'postbuilds': [
{
'postbuild_name': 'Copy and Compile Static Files',
'action': [
'script/copy-files-to-bundle'
],
},
{
'postbuild_name': 'Copy Helper App',
'action': [
'cp',
'-r',
'${BUILT_PRODUCTS_DIR}/Atom Helper.app',
'${BUILT_PRODUCTS_DIR}/Atom.app/Contents/Frameworks',
],
},
{
'postbuild_name': 'Fix Framework Link',
'action': [
'install_name_tool',
'-change',
'@executable_path/libcef.dylib',
'@executable_path/../Frameworks/Chromium Embedded Framework.framework/Libraries/libcef.dylib',
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
],
},
{
'postbuild_name': 'Copy Framework Resources Directory',
'action': [
'cp',
'-r',
'cef/Resources',
'${BUILT_PRODUCTS_DIR}/Atom.app/Contents/Frameworks/Chromium Embedded Framework.framework/'
'<@(fix_framework_link_command)',
],
},
{
@ -231,6 +208,87 @@
}],
],
},
{
'target_name': 'atom_framework',
'product_name': 'Atom',
'type': 'shared_library',
'mac_bundle': 1,
'dependencies': [
'libcef_dll_wrapper',
],
'defines': [
'USING_CEF_SHARED',
],
'xcode_settings': {
'INFOPLIST_FILE': 'native/mac/framework-info.plist',
'LD_DYLIB_INSTALL_NAME': '@rpath/Atom.framework/Atom',
},
'include_dirs': [ '.', 'cef', 'git2' ],
'mac_framework_dirs': [ 'native/frameworks' ],
'sources': [
'<@(includes_common)',
'<@(includes_wrapper)',
'native/atom_application.h',
'native/atom_application.mm',
'native/atom_cef_app.h',
'native/atom_cef_app.h',
'native/atom_cef_client.cpp',
'native/atom_cef_client.h',
'native/atom_cef_client_mac.mm',
'native/atom_cef_render_process_handler.h',
'native/atom_cef_render_process_handler.mm',
'native/atom_window_controller.h',
'native/atom_window_controller.mm',
'native/atom_main.h',
'native/atom_main_mac.mm',
'native/message_translation.cpp',
'native/message_translation.cpp',
'native/message_translation.h',
'native/message_translation.h',
'native/path_watcher.h',
'native/path_watcher.mm',
'native/v8_extensions/atom.h',
'native/v8_extensions/atom.mm',
'native/v8_extensions/git.h',
'native/v8_extensions/git.mm',
'native/v8_extensions/native.h',
'native/v8_extensions/native.mm',
'native/v8_extensions/onig_reg_exp.h',
'native/v8_extensions/onig_reg_exp.mm',
'native/v8_extensions/onig_scanner.h',
'native/v8_extensions/onig_scanner.mm',
'native/v8_extensions/readtags.c',
'native/v8_extensions/readtags.h',
'native/v8_extensions/tags.h',
'native/v8_extensions/tags.mm',
],
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'git2/frameworks/libgit2.0.17.0.dylib',
'native/frameworks/CocoaOniguruma.framework',
'native/frameworks/Sparkle.framework',
],
},
'mac_bundle_resources': [
'native/mac/English.lproj/AtomWindow.xib',
'native/mac/English.lproj/MainMenu.xib',
],
'postbuilds': [
{
'postbuild_name': 'Copy and Compile Static Files',
'action': [
'script/copy-files-to-bundle'
],
},
{
'postbuild_name': 'Fix Framework Link',
'action': [
'<@(fix_framework_link_command)',
],
},
],
},
{
'target_name': 'libcef_dll_wrapper',
'type': 'static_library',
@ -271,46 +329,15 @@
'product_name': 'Atom Helper',
'mac_bundle': 1,
'dependencies': [
'libcef_dll_wrapper',
'atom_framework',
],
'defines': [
'USING_CEF_SHARED',
'PROCESS_HELPER_APP',
],
'include_dirs': [ '.', 'cef', 'git2' ],
'mac_framework_dirs': [ 'native/frameworks' ],
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
],
},
'libraries': [
'native/frameworks/CocoaOniguruma.framework',
'git2/frameworks/libgit2.0.17.0.dylib',
],
'sources': [
'native/atom_cef_app.h',
'native/atom_cef_render_process_handler.h',
'native/atom_cef_render_process_handler.mm',
'native/message_translation.cpp',
'native/message_translation.h',
'native/path_watcher.mm',
'native/path_watcher.h',
'native/main_helper_mac.mm',
'native/v8_extensions/native.mm',
'native/v8_extensions/native.h',
'native/v8_extensions/onig_reg_exp.mm',
'native/v8_extensions/onig_reg_exp.h',
'native/v8_extensions/onig_scanner.mm',
'native/v8_extensions/onig_scanner.h',
'native/v8_extensions/atom.mm',
'native/v8_extensions/atom.h',
'native/v8_extensions/git.mm',
'native/v8_extensions/git.h',
'native/v8_extensions/readtags.h',
'native/v8_extensions/readtags.c',
'native/v8_extensions/tags.h',
'native/v8_extensions/tags.mm',
'native/main.cpp',
],
# TODO(mark): For now, don't put any resources into this app. Its
# resources directory will be a symbolic link to the browser app's
@ -320,45 +347,13 @@
],
'xcode_settings': {
'INFOPLIST_FILE': 'native/mac/helper-info.plist',
'OTHER_LDFLAGS': ['-Wl,-headerpad_max_install_names'], # Necessary to avoid an "install_name_tool: changing install names or rpaths can't be redone" error.
'LD_RUNPATH_SEARCH_PATHS': '@executable_path/../../..',
},
'copies': [
{
'destination': '<(PRODUCT_DIR)/Atom Helper.app/Contents/Frameworks',
'files': [
'native/frameworks/CocoaOniguruma.framework',
],
},
],
'postbuilds': [
{
# The framework defines its load-time path
# (DYLIB_INSTALL_NAME_BASE) relative to the main executable
# (chrome). A different relative path needs to be used in
# atom_helper_app.
'postbuild_name': 'Fix CEF Framework Link',
'postbuild_name': 'Fix Framework Link',
'action': [
'install_name_tool',
'-change',
'@executable_path/libcef.dylib',
'@executable_path/../../../../Frameworks/Chromium Embedded Framework.framework/Libraries/libcef.dylib',
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
],
},
{
'postbuild_name': 'Fix libgit2 Framework Link',
'action': [
'install_name_tool',
'-change',
'@executable_path/libgit2.0.17.0.dylib',
'@executable_path/../../../../Frameworks/libgit2.framework/Libraries/libgit2.0.17.0.dylib',
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
],
},
{
'postbuild_name': 'Copy and Compile Static Files',
'action': [
'script/copy-files-to-bundle'
'<@(fix_framework_link_command)',
],
},
],

View File

@ -4,17 +4,13 @@
#include "include/cef_app.h"
#ifdef PROCESS_HELPER_APP
#include "atom_cef_render_process_handler.h"
#endif
class AtomCefApp : public CefApp {
#ifdef PROCESS_HELPER_APP
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE {
return CefRefPtr<CefRenderProcessHandler>(new AtomCefRenderProcessHandler);
}
#endif
IMPLEMENT_REFCOUNTING(AtomCefApp);
};

1
native/atom_main.h Normal file
View File

@ -0,0 +1 @@
__attribute__((visibility("default"))) int AtomMain(int argc, char* argv[]);

View File

@ -1,3 +1,5 @@
#import "atom_main.h"
#import "atom_cef_app.h"
#import "include/cef_application_mac.h"
#import "native/atom_application.h"
#include <sys/types.h>
@ -10,7 +12,19 @@ void listenForPathToOpen(int fd, NSString *socketPath);
void activateOpenApp();
BOOL isAppAlreadyOpen();
int main(int argc, char* argv[]) {
int AtomMain(int argc, char* argv[]) {
{
// See if we're being run as a secondary process.
CefMainArgs main_args(argc, argv);
CefRefPtr<CefApp> app(new AtomCefApp);
int exitCode = CefExecuteProcess(main_args, app);
if (exitCode >= 0)
return exitCode;
}
// We're the main process.
@autoreleasepool {
handleBeingOpenedAgain(argc, argv);
@ -18,7 +32,7 @@ int main(int argc, char* argv[]) {
AtomApplication *application = [AtomApplication applicationWithArguments:argv count:argc];
NSString *mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
NSNib *mainNib = [[NSNib alloc] initWithNibNamed:mainNibName bundle:[NSBundle mainBundle]];
NSNib *mainNib = [[NSNib alloc] initWithNibNamed:mainNibName bundle:[NSBundle bundleWithIdentifier:@"com.github.atom.framework"]];
[mainNib instantiateNibWithOwner:application topLevelObjects:nil];
CefRunMessageLoop();

View File

@ -44,7 +44,7 @@
}
if (alwaysUseBundleResourcePath || !_resourcePath) {
_resourcePath = [[NSBundle mainBundle] resourcePath];
_resourcePath = [[NSBundle bundleForClass:self.class] resourcePath];
}
_resourcePath = [_resourcePath stringByStandardizingPath];
[_resourcePath retain];
@ -119,7 +119,7 @@
// have the correct initial size based on the frame's last stored size.
// HACK: I hate this and want to place this code directly in windowDidLoad
- (void)attachWebView {
NSURL *url = [[NSBundle mainBundle] resourceURL];
NSURL *url = [[NSBundle bundleForClass:self.class] resourceURL];
NSMutableString *urlString = [NSMutableString string];
[urlString appendString:[[url URLByAppendingPathComponent:@"static/index.html"] absoluteString]];
[urlString appendFormat:@"?bootstrapScript=%@", [self encodeUrlParam:_bootstrapScript]];

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.github.atom.framework</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

5
native/main.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "atom_main.h"
int main(int argc, char* argv[]) {
return AtomMain(argc, argv);
}

View File

@ -1,8 +0,0 @@
#include "include/cef_app.h"
#include "atom_cef_app.h"
int main(int argc, char* argv[]) {
CefMainArgs main_args(argc, argv);
CefRefPtr<CefApp> app(new AtomCefApp);
return CefExecuteProcess(main_args, app); // Execute the secondary process.
}