Merge revision 845 changes:

- Add about:version, about:credits and about:license internal URLs (issue #731).
- Centralize retrieval of the CEF major version number from a new VERSION file.

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1271@846 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-10-08 17:48:20 +00:00
parent c5bb1d019a
commit 4c4206604d
25 changed files with 1377 additions and 633 deletions

1
cef3/VERSION Normal file
View File

@ -0,0 +1 @@
CEF_MAJOR=3

View File

@ -10,7 +10,7 @@
'revision': '<!(python tools/revision.py)',
# Need to be creative to match dylib version formatting requirements.
'version_mac_dylib':
'<!(python ../chrome/tools/build/version.py -f ../chrome/VERSION -t "3<(revision).@BUILD_HI@.@BUILD_LO@" -e "BUILD_HI=int(BUILD)/256" -e "BUILD_LO=int(BUILD)%256")',
'<!(python ../chrome/tools/build/version.py -f VERSION -f ../chrome/VERSION -t "@CEF_MAJOR@<(revision).@BUILD_HI@.@BUILD_LO@" -e "BUILD_HI=int(BUILD)/256" -e "BUILD_LO=int(BUILD)%256")',
},
'includes': [
# Bring in the source file lists.
@ -792,6 +792,8 @@
'libcef/browser/browser_settings.h',
'libcef/browser/browser_urlrequest_impl.cc',
'libcef/browser/browser_urlrequest_impl.h',
'libcef/browser/chrome_scheme_handler.cc',
'libcef/browser/chrome_scheme_handler.h',
'libcef/browser/content_browser_client.cc',
'libcef/browser/content_browser_client.h',
'libcef/browser/context.cc',
@ -810,6 +812,8 @@
'libcef/browser/download_manager_delegate.h',
'libcef/browser/frame_host_impl.cc',
'libcef/browser/frame_host_impl.h',
'libcef/browser/internal_scheme_handler.cc',
'libcef/browser/internal_scheme_handler.h',
'libcef/browser/javascript_dialog.h',
'libcef/browser/javascript_dialog_creator.cc',
'libcef/browser/javascript_dialog_creator.h',
@ -830,6 +834,8 @@
'libcef/browser/resource_request_job.cc',
'libcef/browser/resource_request_job.h',
'libcef/browser/scheme_impl.cc',
'libcef/browser/scheme_registration.cc',
'libcef/browser/scheme_registration.h',
'libcef/browser/sqlite_diagnostics_stub.cc',
'libcef/browser/stream_impl.cc',
'libcef/browser/stream_impl.h',

View File

@ -12,6 +12,7 @@
#include "libcef/browser/context.h"
#include "libcef/browser/devtools_delegate.h"
#include "libcef/browser/navigate_params.h"
#include "libcef/browser/scheme_registration.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/url_request_context_getter.h"
#include "libcef/browser/url_request_context_getter_proxy.h"
@ -1223,6 +1224,10 @@ void CefBrowserHostImpl::DidFinishLoad(
CefRefPtr<CefFrame> frame = GetOrCreateFrame(frame_id,
CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(),
validated_url);
// Give internal scheme handlers an opportunity to update content.
scheme::DidFinishLoad(frame, validated_url);
OnLoadEnd(frame, validated_url);
}

View File

@ -0,0 +1,344 @@
// Copyright (c) 2012 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.
#include "libcef/browser/chrome_scheme_handler.h"
#include <map>
#include <string>
#include "include/cef_version.h"
#include "include/cef_web_plugin.h"
#include "libcef/browser/context.h"
#include "libcef/browser/internal_scheme_handler.h"
#include "base/command_line.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "content/public/common/content_client.h"
#include "grit/cef_resources.h"
#include "v8/include/v8.h"
#include "webkit/user_agent/user_agent_util.h"
namespace scheme {
const char kChromeScheme[] = "chrome";
const char kChromeURL[] = "chrome://";
namespace {
const char kChromeCreditsDomain[] = "credits";
const char kChromeLicenseDomain[] = "license";
const char kChromeVersionDomain[] = "version";
enum ChromeDomain {
CHROME_UNKNOWN = 0,
CHROME_CREDITS,
CHROME_LICENSE,
CHROME_VERSION,
};
ChromeDomain GetChromeDomain(const std::string& domain_name) {
static struct {
const char* name;
ChromeDomain domain;
} domains[] = {
{ kChromeCreditsDomain, CHROME_CREDITS },
{ kChromeLicenseDomain, CHROME_LICENSE },
{ kChromeVersionDomain, CHROME_VERSION },
};
for (size_t i = 0; i < sizeof(domains) / sizeof(domains[0]); ++i) {
if (base::strcasecmp(domains[i].name, domain_name.c_str()) == 0)
return domains[i].domain;
}
return CHROME_UNKNOWN;
}
std::string GetOSType() {
#if defined(OS_WIN)
return "Windows";
#elif defined(OS_MACOSX)
return "Mac OS X";
#elif defined(OS_CHROMEOS)
return "Chromium OS";
#elif defined(OS_ANDROID)
return "Android";
#elif defined(OS_LINUX)
return "Linux";
#elif defined(OS_FREEBSD)
return "FreeBSD";
#elif defined(OS_OPENBSD)
return "OpenBSD";
#elif defined(OS_SOLARIS)
return "Solaris";
#else
return "Unknown";
#endif
}
std::string GetCommandLine() {
#if defined(OS_WIN)
return WideToUTF8(CommandLine::ForCurrentProcess()->GetCommandLineString());
#elif defined(OS_POSIX)
std::string command_line = "";
typedef std::vector<std::string> ArgvList;
const ArgvList& argv = CommandLine::ForCurrentProcess()->argv();
for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
command_line += " " + *iter;
// TODO(viettrungluu): |command_line| could really have any encoding, whereas
// below we assumes it's UTF-8.
return command_line;
#endif
}
std::string GetModulePath() {
FilePath path;
if (PathService::Get(base::FILE_MODULE, &path))
return CefString(path.value());
return std::string();
}
class TemplateParser {
public:
TemplateParser()
: ident_start_("$$"),
ident_end_("$$") {
}
TemplateParser(const std::string& ident_start,
const std::string& ident_end)
: ident_start_(ident_start),
ident_end_(ident_end) {
}
void Add(const std::string& key, const std::string& value) {
values_.insert(std::make_pair(key, value));
}
void Parse(std::string* tmpl) {
int start_pos, end_pos = 0;
int ident_start_len = ident_start_.length();
int ident_end_len = ident_end_.length();
while(true) {
start_pos = tmpl->find(ident_start_, end_pos);
if (start_pos >= 0) {
end_pos = tmpl->find(ident_end_, start_pos + ident_start_len);
if (end_pos >= 0) {
// Found an identifier. Check if a substitution exists.
std::string key = tmpl->substr(start_pos + ident_start_len,
end_pos - start_pos - ident_start_len);
KeyMap::const_iterator it = values_.find(key);
if (it != values_.end()) {
// Peform the substitution.
tmpl->replace(start_pos, end_pos + ident_end_len - start_pos,
it->second);
end_pos = start_pos + it->second.length();
} else {
// Leave the unknown identifier in place.
end_pos += ident_end_len;
}
if (end_pos >= static_cast<int>(tmpl->length()) - ident_start_len -
ident_end_len) {
// Not enough room remaining for more identifiers.
break;
}
} else {
// No end identifier found.
break;
}
} else {
// No start identifier found.
break;
}
}
}
private:
typedef std::map<std::string, std::string> KeyMap;
KeyMap values_;
std::string ident_start_;
std::string ident_end_;
};
class Delegate : public InternalHandlerDelegate {
public:
Delegate() {}
virtual bool OnRequest(CefRefPtr<CefRequest> request,
Action* action) OVERRIDE {
GURL url = GURL(request->GetURL().ToString());
std::string path = url.path();
if (path.length() > 0)
path = path.substr(1);
bool handled = false;
ChromeDomain domain = GetChromeDomain(url.host());
switch (domain) {
case CHROME_CREDITS:
handled = OnCredits(path, action);
break;
case CHROME_LICENSE:
handled = OnLicense(action);
break;
case CHROME_VERSION:
handled = OnVersion(action);
break;
default:
break;
}
if (!handled && domain != CHROME_VERSION) {
action->redirect_url =
GURL(std::string(kChromeURL) + kChromeVersionDomain);
}
return true;
}
bool OnCredits(const std::string& path, Action* action) {
if (path == "credits.js") {
action->resource_id = IDR_CEF_CREDITS_JS;
} else if (path == "swiftshader.jpg") {
action->resource_id = IDR_CEF_CREDITS_SWIFTSHADER_JPG;
} else {
action->mime_type = "text/html";
action->resource_id = IDR_CEF_CREDITS_HTML;
}
return true;
}
bool OnLicense(Action* action) {
base::StringPiece piece = content::GetContentClient()->GetDataResource(
IDR_CEF_LICENSE_TXT, ui::SCALE_FACTOR_NONE);
if (piece.empty()) {
NOTREACHED() << "Failed to load license txt resource.";
return false;
}
std::string html = "<html><head><title>License</title></head><body><pre>" +
piece.as_string() + "</pre></body></html>";
action->mime_type = "text/html";
action->stream = CefStreamReader::CreateForData(
const_cast<char*>(html.c_str()), html.length());
action->stream_size = html.length();
return true;
}
bool OnVersion(Action* action) {
base::StringPiece piece = content::GetContentClient()->GetDataResource(
IDR_CEF_VERSION_HTML, ui::SCALE_FACTOR_NONE);
if (piece.empty()) {
NOTREACHED() << "Failed to load version html resource.";
return false;
}
TemplateParser parser;
parser.Add("YEAR", MAKE_STRING(COPYRIGHT_YEAR));
parser.Add("CEF",
base::StringPrintf("%d.%d.%d",
CEF_VERSION_MAJOR,
CHROME_VERSION_BUILD,
CEF_REVISION));
parser.Add("CHROMIUM",
base::StringPrintf("%d.%d.%d.%d",
CHROME_VERSION_MAJOR,
CHROME_VERSION_MINOR,
CHROME_VERSION_BUILD,
CHROME_VERSION_PATCH));
parser.Add("OS", GetOSType());
parser.Add("WEBKIT",
base::StringPrintf("%d.%d",
webkit_glue::GetWebKitMajorVersion(),
webkit_glue::GetWebKitMinorVersion()));
parser.Add("JAVASCRIPT", v8::V8::GetVersion());
parser.Add("FLASH", std::string()); // Value populated asynchronously.
parser.Add("USERAGENT", content::GetUserAgent(GURL()));
parser.Add("COMMANDLINE", GetCommandLine());
parser.Add("MODULEPATH", GetModulePath());
parser.Add("CACHEPATH", CefString(_Context->cache_path().value()));
std::string tmpl = piece.as_string();
parser.Parse(&tmpl);
action->mime_type = "text/html";
action->stream = CefStreamReader::CreateForData(
const_cast<char*>(tmpl.c_str()), tmpl.length());
action->stream_size = tmpl.length();
return true;
}
};
void DidFinishChromeVersionLoad(CefRefPtr<CefFrame> frame) {
// Retieve Flash version information and update asynchronously.
class Visitor : public CefWebPluginInfoVisitor {
public:
Visitor(CefRefPtr<CefFrame> frame)
: frame_(frame) {
}
virtual bool Visit(CefRefPtr<CefWebPluginInfo> info,
int count, int total) OVERRIDE {
std::string name = info->GetName();
if (name == "Shockwave Flash") {
if (frame_->IsValid()) {
std::string version = info->GetVersion();
frame_->ExecuteJavaScript(
"document.getElementById('flash').innerText = '" + version + "';",
std::string(), 0);
}
return false;
}
return true;
}
private:
CefRefPtr<CefFrame> frame_;
IMPLEMENT_REFCOUNTING(Visitor);
};
CefVisitWebPluginInfo(new Visitor(frame));
}
} // namespace
void RegisterChromeHandler() {
CefRegisterSchemeHandlerFactory(
kChromeScheme,
std::string(),
CreateInternalHandlerFactory(
make_scoped_ptr<InternalHandlerDelegate>(new Delegate())));
}
bool WillHandleBrowserAboutURL(GURL* url,
content::BrowserContext* browser_context) {
std::string text = url->possibly_invalid_spec();
if (text.find("about:") == 0 && text != "about:blank" && text.length() > 6) {
// Redirect about: URLs to chrome://
*url = GURL(kChromeURL + text.substr(6));
}
// Allow the redirection to proceed.
return false;
}
void DidFinishChromeLoad(CefRefPtr<CefFrame> frame,
const GURL& validated_url) {
ChromeDomain domain = GetChromeDomain(validated_url.host());
switch (domain) {
case CHROME_VERSION:
DidFinishChromeVersionLoad(frame);
default:
break;
}
}
} // namespace scheme

View File

@ -0,0 +1,35 @@
// Copyright (c) 2012 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.
#ifndef CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_
#define CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_
#pragma once
#include <string>
#include "include/cef_frame.h"
#include "googleurl/src/gurl.h"
namespace content {
class BrowserContext;
}
namespace scheme {
extern const char kChromeScheme[];
extern const char kChromeURL[];
// Register the chrome scheme handler.
void RegisterChromeHandler();
// Used to redirect about: URLs to chrome: URLs.
bool WillHandleBrowserAboutURL(GURL* url,
content::BrowserContext* browser_context);
// Used to fire any asynchronous content updates.
void DidFinishChromeLoad(CefRefPtr<CefFrame> frame,
const GURL& validated_url);
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_

View File

@ -11,6 +11,7 @@
#include "libcef/browser/browser_main.h"
#include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/browser_settings.h"
#include "libcef/browser/chrome_scheme_handler.h"
#include "libcef/browser/context.h"
#include "libcef/browser/resource_dispatcher_host_delegate.h"
#include "libcef/browser/thread_util.h"
@ -23,6 +24,7 @@
#include "base/path_service.h"
#include "content/browser/plugin_service_impl.h"
#include "content/public/browser/access_token_store.h"
#include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/media_observer.h"
#include "content/public/browser/plugin_service_filter.h"
#include "content/public/browser/quota_permission_context.h"
@ -328,6 +330,13 @@ void CefContentBrowserClient::OverrideWebkitPrefs(
BrowserToWebSettings(browser->settings(), *prefs);
}
void CefContentBrowserClient::BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) {
// Used to redirect about: URLs to chrome: URLs.
handler->AddHandlerPair(&scheme::WillHandleBrowserAboutURL,
content::BrowserURLHandler::null_handler());
}
std::string CefContentBrowserClient::GetDefaultDownloadName() {
return "download";
}

View File

@ -46,6 +46,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
const GURL& url,
webkit_glue::WebPreferences* prefs) OVERRIDE;
virtual void BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) OVERRIDE;
virtual std::string GetDefaultDownloadName() OVERRIDE;
#if defined(OS_WIN)
const wchar_t* GetResourceDllName() OVERRIDE;

View File

@ -8,7 +8,7 @@
#include "libcef/browser/browser_main.h"
#include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/devtools_scheme_handler.h"
#include "libcef/browser/scheme_registration.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/main_delegate.h"
@ -359,8 +359,8 @@ CefDevToolsDelegate* CefContext::devtools_delegate() const {
void CefContext::OnContextInitialized() {
CEF_REQUIRE_UIT();
// Perform DevTools scheme registration.
RegisterDevToolsSchemeHandler();
// Register internal scheme handlers.
scheme::RegisterInternalHandlers();
// Notify the handler.
CefRefPtr<CefApp> app = application();

View File

@ -124,7 +124,7 @@ bool CefDevToolsDelegate::BundlesFrontendResources() {
}
std::string CefDevToolsDelegate::GetFrontendResourcesBaseURL() {
return kChromeDevToolsURL;
return scheme::kChromeDevToolsURL;
}
std::string CefDevToolsDelegate::GetDevToolsURL(content::RenderViewHost* rvh,
@ -140,8 +140,8 @@ std::string CefDevToolsDelegate::GetDevToolsURL(content::RenderViewHost* rvh,
std::string page_id = binding_->GetIdentifier(rvh);
std::string host = http_scheme ?
base::StringPrintf("http://localhost:%d/devtools/", port) :
kChromeDevToolsURL;
scheme::kChromeDevToolsURL;
return base::StringPrintf(
"%sdevtools.html?ws=localhost:%d/devtools/page/%s",
host.c_str(),

View File

@ -1,25 +1,14 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Copyright (c) 2012 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.
#include "libcef/browser/devtools_scheme_handler.h"
#include <string>
#include "include/cef_browser.h"
#include "include/cef_request.h"
#include "include/cef_resource_handler.h"
#include "include/cef_response.h"
#include "include/cef_scheme.h"
#include "include/cef_stream.h"
#include "include/cef_url.h"
#include "base/file_util.h"
#include "libcef/browser/internal_scheme_handler.h"
#include "base/string_util.h"
#include "content/public/common/content_client.h"
#include "grit/devtools_resources_map.h"
#include "ui/base/resource/resource_bundle.h"
namespace scheme {
const char kChromeDevToolsScheme[] = "chrome-devtools";
const char kChromeDevToolsHost[] = "devtools";
@ -27,119 +16,37 @@ const char kChromeDevToolsURL[] = "chrome-devtools://devtools/";
namespace {
static std::string PathWithoutParams(const std::string& path) {
size_t query_position = path.find("?");
if (query_position != std::string::npos)
return path.substr(0, query_position);
return path;
}
static std::string GetMimeType(const std::string& filename) {
if (EndsWith(filename, ".html", false)) {
return "text/html";
} else if (EndsWith(filename, ".css", false)) {
return "text/css";
} else if (EndsWith(filename, ".js", false)) {
return "application/javascript";
} else if (EndsWith(filename, ".png", false)) {
return "image/png";
} else if (EndsWith(filename, ".gif", false)) {
return "image/gif";
}
NOTREACHED();
return "text/plain";
}
class DevToolsSchemeHandler : public CefResourceHandler {
class Delegate : public InternalHandlerDelegate {
public:
DevToolsSchemeHandler(const std::string& path,
CefRefPtr<CefStreamReader> reader,
int size)
: path_(path), reader_(reader), size_(size) {
}
Delegate() {}
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback)
OVERRIDE {
callback->Continue();
return true;
}
virtual bool OnRequest(CefRefPtr<CefRequest> request,
Action* action) OVERRIDE {
GURL url = GURL(request->GetURL().ToString());
std::string path = url.path();
if (path.length() > 0)
path = path.substr(1);
virtual void GetResponseHeaders(CefRefPtr<CefResponse> response,
int64& response_length,
CefString& redirectUrl) OVERRIDE {
response_length = size_;
response->SetMimeType(GetMimeType(path_));
response->SetStatus(200);
}
virtual bool ReadResponse(void* data_out,
int bytes_to_read,
int& bytes_read,
CefRefPtr<CefCallback> callback)
OVERRIDE {
bytes_read = reader_->Read(data_out, 1, bytes_to_read);
return (bytes_read > 0);
}
virtual void Cancel() OVERRIDE {
}
private:
std::string path_;
CefRefPtr<CefStreamReader> reader_;
int size_;
IMPLEMENT_REFCOUNTING(DevToolSSchemeHandler);
};
class DevToolsSchemeHandlerFactory : public CefSchemeHandlerFactory {
public:
DevToolsSchemeHandlerFactory() {}
virtual CefRefPtr<CefResourceHandler> Create(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& scheme_name,
CefRefPtr<CefRequest> request) OVERRIDE {
std::string url = PathWithoutParams(request->GetURL());
const char* path = &url.c_str()[strlen(kChromeDevToolsURL)];
int size = -1;
CefRefPtr<CefStreamReader> reader = GetStreamReader(path, size);
if (!reader.get())
return NULL;
return new DevToolsSchemeHandler(path, reader, size);
}
CefRefPtr<CefStreamReader> GetStreamReader(const char* path, int& size) {
// Create a stream for the grit resource.
for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) {
if (base::strcasecmp(kDevtoolsResources[i].name, path) == 0) {
base::StringPiece piece =
content::GetContentClient()->GetDataResource(
kDevtoolsResources[i].value, ui::SCALE_FACTOR_NONE);
if (!piece.empty()) {
size = piece.size();
return CefStreamReader::CreateForData(const_cast<char*>(piece.data()),
size);
}
if (base::strcasecmp(kDevtoolsResources[i].name,
path.c_str()) == 0) {
action->resource_id = kDevtoolsResources[i].value;
return true;
}
}
NOTREACHED() << "Missing DevTools resource: " << path;
return NULL;
return false;
}
IMPLEMENT_REFCOUNTING(DevToolSSchemeHandlerFactory);
};
} // namespace
// Register the DevTools scheme handler.
void RegisterDevToolsSchemeHandler() {
CefRegisterSchemeHandlerFactory(kChromeDevToolsScheme, kChromeDevToolsHost,
new DevToolsSchemeHandlerFactory());
void RegisterChromeDevToolsHandler() {
CefRegisterSchemeHandlerFactory(
kChromeDevToolsScheme,
kChromeDevToolsHost,
CreateInternalHandlerFactory(
make_scoped_ptr<InternalHandlerDelegate>(new Delegate())));
}
} // namespace scheme

View File

@ -6,11 +6,15 @@
#define CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_
#pragma once
namespace scheme {
extern const char kChromeDevToolsScheme[];
extern const char kChromeDevToolsHost[];
extern const char kChromeDevToolsURL[];
// Register the DevTools scheme handler.
void RegisterDevToolsSchemeHandler();
// Register the chrome-devtools scheme handler.
void RegisterChromeDevToolsHandler();
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_

View File

@ -0,0 +1,178 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/internal_scheme_handler.h"
#include <string>
#include "base/string_util.h"
#include "content/public/common/content_client.h"
#include "ui/base/resource/resource_bundle.h"
namespace scheme {
namespace {
static std::string GetMimeType(const std::string& filename) {
if (EndsWith(filename, ".html", false)) {
return "text/html";
} else if (EndsWith(filename, ".css", false)) {
return "text/css";
} else if (EndsWith(filename, ".jpg", false)) {
return "image/jpeg";
} else if (EndsWith(filename, ".js", false)) {
return "application/javascript";
} else if (EndsWith(filename, ".png", false)) {
return "image/png";
} else if (EndsWith(filename, ".gif", false)) {
return "image/gif";
}
NOTREACHED() << "No known mime type for file: " << filename.c_str();
return "text/plain";
}
class RedirectHandler : public CefResourceHandler {
public:
explicit RedirectHandler(const GURL& url)
: url_(url) {
}
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback) OVERRIDE {
callback->Continue();
return true;
}
virtual void GetResponseHeaders(CefRefPtr<CefResponse> response,
int64& response_length,
CefString& redirectUrl) OVERRIDE {
response_length = 0;
redirectUrl = url_.spec();
}
virtual bool ReadResponse(void* data_out,
int bytes_to_read,
int& bytes_read,
CefRefPtr<CefCallback> callback) OVERRIDE {
return false;
}
virtual void Cancel() OVERRIDE {
}
private:
GURL url_;
IMPLEMENT_REFCOUNTING(RedirectHandler);
};
class InternalHandler : public CefResourceHandler {
public:
InternalHandler(const std::string& mime_type,
CefRefPtr<CefStreamReader> reader,
int size)
: mime_type_(mime_type),
reader_(reader),
size_(size) {
}
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback) OVERRIDE {
callback->Continue();
return true;
}
virtual void GetResponseHeaders(CefRefPtr<CefResponse> response,
int64& response_length,
CefString& redirectUrl) OVERRIDE {
response_length = size_;
response->SetMimeType(mime_type_);
response->SetStatus(200);
}
virtual bool ReadResponse(void* data_out,
int bytes_to_read,
int& bytes_read,
CefRefPtr<CefCallback> callback) OVERRIDE {
bytes_read = reader_->Read(data_out, 1, bytes_to_read);
return (bytes_read > 0);
}
virtual void Cancel() OVERRIDE {
}
private:
std::string mime_type_;
CefRefPtr<CefStreamReader> reader_;
int size_;
IMPLEMENT_REFCOUNTING(InternalHandler);
};
class InternalHandlerFactory : public CefSchemeHandlerFactory {
public:
explicit InternalHandlerFactory(
scoped_ptr<InternalHandlerDelegate> delegate)
: delegate_(delegate.Pass()) {
}
virtual CefRefPtr<CefResourceHandler> Create(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& scheme_name,
CefRefPtr<CefRequest> request) OVERRIDE {
GURL url = GURL(request->GetURL().ToString());
InternalHandlerDelegate::Action action;
if (delegate_->OnRequest(request, &action)) {
if (!action.redirect_url.is_empty() && action.redirect_url.is_valid())
return new RedirectHandler(action.redirect_url);
if (action.mime_type.empty())
action.mime_type = GetMimeType(url.path());
if (action.resource_id >= 0) {
base::StringPiece piece = content::GetContentClient()->GetDataResource(
action.resource_id, ui::SCALE_FACTOR_NONE);
if (!piece.empty()) {
action.stream =
CefStreamReader::CreateForData(const_cast<char*>(piece.data()),
piece.size());
action.stream_size = piece.size();
} else {
NOTREACHED() << "Failed to load internal resource for id: " <<
action.resource_id << " URL: " << url.spec().c_str();
return NULL;
}
}
if (action.stream.get()) {
return new InternalHandler(action.mime_type, action.stream,
action.stream_size);
}
}
return NULL;
}
private:
scoped_ptr<InternalHandlerDelegate> delegate_;
IMPLEMENT_REFCOUNTING(InternalHandlerFactory);
};
} // namespace
InternalHandlerDelegate::Action::Action()
: stream_size(-1),
resource_id(-1) {
}
CefRefPtr<CefSchemeHandlerFactory> CreateInternalHandlerFactory(
scoped_ptr<InternalHandlerDelegate> delegate) {
DCHECK(delegate.get());
return new InternalHandlerFactory(delegate.Pass());
}
} // namespace scheme

View File

@ -0,0 +1,53 @@
// Copyright (c) 2012 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.
#ifndef CEF_LIBCEF_BROWSER_INTERNAL_SCHEME_HANDLER_H_
#define CEF_LIBCEF_BROWSER_INTERNAL_SCHEME_HANDLER_H_
#pragma once
#include <string>
#include "include/cef_scheme.h"
#include "base/memory/scoped_ptr.h"
#include "googleurl/src/gurl.h"
namespace scheme {
// All methods will be called on the browser process IO thread.
class InternalHandlerDelegate {
public:
class Action {
public:
Action();
// Set to the appropriate value or leave empty to have it determined based
// on the file extension.
std::string mime_type;
// Option 1: Provide a stream for the resource contents. Set |stream_size|
// to the stream size or to -1 if unknown.
CefRefPtr<CefStreamReader> stream;
int stream_size;
// Option 2: Specify a resource id to load static content.
int resource_id;
// Option 3: Redirect to the specified URL.
GURL redirect_url;
};
virtual ~InternalHandlerDelegate() {}
// Populate |action| and return true if the request was handled.
virtual bool OnRequest(CefRefPtr<CefRequest> request,
Action* action) = 0;
};
// Create an internal scheme handler factory. The factory will take ownership of
// |delegate|.
CefRefPtr<CefSchemeHandlerFactory> CreateInternalHandlerFactory(
scoped_ptr<InternalHandlerDelegate> delegate);
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_INTERNAL_SCHEME_HANDLER_H_

View File

@ -10,8 +10,8 @@
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools_scheme_handler.h"
#include "libcef/browser/resource_request_job.h"
#include "libcef/browser/scheme_registration.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/url_request_context_getter.h"
#include "libcef/common/request_impl.h"
@ -310,8 +310,8 @@ bool CefClearSchemeHandlerFactories() {
if (CEF_CURRENTLY_ON(CEF_IOT)) {
CefUrlRequestManager::GetInstance()->ClearFactories();
// Re-register the DevTools scheme handler.
RegisterDevToolsSchemeHandler();
// Register internal scheme handlers.
scheme::RegisterInternalHandlers();
} else {
CEF_POST_TASK(CEF_IOT,
base::Bind(base::IgnoreResult(&CefClearSchemeHandlerFactories)));

View File

@ -0,0 +1,44 @@
// Copyright (c) 2012 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.
#include "libcef/browser/scheme_registration.h"
#include "libcef/browser/chrome_scheme_handler.h"
#include "libcef/browser/devtools_scheme_handler.h"
#include "libcef/renderer/content_renderer_client.h"
namespace scheme {
void AddStandardSchemes(std::vector<std::string>* standard_schemes) {
static struct {
const char* name;
bool is_local;
bool is_display_isolated;
} schemes[] = {
{ scheme::kChromeScheme, true, true },
{ scheme::kChromeDevToolsScheme, true, false }
};
for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i)
standard_schemes->push_back(schemes[i].name);
if (CefContentRendererClient::Get()) {
// Running in single-process mode. Register the schemes with WebKit.
for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) {
CefContentRendererClient::Get()->AddCustomScheme(
schemes[i].name, schemes[i].is_local, schemes[i].is_display_isolated);
}
}
}
void RegisterInternalHandlers() {
scheme::RegisterChromeHandler();
scheme::RegisterChromeDevToolsHandler();
}
void DidFinishLoad(CefRefPtr<CefFrame> frame, const GURL& validated_url) {
if (validated_url.scheme() == scheme::kChromeScheme)
scheme::DidFinishChromeLoad(frame, validated_url);
}
} // namespace scheme

View File

@ -0,0 +1,27 @@
// Copyright (c) 2012 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.
#ifndef CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_
#define CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_
#pragma once
#include <string>
#include <vector>
#include "include/cef_frame.h"
#include "googleurl/src/gurl.h"
namespace scheme {
// Add all standard schemes.
void AddStandardSchemes(std::vector<std::string>* standard_schemes);
// Register all internal scheme handlers.
void RegisterInternalHandlers();
// Used to fire any asynchronous content updates.
void DidFinishLoad(CefRefPtr<CefFrame> frame, const GURL& validated_url);
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_

View File

@ -5,10 +5,9 @@
#include "libcef/common/content_client.h"
#include "include/cef_stream.h"
#include "include/cef_version.h"
#include "libcef/browser/devtools_scheme_handler.h"
#include "libcef/browser/scheme_registration.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/scheme_registrar_impl.h"
#include "libcef/renderer/content_renderer_client.h"
#include "base/command_line.h"
#include "base/logging.h"
@ -54,12 +53,7 @@ void CefContentClient::AddAdditionalSchemes(
DCHECK(schemeRegistrar->VerifyRefCount());
}
standard_schemes->push_back(kChromeDevToolsScheme);
if (CefContentRendererClient::Get()) {
// Register the DevTools scheme with WebKit.
CefContentRendererClient::Get()->AddCustomScheme(kChromeDevToolsScheme,
true, false);
}
scheme::AddStandardSchemes(standard_schemes);
}
std::string CefContentClient::GetUserAgent() const {

View File

@ -0,0 +1,123 @@
<!DOCTYPE HTML>
<!--
about:version template page
-->
<html id="t" i18n-values="dir:textdirection;">
<head>
<title>About Version</title>
<style>/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
body {
background-color: white;
color: black;
font-family: Helvetica,Arial,sans-serif;
margin: 0;
}
#outer {
margin-left: auto;
margin-right: auto;
margin-top: 10px;
width: 820px;
}
#inner {
padding-top: 10px;
width: 550px;
}
.label {
-webkit-padding-end: 5px;
font-size: 0.9em;
font-weight: bold;
text-align: end;
white-space: nowrap;
}
.label:after {
content: ':';
}
#logo {
float: right;
margin-left: 40px;
text-align: right;
width: 200px;
}
#company {
font-size: 0.7em;
text-align: right;
}
#copyright {
font-size: 0.7em;
text-align: right;
}
.value {
font-family: monospace;
max-width: 430px;
padding-left: 5px;
}
</style>
</head>
<body>
<div id="outer">
<div id="logo">
<div id="company">Chromium Embedded Framework (CEF)</div>
<div id="copyright">Copyright &copy; $$YEAR$$ The Chromium Embedded Framework Authors.<br/>All rights reserved.<br/><a href="chrome://license">license</a> | <a href="chrome://credits">credits</a></div>
</div>
<table id="inner" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="label" valign="top">CEF</td>
<td class="value">$$CEF$$</td>
</tr>
<tr>
<td class="label" valign="top">Chromium</td>
<td class="value">$$CHROMIUM$$</td>
</tr>
<tr>
<td class="label" valign="top">OS</td>
<td class="value">$$OS$$</td>
</tr>
<tr>
<td class="label" valign="top">WebKit</td>
<td class="value">$$WEBKIT$$</td>
</tr>
<tr>
<td class="label" valign="top">JavaScript</td>
<td class="value">$$JAVASCRIPT$$</td>
</tr>
<tr><td class="label" valign="top">Flash</td>
<td class="value" id="flash">$$FLASH$$</td>
</tr>
<tr>
<td class="label" valign="top">User Agent</td>
<td class="value">$$USERAGENT$$</td>
</tr>
<tr>
<td class="label" valign="top">Command Line</td>
<td class="value">$$COMMANDLINE$$</td>
</tr>
<tr>
<td class="label" valign="top">Module Path</td>
<td class="value">$$MODULEPATH$$</td>
</tr>
<tr>
<td class="label" valign="top">Cache Path</td>
<td class="value">$$CACHEPATH$$</td>
</tr>
</table>
</div>
</body>
</html>

View File

@ -10,6 +10,11 @@
<release seq="1">
<includes>
<include name="IDR_CEF_DEVTOOLS_DISCOVERY_PAGE" file="devtools_discovery_page.html" type="BINDATA" />
<include name="IDR_CEF_CREDITS_HTML" file="..\..\..\chrome\browser\resources\about_credits.html" type="BINDATA" />
<include name="IDR_CEF_CREDITS_JS" file="..\..\..\chrome\browser\resources\about_credits.js" type="BINDATA" />
<include name="IDR_CEF_CREDITS_SWIFTSHADER_JPG" file="..\..\..\chrome\browser\resources\swiftshader.jpg" type="BINDATA" />
<include name="IDR_CEF_LICENSE_TXT" file="..\..\LICENSE.txt" type="BINDATA" />
<include name="IDR_CEF_VERSION_HTML" file="about_version.html" type="BINDATA" />
</includes>
</release>
</grit>

View File

@ -95,8 +95,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,CHROME_VERSION_BUILD,CEF_REVISION,0
PRODUCTVERSION 3,CHROME_VERSION_BUILD,CEF_REVISION,0
FILEVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0
PRODUCTVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -112,12 +112,12 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "Chromium Embedded Framework (CEF) Dynamic Link Library"
VALUE "FileVersion", "3." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
VALUE "FileVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
VALUE "InternalName", "libcef"
VALUE "LegalCopyright", "Copyright (C) " MAKE_STRING(COPYRIGHT_YEAR) " The Chromium Embedded Framework Authors"
VALUE "OriginalFilename", "libcef.dll"
VALUE "ProductName", "Chromium Embedded Framework (CEF) Dynamic Link Library"
VALUE "ProductVersion", "3." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
VALUE "ProductVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
END
END
BLOCK "VarFileInfo"

View File

@ -109,3 +109,11 @@ def make_dir(name, quiet = True):
def get_files(search_glob):
""" Returns all files matching the search glob. """
return iglob(search_glob)
def read_version_file(file, args):
""" Read and parse a version file (key=value pairs, one per line). """
lines = read_file(file).split("\n")
for line in lines:
parts = line.split('=', 1)
if len(parts) == 2:
args[parts[0]] = parts[1]

View File

@ -16,7 +16,8 @@ RunAction(cef_dir, gyper)
print "\nGenerating CEF version header file..."
gyper = [ 'python', 'tools/make_version_header.py',
'--header', 'include/cef_version.h',
'--version', '../chrome/VERSION' ]
'--cef_version', 'VERSION',
'--chrome_version', '../chrome/VERSION' ]
RunAction(cef_dir, gyper)
print "\nPatching build configuration and source files for CEF..."

View File

@ -1,470 +1,467 @@
# 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('--no-symbols',
action='store_true', dest='nosymbols', default=False,
help='do not create symbol files')
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))
# src directory
src_dir = os.path.abspath(os.path.join(cef_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 = '3.'+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)
if not options.nosymbols:
# 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
build_dir = os.path.join(src_dir, 'build/Debug');
if not options.allowpartial or path_exists(build_dir):
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(build_dir, '*.dll'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, '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(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet)
else:
sys.stderr.write("No Debug build files.\n")
# transfer build/Release files
build_dir = os.path.join(src_dir, 'build/Release');
if not options.allowpartial or path_exists(build_dir):
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(build_dir, '*.dll'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, '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(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet)
if not options.nosymbols:
# transfer symbols
copy_file(os.path.join(build_dir, '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_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac_helper'], \
'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
build_dir = os.path.join(src_dir, 'xcodebuild/Debug')
if not options.allowpartial or path_exists(build_dir):
dst_dir = os.path.join(output_dir, 'Debug')
make_dir(dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet)
else:
build_dir = None
# transfer xcodebuild/Release files
build_dir = os.path.join(src_dir, 'xcodebuild/Release')
if not options.allowpartial or path_exists(build_dir):
dst_dir = os.path.join(output_dir, 'Release')
make_dir(dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet)
if not options.nosymbols:
# create the real dSYM file from the "fake" dSYM file
sys.stdout.write("Creating the real dSYM file...\n")
src_path = os.path.join(build_dir, '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)
else:
build_dir = None
if not build_dir is None:
# transfer resource files
dst_dir = os.path.join(output_dir, 'Resources')
make_dir(dst_dir, options.quiet)
copy_files(os.path.join(build_dir, 'cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/*.*'), \
dst_dir, options.quiet)
# 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('../../../build', 'build')
data = data.replace('../../../xcodebuild', 'xcodebuild')
write_file(src_file, data)
elif platform == 'linux':
# 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 out/Debug files
build_dir = os.path.join(src_dir, 'out/Debug');
if not options.allowpartial or path_exists(build_dir):
dst_dir = os.path.join(output_dir, 'Debug')
make_dir(dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)
else:
sys.stderr.write("No Debug build files.\n")
# transfer out/Release files
build_dir = os.path.join(src_dir, 'out/Release');
if not options.allowpartial or path_exists(build_dir):
dst_dir = os.path.join(output_dir, 'Release')
make_dir(dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, '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))
if not options.nosymbols:
# 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('--no-symbols',
action='store_true', dest='nosymbols', default=False,
help='do not create symbol files')
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))
# src directory
src_dir = os.path.abspath(os.path.join(cef_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)
args = {}
read_version_file('VERSION', args)
read_version_file('../chrome/VERSION', args)
cef_ver = args['CEF_MAJOR']+'.'+args['BUILD']+'.'+cef_rev
chromium_ver = args['MAJOR']+'.'+args['MINOR']+'.'+args['BUILD']+'.'+args['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)
if not options.nosymbols:
# 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
build_dir = os.path.join(src_dir, 'build/Debug');
if not options.allowpartial or path_exists(build_dir):
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(build_dir, '*.dll'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, '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(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet)
else:
sys.stderr.write("No Debug build files.\n")
# transfer build/Release files
build_dir = os.path.join(src_dir, 'build/Release');
if not options.allowpartial or path_exists(build_dir):
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(build_dir, '*.dll'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, '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(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet)
if not options.nosymbols:
# transfer symbols
copy_file(os.path.join(build_dir, '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_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac_helper'], \
'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
build_dir = os.path.join(src_dir, 'xcodebuild/Debug')
if not options.allowpartial or path_exists(build_dir):
dst_dir = os.path.join(output_dir, 'Debug')
make_dir(dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet)
else:
build_dir = None
# transfer xcodebuild/Release files
build_dir = os.path.join(src_dir, 'xcodebuild/Release')
if not options.allowpartial or path_exists(build_dir):
dst_dir = os.path.join(output_dir, 'Release')
make_dir(dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet)
if not options.nosymbols:
# create the real dSYM file from the "fake" dSYM file
sys.stdout.write("Creating the real dSYM file...\n")
src_path = os.path.join(build_dir, '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)
else:
build_dir = None
if not build_dir is None:
# transfer resource files
dst_dir = os.path.join(output_dir, 'Resources')
make_dir(dst_dir, options.quiet)
copy_files(os.path.join(build_dir, 'cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/*.*'), \
dst_dir, options.quiet)
# 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('../../../build', 'build')
data = data.replace('../../../xcodebuild', 'xcodebuild')
write_file(src_file, data)
elif platform == 'linux':
# 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 out/Debug files
build_dir = os.path.join(src_dir, 'out/Debug');
if not options.allowpartial or path_exists(build_dir):
dst_dir = os.path.join(output_dir, 'Debug')
make_dir(dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)
else:
sys.stderr.write("No Debug build files.\n")
# transfer out/Release files
build_dir = os.path.join(src_dir, 'out/Release');
if not options.allowpartial or path_exists(build_dir):
dst_dir = os.path.join(output_dir, 'Release')
make_dir(dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, '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))
if not options.nosymbols:
# 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))

View File

@ -1,2 +1,2 @@
@echo off
..\third_party\python_26\python.exe tools\make_version_header.py --header include\cef_version.h --version ../chrome/VERSION
..\third_party\python_26\python.exe tools\make_version_header.py --header include\cef_version.h --cef_version VERSION --chrome_version ../chrome/VERSION

View File

@ -23,7 +23,9 @@ This utility creates the version header file.
parser = OptionParser(description=disc)
parser.add_option('--header', dest='header', metavar='FILE',
help='output version header file [required]')
parser.add_option('--version', dest='version', metavar='FILE',
parser.add_option('--cef_version', dest='cef_version', metavar='FILE',
help='input CEF version config file [required]')
parser.add_option('--chrome_version', dest='chrome_version', metavar='FILE',
help='input Chrome version config file [required]')
parser.add_option('-q', '--quiet',
action='store_true', dest='quiet', default=False,
@ -31,24 +33,22 @@ parser.add_option('-q', '--quiet',
(options, args) = parser.parse_args()
# the header option is required
if options.header is None or options.version is None:
if options.header is None or options.cef_version is None or options.chrome_version is None:
parser.print_help(sys.stdout)
sys.exit()
def write_svn_header(header, version):
def write_svn_header(header, chrome_version, cef_version):
""" Creates the header file for the current revision and Chrome version information
if the information has changed or if the file doesn't already exist. """
if not path_exists(version):
raise Exception('Version file '+version+' does not exist.')
if not path_exists(chrome_version):
raise Exception('Chrome version file '+chrome_version+' does not exist.')
if not path_exists(cef_version):
raise Exception('CEF version file '+cef_version+' does not exist.')
# Read and parse the version file (key=value pairs, one per line)
chrome = {}
lines = read_file(version).split("\n")
for line in lines:
parts = line.split('=', 1)
if len(parts) == 2:
chrome[parts[0]] = parts[1]
args = {}
read_version_file(chrome_version, args)
read_version_file(cef_version, args)
if path_exists(header):
oldcontents = read_file(header)
@ -97,12 +97,13 @@ def write_svn_header(header, version):
'//\n\n'+\
'#ifndef CEF_INCLUDE_CEF_VERSION_H_\n'+\
'#define CEF_INCLUDE_CEF_VERSION_H_\n\n'+\
'#define CEF_VERSION_MAJOR ' + args['CEF_MAJOR'] + '\n'+\
'#define CEF_REVISION ' + revision + '\n'+\
'#define COPYRIGHT_YEAR ' + year + '\n\n'+\
'#define CHROME_VERSION_MAJOR ' + chrome['MAJOR'] + '\n'+\
'#define CHROME_VERSION_MINOR ' + chrome['MINOR'] + '\n'+\
'#define CHROME_VERSION_BUILD ' + chrome['BUILD'] + '\n'+\
'#define CHROME_VERSION_PATCH ' + chrome['PATCH'] + '\n\n'+\
'#define CHROME_VERSION_MAJOR ' + args['MAJOR'] + '\n'+\
'#define CHROME_VERSION_MINOR ' + args['MINOR'] + '\n'+\
'#define CHROME_VERSION_BUILD ' + args['BUILD'] + '\n'+\
'#define CHROME_VERSION_PATCH ' + args['PATCH'] + '\n\n'+\
'#define DO_MAKE_STRING(p) #p\n'+\
'#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\
'#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n'\
@ -125,7 +126,7 @@ def write_svn_header(header, version):
return False
written = write_svn_header(options.header, options.version)
written = write_svn_header(options.header, options.chrome_version, options.cef_version)
if not options.quiet:
if written:
sys.stdout.write('File '+options.header+' updated.\n')