chromium 代码分析(1)

来源:互联网 发布:淘宝小号供应商 编辑:程序博客网 时间:2024/06/04 19:42
chromium源码下载、编译后,只是偶尔调试分析下源码,为了不再浪费那块SSD,决定把chromium design documents仔细阅读一遍,同时分析源码加强理解。

chromium源代码src目录结构如下:

src/  android_webview/  apps/  ash/  base/  breakpad/  build/  cc/  chrome/  chrome_frame/  chromeos/  cloud_print/  components/  content/  courgette/  crypto/  dbus/  device/  extensions/  google_apis/  google_update/  gpu/  ios/  ipc/  jingle/  media/  mojo/  native_client_sdk/  net/  ppapi/  printing/  remoting/  rlz/  sandbox/  sdch/  skia/  sql/  sync/  testing/  third_party/  tools/  ui/  url/  webkit/  win8/

build:编译构建相关的工具支持库。 该目录下build_config.h文件定义了chromium目前支持的平台编译相关的宏,chromium工程中每个文件都包含此文件。

下面是精简后的build_config.h(删除了一些系统的支持):

// Copyright (c) 2013 by tank. All rights reserved.// Use of this source code is governed by a BSD-style license that can be// found in the LICENSE file.// This file adds defines about the platform we're currently building on.//  Operating System://    OS_WIN / OS_MACOSX / OS_IOS / OS_LINUX / OS_POSIX (MACOSX or IOS or LINUX)//  Compiler://    COMPILER_MSVC / COMPILER_GCC//  Processor://    ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)//    ARCH_CPU_32_BITS / ARCH_CPU_64_BITS#ifndef BUILD_BUILD_CONFIG_H_#define BUILD_BUILD_CONFIG_H_#if defined(__APPLE__)#include <TargetConditionals.h>  // Autoconfiguration of TARGET_ conditionals for Mac OS X and iPhone#endif// A set of macros to use for platform detection.#if defined(__APPLE__)#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE#define OS_IOS#else#define OS_MACOSX 1#endif#elif defined(__linux__)#define OS_LINUX 1  #elif defined(_WIN32)#define OS_WIN 1#else#error Please add support for your platform in build/build_config.h#endif// For access to standard POSIXish features, use OS_POSIX instead of a// more specific macro.#if defined(OS_MACOSX) || defined(OS_IOS) || defined(OS_LINUX)#define OS_POSIX 1#endif// Compiler detection.#if defined(__GNUC__)#define COMPILER_GCC 1#elif defined(_MSC_VER)#define COMPILER_MSVC 1#else#error Please add support for your compiler in build/build_config.h#endif// Processor architecture detection.  For more info on what's defined, see://   http://msdn.microsoft.com/en-us/library/b0084kay.aspx//   http://www.agner.org/optimize/calling_conventions.pdf//   or with gcc, run: "echo | gcc -E -dM -"#if defined(_M_X64) || defined(__x86_64__)#define ARCH_CPU_X86_FAMILY 1#define ARCH_CPU_X86_64 1#define ARCH_CPU_64_BITS 1#define ARCH_CPU_LITTLE_ENDIAN 1#elif defined(_M_IX86) || defined(__i386__)#define ARCH_CPU_X86_FAMILY 1#define ARCH_CPU_X86 1#define ARCH_CPU_32_BITS 1#define ARCH_CPU_LITTLE_ENDIAN 1#elif defined(__ARMEL__)#define ARCH_CPU_ARM_FAMILY 1#define ARCH_CPU_ARMEL 1#define ARCH_CPU_32_BITS 1#define ARCH_CPU_LITTLE_ENDIAN 1#elif defined(__pnacl__)#define ARCH_CPU_32_BITS 1#elif defined(__MIPSEL__)#define ARCH_CPU_MIPS_FAMILY 1#define ARCH_CPU_MIPSEL 1#define ARCH_CPU_32_BITS 1#define ARCH_CPU_LITTLE_ENDIAN 1#else#error Please add support for your architecture in build/build_config.h#endif// Type detection for wchar_t.#if defined(OS_WIN)#define WCHAR_T_IS_UTF16#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \    defined(__WCHAR_MAX__) && \    (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)#define WCHAR_T_IS_UTF32#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \    defined(__WCHAR_MAX__) && \    (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to// compile in this mode (in particular, Chrome doesn't). This is intended for// other projects using base who manage their own dependencies and make sure// short wchar works for them.#define WCHAR_T_IS_UTF16#else#error Please add support for your compiler in build/build_config.h#endif#if defined(__ARMEL__) && !defined(OS_IOS)#define WCHAR_T_IS_UNSIGNED 1#elif defined(__MIPSEL__)#define WCHAR_T_IS_UNSIGNED 0#else#error Please add support for your compiler in build/build_config.h#endif#endif  // BUILD_BUILD_CONFIG_H_