From 17229f5e15048c22fd1db3066d069a1f3c142aac Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 6 Sep 2012 17:45:55 +0000 Subject: [PATCH] Merge revision 762 and revision 764 changes: - Move devtools resources to a separate devtools_resources.pak file (issue #714). git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1180@767 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef1/cef.gyp | 26 +- cef1/include/internal/cef_types.h | 12 +- cef1/include/internal/cef_types_wrappers.h | 6 +- cef1/libcef/cef_context.cc | 99 ++- cef1/libcef/cef_context.h | 2 - cef1/tests/cefclient/cefclient.cpp | 4 +- cef1/tests/cefclient/cefclient_switches.cpp | 2 +- cef1/tests/cefclient/cefclient_switches.h | 2 +- cef1/tests/unittests/test_suite.cc | 4 +- cef1/tools/distrib/linux/README.txt | 18 +- cef1/tools/distrib/mac/README.txt | 28 +- cef1/tools/distrib/win/README.txt | 20 +- cef1/tools/make_distrib.py | 895 ++++++++++---------- 13 files changed, 561 insertions(+), 557 deletions(-) diff --git a/cef1/cef.gyp b/cef1/cef.gyp index faf9fce67..03743a4dc 100644 --- a/cef1/cef.gyp +++ b/cef1/cef.gyp @@ -49,6 +49,7 @@ ], 'mac_bundle_resources': [ '<@(cefclient_bundle_resources_mac)', + '<(grit_out_dir)/devtools_resources.pak', ], 'mac_bundle_resources!': [ # TODO(mark): Come up with a fancier way to do this (mac_info_plist?) @@ -87,24 +88,6 @@ '<@(locales)', ], }, - { - # On Windows chrome.pak will contain only the inspector resources. - # Other resources are built into libcef.dll. - 'action_name': 'repack_resources', - 'variables': { - 'pak_inputs': [ - '<(grit_out_dir)/devtools_resources.pak', - ], - }, - 'inputs': [ - '<(repack_path)', - '<@(pak_inputs)', - ], - 'outputs': [ - '<(INTERMEDIATE_DIR)/repack/chrome.pak', - ], - 'action': ['python', '<(repack_path)', '<@(_outputs)', '<@(pak_inputs)'], - }, ], 'copies': [ { @@ -116,7 +99,7 @@ { 'destination': '<(PRODUCT_DIR)', 'files': [ - '<(INTERMEDIATE_DIR)/repack/chrome.pak' + '<(grit_out_dir)/devtools_resources.pak' ], }, ], @@ -175,7 +158,6 @@ 'process_outputs_as_mac_bundle_resources': 1, 'variables': { 'pak_inputs': [ - '<(grit_out_dir)/devtools_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', @@ -255,7 +237,6 @@ 'action_name': 'repack_resources', 'variables': { 'pak_inputs': [ - '<(grit_out_dir)/devtools_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', @@ -282,7 +263,8 @@ { 'destination': '<(PRODUCT_DIR)', 'files': [ - '<(INTERMEDIATE_DIR)/repack/chrome.pak' + '<(INTERMEDIATE_DIR)/repack/chrome.pak', + '<(grit_out_dir)/devtools_resources.pak', ], }, { diff --git a/cef1/include/internal/cef_types.h b/cef1/include/internal/cef_types.h index 611281ee6..c8e131007 100644 --- a/cef1/include/internal/cef_types.h +++ b/cef1/include/internal/cef_types.h @@ -188,18 +188,18 @@ typedef struct _cef_settings_t { #endif /// - // The fully qualified path for the cef.pak file. If this value is empty - // the cef.pak file must be located in the module directory. This value is - // ignored on Mac OS X where pack files are always loaded from the app bundle - // resource directory. + // The fully qualified path for the resources directory. If this value is + // empty the chrome.pak and/or devtools_resources.pak files must be located in + // the module directory on Windows/Linux or the app bundle Resources directory + // on Mac OS X. /// - cef_string_t pack_file_path; + cef_string_t resources_dir_path; /// // The fully qualified path for the locales directory. If this value is empty // the locales directory must be located in the module directory. This value // is ignored on Mac OS X where pack files are always loaded from the app - // bundle resource directory. + // bundle Resources directory. /// cef_string_t locales_dir_path; diff --git a/cef1/include/internal/cef_types_wrappers.h b/cef1/include/internal/cef_types_wrappers.h index 20a182c88..ce1ae6b38 100644 --- a/cef1/include/internal/cef_types_wrappers.h +++ b/cef1/include/internal/cef_types_wrappers.h @@ -259,7 +259,7 @@ struct CefSettingsTraits { cef_string_list_free(s->extra_plugin_paths); cef_string_clear(&s->log_file); cef_string_clear(&s->javascript_flags); - cef_string_clear(&s->pack_file_path); + cef_string_clear(&s->resources_dir_path); cef_string_clear(&s->locales_dir_path); } @@ -294,8 +294,8 @@ struct CefSettingsTraits { src->auto_detect_proxy_settings_enabled; #endif - cef_string_set(src->pack_file_path.str, src->pack_file_path.length, - &target->pack_file_path, copy); + cef_string_set(src->resources_dir_path.str, src->resources_dir_path.length, + &target->resources_dir_path, copy); cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length, &target->locales_dir_path, copy); target->pack_loading_disabled = src->pack_loading_disabled; diff --git a/cef1/libcef/cef_context.cc b/cef1/libcef/cef_context.cc index 852f3749f..33efc7188 100644 --- a/cef1/libcef/cef_context.cc +++ b/cef1/libcef/cef_context.cc @@ -37,31 +37,6 @@ namespace { // to initialize or reset to the same value. const int kNextBrowserIdReset = 1; -#if defined(OS_MACOSX) - -FilePath GetDefaultPackPath() { - // Start out with the path to the running executable. - FilePath execPath; - PathService::Get(base::FILE_EXE, &execPath); - - // Get the main bundle path. - FilePath bundlePath = base::mac::GetAppBundlePath(execPath); - - // Go into the Contents/Resources directory. - return bundlePath.Append(FILE_PATH_LITERAL("Contents")) - .Append(FILE_PATH_LITERAL("Resources")); -} - -#else // !defined(OS_MACOSX) - -FilePath GetDefaultPackPath() { - FilePath pak_dir; - PathService::Get(base::DIR_MODULE, &pak_dir); - return pak_dir; -} - -#endif // !defined(OS_MACOSX) - // Used in multi-threaded message loop mode to observe shutdown of the UI // thread. class DestructionObserver : public MessageLoop::DestructionObserver { @@ -392,14 +367,26 @@ CefRefPtr CefContext::GetBrowserByID(int id) { } void CefContext::InitializeResourceBundle() { - FilePath pak_file, locales_dir; +#if !defined(OS_WIN) + FilePath chrome_pak_file; +#endif + FilePath devtools_pak_file, locales_dir; if (!settings_.pack_loading_disabled) { - if (settings_.pack_file_path.length > 0) - pak_file = FilePath(CefString(&settings_.pack_file_path)); + FilePath resources_dir_path; + if (settings_.resources_dir_path.length > 0) + resources_dir_path = FilePath(CefString(&settings_.resources_dir_path)); + if (resources_dir_path.empty()) + resources_dir_path = GetResourcesFilePath(); - if (pak_file.empty()) - pak_file = GetDefaultPackPath().Append(FILE_PATH_LITERAL("chrome.pak")); + if (!resources_dir_path.empty()) { +#if !defined(OS_WIN) + chrome_pak_file = resources_dir_path.Append( + FILE_PATH_LITERAL("chrome.pak")); +#endif + devtools_pak_file = resources_dir_path.Append( + FILE_PATH_LITERAL("devtools_resources.pak")); + } if (settings_.locales_dir_path.length > 0) locales_dir = FilePath(CefString(&settings_.locales_dir_path)); @@ -420,14 +407,25 @@ void CefContext::InitializeResourceBundle() { CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale_str; - if (file_util::PathExists(pak_file)) { - resource_bundle_delegate_->set_allow_pack_file_load(true); + resource_bundle_delegate_->set_allow_pack_file_load(true); + + // The chrome.pak file is required on non-Windows platforms. +#if !defined(OS_WIN) + if (file_util::PathExists(chrome_pak_file)) { ResourceBundle::GetSharedInstance().AddDataPack( - pak_file, ui::SCALE_FACTOR_NONE); - resource_bundle_delegate_->set_allow_pack_file_load(false); + chrome_pak_file, ui::SCALE_FACTOR_NONE); } else { NOTREACHED() << "Could not load chrome.pak"; } +#endif + + // The devtools_resources.pak file is optional. + if (file_util::PathExists(devtools_pak_file)) { + ResourceBundle::GetSharedInstance().AddDataPack( + devtools_pak_file, ui::SCALE_FACTOR_NONE); + } + + resource_bundle_delegate_->set_allow_pack_file_load(false); } } @@ -536,25 +534,24 @@ base::StringPiece CefContext::GetDataResource(int resource_id) const { return value; } -#if defined(OS_MACOSX) FilePath CefContext::GetResourcesFilePath() const { - FilePath path; - // We need to know if we're bundled or not to know which path to use. - if (base::mac::AmIBundled()) { - PathService::Get(base::DIR_EXE, &path); - path = path.Append(FilePath::kParentDirectory); - return path.AppendASCII("Resources"); - } else { - // TODO(port): Allow the embedder to customize the resource path. - PathService::Get(base::DIR_SOURCE_ROOT, &path); - path = path.AppendASCII("src"); - path = path.AppendASCII("cef"); - path = path.AppendASCII("tests"); - path = path.AppendASCII("cefclient"); - return path.AppendASCII("res"); - } +#if defined(OS_MACOSX) + // Start out with the path to the running executable. + FilePath execPath; + PathService::Get(base::FILE_EXE, &execPath); + + // Get the main bundle path. + FilePath bundlePath = base::mac::GetAppBundlePath(execPath); + + // Go into the Contents/Resources directory. + return bundlePath.Append(FILE_PATH_LITERAL("Contents")) + .Append(FILE_PATH_LITERAL("Resources")); +#else + FilePath pak_dir; + PathService::Get(base::DIR_MODULE, &pak_dir); + return pak_dir; +#endif } -#endif // defined(OS_MACOSX) std::string CefContext::locale() const { std::string localeStr = CefString(&settings_.locale); diff --git a/cef1/libcef/cef_context.h b/cef1/libcef/cef_context.h index f6d867bc9..664d37730 100644 --- a/cef1/libcef/cef_context.h +++ b/cef1/libcef/cef_context.h @@ -59,9 +59,7 @@ class CefContext : public CefBase { string16 GetLocalizedString(int message_id) const; base::StringPiece GetDataResource(int resource_id) const; -#if defined(OS_MACOSX) FilePath GetResourcesFilePath() const; -#endif // Retrieve the path at which cache data will be stored on disk. If empty, // cache data will be stored in-memory. diff --git a/cef1/tests/cefclient/cefclient.cpp b/cef1/tests/cefclient/cefclient.cpp index d302fcb4c..1241aa7b7 100644 --- a/cef1/tests/cefclient/cefclient.cpp +++ b/cef1/tests/cefclient/cefclient.cpp @@ -250,8 +250,8 @@ void AppGetSettings(CefSettings& settings, CefRefPtr& app) { CefString(&settings.javascript_flags) = g_command_line->GetSwitchValue(cefclient::kJavascriptFlags); - CefString(&settings.pack_file_path) = - g_command_line->GetSwitchValue(cefclient::kPackFilePath); + CefString(&settings.resources_dir_path) = + g_command_line->GetSwitchValue(cefclient::kResourcesDirPath); CefString(&settings.locales_dir_path) = g_command_line->GetSwitchValue(cefclient::kLocalesDirPath); diff --git a/cef1/tests/cefclient/cefclient_switches.cpp b/cef1/tests/cefclient/cefclient_switches.cpp index 9bd160a4a..d95f2de8e 100644 --- a/cef1/tests/cefclient/cefclient_switches.cpp +++ b/cef1/tests/cefclient/cefclient_switches.cpp @@ -30,7 +30,7 @@ const char kGraphicsImpl_DesktopCmdBuffer[] = "desktop-command-buffer"; const char kLocalStorageQuota[] = "local-storage-quota"; const char kSessionStorageQuota[] = "session-storage-quota"; const char kJavascriptFlags[] = "javascript-flags"; -const char kPackFilePath[] = "pack-file-path"; +const char kResourcesDirPath[] = "resources-dir-path"; const char kLocalesDirPath[] = "locales-dir-path"; const char kPackLoadingDisabled[] = "pack-loading-disabled"; diff --git a/cef1/tests/cefclient/cefclient_switches.h b/cef1/tests/cefclient/cefclient_switches.h index e735670e8..4701ded47 100644 --- a/cef1/tests/cefclient/cefclient_switches.h +++ b/cef1/tests/cefclient/cefclient_switches.h @@ -32,7 +32,7 @@ extern const char kGraphicsImpl_DesktopCmdBuffer[]; extern const char kLocalStorageQuota[]; extern const char kSessionStorageQuota[]; extern const char kJavascriptFlags[]; -extern const char kPackFilePath[]; +extern const char kResourcesDirPath[]; extern const char kLocalesDirPath[]; extern const char kPackLoadingDisabled[]; diff --git a/cef1/tests/unittests/test_suite.cc b/cef1/tests/unittests/test_suite.cc index 7625a2e00..da9d2fb4b 100644 --- a/cef1/tests/unittests/test_suite.cc +++ b/cef1/tests/unittests/test_suite.cc @@ -117,8 +117,8 @@ void CefTestSuite::GetSettings(CefSettings& settings) { javascript_flags += " " + other_javascript_flags; CefString(&settings.javascript_flags) = javascript_flags; - CefString(&settings.pack_file_path) = - commandline_->GetSwitchValueASCII(cefclient::kPackFilePath); + CefString(&settings.resources_dir_path) = + commandline_->GetSwitchValueASCII(cefclient::kResourcesDirPath); CefString(&settings.locales_dir_path) = commandline_->GetSwitchValueASCII(cefclient::kLocalesDirPath); diff --git a/cef1/tools/distrib/linux/README.txt b/cef1/tools/distrib/linux/README.txt index 0bac8a2cc..643967c91 100644 --- a/cef1/tools/distrib/linux/README.txt +++ b/cef1/tools/distrib/linux/README.txt @@ -61,16 +61,24 @@ Required components: * CEF core library libcef.so +Optional components: + * Localized resources locales/ - Note: A .pak file is loaded from this folder based on the value of - CefSettings.locale. Only configured locales need to be distributed. If no - locale is configured the default locale of "en-US" will be used. The - locales folder must exist in the same directory as the executable. + Note: Contains localized strings for WebKit UI controls. A .pak file is loaded + from this folder based on the value of environment variables which are read + with the following precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. + Only configured locales need to be distributed. If no locale is configured the + default locale of "en-US" will be used. Locale file loading can be disabled + completely using CefSettings.pack_loading_disabled. The locales folder path + can be customized using CefSettings.locales_dir_path. * Other resources chrome.pak - Note: The chrome.pak file must exist in the same directory as the executable. + devtools_resources.pak + Note: Contains WebKit image and inspector resources. Pack file loading can be + disabled completely using CefSettings.pack_loading_disabled. The resources + directory path can be customized using CefSettings.resources_dir_path. LICENSING diff --git a/cef1/tools/distrib/mac/README.txt b/cef1/tools/distrib/mac/README.txt index f225b6035..844c40715 100644 --- a/cef1/tools/distrib/mac/README.txt +++ b/cef1/tools/distrib/mac/README.txt @@ -48,6 +48,10 @@ USAGE Xcode 3 and 4: Open the cefclient.xcodeproj project and build. +When using Xcode 4.2 or newer you will need to change the "Compiler for +C/C++/Objective-C" setting to "LLVM GCC 4.2" under "Build Settings" for +each target. + Please visit the CEF Website for additional usage information. http://code.google.com/p/chromiumembedded @@ -66,19 +70,27 @@ Required components: * CEF core library libcef.dylib -* Localized resources - Resources/*.lproj/ - Note: A .pak file is loaded from this folder based on the value of - CefSettings.locale. Only configured locales need to be distributed. If no - locale is configured the default locale of "en" will be used. - -* Other resources - Resources/chrome.pak +* Cursor resources Resources/*.png Resources/*.tiff Optional components: +* Localized resources + Resources/*.lproj/ + Note: Contains localized strings for WebKit UI controls. A .pak file is loaded + from this folder based on the CefSettings.locale value. Only configured + locales need to be distributed. If no locale is configured the default locale + of "en" will be used. Locale file loading can be disabled completely using + CefSettings.pack_loading_disabled. + +* Other resources + Resources/chrome.pak + Resources/devtools_resources.pak + Note: Contains WebKit image and inspector resources. Pack file loading can be + disabled completely using CefSettings.pack_loading_disabled. The resources + directory path can be customized using CefSettings.resources_dir_path. + * FFmpeg audio and video support ffmpegsumo.so Note: Without this component HTML5 audio and video will not function. diff --git a/cef1/tools/distrib/win/README.txt b/cef1/tools/distrib/win/README.txt index c51bf9f3b..2d492386c 100644 --- a/cef1/tools/distrib/win/README.txt +++ b/cef1/tools/distrib/win/README.txt @@ -72,18 +72,22 @@ Required components: * Unicode support icudt.dll +Optional components: + * Localized resources locales/ - Note: A .pak file is loaded from this folder based on the value of - CefSettings.locale. Only configured locales need to be distributed. If no - locale is configured the default locale of "en-US" will be used. The - locales folder must exist in the same directory as libcef.dll. + Note: Contains localized strings for WebKit UI controls. A .pak file is loaded + from this folder based on the CefSettings.locale value. Only configured + locales need to be distributed. If no locale is configured the default locale + of "en-US" will be used. Locale file loading can be disabled completely using + CefSettings.pack_loading_disabled. The locales folder path can be customized + using CefSettings.locales_dir_path. * Other resources - chrome.pak - Note: The chrome.pak file must exist in the same directory as libcef.dll. - -Optional components: + devtools_resources.pak + Note: Contains WebKit image and inspector resources. Pack file loading can be + disabled completely using CefSettings.pack_loading_disabled. The resources + directory path can be customized using CefSettings.resources_dir_path. * FFmpeg audio and video support avcodec-54.dll diff --git a/cef1/tools/make_distrib.py b/cef1/tools/make_distrib.py index d7ea8692a..e2e29bb45 100644 --- a/cef1/tools/make_distrib.py +++ b/cef1/tools/make_distrib.py @@ -1,446 +1,449 @@ -# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights -# reserved. Use of this source code is governed by a BSD-style license that -# can be found in the LICENSE file. - -from date_util import * -from file_util import * -from gclient_util import * -from optparse import OptionParser -import os -import re -import shlex -import subprocess -from svn_util import * -import sys -import zipfile - -def create_archive(input_dir, zip_file): - """ Creates a zip archive of the specified input directory. """ - zf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) - def addDir(dir): - for f in os.listdir(dir): - full_path = os.path.join(dir, f) - if os.path.isdir(full_path): - addDir(full_path) - else: - zf.write(full_path, os.path.relpath(full_path, \ - os.path.join(input_dir, os.pardir))) - addDir(input_dir) - zf.close() - -def create_readme(src, output_dir, cef_url, cef_rev, cef_ver, chromium_url, \ - chromium_rev, chromium_ver, date): - """ Creates the README.TXT file. """ - data = read_file(src) - data = data.replace('$CEF_URL$', cef_url) - data = data.replace('$CEF_REV$', cef_rev) - data = data.replace('$CEF_VER$', cef_ver) - data = data.replace('$CHROMIUM_URL$', chromium_url) - data = data.replace('$CHROMIUM_REV$', chromium_rev) - data = data.replace('$CHROMIUM_VER$', chromium_ver) - 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) - -def transfer_gypi_files(src_dir, gypi_paths, gypi_path_prefix, dst_dir, quiet): - """ Transfer files from one location to another. """ - for path in gypi_paths: - # skip gyp includes - if path[:2] == '<@': - continue - src = os.path.join(src_dir, path) - dst = os.path.join(dst_dir, path.replace(gypi_path_prefix, '')) - dst_path = os.path.dirname(dst) - make_dir(dst_path, quiet) - copy_file(src, dst, quiet) - -def normalize_headers(file, new_path = ''): - """ Normalize headers post-processing. Remove the path component from any - project include directives. """ - data = read_file(file) - data = re.sub(r'''#include \"(?!include\/)[a-zA-Z0-9_\/]+\/+([a-zA-Z0-9_\.]+)\"''', \ - "// Include path modified for CEF Binary Distribution.\n#include \""+new_path+"\\1\"", data) - write_file(file, data) - -def transfer_files(cef_dir, script_dir, transfer_cfg, output_dir, quiet): - """ Transfer files based on the specified configuration. """ - if not path_exists(transfer_cfg): - return - - configs = eval_file(transfer_cfg) - for cfg in configs: - dst = os.path.join(output_dir, cfg['target']) - - # perform a copy if source is specified - if not cfg['source'] is None: - src = os.path.join(cef_dir, cfg['source']) - dst_path = os.path.dirname(dst) - make_dir(dst_path, quiet) - copy_file(src, dst, quiet) - - # place a readme file in the destination directory - readme = os.path.join(dst_path, 'README-TRANSFER.txt') - if not path_exists(readme): - copy_file(os.path.join(script_dir, 'distrib/README-TRANSFER.txt'), readme) - open(readme, 'ab').write(cfg['source']+"\n") - - # perform any required post-processing - 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. """ - sys.stdout.write('Generating '+version+' project files...') - os.environ['GYP_MSVS_VERSION'] = version - gyper = [ 'python', 'tools/gyp_cef', os.path.relpath(os.path.join(output_dir, 'cefclient.gyp'), cef_dir) ] - RunAction(cef_dir, gyper); - move_file(os.path.relpath(os.path.join(output_dir, 'cefclient.sln')), \ - os.path.relpath(os.path.join(output_dir, 'cefclient'+version+'.sln'))) - -def fix_msvs_projects(): - """ Fix the output directory path in all .vcproj and .vcxproj files. """ - files = [] - for file in get_files(os.path.join(output_dir, '*.vcproj')): - files.append(file) - for file in get_files(os.path.join(output_dir, '*.vcxproj')): - files.append(file) - for file in files: - data = read_file(file) - data = data.replace('../../..\\build\\', '') - write_file(file, data) - -def run(command_line, working_dir): - """ Run a command. """ - sys.stdout.write('-------- Running "'+command_line+'" in "'+\ - working_dir+'"...'+"\n") - args = shlex.split(command_line.replace('\\', '\\\\')) - return subprocess.check_call(args, cwd=working_dir, env=os.environ, - shell=(sys.platform == 'win32')) - -# cannot be loaded as a module -if __name__ != "__main__": - sys.stderr.write('This file cannot be loaded as a module!') - sys.exit() - -# parse command-line options -disc = """ -This utility builds the CEF Binary Distribution. -""" - -parser = OptionParser(description=disc) -parser.add_option('--output-dir', dest='outputdir', metavar='DIR', - help='output directory [required]') -parser.add_option('--allow-partial', - action='store_true', dest='allowpartial', default=False, - help='allow creation of partial distributions') -parser.add_option('-q', '--quiet', - action='store_true', dest='quiet', default=False, - help='do not output detailed status information') -(options, args) = parser.parse_args() - -# the outputdir option is required -if options.outputdir is None: - parser.print_help(sys.stdout) - sys.exit() - -# script directory -script_dir = os.path.dirname(__file__) - -# CEF root directory -cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir)) - -# retrieve url, revision and date information -cef_info = get_svn_info(cef_dir) -cef_url = cef_info['url'] -cef_rev = cef_info['revision'] -chromium_info = get_svn_info(os.path.join(cef_dir, os.pardir)) -chromium_url = chromium_info['url'] -chromium_rev = chromium_info['revision'] -date = get_date() - -# Read and parse the version file (key=value pairs, one per line) -chrome = {} -lines = read_file(os.path.join(cef_dir, '../chrome/VERSION')).split("\n") -for line in lines: - parts = line.split('=', 1) - if len(parts) == 2: - chrome[parts[0]] = parts[1] - -cef_ver = '1.'+chrome['BUILD']+'.'+cef_rev -chromium_ver = chrome['MAJOR']+'.'+chrome['MINOR']+'.'+chrome['BUILD']+'.'+chrome['PATCH'] - -# Test the operating system. -platform = ''; -if sys.platform == 'win32': - platform = 'windows' -elif sys.platform == 'darwin': - platform = 'macosx' -elif sys.platform.startswith('linux'): - platform = 'linux' - -# output directory -output_dir = os.path.abspath(os.path.join(options.outputdir, \ - 'cef_binary_'+cef_ver+'_'+platform)) -remove_dir(output_dir, options.quiet) -make_dir(output_dir, options.quiet) - -# symbol directory -symbol_dir = os.path.abspath(os.path.join(options.outputdir, \ - 'cef_binary_'+cef_ver+'_'+platform+'_symbols')) -remove_dir(symbol_dir, options.quiet) -make_dir(symbol_dir, options.quiet) - -# transfer the LICENSE.txt file -copy_file(os.path.join(cef_dir, 'LICENSE.txt'), output_dir, options.quiet) - -# read the variables list from the autogenerated cef_paths.gypi file -cef_paths = eval_file(os.path.join(cef_dir, 'cef_paths.gypi')) -cef_paths = cef_paths['variables'] - -# read the variables list from the manually edited cef_paths2.gypi file -cef_paths2 = eval_file(os.path.join(cef_dir, 'cef_paths2.gypi')) -cef_paths2 = cef_paths2['variables'] - -# create the include directory -include_dir = os.path.join(output_dir, 'include') -make_dir(include_dir, options.quiet) - -# create the cefclient directory -cefclient_dir = os.path.join(output_dir, 'cefclient') -make_dir(cefclient_dir, options.quiet) - -# create the libcef_dll_wrapper directory -wrapper_dir = os.path.join(output_dir, 'libcef_dll') -make_dir(wrapper_dir, options.quiet) - -# transfer common include files -transfer_gypi_files(cef_dir, cef_paths2['includes_common'], \ - 'include/', include_dir, options.quiet) -transfer_gypi_files(cef_dir, cef_paths2['includes_capi'], \ - 'include/', include_dir, options.quiet) -transfer_gypi_files(cef_dir, cef_paths2['includes_wrapper'], \ - 'include/', include_dir, options.quiet) -transfer_gypi_files(cef_dir, cef_paths['autogen_cpp_includes'], \ - 'include/', include_dir, options.quiet) -transfer_gypi_files(cef_dir, cef_paths['autogen_capi_includes'], \ - 'include/', include_dir, options.quiet) - -# transfer common cefclient files -transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_common'], \ - 'tests/cefclient/', cefclient_dir, options.quiet) - -# transfer common libcef_dll_wrapper files -transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_common'], \ - 'libcef_dll/', wrapper_dir, options.quiet) -transfer_gypi_files(cef_dir, cef_paths['autogen_client_side'], \ - 'libcef_dll/', wrapper_dir, options.quiet) - -# transfer gyp files -copy_file(os.path.join(script_dir, 'distrib/cefclient.gyp'), output_dir, options.quiet) -paths_gypi = os.path.join(cef_dir, 'cef_paths2.gypi') -data = read_file(paths_gypi) -data = data.replace('tests/cefclient/', 'cefclient/') -write_file(os.path.join(output_dir, 'cef_paths2.gypi'), data) -copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \ - os.path.join(output_dir, 'cef_paths.gypi'), options.quiet) - -# transfer additional files -transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/transfer.cfg'), \ - output_dir, options.quiet) - -if platform == 'windows': - # create the README.TXT file - create_readme(os.path.join(script_dir, 'distrib/win/README.txt'), output_dir, cef_url, \ - cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) - - # transfer include files - transfer_gypi_files(cef_dir, cef_paths2['includes_win'], \ - 'include/', include_dir, options.quiet) - - # transfer cefclient files - transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_win'], \ - 'tests/cefclient/', cefclient_dir, options.quiet) - - # transfer build/Debug files - if not options.allowpartial or path_exists(os.path.join(cef_dir, 'Debug')): - dst_dir = os.path.join(output_dir, 'Debug') - make_dir(dst_dir, options.quiet) - copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) - copy_files(os.path.join(cef_dir, 'Debug/*.dll'), dst_dir, options.quiet) - copy_file(os.path.join(cef_dir, 'Debug/cefclient.exe'), dst_dir, options.quiet) - copy_file(os.path.join(cef_dir, 'Debug/chrome.pak'), dst_dir, options.quiet) - copy_dir(os.path.join(cef_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), \ - options.quiet) - - # transfer lib/Debug files - dst_dir = os.path.join(output_dir, 'lib/Debug') - make_dir(dst_dir, options.quiet) - copy_file(os.path.join(cef_dir, 'Debug/lib/libcef.lib'), dst_dir, options.quiet) - else: - sys.stderr.write("No Debug build files.\n") - - # transfer build/Release files - if not options.allowpartial or path_exists(os.path.join(cef_dir, 'Release')): - dst_dir = os.path.join(output_dir, 'Release') - make_dir(dst_dir, options.quiet) - copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) - copy_files(os.path.join(cef_dir, 'Release/*.dll'), dst_dir, options.quiet) - copy_file(os.path.join(cef_dir, 'Release/cefclient.exe'), dst_dir, options.quiet) - copy_file(os.path.join(cef_dir, 'Release/chrome.pak'), dst_dir, options.quiet) - copy_dir(os.path.join(cef_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), \ - options.quiet) - - # transfer lib/Release files - dst_dir = os.path.join(output_dir, 'lib/Release') - make_dir(dst_dir, options.quiet) - copy_file(os.path.join(cef_dir, 'Release/lib/libcef.lib'), dst_dir, options.quiet) - - # transfer symbols - copy_file(os.path.join(cef_dir, 'Release/libcef.pdb'), symbol_dir, options.quiet) - else: - sys.stderr.write("No Release build files.\n") - - # generate doc files - os.popen('make_cppdocs.bat '+cef_rev) - - # transfer docs files - dst_dir = os.path.join(output_dir, 'docs') - src_dir = os.path.join(cef_dir, 'docs') - if path_exists(src_dir): - copy_dir(src_dir, dst_dir, options.quiet) - - # transfer additional files, if any - transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/win/transfer.cfg'), \ - output_dir, options.quiet) - - # generate the project files - generate_msvs_projects('2005'); - generate_msvs_projects('2008'); - generate_msvs_projects('2010'); - fix_msvs_projects(); - -elif platform == 'macosx': - # create the README.TXT file - create_readme(os.path.join(script_dir, 'distrib/mac/README.txt'), output_dir, cef_url, \ - cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) - - # transfer include files - transfer_gypi_files(cef_dir, cef_paths2['includes_mac'], \ - 'include/', include_dir, options.quiet) - - # transfer cefclient files - transfer_gypi_files(cef_dir, cef_paths2['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 - if not options.allowpartial or path_exists(os.path.join(cef_dir, '../xcodebuild/Debug')): - 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 - if not options.allowpartial or path_exists(os.path.join(cef_dir, '../xcodebuild/Release')): - 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) - - # create the real dSYM file from the "fake" dSYM file - sys.stdout.write("Creating the real dSYM file...\n") - src_path = os.path.join(cef_dir, '../xcodebuild/Release/libcef.dylib.dSYM/Contents/Resources/DWARF/libcef.dylib') - dst_path = os.path.join(symbol_dir, 'libcef.dylib.dSYM') - run('dsymutil '+src_path+' -o '+dst_path, cef_dir) - - # 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 platform == 'linux': - linux_build_dir = os.path.join(cef_dir, os.pardir, 'out') - - # create the README.TXT file - create_readme(os.path.join(script_dir, 'distrib/linux/README.txt'), output_dir, cef_url, \ - cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) - - # transfer build/Debug files - if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Debug')): - dst_dir = os.path.join(output_dir, 'Debug') - make_dir(dst_dir, options.quiet) - copy_dir(os.path.join(linux_build_dir, 'Debug/lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) - copy_file(os.path.join(linux_build_dir, 'Debug/cefclient'), dst_dir, options.quiet) - copy_file(os.path.join(linux_build_dir, 'Debug/chrome.pak'), dst_dir, options.quiet) - copy_dir(os.path.join(linux_build_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), options.quiet) - - else: - sys.stderr.write("No Debug build files.\n") - - # transfer build/Release files - if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Release')): - dst_dir = os.path.join(output_dir, 'Release') - make_dir(dst_dir, options.quiet) - copy_dir(os.path.join(linux_build_dir, 'Release/lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) - copy_file(os.path.join(linux_build_dir, 'Release/cefclient'), dst_dir, options.quiet) - copy_file(os.path.join(linux_build_dir, 'Release/chrome.pak'), dst_dir, options.quiet) - copy_dir(os.path.join(linux_build_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), options.quiet) - - else: - sys.stderr.write("No Release build files.\n") - - # transfer include files - transfer_gypi_files(cef_dir, cef_paths2['includes_linux'], \ - 'include/', include_dir, options.quiet) - - # transfer cefclient files - transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \ - 'tests/cefclient/', cefclient_dir, options.quiet) - - # transfer additional files, if any - transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/linux/transfer.cfg'), \ - output_dir, options.quiet) - -# Create an archive of the output directory -zip_file = os.path.split(output_dir)[1] + '.zip' -if not options.quiet: - sys.stdout.write('Creating '+zip_file+"...\n") -create_archive(output_dir, os.path.join(output_dir, os.pardir, zip_file)) - -# Create an archive of the symbol directory -zip_file = os.path.split(symbol_dir)[1] + '.zip' -if not options.quiet: - sys.stdout.write('Creating '+zip_file+"...\n") -create_archive(symbol_dir, os.path.join(symbol_dir, os.pardir, zip_file)) +# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +# reserved. Use of this source code is governed by a BSD-style license that +# can be found in the LICENSE file. + +from date_util import * +from file_util import * +from gclient_util import * +from optparse import OptionParser +import os +import re +import shlex +import subprocess +from svn_util import * +import sys +import zipfile + +def create_archive(input_dir, zip_file): + """ Creates a zip archive of the specified input directory. """ + zf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) + def addDir(dir): + for f in os.listdir(dir): + full_path = os.path.join(dir, f) + if os.path.isdir(full_path): + addDir(full_path) + else: + zf.write(full_path, os.path.relpath(full_path, \ + os.path.join(input_dir, os.pardir))) + addDir(input_dir) + zf.close() + +def create_readme(src, output_dir, cef_url, cef_rev, cef_ver, chromium_url, \ + chromium_rev, chromium_ver, date): + """ Creates the README.TXT file. """ + data = read_file(src) + data = data.replace('$CEF_URL$', cef_url) + data = data.replace('$CEF_REV$', cef_rev) + data = data.replace('$CEF_VER$', cef_ver) + data = data.replace('$CHROMIUM_URL$', chromium_url) + data = data.replace('$CHROMIUM_REV$', chromium_rev) + data = data.replace('$CHROMIUM_VER$', chromium_ver) + 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) + +def transfer_gypi_files(src_dir, gypi_paths, gypi_path_prefix, dst_dir, quiet): + """ Transfer files from one location to another. """ + for path in gypi_paths: + # skip gyp includes + if path[:2] == '<@': + continue + src = os.path.join(src_dir, path) + dst = os.path.join(dst_dir, path.replace(gypi_path_prefix, '')) + dst_path = os.path.dirname(dst) + make_dir(dst_path, quiet) + copy_file(src, dst, quiet) + +def normalize_headers(file, new_path = ''): + """ Normalize headers post-processing. Remove the path component from any + project include directives. """ + data = read_file(file) + data = re.sub(r'''#include \"(?!include\/)[a-zA-Z0-9_\/]+\/+([a-zA-Z0-9_\.]+)\"''', \ + "// Include path modified for CEF Binary Distribution.\n#include \""+new_path+"\\1\"", data) + write_file(file, data) + +def transfer_files(cef_dir, script_dir, transfer_cfg, output_dir, quiet): + """ Transfer files based on the specified configuration. """ + if not path_exists(transfer_cfg): + return + + configs = eval_file(transfer_cfg) + for cfg in configs: + dst = os.path.join(output_dir, cfg['target']) + + # perform a copy if source is specified + if not cfg['source'] is None: + src = os.path.join(cef_dir, cfg['source']) + dst_path = os.path.dirname(dst) + make_dir(dst_path, quiet) + copy_file(src, dst, quiet) + + # place a readme file in the destination directory + readme = os.path.join(dst_path, 'README-TRANSFER.txt') + if not path_exists(readme): + copy_file(os.path.join(script_dir, 'distrib/README-TRANSFER.txt'), readme) + open(readme, 'ab').write(cfg['source']+"\n") + + # perform any required post-processing + 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. """ + sys.stdout.write('Generating '+version+' project files...') + os.environ['GYP_MSVS_VERSION'] = version + gyper = [ 'python', 'tools/gyp_cef', os.path.relpath(os.path.join(output_dir, 'cefclient.gyp'), cef_dir) ] + RunAction(cef_dir, gyper); + move_file(os.path.relpath(os.path.join(output_dir, 'cefclient.sln')), \ + os.path.relpath(os.path.join(output_dir, 'cefclient'+version+'.sln'))) + +def fix_msvs_projects(): + """ Fix the output directory path in all .vcproj and .vcxproj files. """ + files = [] + for file in get_files(os.path.join(output_dir, '*.vcproj')): + files.append(file) + for file in get_files(os.path.join(output_dir, '*.vcxproj')): + files.append(file) + for file in files: + data = read_file(file) + data = data.replace('../../..\\build\\', '') + write_file(file, data) + +def run(command_line, working_dir): + """ Run a command. """ + sys.stdout.write('-------- Running "'+command_line+'" in "'+\ + working_dir+'"...'+"\n") + args = shlex.split(command_line.replace('\\', '\\\\')) + return subprocess.check_call(args, cwd=working_dir, env=os.environ, + shell=(sys.platform == 'win32')) + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + +# parse command-line options +disc = """ +This utility builds the CEF Binary Distribution. +""" + +parser = OptionParser(description=disc) +parser.add_option('--output-dir', dest='outputdir', metavar='DIR', + help='output directory [required]') +parser.add_option('--allow-partial', + action='store_true', dest='allowpartial', default=False, + help='allow creation of partial distributions') +parser.add_option('-q', '--quiet', + action='store_true', dest='quiet', default=False, + help='do not output detailed status information') +(options, args) = parser.parse_args() + +# the outputdir option is required +if options.outputdir is None: + parser.print_help(sys.stdout) + sys.exit() + +# script directory +script_dir = os.path.dirname(__file__) + +# CEF root directory +cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir)) + +# retrieve url, revision and date information +cef_info = get_svn_info(cef_dir) +cef_url = cef_info['url'] +cef_rev = cef_info['revision'] +chromium_info = get_svn_info(os.path.join(cef_dir, os.pardir)) +chromium_url = chromium_info['url'] +chromium_rev = chromium_info['revision'] +date = get_date() + +# Read and parse the version file (key=value pairs, one per line) +chrome = {} +lines = read_file(os.path.join(cef_dir, '../chrome/VERSION')).split("\n") +for line in lines: + parts = line.split('=', 1) + if len(parts) == 2: + chrome[parts[0]] = parts[1] + +cef_ver = '1.'+chrome['BUILD']+'.'+cef_rev +chromium_ver = chrome['MAJOR']+'.'+chrome['MINOR']+'.'+chrome['BUILD']+'.'+chrome['PATCH'] + +# Test the operating system. +platform = ''; +if sys.platform == 'win32': + platform = 'windows' +elif sys.platform == 'darwin': + platform = 'macosx' +elif sys.platform.startswith('linux'): + platform = 'linux' + +# output directory +output_dir = os.path.abspath(os.path.join(options.outputdir, \ + 'cef_binary_'+cef_ver+'_'+platform)) +remove_dir(output_dir, options.quiet) +make_dir(output_dir, options.quiet) + +# symbol directory +symbol_dir = os.path.abspath(os.path.join(options.outputdir, \ + 'cef_binary_'+cef_ver+'_'+platform+'_symbols')) +remove_dir(symbol_dir, options.quiet) +make_dir(symbol_dir, options.quiet) + +# transfer the LICENSE.txt file +copy_file(os.path.join(cef_dir, 'LICENSE.txt'), output_dir, options.quiet) + +# read the variables list from the autogenerated cef_paths.gypi file +cef_paths = eval_file(os.path.join(cef_dir, 'cef_paths.gypi')) +cef_paths = cef_paths['variables'] + +# read the variables list from the manually edited cef_paths2.gypi file +cef_paths2 = eval_file(os.path.join(cef_dir, 'cef_paths2.gypi')) +cef_paths2 = cef_paths2['variables'] + +# create the include directory +include_dir = os.path.join(output_dir, 'include') +make_dir(include_dir, options.quiet) + +# create the cefclient directory +cefclient_dir = os.path.join(output_dir, 'cefclient') +make_dir(cefclient_dir, options.quiet) + +# create the libcef_dll_wrapper directory +wrapper_dir = os.path.join(output_dir, 'libcef_dll') +make_dir(wrapper_dir, options.quiet) + +# transfer common include files +transfer_gypi_files(cef_dir, cef_paths2['includes_common'], \ + 'include/', include_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths2['includes_capi'], \ + 'include/', include_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths2['includes_wrapper'], \ + 'include/', include_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths['autogen_cpp_includes'], \ + 'include/', include_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths['autogen_capi_includes'], \ + 'include/', include_dir, options.quiet) + +# transfer common cefclient files +transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_common'], \ + 'tests/cefclient/', cefclient_dir, options.quiet) + +# transfer common libcef_dll_wrapper files +transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_common'], \ + 'libcef_dll/', wrapper_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths['autogen_client_side'], \ + 'libcef_dll/', wrapper_dir, options.quiet) + +# transfer gyp files +copy_file(os.path.join(script_dir, 'distrib/cefclient.gyp'), output_dir, options.quiet) +paths_gypi = os.path.join(cef_dir, 'cef_paths2.gypi') +data = read_file(paths_gypi) +data = data.replace('tests/cefclient/', 'cefclient/') +write_file(os.path.join(output_dir, 'cef_paths2.gypi'), data) +copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \ + os.path.join(output_dir, 'cef_paths.gypi'), options.quiet) + +# transfer additional files +transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/transfer.cfg'), \ + output_dir, options.quiet) + +if platform == 'windows': + # create the README.TXT file + create_readme(os.path.join(script_dir, 'distrib/win/README.txt'), output_dir, cef_url, \ + cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) + + # transfer include files + transfer_gypi_files(cef_dir, cef_paths2['includes_win'], \ + 'include/', include_dir, options.quiet) + + # transfer cefclient files + transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_win'], \ + 'tests/cefclient/', cefclient_dir, options.quiet) + + # transfer build/Debug files + if not options.allowpartial or path_exists(os.path.join(cef_dir, 'Debug')): + dst_dir = os.path.join(output_dir, 'Debug') + make_dir(dst_dir, options.quiet) + copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) + copy_files(os.path.join(cef_dir, 'Debug/*.dll'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, 'Debug/cefclient.exe'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, 'Debug/devtools_resources.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(cef_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), \ + options.quiet) + + # transfer lib/Debug files + dst_dir = os.path.join(output_dir, 'lib/Debug') + make_dir(dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, 'Debug/lib/libcef.lib'), dst_dir, options.quiet) + else: + sys.stderr.write("No Debug build files.\n") + + # transfer build/Release files + if not options.allowpartial or path_exists(os.path.join(cef_dir, 'Release')): + dst_dir = os.path.join(output_dir, 'Release') + make_dir(dst_dir, options.quiet) + copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) + copy_files(os.path.join(cef_dir, 'Release/*.dll'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, 'Release/cefclient.exe'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, 'Release/devtools_resources.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(cef_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), \ + options.quiet) + + # transfer lib/Release files + dst_dir = os.path.join(output_dir, 'lib/Release') + make_dir(dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, 'Release/lib/libcef.lib'), dst_dir, options.quiet) + + # transfer symbols + copy_file(os.path.join(cef_dir, 'Release/libcef.pdb'), symbol_dir, options.quiet) + else: + sys.stderr.write("No Release build files.\n") + + # generate doc files + os.popen('make_cppdocs.bat '+cef_rev) + + # transfer docs files + dst_dir = os.path.join(output_dir, 'docs') + src_dir = os.path.join(cef_dir, 'docs') + if path_exists(src_dir): + copy_dir(src_dir, dst_dir, options.quiet) + + # transfer additional files, if any + transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/win/transfer.cfg'), \ + output_dir, options.quiet) + + # generate the project files + generate_msvs_projects('2005'); + generate_msvs_projects('2008'); + generate_msvs_projects('2010'); + fix_msvs_projects(); + +elif platform == 'macosx': + # create the README.TXT file + create_readme(os.path.join(script_dir, 'distrib/mac/README.txt'), output_dir, cef_url, \ + cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) + + # transfer include files + transfer_gypi_files(cef_dir, cef_paths2['includes_mac'], \ + 'include/', include_dir, options.quiet) + + # transfer cefclient files + transfer_gypi_files(cef_dir, cef_paths2['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 + if not options.allowpartial or path_exists(os.path.join(cef_dir, '../xcodebuild/Debug')): + 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 + if not options.allowpartial or path_exists(os.path.join(cef_dir, '../xcodebuild/Release')): + 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) + + # create the real dSYM file from the "fake" dSYM file + sys.stdout.write("Creating the real dSYM file...\n") + src_path = os.path.join(cef_dir, '../xcodebuild/Release/libcef.dylib.dSYM/Contents/Resources/DWARF/libcef.dylib') + dst_path = os.path.join(symbol_dir, 'libcef.dylib.dSYM') + run('dsymutil '+src_path+' -o '+dst_path, cef_dir) + + # 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_file(os.path.join(cef_dir, '../xcodebuild/Release/cefclient.app/Contents/Resources/devtools_resources.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 platform == 'linux': + linux_build_dir = os.path.join(cef_dir, os.pardir, 'out') + + # create the README.TXT file + create_readme(os.path.join(script_dir, 'distrib/linux/README.txt'), output_dir, cef_url, \ + cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) + + # transfer build/Debug files + if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Debug')): + dst_dir = os.path.join(output_dir, 'Debug') + make_dir(dst_dir, options.quiet) + copy_dir(os.path.join(linux_build_dir, 'Debug/lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) + copy_file(os.path.join(linux_build_dir, 'Debug/cefclient'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Debug/chrome.pak'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Debug/devtools_resources.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(linux_build_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), options.quiet) + + else: + sys.stderr.write("No Debug build files.\n") + + # transfer build/Release files + if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Release')): + dst_dir = os.path.join(output_dir, 'Release') + make_dir(dst_dir, options.quiet) + copy_dir(os.path.join(linux_build_dir, 'Release/lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) + copy_file(os.path.join(linux_build_dir, 'Release/cefclient'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Release/chrome.pak'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Release/devtools_resources.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(linux_build_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), options.quiet) + + else: + sys.stderr.write("No Release build files.\n") + + # transfer include files + transfer_gypi_files(cef_dir, cef_paths2['includes_linux'], \ + 'include/', include_dir, options.quiet) + + # transfer cefclient files + transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \ + 'tests/cefclient/', cefclient_dir, options.quiet) + + # transfer additional files, if any + transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/linux/transfer.cfg'), \ + output_dir, options.quiet) + +# Create an archive of the output directory +zip_file = os.path.split(output_dir)[1] + '.zip' +if not options.quiet: + sys.stdout.write('Creating '+zip_file+"...\n") +create_archive(output_dir, os.path.join(output_dir, os.pardir, zip_file)) + +# Create an archive of the symbol directory +zip_file = os.path.split(symbol_dir)[1] + '.zip' +if not options.quiet: + sys.stdout.write('Creating '+zip_file+"...\n") +create_archive(symbol_dir, os.path.join(symbol_dir, os.pardir, zip_file))