From 29386a3abcb6cce5591ea0967b99e4a6cf01ef8e Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 3 Oct 2011 10:25:14 +0000 Subject: [PATCH] Mac: Add make_distrib support (issue #260) git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@298 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef.gyp | 11 +--- cef_paths.gypi | 15 +++++- libcef_dll/ctocpp/v8value_ctocpp.cc | 8 +-- tools/distrib/cefclient.gyp | 49 ++++++++++++++++++ tools/distrib/mac/README.txt | 48 +++++++++++++++++ tools/distrib/mac/transfer.cfg | 29 +++++++++++ tools/distrib/{ => win}/README.txt | 4 +- tools/file_util.py | 6 ++- tools/make_distrib.bat | 2 +- tools/make_distrib.py | 80 +++++++++++++++++++++++------ tools/make_distrib.sh | 2 + 11 files changed, 218 insertions(+), 36 deletions(-) create mode 100644 tools/distrib/mac/README.txt create mode 100644 tools/distrib/mac/transfer.cfg rename tools/distrib/{ => win}/README.txt (97%) create mode 100644 tools/make_distrib.sh diff --git a/cef.gyp b/cef.gyp index 8b4c21c03..66a4527a0 100644 --- a/cef.gyp +++ b/cef.gyp @@ -35,16 +35,7 @@ '<@(cefclient_sources_common)', ], 'mac_bundle_resources': [ - 'tests/cefclient/mac/cefclient.icns', - 'tests/cefclient/mac/data/', - 'tests/cefclient/mac/English.lproj/InfoPlist.strings', - 'tests/cefclient/mac/English.lproj/MainMenu.xib', - 'tests/cefclient/mac/Info.plist', - 'tests/cefclient/res/domaccess.html', - 'tests/cefclient/res/extensionperf.html', - 'tests/cefclient/res/localstorage.html', - 'tests/cefclient/res/logo.png', - 'tests/cefclient/res/xmlhttprequest.html', + '<@(cefclient_bundle_resources_mac)', ], 'mac_bundle_resources!': [ # TODO(mark): Come up with a fancier way to do this (mac_info_plist?) diff --git a/cef_paths.gypi b/cef_paths.gypi index 6c6995da4..3a0466352 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -92,7 +92,20 @@ 'cefclient_sources_mac': [ 'tests/cefclient/cefclient_mac.mm', 'tests/cefclient/client_handler_mac.mm', - 'tests/cefclient/resource_util_mac.mm', + 'tests/cefclient/resource_util_mac.mm', + 'tests/cefclient/res/logo.png', + ], + 'cefclient_bundle_resources_mac': [ + 'tests/cefclient/mac/cefclient.icns', + 'tests/cefclient/mac/data/', + 'tests/cefclient/mac/English.lproj/InfoPlist.strings', + 'tests/cefclient/mac/English.lproj/MainMenu.xib', + 'tests/cefclient/mac/Info.plist', + 'tests/cefclient/res/domaccess.html', + 'tests/cefclient/res/extensionperf.html', + 'tests/cefclient/res/localstorage.html', + 'tests/cefclient/res/logo.png', + 'tests/cefclient/res/xmlhttprequest.html', ], 'cefclient_sources_linux': [ 'tests/cefclient/cefclient_gtk.cpp', diff --git a/libcef_dll/ctocpp/v8value_ctocpp.cc b/libcef_dll/ctocpp/v8value_ctocpp.cc index 3770672a9..7f1b2b1db 100644 --- a/libcef_dll/ctocpp/v8value_ctocpp.cc +++ b/libcef_dll/ctocpp/v8value_ctocpp.cc @@ -297,7 +297,7 @@ bool CefV8ValueCToCpp::DeleteValue(int index) CefRefPtr CefV8ValueCToCpp::GetValue(const CefString& key) { if(CEF_MEMBER_MISSING(struct_, get_value_bykey)) - return false; + return NULL; cef_v8value_t* valueStruct = struct_->get_value_bykey(struct_, key.GetStruct()); @@ -309,7 +309,7 @@ CefRefPtr CefV8ValueCToCpp::GetValue(const CefString& key) CefRefPtr CefV8ValueCToCpp::GetValue(int index) { if(CEF_MEMBER_MISSING(struct_, get_value_byindex)) - return false; + return NULL; cef_v8value_t* valueStruct = struct_->get_value_byindex(struct_, index); if(valueStruct) @@ -363,7 +363,7 @@ bool CefV8ValueCToCpp::GetKeys(std::vector& keys) CefRefPtr CefV8ValueCToCpp::GetUserData() { if(CEF_MEMBER_MISSING(struct_, get_user_data)) - return false; + return NULL; cef_base_t* baseStruct = struct_->get_user_data(struct_); if(baseStruct) @@ -393,7 +393,7 @@ CefString CefV8ValueCToCpp::GetFunctionName() CefRefPtr CefV8ValueCToCpp::GetFunctionHandler() { if(CEF_MEMBER_MISSING(struct_, get_function_handler)) - return false; + return NULL; cef_v8handler_t* handlerStruct = struct_->get_function_handler(struct_); if(handlerStruct) diff --git a/tools/distrib/cefclient.gyp b/tools/distrib/cefclient.gyp index b918def55..3f2043593 100644 --- a/tools/distrib/cefclient.gyp +++ b/tools/distrib/cefclient.gyp @@ -5,6 +5,12 @@ { 'variables': { 'chromium_code': 1, + 'conditions': [ + [ 'OS=="mac"', { + # Don't use clang with CEF binary releases due to Chromium tree structure dependency. + 'clang': 0, + }], + ] }, 'includes': [ # Bring in the source file lists for cefclient. @@ -14,6 +20,7 @@ { 'target_name': 'cefclient', 'type': 'executable', + 'mac_bundle': 1, 'msvs_guid': '6617FED9-C5D4-4907-BF55-A90062A6683F', 'dependencies': [ 'libcef_dll_wrapper', @@ -29,6 +36,20 @@ '<@(includes_common)', '<@(cefclient_sources_common)', ], + 'mac_bundle_resources': [ + '<@(cefclient_bundle_resources_mac)', + ], + 'mac_bundle_resources!': [ + # TODO(mark): Come up with a fancier way to do this (mac_info_plist?) + # that automatically sets the correct INFOPLIST_FILE setting and adds + # the file to a source group. + 'cefclient/mac/Info.plist', + ], + 'xcode_settings': { + 'INFOPLIST_FILE': 'cefclient/mac/Info.plist', + # Target build path. + 'SYMROOT': 'xcodebuild', + }, 'conditions': [ ['OS=="win"', { 'msvs_settings': { @@ -54,6 +75,30 @@ ], }], [ 'OS=="mac"', { + 'product_name': 'cefclient', + 'copies': [ + { + # Add library dependencies to the bundle. + 'destination': '<(PRODUCT_DIR)/cefclient.app/Contents/MacOS/', + 'files': [ + '$(CONFIGURATION)/libcef.dylib', + '$(CONFIGURATION)/ffmpegsumo.so', + ], + }, + { + # Add other resources to the bundle. + 'destination': '<(PRODUCT_DIR)/cefclient.app/Contents/', + 'files': [ + 'Resources/', + ], + }, + ], + 'link_settings': { + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/AppKit.framework', + '$(CONFIGURATION)/libcef.dylib' + ], + }, 'sources': [ '<@(includes_mac)', '<@(cefclient_sources_mac)', @@ -82,6 +127,10 @@ '<@(includes_common)', '<@(libcef_dll_wrapper_sources_common)', ], + 'xcode_settings': { + # Target build path. + 'SYMROOT': 'xcodebuild', + }, }, ] } diff --git a/tools/distrib/mac/README.txt b/tools/distrib/mac/README.txt new file mode 100644 index 000000000..d21f6702c --- /dev/null +++ b/tools/distrib/mac/README.txt @@ -0,0 +1,48 @@ +Chromium Embedded Framework (CEF) Binary Distribution +------------------------------------------------------------------------------- + +CEF Revision: $CEF_REV$ +Chromium Revision: $CHROMIUM_REV$ +Date: $DATE$ + +This distribution contains all files necessary to build an application using +CEF. Please read the included LICENSE.txt file for licensing terms and +restrictions. + + +CONTENTS +-------- + +cefclient Contains the cefclient sample application configured to build + using the files in this distribution. + +Debug Contains libcef.dylib and other libraries required to run the debug + version of CEF-based applications. + +docs Contains C++ API documentation generated from the CEF header files. + +include Contains all required CEF and NPAPI-related header files. Read + the include/internal/npapi/README-TRANSFER.txt file for more + information about the NPAPI-related header files. + +libcef_dll Contains the source code for the libcef_dll_wrapper static library + that all applications using the CEF C++ API must link against. + +Release Contains libcef.dylib and other libraries required to run the + release version of CEF-based applications. + +Resources Contains images and resources required by applications using CEF. + The contents of this folder should be transferred to the + Contents/Resources folder in the app bundle. + +tools Scripts that perform post-processing on Mac release targets. + + +USAGE +----- + +Xcode 3 and 4: Open the cefclient.xcodeproj project and build. + +Please visit the CEF Website for additional usage information. + +http://code.google.com/p/chromiumembedded diff --git a/tools/distrib/mac/transfer.cfg b/tools/distrib/mac/transfer.cfg new file mode 100644 index 000000000..92d2af055 --- /dev/null +++ b/tools/distrib/mac/transfer.cfg @@ -0,0 +1,29 @@ +# Additional handling of transfer files. +# target: Target location relative to the target release directory. This +# value is required. +# source: Source location relative to the CEF root directory. This value +# is optional. If specified the target will be copied to this location +# and a TRANSFER-README.txt file will be created. +# post-process: Post-processing operation to perform. This value is +# optional and may be any one of the following: +# 'normalize_headers': Replace fully-qualified project header paths with +# the optionally specified 'new_header_path' value. + +[ + { + 'source' : '../build/mac/change_mach_o_flags_from_xcode.sh', + 'target' : 'tools/change_mach_o_flags_from_xcode.sh', + }, + { + 'source' : '../build/mac/change_mach_o_flags.py', + 'target' : 'tools/change_mach_o_flags.py', + }, + { + 'source' : '../build/mac/strip_from_xcode', + 'target' : 'tools/strip_from_xcode', + }, + { + 'source' : '../build/mac/strip_save_dsym', + 'target' : 'tools/strip_save_dsym', + }, +] diff --git a/tools/distrib/README.txt b/tools/distrib/win/README.txt similarity index 97% rename from tools/distrib/README.txt rename to tools/distrib/win/README.txt index 3d4216aca..61f23e9a7 100644 --- a/tools/distrib/README.txt +++ b/tools/distrib/win/README.txt @@ -17,7 +17,7 @@ cefclient Contains the cefclient sample application configured to build using the files in this distribution. Debug Contains libcef.dll and other DLLs required to run the debug version - of CEF-based applications. Also acts as the build target for the + of CEF-based applications. Also acts as the build target for the Debug build of cefclient. docs Contains C++ API documentation generated from the CEF header files. @@ -33,7 +33,7 @@ libcef_dll Contains the source code for the libcef_dll_wrapper static library that all applications using the CEF C++ API must link against. Release Contains libcef.dll and other DLLs required to run the release - version of CEF-based applications. Also acts as the build target for + version of CEF-based applications. Also acts as the build target for the Release build of cefclient. diff --git a/tools/file_util.py b/tools/file_util.py index 19f4a322a..135f2143d 100644 --- a/tools/file_util.py +++ b/tools/file_util.py @@ -67,7 +67,11 @@ def move_file(src, dst, quiet = True): def copy_files(src_glob, dst_folder, quiet = True): """ Copy multiple files. """ for fname in iglob(src_glob): - copy_file(fname, os.path.join(dst_folder, os.path.basename(fname)), quiet) + dst = os.path.join(dst_folder, os.path.basename(fname)) + if os.path.isdir(fname): + copy_dir(fname, dst, quiet) + else: + copy_file(fname, dst, quiet) def copy_dir(src, dst, quiet = True): """ Copy a directory tree. """ diff --git a/tools/make_distrib.bat b/tools/make_distrib.bat index 35c7343bf..e0a660b37 100644 --- a/tools/make_distrib.bat +++ b/tools/make_distrib.bat @@ -1,2 +1,2 @@ @echo off -..\..\third_party\python_26\python.exe make_distrib.py --output-dir ..\binary_distrib +..\..\third_party\python_26\python.exe make_distrib.py --output-dir ..\binary_distrib\ diff --git a/tools/make_distrib.py b/tools/make_distrib.py index c3eea4bc4..c9131543d 100644 --- a/tools/make_distrib.py +++ b/tools/make_distrib.py @@ -11,6 +11,16 @@ import re from svn_util import * import sys +def create_readme(src, output_dir, cef_rev, chromium_rev, date): + """ Creates the README.TXT file. """ + data = read_file(src) + data = data.replace('$CEF_REV$', cef_rev) + data = data.replace('$CHROMIUM_REV$', chromium_rev) + data = data.replace('$DATE$', date) + write_file(os.path.join(output_dir, 'README.TXT'), data) + if not options.quiet: + sys.stdout.write('Creating README.TXT file.\n') + def eval_file(src): """ Loads and evaluates the contents of the specified file. """ return eval(read_file(src), {'__builtins__': None}, None) @@ -55,12 +65,13 @@ def transfer_files(cef_dir, script_dir, transfer_cfg, output_dir, quiet): open(readme, 'a').write(cfg['source']+"\n") # perform any required post-processing - post = cfg['post-process'] - if post == 'normalize_headers': - new_path = '' - if cfg.has_key('new_header_path'): - new_path = cfg['new_header_path'] - normalize_headers(dst, new_path) + if 'post-process' in cfg: + post = cfg['post-process'] + if post == 'normalize_headers': + new_path = '' + if cfg.has_key('new_header_path'): + new_path = cfg['new_header_path'] + normalize_headers(dst, new_path) def generate_msvs_projects(version): """ Generate MSVS projects for the specified version. """ @@ -110,15 +121,6 @@ output_dir = os.path.abspath(os.path.join(options.outputdir, 'cef_binary_r'+cef_ remove_dir(output_dir, options.quiet) make_dir(output_dir, options.quiet) -# write the README.TXT file -data = read_file(os.path.join(script_dir, 'distrib/README.TXT')) -data = data.replace('$CEF_REV$', cef_rev) -data = data.replace('$CHROMIUM_REV$', chromium_rev) -data = data.replace('$DATE$', date) -write_file(os.path.join(output_dir, 'README.TXT'), data) -if not options.quiet: - sys.stdout.write('Creating README.TXT file.\n') - # transfer the LICENSE.TXT file copy_file(os.path.join(cef_dir, 'LICENSE.TXT'), output_dir, options.quiet) @@ -162,7 +164,11 @@ transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/transfer.c output_dir, options.quiet) if sys.platform == 'win32': - # transfer include files + # create the README.TXT file + create_readme(os.path.join(script_dir, 'distrib/win/README.TXT'), output_dir, cef_rev, \ + chromium_rev, date) + + # transfer include files transfer_gypi_files(cef_dir, cef_paths['includes_win'], \ 'include/', include_dir, options.quiet) @@ -219,7 +225,11 @@ if sys.platform == 'win32': generate_msvs_projects('2010'); elif sys.platform == 'darwin': - # transfer include files + # create the README.TXT file + create_readme(os.path.join(script_dir, 'distrib/mac/README.TXT'), output_dir, cef_rev, \ + chromium_rev, date) + + # transfer include files transfer_gypi_files(cef_dir, cef_paths['includes_mac'], \ 'include/', include_dir, options.quiet) @@ -227,10 +237,46 @@ elif sys.platform == 'darwin': transfer_gypi_files(cef_dir, cef_paths['cefclient_sources_mac'], \ 'tests/cefclient/', cefclient_dir, options.quiet) + # transfer cefclient/mac files + copy_dir(os.path.join(cef_dir, 'tests/cefclient/mac/'), os.path.join(output_dir, 'cefclient/mac/'), \ + options.quiet) + + # transfer xcodebuild/Debug files + dst_dir = os.path.join(output_dir, 'Debug') + make_dir(dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, '../xcodebuild/Debug/ffmpegsumo.so'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, '../xcodebuild/Debug/libcef.dylib'), dst_dir, options.quiet) + + # transfer xcodebuild/Release files + dst_dir = os.path.join(output_dir, 'Release') + make_dir(dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, '../xcodebuild/Release/ffmpegsumo.so'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, '../xcodebuild/Release/libcef.dylib'), dst_dir, options.quiet) + + # transfer resource files + dst_dir = os.path.join(output_dir, 'Resources') + make_dir(dst_dir, options.quiet) + copy_files(os.path.join(cef_dir, '../third_party/WebKit/Source/WebCore/Resources/*.*'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, '../xcodebuild/Release/cefclient.app/Contents/Resources/chrome.pak'), dst_dir, options.quiet) + copy_files(os.path.join(cef_dir, '../xcodebuild/Release/cefclient.app/Contents/Resources/*.lproj'), dst_dir, options.quiet) + remove_dir(os.path.join(dst_dir, 'English.lproj')) + # transfer additional files, if any transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/mac/transfer.cfg'), \ output_dir, options.quiet) + # Generate Xcode project files + sys.stdout.write('Generating Xcode project files...') + gyper = [ 'python', 'tools/gyp_cef', os.path.relpath(os.path.join(output_dir, 'cefclient.gyp'), cef_dir) ] + RunAction(cef_dir, gyper); + + # Post-process the Xcode project to fix file paths + src_file = os.path.join(output_dir, 'cefclient.xcodeproj/project.pbxproj') + data = read_file(src_file) + data = data.replace('../../../build/mac/', 'tools/') + data = data.replace('../../../', '') + write_file(src_file, data) + elif sys.platform == 'linux2': # transfer include files transfer_gypi_files(cef_dir, cef_paths['includes_linux'], \ diff --git a/tools/make_distrib.sh b/tools/make_distrib.sh new file mode 100644 index 000000000..fd0a37f3b --- /dev/null +++ b/tools/make_distrib.sh @@ -0,0 +1,2 @@ +#!/bin/sh +python make_distrib.py --output-dir ../binary_distrib/