diff options
author | Kristian Monsen <kristianm@google.com> | 2010-10-22 16:03:18 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-10-25 14:24:50 +0100 |
commit | 7f92e4ca7bcb209f5d9b38cacaf3a1c6cbe493aa (patch) | |
tree | 30ce89a8ad24ad7500e31f201768fb5401b99386 | |
parent | 0a9386cf3f296ffd7a8960e96689e810e13af849 (diff) | |
download | external_chromium-7f92e4ca7bcb209f5d9b38cacaf3a1c6cbe493aa.zip external_chromium-7f92e4ca7bcb209f5d9b38cacaf3a1c6cbe493aa.tar.gz external_chromium-7f92e4ca7bcb209f5d9b38cacaf3a1c6cbe493aa.tar.bz2 |
Syncing external/chromium with chromium release 61029, base part 1
Adding/deleting files to match chromium upstream at 61029.
Mostly unused files, but sha1.cc was replaced with sha1_portable.cc
Change-Id: I3e831af60cecf618d144ba9f56fb568512cfc9b5
55 files changed, 736 insertions, 9164 deletions
@@ -69,7 +69,7 @@ LOCAL_SRC_FILES := \ base/rand_util_posix.cc \ base/ref_counted.cc \ base/safe_strerror_posix.cc \ - base/sha1.cc \ + base/sha1_portable.cc \ base/sha2.cc \ base/stats_counters.cc \ base/stats_table.cc \ diff --git a/base/SConstruct b/base/SConstruct deleted file mode 100644 index e7da122..0000000 --- a/base/SConstruct +++ /dev/null @@ -1,2 +0,0 @@ -# This file is generated; do not edit. -SConscript('base_main.scons') diff --git a/base/allocator/allocator.Makefile b/base/allocator/allocator.Makefile deleted file mode 100644 index e281107..0000000 --- a/base/allocator/allocator.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= /usr/local/google/src/chromium-merge/src/base/allocator/out -.PHONY: all -all: - $(MAKE) -C ../.. allocator diff --git a/base/allocator/allocator.target.mk b/base/allocator/allocator.target.mk deleted file mode 100644 index 06a84d6..0000000 --- a/base/allocator/allocator.target.mk +++ /dev/null @@ -1,161 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := allocator -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -pipe \ - -fno-strict-aliasing \ - -DNO_HEAP_CHECK \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := -Ibase/allocator \ - -Ithird_party/tcmalloc/chromium/src/base \ - -Ithird_party/tcmalloc/chromium/src \ - -I. - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -pipe \ - -fno-strict-aliasing \ - -DNO_HEAP_CHECK \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := -Ibase/allocator \ - -Ithird_party/tcmalloc/chromium/src/base \ - -Ithird_party/tcmalloc/chromium/src \ - -I. - -OBJS := $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/base/linuxthreads.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/base/logging.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/base/low_level_alloc.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/base/spinlock.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/base/sysinfo.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/base/thread_lister.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/base/vdso_support.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/central_freelist.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/common.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/heap-profile-table.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/heap-profiler.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/internal_logging.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/malloc_extension.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/malloc_hook.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/maybe_threads.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/memory_region_map.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/page_heap.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/profile-handler.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/profiledata.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/profiler.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/raw_printer.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/sampler.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/span.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/stack_trace_table.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/stacktrace.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/static_vars.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/symbolize.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/system-alloc.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/tcmalloc.o \ - $(obj).target/$(TARGET)/third_party/tcmalloc/chromium/src/thread_cache.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := - -$(obj).target/base/allocator/liballocator.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/base/allocator/liballocator.a: LIBS := $(LIBS) -$(obj).target/base/allocator/liballocator.a: TOOLSET := $(TOOLSET) -$(obj).target/base/allocator/liballocator.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/base/allocator/liballocator.a -# Add target alias -.PHONY: allocator -allocator: $(obj).target/base/allocator/liballocator.a - -# Add target alias to "all" target. -.PHONY: all -all: allocator - diff --git a/base/allocator/allocator_unittests.target.mk b/base/allocator/allocator_unittests.target.mk deleted file mode 100644 index 32bfc87..0000000 --- a/base/allocator/allocator_unittests.target.mk +++ /dev/null @@ -1,135 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := allocator_unittests -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DUNIT_TEST' \ - '-DGTEST_HAS_RTTI=0' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := -Ibase/allocator \ - -Ithird_party/tcmalloc/chromium/src/base \ - -Ithird_party/tcmalloc/chromium/src \ - -I. \ - -Itesting/gtest/include - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DUNIT_TEST' \ - '-DGTEST_HAS_RTTI=0' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := -Ibase/allocator \ - -Ithird_party/tcmalloc/chromium/src/base \ - -Ithird_party/tcmalloc/chromium/src \ - -I. \ - -Itesting/gtest/include - -OBJS := $(obj).target/$(TARGET)/base/allocator/unittest_utils.o \ - $(obj).target/$(TARGET)/base/allocator/allocator_unittests.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/base/allocator/liballocator.a $(obj).target/testing/libgtest.a $(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-uIsHeapProfilerRunning,-uProfilerStart \ - -Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi \ - -Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-uIsHeapProfilerRunning,-uProfilerStart \ - -Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi \ - -Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := - -$(builddir)/allocator_unittests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/allocator_unittests: LIBS := $(LIBS) -$(builddir)/allocator_unittests: TOOLSET := $(TOOLSET) -$(builddir)/allocator_unittests: $(OBJS) $(obj).target/base/allocator/liballocator.a $(obj).target/testing/libgtest.a $(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/allocator_unittests -# Add target alias -.PHONY: allocator_unittests -allocator_unittests: $(builddir)/allocator_unittests - diff --git a/base/base.Makefile b/base/base.Makefile deleted file mode 100644 index d4421bf..0000000 --- a/base/base.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= /usr/local/google/src/chromium-merge/src/base/out -.PHONY: all -all: - $(MAKE) -C .. xdg_mime symbolize base base_i18n test_support_perf test_support_base base_unittests diff --git a/base/base.scons b/base/base.scons deleted file mode 100644 index bb95fd8..0000000 --- a/base/base.scons +++ /dev/null @@ -1,603 +0,0 @@ -# This file is generated; do not edit. - -import os - -Import("env") - -env = env.Clone(COMPONENT_NAME='base', - TARGET_NAME='base') - -configurations = { - 'Debug' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-Wno-write-strings', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-I/usr/include/nss', - '-I/usr/include/nspr', - '-O0', - '-g' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - '_DEBUG' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/..') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-rdynamic' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, - 'Release' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-Wno-write-strings', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-I/usr/include/nss', - '-I/usr/include/nspr', - '-O2', - '-fno-ident', - '-fdata-sections', - '-ffunction-sections' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'NDEBUG', - 'NVALGRIND' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/..') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-Wl,--gc-sections' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, -} - -config = configurations[env['CONFIG_NAME']] -env.Append(**config['Append']) -env.FilterOut(**config['FilterOut']) -env.Replace(**config['Replace']) - -# Scons forces -fPIC for SHCCFLAGS on some platforms. -# Disable that so we can control it from cflags in gyp. -# Note that Scons itself is inconsistent with its -fPIC -# setting. SHCCFLAGS forces -fPIC, and SHCFLAGS does not. -# This will make SHCCFLAGS consistent with SHCFLAGS. -env['SHCCFLAGS'] = ['$CCFLAGS'] - -for _var in config['ImportExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env[_var] = os.environ[_var] -for _var in config['PropagateExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env['ENV'][_var] = os.environ[_var] - -env['ENV']['LD_LIBRARY_PATH'] = env.subst('$LIB_DIR') - -if ARGUMENTS.get('COVERAGE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-fprofile-arcs', - '-ftest-coverage' - ], - LINKFLAGS = [ - '-fprofile-arcs' - ], - ) - -if ARGUMENTS.get('PROFILE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-pg', - '-g' - ], - LINKFLAGS = [ - '-pg' - ], - ) - -if ARGUMENTS.get('SYMBOLS') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-g' - ], - ) - -input_files = [ - '../build/build_config.h', - 'crypto/rsa_private_key.h', - 'crypto/rsa_private_key.cc', - 'crypto/rsa_private_key_nss.cc', - 'crypto/signature_creator.h', - 'crypto/signature_creator_nss.cc', - 'crypto/signature_verifier.h', - 'crypto/signature_verifier_nss.cc', - 'third_party/dmg_fp/dmg_fp.h', - 'third_party/dmg_fp/dtoa.cc', - 'third_party/dmg_fp/g_fmt.cc', - 'third_party/icu/icu_utf.cc', - 'third_party/icu/icu_utf.h', - 'third_party/nspr/prcpucfg.h', - 'third_party/nspr/prcpucfg_win.h', - 'third_party/nspr/prtime.cc', - 'third_party/nspr/prtime.h', - 'third_party/nspr/prtypes.h', - 'third_party/nss/blapi.h', - 'third_party/nss/blapit.h', - 'third_party/nss/sha256.h', - 'third_party/nss/sha512.cc', - 'third_party/purify/pure.h', - 'third_party/xdg_mime/xdgmime.c', - 'third_party/xdg_mime/xdgmime.h', - 'third_party/xdg_mime/xdgmimealias.c', - 'third_party/xdg_mime/xdgmimealias.h', - 'third_party/xdg_mime/xdgmimecache.c', - 'third_party/xdg_mime/xdgmimecache.h', - 'third_party/xdg_mime/xdgmimeglob.c', - 'third_party/xdg_mime/xdgmimeglob.h', - 'third_party/xdg_mime/xdgmimeicon.c', - 'third_party/xdg_mime/xdgmimeicon.h', - 'third_party/xdg_mime/xdgmimeint.c', - 'third_party/xdg_mime/xdgmimeint.h', - 'third_party/xdg_mime/xdgmimemagic.c', - 'third_party/xdg_mime/xdgmimemagic.h', - 'third_party/xdg_mime/xdgmimeparent.c', - 'third_party/xdg_mime/xdgmimeparent.h', - 'atomicops_internals_x86_gcc.cc', - 'at_exit.cc', - 'at_exit.h', - 'atomic_flag.h', - 'atomic_flag.cc', - 'atomic_ref_count.h', - 'atomic_sequence_num.h', - 'atomicops.h', - 'atomicops_internals_x86_msvc.h', - 'base_drag_source.h', - 'base_drop_target.h', - 'base_paths.cc', - 'base_paths.h', - 'base_paths_linux.h', - 'base_paths_linux.cc', - 'base_paths_mac.h', - 'base_paths_win.h', - 'base_switches.cc', - 'base_switches.h', - 'basictypes.h', - 'bits.h', - 'bzip2_error_handler.cc', - 'chrome_application_mac.h', - 'cocoa_protocols_mac.h', - 'command_line.cc', - 'command_line.h', - 'compiler_specific.h', - 'condition_variable.h', - 'condition_variable_posix.cc', - 'cpu.h', - 'data_pack.cc', - 'debug_on_start.h', - 'debug_util.cc', - 'debug_util.h', - 'debug_util_posix.cc', - 'directory_watcher.h', - 'directory_watcher_inotify.cc', - 'dynamic_annotations.h', - 'dynamic_annotations.cc', - 'event_recorder.h', - 'event_recorder_stubs.cc', - 'field_trial.cc', - 'field_trial.h', - 'file_descriptor_shuffle.cc', - 'file_descriptor_shuffle.h', - 'file_path.cc', - 'file_path.h', - 'file_util.cc', - 'file_util.h', - 'file_util_linux.cc', - 'file_util_posix.cc', - 'file_version_info.h', - 'fix_wp64.h', - 'float_util.h', - 'foundation_utils_mac.h', - 'gfx/point.cc', - 'gfx/point.h', - 'gfx/rect.cc', - 'gfx/rect.h', - 'gfx/size.cc', - 'gfx/size.h', - 'global_descriptors_posix.h', - 'global_descriptors_posix.cc', - 'hash_tables.h', - 'histogram.cc', - 'histogram.h', - 'hmac.h', - 'hmac_nss.cc', - 'iat_patch.h', - 'id_map.h', - 'image_util.h', - 'json/json_reader.cc', - 'json/json_reader.h', - 'json/json_writer.cc', - 'json/json_writer.h', - 'json/string_escape.cc', - 'json/string_escape.h', - 'keyboard_code_conversion_gtk.cc', - 'keyboard_code_conversion_gtk.h', - 'keyboard_codes.h', - 'keyboard_codes_win.h', - 'keyboard_codes_posix.h', - 'lazy_instance.cc', - 'lazy_instance.h', - 'leak_annotations.h', - 'leak_tracker.h', - 'linked_list.h', - 'linked_ptr.h', - 'linux_util.cc', - 'linux_util.h', - 'lock.cc', - 'lock.h', - 'lock_impl.h', - 'lock_impl_posix.cc', - 'logging.cc', - 'logging.h', - 'mac_util.h', - 'md5.cc', - 'md5.h', - 'memory_debug.cc', - 'memory_debug.h', - 'message_loop.cc', - 'message_loop.h', - 'message_pump.h', - 'message_pump_default.cc', - 'message_pump_default.h', - 'message_pump_glib.cc', - 'message_pump_glib.h', - 'message_pump_libevent.cc', - 'message_pump_libevent.h', - 'message_pump_mac.h', - 'message_pump_win.h', - 'mime_util.h', - 'mime_util_linux.cc', - 'native_library.h', - 'native_library_linux.cc', - 'non_thread_safe.cc', - 'non_thread_safe.h', - 'nsimage_cache_mac.h', - 'nss_init.cc', - 'nss_init.h', - 'nullable_string16.h', - 'object_watcher.h', - 'observer_list.h', - 'observer_list_threadsafe.h', - 'path_service.cc', - 'path_service.h', - 'pe_image.h', - 'pickle.cc', - 'pickle.h', - 'platform_file.h', - 'platform_file_posix.cc', - 'platform_thread.h', - 'platform_thread_posix.cc', - 'port.h', - 'profiler.cc', - 'profiler.h', - 'process.h', - 'process_linux.cc', - 'process_posix.cc', - 'process_util.h', - 'process_util_linux.cc', - 'process_util_posix.cc', - 'rand_util.cc', - 'rand_util.h', - 'rand_util_posix.cc', - 'ref_counted.cc', - 'ref_counted.h', - 'ref_counted_memory.h', - 'registry.h', - 'resource_util.h', - 'safe_strerror_posix.cc', - 'safe_strerror_posix.h', - 'scoped_bool.h', - 'scoped_bstr_win.h', - 'scoped_cftyperef.h', - 'scoped_comptr_win.h', - 'scoped_handle.h', - 'scoped_handle_gtk.h', - 'scoped_handle_win.h', - 'scoped_nsautorelease_pool.h', - 'scoped_nsdisable_screen_updates.h', - 'scoped_nsobject.h', - 'scoped_ptr.h', - 'scoped_temp_dir.cc', - 'scoped_temp_dir.h', - 'scoped_variant_win.h', - 'scoped_vector.h', - 'setproctitle_linux.c', - 'setproctitle_linux.h', - 'sha1.cc', - 'sha1.h', - 'sha2.cc', - 'sha2.h', - 'shared_memory.h', - 'shared_memory_posix.cc', - 'simple_thread.cc', - 'simple_thread.h', - 'singleton.h', - 'spin_wait.h', - 'stack_container.h', - 'stats_counters.h', - 'stats_table.cc', - 'stats_table.h', - 'stl_util-inl.h', - 'string16.cc', - 'string16.h', - 'string_piece.cc', - 'string_piece.h', - 'string_tokenizer.h', - 'string_util.cc', - 'string_util.h', - 'string_util_win.h', - 'sys_info.h', - 'sys_info_posix.cc', - 'sys_string_conversions.h', - 'sys_string_conversions_linux.cc', - 'system_monitor.cc', - 'system_monitor.h', - 'system_monitor_posix.cc', - 'task.h', - 'thread.cc', - 'thread.h', - 'thread_collision_warner.cc', - 'thread_collision_warner.h', - 'thread_local.h', - 'thread_local_posix.cc', - 'thread_local_storage.h', - 'thread_local_storage_posix.cc', - 'time.cc', - 'time.h', - 'time_posix.cc', - 'timer.cc', - 'timer.h', - 'trace_event.cc', - 'trace_event.h', - 'tracked.cc', - 'tracked.h', - 'tracked_objects.cc', - 'tracked_objects.h', - 'tuple.h', - 'utf_offset_string_conversions.cc', - 'utf_offset_string_conversions.h', - 'utf_string_conversion_utils.cc', - 'utf_string_conversion_utils.h', - 'utf_string_conversions.cc', - 'utf_string_conversions.h', - 'unix_domain_socket_posix.cc', - 'values.cc', - 'values.h', - 'version.cc', - 'version.h', - 'waitable_event.h', - 'waitable_event_posix.cc', - 'waitable_event_watcher.h', - 'waitable_event_watcher_posix.cc', - 'watchdog.cc', - 'watchdog.h', - 'weak_ptr.h', - 'win_util.h', - 'windows_message_list.h', - 'wmi_util.h', - 'worker_pool.h', - 'worker_pool_linux.cc', - 'worker_pool_linux.h', - 'worker_pool_mac.h', -] - -target_files = [] -prerequisites = [] - -_result = [] -for infile in input_files: - if env.compilable(infile): - if (type(infile) == type('') - and (infile.startswith('$SRC_DIR/base/') - or not os.path.isabs(env.subst(infile)))): - # Force files below the build directory by replacing all '..' - # elements in the path with '__': - base, ext = os.path.splitext(os.path.normpath(infile)) - base = [d == '..' and '__' or d for d in base.split('/')] - base = os.path.join(*base) - object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base - if not infile.startswith('$SRC_DIR/base/'): - infile = '$SRC_DIR/base/' + infile - infile = env.StaticObject(object, infile)[0] - else: - infile = env.StaticObject(infile)[0] - _result.append(infile) -input_files = _result - -_outputs = env.GypStaticLibrary('base', input_files) -target_files.extend(_outputs) - -gyp_target = env.Alias('base', target_files) -dependencies = [ - Alias('lastchange'), - Alias('gtk'), - Alias('nss') -] -env.Requires(target_files, dependencies) -env.Requires(gyp_target, dependencies) -for prerequisite in prerequisites: - env.Requires(prerequisite, dependencies) -env.Requires(gyp_target, prerequisites) -Return("gyp_target") diff --git a/base/base.target.mk b/base/base.target.mk deleted file mode 100644 index 566e074..0000000 --- a/base/base.target.mk +++ /dev/null @@ -1,294 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := base -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-D__STDC_FORMAT_MACROS' \ - '-DUSE_SYMBOLIZE' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -I../net/third_party/nss/ssl \ - -Inet/third_party/nss/ssl \ - -IWebKit/chromium/net/third_party/nss/ssl \ - -I/usr/include/nss \ - -I/usr/include/nspr \ - -Wno-write-strings \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := -I. - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-D__STDC_FORMAT_MACROS' \ - '-DUSE_SYMBOLIZE' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -I../net/third_party/nss/ssl \ - -Inet/third_party/nss/ssl \ - -IWebKit/chromium/net/third_party/nss/ssl \ - -I/usr/include/nss \ - -I/usr/include/nspr \ - -Wno-write-strings \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := -I. - -OBJS := $(obj).target/$(TARGET)/base/third_party/dmg_fp/dtoa.o \ - $(obj).target/$(TARGET)/base/third_party/dmg_fp/g_fmt.o \ - $(obj).target/$(TARGET)/base/third_party/icu/icu_utf.o \ - $(obj).target/$(TARGET)/base/third_party/nspr/prtime.o \ - $(obj).target/$(TARGET)/base/at_exit.o \ - $(obj).target/$(TARGET)/base/atomicops_internals_x86_gcc.o \ - $(obj).target/$(TARGET)/base/base_paths.o \ - $(obj).target/$(TARGET)/base/base_paths_posix.o \ - $(obj).target/$(TARGET)/base/base_switches.o \ - $(obj).target/$(TARGET)/base/bzip2_error_handler.o \ - $(obj).target/$(TARGET)/base/cancellation_flag.o \ - $(obj).target/$(TARGET)/base/command_line.o \ - $(obj).target/$(TARGET)/base/condition_variable_posix.o \ - $(obj).target/$(TARGET)/base/debug_util.o \ - $(obj).target/$(TARGET)/base/debug_util_posix.o \ - $(obj).target/$(TARGET)/base/environment.o \ - $(obj).target/$(TARGET)/base/file_path.o \ - $(obj).target/$(TARGET)/base/file_util.o \ - $(obj).target/$(TARGET)/base/file_util_linux.o \ - $(obj).target/$(TARGET)/base/file_util_posix.o \ - $(obj).target/$(TARGET)/base/file_util_proxy.o \ - $(obj).target/$(TARGET)/base/global_descriptors_posix.o \ - $(obj).target/$(TARGET)/base/gtk_util.o \ - $(obj).target/$(TARGET)/base/histogram.o \ - $(obj).target/$(TARGET)/base/json/json_reader.o \ - $(obj).target/$(TARGET)/base/json/json_writer.o \ - $(obj).target/$(TARGET)/base/json/string_escape.o \ - $(obj).target/$(TARGET)/base/lazy_instance.o \ - $(obj).target/$(TARGET)/base/lock.o \ - $(obj).target/$(TARGET)/base/lock_impl_posix.o \ - $(obj).target/$(TARGET)/base/logging.o \ - $(obj).target/$(TARGET)/base/memory_debug.o \ - $(obj).target/$(TARGET)/base/message_loop.o \ - $(obj).target/$(TARGET)/base/message_loop_proxy.o \ - $(obj).target/$(TARGET)/base/message_loop_proxy_impl.o \ - $(obj).target/$(TARGET)/base/message_pump.o \ - $(obj).target/$(TARGET)/base/message_pump_default.o \ - $(obj).target/$(TARGET)/base/mime_util_xdg.o \ - $(obj).target/$(TARGET)/base/native_library_linux.o \ - $(obj).target/$(TARGET)/base/non_thread_safe.o \ - $(obj).target/$(TARGET)/base/path_service.o \ - $(obj).target/$(TARGET)/base/pickle.o \ - $(obj).target/$(TARGET)/base/platform_file_posix.o \ - $(obj).target/$(TARGET)/base/platform_thread_posix.o \ - $(obj).target/$(TARGET)/base/process_linux.o \ - $(obj).target/$(TARGET)/base/process_posix.o \ - $(obj).target/$(TARGET)/base/process_util.o \ - $(obj).target/$(TARGET)/base/process_util_linux.o \ - $(obj).target/$(TARGET)/base/process_util_posix.o \ - $(obj).target/$(TARGET)/base/profiler.o \ - $(obj).target/$(TARGET)/base/rand_util.o \ - $(obj).target/$(TARGET)/base/rand_util_posix.o \ - $(obj).target/$(TARGET)/base/ref_counted.o \ - $(obj).target/$(TARGET)/base/ref_counted_memory.o \ - $(obj).target/$(TARGET)/base/safe_strerror_posix.o \ - $(obj).target/$(TARGET)/base/scoped_temp_dir.o \ - $(obj).target/$(TARGET)/base/sha1_portable.o \ - $(obj).target/$(TARGET)/base/shared_memory_posix.o \ - $(obj).target/$(TARGET)/base/simple_thread.o \ - $(obj).target/$(TARGET)/base/stats_counters.o \ - $(obj).target/$(TARGET)/base/stats_table.o \ - $(obj).target/$(TARGET)/base/string_number_conversions.o \ - $(obj).target/$(TARGET)/base/string_piece.o \ - $(obj).target/$(TARGET)/base/string_split.o \ - $(obj).target/$(TARGET)/base/string_util.o \ - $(obj).target/$(TARGET)/base/stringprintf.o \ - $(obj).target/$(TARGET)/base/sys_info_linux.o \ - $(obj).target/$(TARGET)/base/sys_info_posix.o \ - $(obj).target/$(TARGET)/base/sys_string_conversions_linux.o \ - $(obj).target/$(TARGET)/base/task.o \ - $(obj).target/$(TARGET)/base/task_queue.o \ - $(obj).target/$(TARGET)/base/thread.o \ - $(obj).target/$(TARGET)/base/thread_checker.o \ - $(obj).target/$(TARGET)/base/thread_collision_warner.o \ - $(obj).target/$(TARGET)/base/thread_local_posix.o \ - $(obj).target/$(TARGET)/base/thread_local_storage_posix.o \ - $(obj).target/$(TARGET)/base/time.o \ - $(obj).target/$(TARGET)/base/timer.o \ - $(obj).target/$(TARGET)/base/trace_event.o \ - $(obj).target/$(TARGET)/base/tracked.o \ - $(obj).target/$(TARGET)/base/tracked_objects.o \ - $(obj).target/$(TARGET)/base/unix_domain_socket_posix.o \ - $(obj).target/$(TARGET)/base/utf_offset_string_conversions.o \ - $(obj).target/$(TARGET)/base/utf_string_conversion_utils.o \ - $(obj).target/$(TARGET)/base/utf_string_conversions.o \ - $(obj).target/$(TARGET)/base/values.o \ - $(obj).target/$(TARGET)/base/vlog.o \ - $(obj).target/$(TARGET)/base/waitable_event_posix.o \ - $(obj).target/$(TARGET)/base/waitable_event_watcher_posix.o \ - $(obj).target/$(TARGET)/base/watchdog.o \ - $(obj).target/$(TARGET)/base/weak_ptr.o \ - $(obj).target/$(TARGET)/base/worker_pool_linux.o \ - $(obj).target/$(TARGET)/base/xdg_util.o \ - $(obj).target/$(TARGET)/base/crypto/encryptor_nss.o \ - $(obj).target/$(TARGET)/base/crypto/rsa_private_key.o \ - $(obj).target/$(TARGET)/base/crypto/rsa_private_key_nss.o \ - $(obj).target/$(TARGET)/base/crypto/signature_creator_nss.o \ - $(obj).target/$(TARGET)/base/crypto/signature_verifier_nss.o \ - $(obj).target/$(TARGET)/base/crypto/symmetric_key_nss.o \ - $(obj).target/$(TARGET)/base/third_party/nss/sha512.o \ - $(obj).target/$(TARGET)/base/third_party/xdg_user_dirs/xdg_user_dir_lookup.o \ - $(obj).target/$(TARGET)/base/base64.o \ - $(obj).target/$(TARGET)/base/data_pack.o \ - $(obj).target/$(TARGET)/base/event_recorder_stubs.o \ - $(obj).target/$(TARGET)/base/field_trial.o \ - $(obj).target/$(TARGET)/base/file_descriptor_shuffle.o \ - $(obj).target/$(TARGET)/base/hmac_nss.o \ - $(obj).target/$(TARGET)/base/linux_util.o \ - $(obj).target/$(TARGET)/base/md5.o \ - $(obj).target/$(TARGET)/base/message_pump_glib.o \ - $(obj).target/$(TARGET)/base/message_pump_libevent.o \ - $(obj).target/$(TARGET)/base/nss_util.o \ - $(obj).target/$(TARGET)/base/setproctitle_linux.o \ - $(obj).target/$(TARGET)/base/sha2.o \ - $(obj).target/$(TARGET)/base/string16.o \ - $(obj).target/$(TARGET)/base/sync_socket_posix.o \ - $(obj).target/$(TARGET)/base/time_posix.o \ - $(obj).target/$(TARGET)/base/version.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/build/util/lastchange.stamp - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := - -$(obj).target/base/libbase.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/base/libbase.a: LIBS := $(LIBS) -$(obj).target/base/libbase.a: TOOLSET := $(TOOLSET) -$(obj).target/base/libbase.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/base/libbase.a -# Add target alias -.PHONY: base -base: $(obj).target/base/libbase.a - -# Add target alias to "all" target. -.PHONY: all -all: base - diff --git a/base/base_gfx.scons b/base/base_gfx.scons deleted file mode 100644 index 5b26f8f..0000000 --- a/base/base_gfx.scons +++ /dev/null @@ -1,335 +0,0 @@ -# This file is generated; do not edit. - -import os - -Import("env") - -configurations = { - 'Debug' : { - 'Append' : dict( - ASFLAGS = [ - '-32' - ], - CCFLAGS = [ - '-Werror', - '-pthread', - '-m32', - '-fno-exceptions', - '-Wall', - '-march=pentium4', - '-msse2', - '-mfpmath=sse', - '-DPNG_NO_MMX_CODE', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-O0', - '-g' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'CHROME_PNG_WRITE_SUPPORT', - 'PNG_USER_CONFIG', - '_DEBUG' - ], - CPPPATH = [ - '..', - '../skia/config', - '../third_party/skia/include/core', - '../third_party/skia/include/effects', - '../skia/ext', - '../third_party/harfbuzz/src', - '../third_party/harfbuzz/contrib', - '../third_party/libjpeg', - '../third_party/libpng', - '../third_party/zlib' - ], - CXXFLAGS = [ - '-fno-threadsafe-statics' - ], - LINKFLAGS = [ - '-pthread', - '-m32', - '-rdynamic' - ], - SHLINKFLAGS = [ - '-pthread', - '-m32', - '-rdynamic' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = 0, - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, - 'Release' : { - 'Append' : dict( - ASFLAGS = [ - '-32' - ], - CCFLAGS = [ - '-Werror', - '-pthread', - '-m32', - '-fno-exceptions', - '-Wall', - '-march=pentium4', - '-msse2', - '-mfpmath=sse', - '-DPNG_NO_MMX_CODE', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-O2', - '-fno-ident', - '-fdata-sections', - '-ffunction-sections' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'CHROME_PNG_WRITE_SUPPORT', - 'PNG_USER_CONFIG', - 'NDEBUG' - ], - CPPPATH = [ - '..', - '../skia/config', - '../third_party/skia/include/core', - '../third_party/skia/include/effects', - '../skia/ext', - '../third_party/harfbuzz/src', - '../third_party/harfbuzz/contrib', - '../third_party/libjpeg', - '../third_party/libpng', - '../third_party/zlib' - ], - CXXFLAGS = [ - '-fno-threadsafe-statics' - ], - LINKFLAGS = [ - '-pthread', - '-m32' - ], - SHLINKFLAGS = [ - '-pthread', - '-m32' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = 0, - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, -} - -env = env.Clone(COMPONENT_NAME='base', - TARGET_NAME='base_gfx') - -config = configurations[env['CONFIG_NAME']] -env.Append(**config['Append']) -env.FilterOut(**config['FilterOut']) -env.Replace(**config['Replace']) -for _var in config['ImportExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env[_var] = os.environ[_var] -for _var in config['PropagateExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env['ENV'][_var] = os.environ[_var] - -if ARGUMENTS.get('COVERAGE') not in (None, '0'): - env.Append( - CCFLAGS = [ - '-fprofile-arcs', - '-ftest-coverage' - ], - LINKFLAGS = [ - '-fprofile-arcs' - ], - SHLINKFLAGS = [ - '-fprofile-arcs' - ], - ) - -if ARGUMENTS.get('PROFILE') not in (None, '0'): - env.Append( - CCFLAGS = [ - '-pg', - '-g' - ], - LINKFLAGS = [ - '-pg' - ], - SHLINKFLAGS = [ - '-pg' - ], - ) - -if ARGUMENTS.get('SYMBOLS') not in (None, '0'): - env.Append( - CCFLAGS = [ - '-g' - ], - ) - -input_files = ChromeFileList([ - 'gfx/gdi_util.h', - 'gfx/gtk_native_view_id_manager.cc', - 'gfx/gtk_native_view_id_manager.h', - 'gfx/gtk_util.cc', - 'gfx/gtk_util.h', - 'gfx/jpeg_codec.cc', - 'gfx/jpeg_codec.h', - 'gfx/native_theme.h', - 'gfx/native_widget_types.h', - 'gfx/native_widget_types_gtk.cc', - 'gfx/png_decoder.cc', - 'gfx/png_decoder.h', - 'gfx/png_encoder.cc', - 'gfx/png_encoder.h', - 'gfx/point.cc', - 'gfx/point.h', - 'gfx/rect.cc', - 'gfx/rect.h', - 'gfx/size.cc', - 'gfx/size.h', -]) - -target_files = [] -prerequisites = [] - -_outputs = env.ChromeStaticLibrary('base_gfx', input_files) -target_files.extend(_outputs) - -gyp_target = env.Alias('base_gfx', target_files) -env.Requires(gyp_target, [ - Alias('gtk') -]) -env.Requires(gyp_target, prerequisites) -Return("gyp_target") diff --git a/base/base_i18n.scons b/base/base_i18n.scons deleted file mode 100644 index c123734..0000000 --- a/base/base_i18n.scons +++ /dev/null @@ -1,328 +0,0 @@ -# This file is generated; do not edit. - -import os - -Import("env") - -env = env.Clone(COMPONENT_NAME='base', - TARGET_NAME='base_i18n') - -configurations = { - 'Debug' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-O0', - '-g' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'U_STATIC_IMPLEMENTATION', - '_DEBUG' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/../third_party/icu/public/common'), - env.Dir('$SRC_DIR/base/../third_party/icu/public/i18n'), - env.Dir('$SRC_DIR/base/..') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-rdynamic' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, - 'Release' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-O2', - '-fno-ident', - '-fdata-sections', - '-ffunction-sections' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'U_STATIC_IMPLEMENTATION', - 'NDEBUG', - 'NVALGRIND' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/../third_party/icu/public/common'), - env.Dir('$SRC_DIR/base/../third_party/icu/public/i18n'), - env.Dir('$SRC_DIR/base/..') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-Wl,--gc-sections' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, -} - -config = configurations[env['CONFIG_NAME']] -env.Append(**config['Append']) -env.FilterOut(**config['FilterOut']) -env.Replace(**config['Replace']) - -# Scons forces -fPIC for SHCCFLAGS on some platforms. -# Disable that so we can control it from cflags in gyp. -# Note that Scons itself is inconsistent with its -fPIC -# setting. SHCCFLAGS forces -fPIC, and SHCFLAGS does not. -# This will make SHCCFLAGS consistent with SHCFLAGS. -env['SHCCFLAGS'] = ['$CCFLAGS'] - -for _var in config['ImportExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env[_var] = os.environ[_var] -for _var in config['PropagateExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env['ENV'][_var] = os.environ[_var] - -env['ENV']['LD_LIBRARY_PATH'] = env.subst('$LIB_DIR') - -if ARGUMENTS.get('COVERAGE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-fprofile-arcs', - '-ftest-coverage' - ], - LINKFLAGS = [ - '-fprofile-arcs' - ], - ) - -if ARGUMENTS.get('PROFILE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-pg', - '-g' - ], - LINKFLAGS = [ - '-pg' - ], - ) - -if ARGUMENTS.get('SYMBOLS') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-g' - ], - ) - -input_files = [ - 'i18n/file_util_icu.cc', - 'i18n/file_util_icu.h', - 'i18n/icu_string_conversions.cc', - 'i18n/icu_string_conversions.h', - 'i18n/icu_util.cc', - 'i18n/icu_util.h', - 'i18n/number_formatting.cc', - 'i18n/number_formatting.h', - 'i18n/time_formatting.cc', - 'i18n/time_formatting.h', - 'i18n/word_iterator.cc', - 'i18n/word_iterator.h', -] - -target_files = [] -prerequisites = [] - -_result = [] -for infile in input_files: - if env.compilable(infile): - if (type(infile) == type('') - and (infile.startswith('$SRC_DIR/base/') - or not os.path.isabs(env.subst(infile)))): - # Force files below the build directory by replacing all '..' - # elements in the path with '__': - base, ext = os.path.splitext(os.path.normpath(infile)) - base = [d == '..' and '__' or d for d in base.split('/')] - base = os.path.join(*base) - object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base - if not infile.startswith('$SRC_DIR/base/'): - infile = '$SRC_DIR/base/' + infile - infile = env.StaticObject(object, infile)[0] - else: - infile = env.StaticObject(infile)[0] - _result.append(infile) -input_files = _result - -_outputs = env.GypStaticLibrary('base_i18n', input_files) -target_files.extend(_outputs) - -gyp_target = env.Alias('base_i18n', target_files) -dependencies = [ - Alias('gtk') -] -env.Requires(target_files, dependencies) -env.Requires(gyp_target, dependencies) -for prerequisite in prerequisites: - env.Requires(prerequisite, dependencies) -env.Requires(gyp_target, prerequisites) -Return("gyp_target") diff --git a/base/base_i18n.target.mk b/base/base_i18n.target.mk deleted file mode 100644 index 1ceeabd..0000000 --- a/base/base_i18n.target.mk +++ /dev/null @@ -1,165 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := base_i18n -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DU_STATIC_IMPLEMENTATION' \ - '-D__STDC_FORMAT_MACROS' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := -Ithird_party/icu/public/common \ - -Ithird_party/icu/public/i18n \ - -I. - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DU_STATIC_IMPLEMENTATION' \ - '-D__STDC_FORMAT_MACROS' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := -Ithird_party/icu/public/common \ - -Ithird_party/icu/public/i18n \ - -I. - -OBJS := $(obj).target/$(TARGET)/base/i18n/char_iterator.o \ - $(obj).target/$(TARGET)/base/i18n/file_util_icu.o \ - $(obj).target/$(TARGET)/base/i18n/icu_encoding_detection.o \ - $(obj).target/$(TARGET)/base/i18n/icu_string_conversions.o \ - $(obj).target/$(TARGET)/base/i18n/icu_util.o \ - $(obj).target/$(TARGET)/base/i18n/number_formatting.o \ - $(obj).target/$(TARGET)/base/i18n/rtl.o \ - $(obj).target/$(TARGET)/base/i18n/time_formatting.o \ - $(obj).target/$(TARGET)/base/i18n/word_iterator.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := - -$(obj).target/base/libbase_i18n.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/base/libbase_i18n.a: LIBS := $(LIBS) -$(obj).target/base/libbase_i18n.a: TOOLSET := $(TOOLSET) -$(obj).target/base/libbase_i18n.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/base/libbase_i18n.a -# Add target alias -.PHONY: base_i18n -base_i18n: $(obj).target/base/libbase_i18n.a - -# Add target alias to "all" target. -.PHONY: all -all: base_i18n - diff --git a/base/base_main.scons b/base/base_main.scons deleted file mode 100644 index 96fb505..0000000 --- a/base/base_main.scons +++ /dev/null @@ -1,340 +0,0 @@ -# This file is generated; do not edit. - -__doc__ = ''' -Wrapper configuration for building this entire "solution," -including all the specific targets in various *.scons files. -''' - -import os -import sys - -import SCons.Environment -import SCons.Util - -def GetProcessorCount(): - ''' - Detects the number of CPUs on the system. Adapted form: - http://codeliberates.blogspot.com/2008/05/detecting-cpuscores-in-python.html - ''' - # Linux, Unix and Mac OS X: - if hasattr(os, 'sysconf'): - if os.sysconf_names.has_key('SC_NPROCESSORS_ONLN'): - # Linux and Unix or Mac OS X with python >= 2.5: - return os.sysconf('SC_NPROCESSORS_ONLN') - else: # Mac OS X with Python < 2.5: - return int(os.popen2("sysctl -n hw.ncpu")[1].read()) - # Windows: - if os.environ.has_key('NUMBER_OF_PROCESSORS'): - return max(int(os.environ.get('NUMBER_OF_PROCESSORS', '1')), 1) - return 1 # Default - -# Support PROGRESS= to show progress in different ways. -p = ARGUMENTS.get('PROGRESS') -if p == 'spinner': - Progress(['/\r', '|\r', '\\\r', '-\r'], - interval=5, - file=open('/dev/tty', 'w')) -elif p == 'name': - Progress('$TARGET\r', overwrite=True, file=open('/dev/tty', 'w')) - -# Set the default -j value based on the number of processors. -SetOption('num_jobs', GetProcessorCount() + 1) - -# Have SCons use its cached dependency information. -SetOption('implicit_cache', 1) - -# Only re-calculate MD5 checksums if a timestamp has changed. -Decider('MD5-timestamp') - -# Since we set the -j value by default, suppress SCons warnings about being -# unable to support parallel build on versions of Python with no threading. -default_warnings = ['no-no-parallel-support'] -SetOption('warn', default_warnings + GetOption('warn')) - -AddOption('--mode', nargs=1, dest='conf_list', default=[], - action='append', help='Configuration to build.') - -AddOption('--verbose', dest='verbose', default=False, - action='store_true', help='Verbose command-line output.') - - -# -sconscript_file_map = dict( - base = 'base.scons', - base_i18n = 'base_i18n.scons', - base_unittests = 'base_unittests.scons', - gmock = '../testing/gmock.scons', - gtest = '../testing/gtest.scons', - icudata = '../third_party/icu/icudata.scons', - icui18n = '../third_party/icu/icui18n.scons', - icuuc = '../third_party/icu/icuuc.scons', - lastchange = '../build/util/lastchange.scons', - libevent = '../third_party/libevent/libevent.scons', - linux_versioninfo = 'linux_versioninfo.scons', - test_support_base = 'test_support_base.scons', - test_support_perf = 'test_support_perf.scons', - xdisplaycheck = '../tools/xdisplaycheck/xdisplaycheck.scons', -) - -class LoadTarget: - ''' - Class for deciding if a given target sconscript is to be included - based on a list of included target names, optionally prefixed with '-' - to exclude a target name. - ''' - def __init__(self, load): - ''' - Initialize a class with a list of names for possible loading. - - Arguments: - load: list of elements in the LOAD= specification - ''' - self.included = set([c for c in load if not c.startswith('-')]) - self.excluded = set([c[1:] for c in load if c.startswith('-')]) - - if not self.included: - self.included = set(['all']) - - def __call__(self, target): - ''' - Returns True if the specified target's sconscript file should be - loaded, based on the initialized included and excluded lists. - ''' - return (target in self.included or - ('all' in self.included and not target in self.excluded)) - -if 'LOAD' in ARGUMENTS: - load = ARGUMENTS['LOAD'].split(',') -else: - load = [] -load_target = LoadTarget(load) - -sconscript_files = [] -for target, sconscript in sconscript_file_map.iteritems(): - if load_target(target): - sconscript_files.append(sconscript) - - -target_alias_list= [] - -conf_list = GetOption('conf_list') -if conf_list: - # In case the same --mode= value was specified multiple times. - conf_list = list(set(conf_list)) -else: - conf_list = ['Debug'] - -sconsbuild_dir = Dir('../sconsbuild') - - -def FilterOut(self, **kw): - kw = SCons.Environment.copy_non_reserved_keywords(kw) - for key, val in kw.items(): - envval = self.get(key, None) - if envval is None: - # No existing variable in the environment, so nothing to delete. - continue - - for vremove in val: - # Use while not if, so we can handle duplicates. - while vremove in envval: - envval.remove(vremove) - - self[key] = envval - - # TODO(sgk): SCons.Environment.Append() has much more logic to deal - # with various types of values. We should handle all those cases in here - # too. (If variable is a dict, etc.) - - -non_compilable_suffixes = { - 'LINUX' : set([ - '.bdic', - '.css', - '.dat', - '.fragment', - '.gperf', - '.h', - '.hh', - '.hpp', - '.html', - '.hxx', - '.idl', - '.in', - '.in0', - '.in1', - '.js', - '.mk', - '.rc', - '.sigs', - '', - ]), - 'WINDOWS' : set([ - '.h', - '.hh', - '.hpp', - '.dat', - '.idl', - '.in', - '.in0', - '.in1', - ]), -} - -def compilable(env, file): - base, ext = os.path.splitext(str(file)) - if ext in non_compilable_suffixes[env['TARGET_PLATFORM']]: - return False - return True - -def compilable_files(env, sources): - return [x for x in sources if compilable(env, x)] - -def GypProgram(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.Program('$TOP_BUILDDIR/' + str(target), source, *args, **kw) - if env.get('INCREMENTAL'): - env.Precious(result) - return result - -def GypTestProgram(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.Program('$TOP_BUILDDIR/' + str(target), source, *args, **kw) - if env.get('INCREMENTAL'): - env.Precious(*result) - return result - -def GypLibrary(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.Library('$LIB_DIR/' + str(target), source, *args, **kw) - return result - -def GypLoadableModule(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.LoadableModule('$TOP_BUILDDIR/' + str(target), source, *args, - **kw) - return result - -def GypStaticLibrary(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.StaticLibrary('$LIB_DIR/' + str(target), source, *args, **kw) - return result - -def GypSharedLibrary(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.SharedLibrary('$LIB_DIR/' + str(target), source, *args, **kw) - if env.get('INCREMENTAL'): - env.Precious(result) - return result - -def add_gyp_methods(env): - env.AddMethod(GypProgram) - env.AddMethod(GypTestProgram) - env.AddMethod(GypLibrary) - env.AddMethod(GypLoadableModule) - env.AddMethod(GypStaticLibrary) - env.AddMethod(GypSharedLibrary) - - env.AddMethod(FilterOut) - - env.AddMethod(compilable) - - -base_env = Environment( - tools = ['ar', 'as', 'gcc', 'g++', 'gnulink', 'chromium_builders'], - INTERMEDIATE_DIR='$OBJ_DIR/${COMPONENT_NAME}/_${TARGET_NAME}_intermediate', - LIB_DIR='$TOP_BUILDDIR/lib', - OBJ_DIR='$TOP_BUILDDIR/obj', - SCONSBUILD_DIR=sconsbuild_dir.abspath, - SHARED_INTERMEDIATE_DIR='$OBJ_DIR/_global_intermediate', - SRC_DIR=Dir('..'), - TARGET_PLATFORM='LINUX', - TOP_BUILDDIR='$SCONSBUILD_DIR/$CONFIG_NAME', - LIBPATH=['$LIB_DIR'], -) - -if not GetOption('verbose'): - base_env.SetDefault( - ARCOMSTR='Creating library $TARGET', - ASCOMSTR='Assembling $TARGET', - CCCOMSTR='Compiling $TARGET', - CONCATSOURCECOMSTR='ConcatSource $TARGET', - CXXCOMSTR='Compiling $TARGET', - LDMODULECOMSTR='Building loadable module $TARGET', - LINKCOMSTR='Linking $TARGET', - MANIFESTCOMSTR='Updating manifest for $TARGET', - MIDLCOMSTR='Compiling IDL $TARGET', - PCHCOMSTR='Precompiling $TARGET', - RANLIBCOMSTR='Indexing $TARGET', - RCCOMSTR='Compiling resource $TARGET', - SHCCCOMSTR='Compiling $TARGET', - SHCXXCOMSTR='Compiling $TARGET', - SHLINKCOMSTR='Linking $TARGET', - SHMANIFESTCOMSTR='Updating manifest for $TARGET', - ) - -add_gyp_methods(base_env) - -for conf in conf_list: - env = base_env.Clone(CONFIG_NAME=conf) - SConsignFile(env.File('$TOP_BUILDDIR/.sconsign').abspath) - for sconscript in sconscript_files: - target_alias = env.SConscript(sconscript, exports=['env']) - if target_alias: - target_alias_list.extend(target_alias) - -Default(Alias('all', target_alias_list)) - -help_fmt = ''' -Usage: hammer [SCONS_OPTIONS] [VARIABLES] [TARGET] ... - -Local command-line build options: - --mode=CONFIG Configuration to build: - --mode=Debug [default] - --mode=Release - --verbose Print actual executed command lines. - -Supported command-line build variables: - LOAD=[module,...] Comma-separated list of components to load in the - dependency graph ('-' prefix excludes) - PROGRESS=type Display a progress indicator: - name: print each evaluated target name - spinner: print a spinner every 5 targets - -The following TARGET names can also be used as LOAD= module names: - -%s -''' - -if GetOption('help'): - def columnar_text(items, width=78, indent=2, sep=2): - result = [] - colwidth = max(map(len, items)) + sep - cols = (width - indent) / colwidth - if cols < 1: - cols = 1 - rows = (len(items) + cols - 1) / cols - indent = '%*s' % (indent, '') - sep = indent - for row in xrange(0, rows): - result.append(sep) - for i in xrange(row, len(items), rows): - result.append('%-*s' % (colwidth, items[i])) - sep = '\n' + indent - result.append('\n') - return ''.join(result) - - load_list = set(sconscript_file_map.keys()) - target_aliases = set(map(str, target_alias_list)) - - common = load_list and target_aliases - load_only = load_list - common - target_only = target_aliases - common - help_text = [help_fmt % columnar_text(sorted(list(common)))] - if target_only: - fmt = "The following are additional TARGET names:\n\n%s\n" - help_text.append(fmt % columnar_text(sorted(list(target_only)))) - if load_only: - fmt = "The following are additional LOAD= module names:\n\n%s\n" - help_text.append(fmt % columnar_text(sorted(list(load_only)))) - Help(''.join(help_text)) diff --git a/base/base_unittests.scons b/base/base_unittests.scons deleted file mode 100644 index 024f259..0000000 --- a/base/base_unittests.scons +++ /dev/null @@ -1,499 +0,0 @@ -# This file is generated; do not edit. - -import os - -Import("env") - -env = env.Clone(COMPONENT_NAME='base', - TARGET_NAME='base_unittests') - -configurations = { - 'Debug' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-I/usr/include/nss', - '-I/usr/include/nspr', - '-O0', - '-g' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'UNIT_TEST', - 'GTEST_HAS_RTTI=0', - '_DEBUG' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/../third_party/icu/public/common'), - env.Dir('$SRC_DIR/base/..'), - env.Dir('$SRC_DIR/base/../testing/gmock/include'), - env.Dir('$SRC_DIR/base/../testing/gtest/include') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-rdynamic' - ], - LIBS = [ - '-lrt', - '-lgtk-x11-2.0', - '-lgdk-x11-2.0', - '-latk-1.0', - '-lgdk_pixbuf-2.0', - '-lm', - '-lpangocairo-1.0', - '-lpango-1.0', - '-lcairo', - '-lgobject-2.0', - '-lgmodule-2.0', - '-ldl', - '-lgthread-2.0', - '-lrt', - '-lglib-2.0', - '-lnss3', - '-lnssutil3', - '-lsmime3', - '-lssl3', - '-lplds4', - '-lplc4', - '-lnspr4', - '-lpthread', - '-ldl', - '-lrt', - 'base', - 'base_i18n', - 'gmock', - 'gtest', - 'event', - 'icui18n', - 'icuuc', - 'icudata' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, - 'Release' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-I/usr/include/nss', - '-I/usr/include/nspr', - '-O2', - '-fno-ident', - '-fdata-sections', - '-ffunction-sections' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'UNIT_TEST', - 'GTEST_HAS_RTTI=0', - 'NDEBUG', - 'NVALGRIND' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/../third_party/icu/public/common'), - env.Dir('$SRC_DIR/base/..'), - env.Dir('$SRC_DIR/base/../testing/gmock/include'), - env.Dir('$SRC_DIR/base/../testing/gtest/include') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-Wl,--gc-sections' - ], - LIBS = [ - '-lrt', - '-lgtk-x11-2.0', - '-lgdk-x11-2.0', - '-latk-1.0', - '-lgdk_pixbuf-2.0', - '-lm', - '-lpangocairo-1.0', - '-lpango-1.0', - '-lcairo', - '-lgobject-2.0', - '-lgmodule-2.0', - '-ldl', - '-lgthread-2.0', - '-lrt', - '-lglib-2.0', - '-lnss3', - '-lnssutil3', - '-lsmime3', - '-lssl3', - '-lplds4', - '-lplc4', - '-lnspr4', - '-lpthread', - '-ldl', - '-lrt', - 'base', - 'base_i18n', - 'gmock', - 'gtest', - 'event', - 'icui18n', - 'icuuc', - 'icudata' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, -} - -config = configurations[env['CONFIG_NAME']] -env.Append(**config['Append']) -env.FilterOut(**config['FilterOut']) -env.Replace(**config['Replace']) - -# Scons forces -fPIC for SHCCFLAGS on some platforms. -# Disable that so we can control it from cflags in gyp. -# Note that Scons itself is inconsistent with its -fPIC -# setting. SHCCFLAGS forces -fPIC, and SHCFLAGS does not. -# This will make SHCCFLAGS consistent with SHCFLAGS. -env['SHCCFLAGS'] = ['$CCFLAGS'] - -for _var in config['ImportExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env[_var] = os.environ[_var] -for _var in config['PropagateExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env['ENV'][_var] = os.environ[_var] - -env['ENV']['LD_LIBRARY_PATH'] = env.subst('$LIB_DIR') - -if ARGUMENTS.get('COVERAGE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-fprofile-arcs', - '-ftest-coverage' - ], - LINKFLAGS = [ - '-fprofile-arcs' - ], - ) - -if ARGUMENTS.get('PROFILE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-pg', - '-g' - ], - LINKFLAGS = [ - '-pg' - ], - ) - -if ARGUMENTS.get('SYMBOLS') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-g' - ], - ) - -input_files = [ - 'multiprocess_test.h', - 'test/run_all_unittests.cc', - 'test/test_suite.h', - 'at_exit_unittest.cc', - 'atomic_flag_unittest.cc', - 'atomicops_unittest.cc', - 'bits_unittest.cc', - 'command_line_unittest.cc', - 'condition_variable_unittest.cc', - 'crypto/rsa_private_key_unittest.cc', - 'crypto/signature_creator_unittest.cc', - 'crypto/signature_verifier_unittest.cc', - 'data_pack_unittest.cc', - 'debug_util_unittest.cc', - 'directory_watcher_unittest.cc', - 'field_trial_unittest.cc', - 'file_descriptor_shuffle_unittest.cc', - 'file_path_unittest.cc', - 'file_util_unittest.cc', - 'gfx/rect_unittest.cc', - 'gmock_unittest.cc', - 'histogram_unittest.cc', - 'hmac_unittest.cc', - 'id_map_unittest.cc', - 'i18n/file_util_icu_unittest.cc', - 'i18n/icu_string_conversions_unittest.cc', - 'i18n/word_iterator_unittest.cc', - 'json/json_reader_unittest.cc', - 'json/json_writer_unittest.cc', - 'json/string_escape_unittest.cc', - 'lazy_instance_unittest.cc', - 'leak_tracker_unittest.cc', - 'linked_list_unittest.cc', - 'linked_ptr_unittest.cc', - 'message_loop_unittest.cc', - 'message_pump_glib_unittest.cc', - 'observer_list_unittest.cc', - 'path_service_unittest.cc', - 'pickle_unittest.cc', - 'pr_time_unittest.cc', - 'process_util_unittest.cc', - 'rand_util_unittest.cc', - 'ref_counted_unittest.cc', - 'scoped_ptr_unittest.cc', - 'scoped_temp_dir_unittest.cc', - 'sha1_unittest.cc', - 'sha2_unittest.cc', - 'shared_memory_unittest.cc', - 'simple_thread_unittest.cc', - 'singleton_unittest.cc', - 'stack_container_unittest.cc', - 'stats_table_unittest.cc', - 'string_piece_unittest.cc', - 'string_tokenizer_unittest.cc', - 'string_util_unittest.cc', - 'sys_info_unittest.cc', - 'sys_string_conversions_unittest.cc', - 'task_unittest.cc', - 'thread_collision_warner_unittest.cc', - 'thread_local_storage_unittest.cc', - 'thread_local_unittest.cc', - 'thread_unittest.cc', - 'time_unittest.cc', - 'timer_unittest.cc', - 'tracked_objects_unittest.cc', - 'tuple_unittest.cc', - 'utf_offset_string_conversions_unittest.cc', - 'utf_string_conversions_unittest.cc', - 'values_unittest.cc', - 'version_unittest.cc', - 'waitable_event_unittest.cc', - 'waitable_event_watcher_unittest.cc', - 'watchdog_unittest.cc', - 'weak_ptr_unittest.cc', - 'worker_pool_unittest.cc', -] - -target_files = [] -prerequisites = [] - -_program = env.File('${PROGPREFIX}base_unittests${PROGSUFFIX}') -_result = [] -for infile in input_files: - if env.compilable(infile): - if (type(infile) == type('') - and (infile.startswith('$SRC_DIR/base/') - or not os.path.isabs(env.subst(infile)))): - # Force files below the build directory by replacing all '..' - # elements in the path with '__': - base, ext = os.path.splitext(os.path.normpath(infile)) - base = [d == '..' and '__' or d for d in base.split('/')] - base = os.path.join(*base) - object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base - if not infile.startswith('$SRC_DIR/base/'): - infile = '$SRC_DIR/base/' + infile - infile = env.StaticObject(object, infile)[0] - else: - infile = env.StaticObject(infile)[0] - _result.append(infile) -input_files = _result - -_outputs = env.GypProgram(_program, input_files) -target_files.extend(_outputs) - -if GetOption('verbose'): - _action = Action([['cd', - '"/usr/local/google/chromium/src/base"', - '&&', - '$TARGET_NAME', - '--gtest_print_time']]) -else: - _action = Action([['cd', - '"/usr/local/google/chromium/src/base"', - '&&', - '$TARGET_NAME', - '--gtest_print_time']], ) - -gyp_target = env.Alias('base_unittests', target_files) -dependencies = [ - Alias('base'), - Alias('base_i18n'), - Alias('gmock'), - Alias('gtest'), - Alias('gtk'), - Alias('nss'), - Alias('xdisplaycheck'), - Alias('libevent'), - Alias('icui18n'), - Alias('icuuc'), - Alias('icudata') -] -env.Requires(target_files, dependencies) -env.Requires(gyp_target, dependencies) -for prerequisite in prerequisites: - env.Requires(prerequisite, dependencies) -env.Requires(gyp_target, prerequisites) - -_run_as_target = env.Alias('run_base_unittests', target_files, _action) -env.Requires(_run_as_target, [ - Alias('base_unittests'), -]) -env.AlwaysBuild(_run_as_target) -Return("gyp_target") diff --git a/base/base_unittests.target.mk b/base/base_unittests.target.mk deleted file mode 100644 index bccc717..0000000 --- a/base/base_unittests.target.mk +++ /dev/null @@ -1,297 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := base_unittests -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DUNIT_TEST' \ - '-DGTEST_HAS_RTTI=0' \ - '-D__STDC_FORMAT_MACROS' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -I../net/third_party/nss/ssl \ - -Inet/third_party/nss/ssl \ - -IWebKit/chromium/net/third_party/nss/ssl \ - -I/usr/include/nss \ - -I/usr/include/nspr \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := -Ithird_party/icu/public/common \ - -I. \ - -Itesting/gmock/include \ - -Itesting/gtest/include - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DUNIT_TEST' \ - '-DGTEST_HAS_RTTI=0' \ - '-D__STDC_FORMAT_MACROS' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -I../net/third_party/nss/ssl \ - -Inet/third_party/nss/ssl \ - -IWebKit/chromium/net/third_party/nss/ssl \ - -I/usr/include/nss \ - -I/usr/include/nspr \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := -Ithird_party/icu/public/common \ - -I. \ - -Itesting/gmock/include \ - -Itesting/gtest/include - -OBJS := $(obj).target/$(TARGET)/base/test/run_all_unittests.o \ - $(obj).target/$(TARGET)/base/at_exit_unittest.o \ - $(obj).target/$(TARGET)/base/atomicops_unittest.o \ - $(obj).target/$(TARGET)/base/base64_unittest.o \ - $(obj).target/$(TARGET)/base/bits_unittest.o \ - $(obj).target/$(TARGET)/base/callback_unittest.o \ - $(obj).target/$(TARGET)/base/cancellation_flag_unittest.o \ - $(obj).target/$(TARGET)/base/command_line_unittest.o \ - $(obj).target/$(TARGET)/base/condition_variable_unittest.o \ - $(obj).target/$(TARGET)/base/crypto/encryptor_unittest.o \ - $(obj).target/$(TARGET)/base/crypto/rsa_private_key_unittest.o \ - $(obj).target/$(TARGET)/base/crypto/rsa_private_key_nss_unittest.o \ - $(obj).target/$(TARGET)/base/crypto/signature_creator_unittest.o \ - $(obj).target/$(TARGET)/base/crypto/signature_verifier_unittest.o \ - $(obj).target/$(TARGET)/base/crypto/symmetric_key_unittest.o \ - $(obj).target/$(TARGET)/base/data_pack_unittest.o \ - $(obj).target/$(TARGET)/base/debug_util_unittest.o \ - $(obj).target/$(TARGET)/base/dir_reader_posix_unittest.o \ - $(obj).target/$(TARGET)/base/environment_unittest.o \ - $(obj).target/$(TARGET)/base/field_trial_unittest.o \ - $(obj).target/$(TARGET)/base/file_descriptor_shuffle_unittest.o \ - $(obj).target/$(TARGET)/base/file_path_unittest.o \ - $(obj).target/$(TARGET)/base/file_util_unittest.o \ - $(obj).target/$(TARGET)/base/gmock_unittest.o \ - $(obj).target/$(TARGET)/base/histogram_unittest.o \ - $(obj).target/$(TARGET)/base/hmac_unittest.o \ - $(obj).target/$(TARGET)/base/id_map_unittest.o \ - $(obj).target/$(TARGET)/base/i18n/char_iterator_unittest.o \ - $(obj).target/$(TARGET)/base/i18n/file_util_icu_unittest.o \ - $(obj).target/$(TARGET)/base/i18n/icu_string_conversions_unittest.o \ - $(obj).target/$(TARGET)/base/i18n/rtl_unittest.o \ - $(obj).target/$(TARGET)/base/i18n/word_iterator_unittest.o \ - $(obj).target/$(TARGET)/base/json/json_reader_unittest.o \ - $(obj).target/$(TARGET)/base/json/json_writer_unittest.o \ - $(obj).target/$(TARGET)/base/json/string_escape_unittest.o \ - $(obj).target/$(TARGET)/base/lazy_instance_unittest.o \ - $(obj).target/$(TARGET)/base/leak_tracker_unittest.o \ - $(obj).target/$(TARGET)/base/linked_list_unittest.o \ - $(obj).target/$(TARGET)/base/linked_ptr_unittest.o \ - $(obj).target/$(TARGET)/base/lock_unittest.o \ - $(obj).target/$(TARGET)/base/message_loop_proxy_impl_unittest.o \ - $(obj).target/$(TARGET)/base/message_loop_unittest.o \ - $(obj).target/$(TARGET)/base/message_pump_glib_unittest.o \ - $(obj).target/$(TARGET)/base/non_thread_safe_unittest.o \ - $(obj).target/$(TARGET)/base/observer_list_unittest.o \ - $(obj).target/$(TARGET)/base/path_service_unittest.o \ - $(obj).target/$(TARGET)/base/pickle_unittest.o \ - $(obj).target/$(TARGET)/base/platform_file_unittest.o \ - $(obj).target/$(TARGET)/base/platform_thread_unittest.o \ - $(obj).target/$(TARGET)/base/pr_time_unittest.o \ - $(obj).target/$(TARGET)/base/process_util_unittest.o \ - $(obj).target/$(TARGET)/base/rand_util_unittest.o \ - $(obj).target/$(TARGET)/base/ref_counted_unittest.o \ - $(obj).target/$(TARGET)/base/scoped_native_library_unittest.o \ - $(obj).target/$(TARGET)/base/scoped_ptr_unittest.o \ - $(obj).target/$(TARGET)/base/scoped_temp_dir_unittest.o \ - $(obj).target/$(TARGET)/base/sha1_unittest.o \ - $(obj).target/$(TARGET)/base/sha2_unittest.o \ - $(obj).target/$(TARGET)/base/shared_memory_unittest.o \ - $(obj).target/$(TARGET)/base/simple_thread_unittest.o \ - $(obj).target/$(TARGET)/base/singleton_unittest.o \ - $(obj).target/$(TARGET)/base/stack_container_unittest.o \ - $(obj).target/$(TARGET)/base/stats_table_unittest.o \ - $(obj).target/$(TARGET)/base/string_number_conversions_unittest.o \ - $(obj).target/$(TARGET)/base/string_piece_unittest.o \ - $(obj).target/$(TARGET)/base/string_split_unittest.o \ - $(obj).target/$(TARGET)/base/string_tokenizer_unittest.o \ - $(obj).target/$(TARGET)/base/string_util_unittest.o \ - $(obj).target/$(TARGET)/base/stringprintf_unittest.o \ - $(obj).target/$(TARGET)/base/sys_info_unittest.o \ - $(obj).target/$(TARGET)/base/sys_string_conversions_unittest.o \ - $(obj).target/$(TARGET)/base/task_queue_unittest.o \ - $(obj).target/$(TARGET)/base/thread_checker_unittest.o \ - $(obj).target/$(TARGET)/base/thread_collision_warner_unittest.o \ - $(obj).target/$(TARGET)/base/thread_local_storage_unittest.o \ - $(obj).target/$(TARGET)/base/thread_local_unittest.o \ - $(obj).target/$(TARGET)/base/thread_unittest.o \ - $(obj).target/$(TARGET)/base/time_unittest.o \ - $(obj).target/$(TARGET)/base/timer_unittest.o \ - $(obj).target/$(TARGET)/base/tools_sanity_unittest.o \ - $(obj).target/$(TARGET)/base/tracked_objects_unittest.o \ - $(obj).target/$(TARGET)/base/tuple_unittest.o \ - $(obj).target/$(TARGET)/base/utf_offset_string_conversions_unittest.o \ - $(obj).target/$(TARGET)/base/utf_string_conversions_unittest.o \ - $(obj).target/$(TARGET)/base/values_unittest.o \ - $(obj).target/$(TARGET)/base/version_unittest.o \ - $(obj).target/$(TARGET)/base/vlog_unittest.o \ - $(obj).target/$(TARGET)/base/waitable_event_unittest.o \ - $(obj).target/$(TARGET)/base/waitable_event_watcher_unittest.o \ - $(obj).target/$(TARGET)/base/watchdog_unittest.o \ - $(obj).target/$(TARGET)/base/weak_ptr_unittest.o \ - $(obj).target/$(TARGET)/base/worker_pool_unittest.o \ - $(obj).target/$(TARGET)/base/xdg_util_unittest.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/base/libbase.a $(obj).target/base/libbase_i18n.a $(obj).target/base/libtest_support_base.a $(obj).target/testing/libgmock.a $(obj).target/testing/libgtest.a xdisplaycheck $(obj).target/third_party/modp_b64/libmodp_b64.a $(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a $(obj).target/base/libsymbolize.a $(obj).target/net/third_party/nss/libssl.a $(obj).target/third_party/zlib/libzlib.a $(obj).target/base/libxdg_mime.a $(obj).target/base/allocator/liballocator.a $(obj).target/third_party/libevent/libevent.a $(obj).target/third_party/icu/libicui18n.a $(obj).target/third_party/icu/libicuuc.a $(obj).target/third_party/icu/libicudata.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-uIsHeapProfilerRunning,-uProfilerStart \ - -Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi \ - -Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-uIsHeapProfilerRunning,-uProfilerStart \ - -Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi \ - -Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := -lrt \ - -ldl \ - -lgtk-x11-2.0 \ - -lgdk-x11-2.0 \ - -latk-1.0 \ - -lgio-2.0 \ - -lpangoft2-1.0 \ - -lgdk_pixbuf-2.0 \ - -lm \ - -lpangocairo-1.0 \ - -lcairo \ - -lpango-1.0 \ - -lfreetype \ - -lfontconfig \ - -lgobject-2.0 \ - -lgmodule-2.0 \ - -lgthread-2.0 \ - -lglib-2.0 \ - -lnss3 \ - -lnssutil3 \ - -lsmime3 \ - -lplds4 \ - -lplc4 \ - -lnspr4 \ - -lpthread \ - -lz - -$(builddir)/base_unittests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/base_unittests: LIBS := $(LIBS) -$(builddir)/base_unittests: TOOLSET := $(TOOLSET) -$(builddir)/base_unittests: $(OBJS) $(obj).target/base/libbase.a $(obj).target/base/libbase_i18n.a $(obj).target/base/libtest_support_base.a $(obj).target/testing/libgmock.a $(obj).target/testing/libgtest.a $(obj).target/third_party/modp_b64/libmodp_b64.a $(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a $(obj).target/base/libsymbolize.a $(obj).target/net/third_party/nss/libssl.a $(obj).target/third_party/zlib/libzlib.a $(obj).target/base/libxdg_mime.a $(obj).target/base/allocator/liballocator.a $(obj).target/third_party/libevent/libevent.a $(obj).target/third_party/icu/libicui18n.a $(obj).target/third_party/icu/libicuuc.a $(obj).target/third_party/icu/libicudata.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/base_unittests -# Add target alias -.PHONY: base_unittests -base_unittests: $(builddir)/base_unittests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/base_unittests - diff --git a/base/crypto/rsa_private_key_nss_unittest.cc b/base/crypto/rsa_private_key_nss_unittest.cc new file mode 100644 index 0000000..7dbe628 --- /dev/null +++ b/base/crypto/rsa_private_key_nss_unittest.cc @@ -0,0 +1,64 @@ +// Copyright (c) 2010 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 "base/crypto/rsa_private_key.h" + +#include <keyhi.h> +#include <pk11pub.h> + +#include "base/nss_util.h" +#include "base/scoped_ptr.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace base { + +class RSAPrivateKeyNSSTest : public testing::Test { + public: + RSAPrivateKeyNSSTest() {} + virtual ~RSAPrivateKeyNSSTest() {} + + virtual void SetUp() { +#if defined(OS_CHROMEOS) + base::OpenPersistentNSSDB(); +#endif + } + + private: + DISALLOW_COPY_AND_ASSIGN(RSAPrivateKeyNSSTest); +}; + +TEST_F(RSAPrivateKeyNSSTest, FindFromPublicKey) { + // Create a keypair, which will put the keys in the user's NSSDB. + scoped_ptr<base::RSAPrivateKey> key_pair(base::RSAPrivateKey::Create(256)); + + std::vector<uint8> public_key; + ASSERT_TRUE(key_pair->ExportPublicKey(&public_key)); + + scoped_ptr<base::RSAPrivateKey> key_pair_2( + base::RSAPrivateKey::FindFromPublicKeyInfo(public_key)); + + EXPECT_EQ(key_pair->key_->pkcs11ID, key_pair_2->key_->pkcs11ID); +} + +TEST_F(RSAPrivateKeyNSSTest, FailedFindFromPublicKey) { + // Create a keypair, which will put the keys in the user's NSSDB. + scoped_ptr<base::RSAPrivateKey> key_pair(base::RSAPrivateKey::Create(256)); + + std::vector<uint8> public_key; + ASSERT_TRUE(key_pair->ExportPublicKey(&public_key)); + + // Remove the keys from the DB, and make sure we can't find them again. + if (key_pair->key_) { + PK11_DestroyTokenObject(key_pair->key_->pkcs11Slot, + key_pair->key_->pkcs11ID); + } + if (key_pair->public_key_) { + PK11_DestroyTokenObject(key_pair->public_key_->pkcs11Slot, + key_pair->public_key_->pkcs11ID); + } + + EXPECT_EQ(NULL, base::RSAPrivateKey::FindFromPublicKeyInfo(public_key)); +} + +} // namespace base diff --git a/base/directory_watcher.h b/base/directory_watcher.h deleted file mode 100644 index 207d6d2..0000000 --- a/base/directory_watcher.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2006-2008 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. - -// This module provides a way to monitor a directory for changes. - -#ifndef BASE_DIRECTORY_WATCHER_H_ -#define BASE_DIRECTORY_WATCHER_H_ - -#include "base/basictypes.h" -#include "base/ref_counted.h" - -class FilePath; -class MessageLoop; - -// This class lets you register interest in changes on a directory. -// The delegate will get called whenever a file is added or changed in the -// directory. -class DirectoryWatcher { - public: - class Delegate { - public: - virtual ~Delegate() {} - virtual void OnDirectoryChanged(const FilePath& path) = 0; - }; - - DirectoryWatcher(); - ~DirectoryWatcher() {} - - // Register interest in any changes in the directory |path|. - // OnDirectoryChanged will be called back for each change within the dir. - // Any background operations will be ran on |backend_loop|, or inside Watch - // if |backend_loop| is NULL. If |recursive| is true, the delegate will be - // notified for each change within the directory tree starting at |path|. - // Returns false on error. - // - // Note: on Windows you may got more notifications for non-recursive watch - // than you expect, especially on versions earlier than Vista. The behavior - // is consistent on any particular version of Windows, but not across - // different versions. - bool Watch(const FilePath& path, Delegate* delegate, - MessageLoop* backend_loop, bool recursive) { - return impl_->Watch(path, delegate, backend_loop, recursive); - } - - // Used internally to encapsulate different members on different platforms. - class PlatformDelegate : public base::RefCounted<PlatformDelegate> { - public: - virtual bool Watch(const FilePath& path, Delegate* delegate, - MessageLoop* backend_loop, bool recursive) = 0; - - protected: - friend class base::RefCounted<PlatformDelegate>; - - virtual ~PlatformDelegate() {} - }; - - private: - scoped_refptr<PlatformDelegate> impl_; - - DISALLOW_COPY_AND_ASSIGN(DirectoryWatcher); -}; - -#endif // BASE_DIRECTORY_WATCHER_H_ diff --git a/base/directory_watcher_inotify.cc b/base/directory_watcher_inotify.cc deleted file mode 100644 index c593ff5..0000000 --- a/base/directory_watcher_inotify.cc +++ /dev/null @@ -1,473 +0,0 @@ -// Copyright (c) 2009 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 "base/directory_watcher.h" - -#include <errno.h> -#include <string.h> -#include <sys/inotify.h> -#include <sys/ioctl.h> -#include <sys/select.h> -#include <unistd.h> - -#include <algorithm> -#include <set> -#include <utility> -#include <vector> - -#include "base/eintr_wrapper.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/hash_tables.h" -#include "base/lock.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "base/scoped_ptr.h" -#include "base/singleton.h" -#include "base/task.h" -#include "base/thread.h" -#include "base/waitable_event.h" - -namespace { - -class DirectoryWatcherImpl; - -// Singleton to manage all inotify watches. -class InotifyReader { - public: - typedef int Watch; // Watch descriptor used by AddWatch and RemoveWatch. - static const Watch kInvalidWatch = -1; - - // Watch |path| for changes. |watcher| will be notified on each change. - // Returns kInvalidWatch on failure. - Watch AddWatch(const FilePath& path, DirectoryWatcherImpl* watcher); - - // Remove |watch|. Returns true on success. - bool RemoveWatch(Watch watch, DirectoryWatcherImpl* watcher); - - // Callback for InotifyReaderTask. - void OnInotifyEvent(const inotify_event* event); - - private: - friend struct DefaultSingletonTraits<InotifyReader>; - - typedef std::set<DirectoryWatcherImpl*> WatcherSet; - - InotifyReader(); - ~InotifyReader(); - - // We keep track of which delegates want to be notified on which watches. - base::hash_map<Watch, WatcherSet> watchers_; - - // For each watch we also want to know the path it's watching. - base::hash_map<Watch, FilePath> paths_; - - // Lock to protect delegates_ and paths_. - Lock lock_; - - // Separate thread on which we run blocking read for inotify events. - base::Thread thread_; - - // File descriptor returned by inotify_init. - const int inotify_fd_; - - // Use self-pipe trick to unblock select during shutdown. - int shutdown_pipe_[2]; - - // Flag set to true when startup was successful. - bool valid_; - - DISALLOW_COPY_AND_ASSIGN(InotifyReader); -}; - -class DirectoryWatcherImpl : public DirectoryWatcher::PlatformDelegate { - public: - typedef std::set<FilePath> FilePathSet; - - DirectoryWatcherImpl(); - ~DirectoryWatcherImpl(); - - void EnsureSetupFinished(); - - // Called for each event coming from one of watches. - void OnInotifyEvent(const inotify_event* event); - - // Callback for RegisterSubtreeWatchesTask. - bool OnEnumeratedSubtree(const FilePathSet& paths); - - // Start watching |path| for changes and notify |delegate| on each change. - // If |recursive| is true, watch entire subtree. - // Returns true if watch for |path| has been added successfully. Watches - // required for |recursive| are added on a background thread and have no - // effect on the return value. - virtual bool Watch(const FilePath& path, DirectoryWatcher::Delegate* delegate, - MessageLoop* backend_loop, bool recursive); - - private: - typedef std::set<InotifyReader::Watch> WatchSet; - typedef std::set<ino_t> InodeSet; - - // Returns true if |inode| is watched by DirectoryWatcherImpl. - bool IsInodeWatched(ino_t inode) const; - - // Delegate to notify upon changes. - DirectoryWatcher::Delegate* delegate_; - - // Path we're watching (passed to delegate). - FilePath root_path_; - - // Watch returned by InotifyReader. - InotifyReader::Watch watch_; - - // Set of watched inodes. - InodeSet inodes_watched_; - - // Keep track of registered watches. - WatchSet watches_; - - // Lock to protect inodes_watched_ and watches_. - Lock lock_; - - // Flag set to true when recursively watching subtree. - bool recursive_; - - // Loop where we post directory change notifications to. - MessageLoop* loop_; - - // Event signaled when the background task finished adding initial inotify - // watches for recursive watch. - base::WaitableEvent recursive_setup_finished_; - - DISALLOW_COPY_AND_ASSIGN(DirectoryWatcherImpl); -}; - -class RegisterSubtreeWatchesTask : public Task { - public: - RegisterSubtreeWatchesTask(DirectoryWatcherImpl* watcher, - const FilePath& path) - : watcher_(watcher), - path_(path) { - } - - virtual void Run() { - file_util::FileEnumerator dir_list(path_, true, - file_util::FileEnumerator::DIRECTORIES); - - DirectoryWatcherImpl::FilePathSet subtree; - for (FilePath subdirectory = dir_list.Next(); - !subdirectory.empty(); - subdirectory = dir_list.Next()) { - subtree.insert(subdirectory); - } - watcher_->OnEnumeratedSubtree(subtree); - } - - private: - DirectoryWatcherImpl* watcher_; - FilePath path_; - - DISALLOW_COPY_AND_ASSIGN(RegisterSubtreeWatchesTask); -}; - -class DirectoryWatcherImplNotifyTask : public Task { - public: - DirectoryWatcherImplNotifyTask(DirectoryWatcher::Delegate* delegate, - const FilePath& path) - : delegate_(delegate), - path_(path) { - } - - virtual void Run() { - delegate_->OnDirectoryChanged(path_); - } - - private: - DirectoryWatcher::Delegate* delegate_; - FilePath path_; - - DISALLOW_COPY_AND_ASSIGN(DirectoryWatcherImplNotifyTask); -}; - -class InotifyReaderTask : public Task { - public: - InotifyReaderTask(InotifyReader* reader, int inotify_fd, int shutdown_fd) - : reader_(reader), - inotify_fd_(inotify_fd), - shutdown_fd_(shutdown_fd) { - } - - virtual void Run() { - while (true) { - fd_set rfds; - FD_ZERO(&rfds); - FD_SET(inotify_fd_, &rfds); - FD_SET(shutdown_fd_, &rfds); - - // Wait until some inotify events are available. - int select_result = - HANDLE_EINTR(select(std::max(inotify_fd_, shutdown_fd_) + 1, - &rfds, NULL, NULL, NULL)); - if (select_result < 0) { - DPLOG(WARNING) << "select failed"; - return; - } - - if (FD_ISSET(shutdown_fd_, &rfds)) - return; - - // Adjust buffer size to current event queue size. - int buffer_size; - int ioctl_result = HANDLE_EINTR(ioctl(inotify_fd_, FIONREAD, - &buffer_size)); - - if (ioctl_result != 0) { - DPLOG(WARNING) << "ioctl failed"; - return; - } - - std::vector<char> buffer(buffer_size); - - ssize_t bytes_read = HANDLE_EINTR(read(inotify_fd_, &buffer[0], - buffer_size)); - - if (bytes_read < 0) { - DPLOG(WARNING) << "read from inotify fd failed"; - return; - } - - ssize_t i = 0; - while (i < bytes_read) { - inotify_event* event = reinterpret_cast<inotify_event*>(&buffer[i]); - size_t event_size = sizeof(inotify_event) + event->len; - DCHECK(i + event_size <= static_cast<size_t>(bytes_read)); - reader_->OnInotifyEvent(event); - i += event_size; - } - } - } - - private: - InotifyReader* reader_; - int inotify_fd_; - int shutdown_fd_; - - DISALLOW_COPY_AND_ASSIGN(InotifyReaderTask); -}; - -InotifyReader::InotifyReader() - : thread_("inotify_reader"), - inotify_fd_(inotify_init()), - valid_(false) { - shutdown_pipe_[0] = -1; - shutdown_pipe_[1] = -1; - if (inotify_fd_ >= 0 && pipe(shutdown_pipe_) == 0 && thread_.Start()) { - thread_.message_loop()->PostTask( - FROM_HERE, new InotifyReaderTask(this, inotify_fd_, shutdown_pipe_[0])); - valid_ = true; - } -} - -InotifyReader::~InotifyReader() { - if (valid_) { - // Write to the self-pipe so that the select call in InotifyReaderTask - // returns. - ssize_t ret = HANDLE_EINTR(write(shutdown_pipe_[1], "", 1)); - DPCHECK(ret > 0); - DCHECK_EQ(ret, 1); - thread_.Stop(); - } - if (inotify_fd_ >= 0) - close(inotify_fd_); - if (shutdown_pipe_[0] >= 0) - close(shutdown_pipe_[0]); - if (shutdown_pipe_[1] >= 0) - close(shutdown_pipe_[1]); -} - -InotifyReader::Watch InotifyReader::AddWatch( - const FilePath& path, DirectoryWatcherImpl* watcher) { - - if (!valid_) - return kInvalidWatch; - - AutoLock auto_lock(lock_); - - Watch watch = inotify_add_watch(inotify_fd_, path.value().c_str(), - IN_CREATE | IN_DELETE | - IN_CLOSE_WRITE | IN_MOVE); - - if (watch == kInvalidWatch) - return kInvalidWatch; - - if (paths_[watch].empty()) - paths_[watch] = path; // We don't yet watch this path. - - watchers_[watch].insert(watcher); - - return watch; -} - -bool InotifyReader::RemoveWatch(Watch watch, - DirectoryWatcherImpl* watcher) { - if (!valid_) - return false; - - AutoLock auto_lock(lock_); - - if (paths_[watch].empty()) - return false; // We don't recognize this watch. - - watchers_[watch].erase(watcher); - - if (watchers_[watch].empty()) { - paths_.erase(watch); - watchers_.erase(watch); - return (inotify_rm_watch(inotify_fd_, watch) == 0); - } - - return true; -} - -void InotifyReader::OnInotifyEvent(const inotify_event* event) { - if (event->mask & IN_IGNORED) - return; - - // In case you want to limit the scope of this lock, it's not sufficient - // to just copy things under the lock, and then run the notifications - // without holding the lock. DirectoryWatcherImpl's dtor removes its watches, - // and to do that obtains the lock. After it finishes removing watches, - // it's destroyed. So, if you copy under the lock and notify without the lock, - // it's possible you'll copy the DirectoryWatcherImpl which is being - // destroyed, then it will destroy itself, and then you'll try to notify it. - AutoLock auto_lock(lock_); - - for (WatcherSet::iterator watcher = watchers_[event->wd].begin(); - watcher != watchers_[event->wd].end(); - ++watcher) { - (*watcher)->OnInotifyEvent(event); - } -} - -DirectoryWatcherImpl::DirectoryWatcherImpl() - : watch_(InotifyReader::kInvalidWatch), - recursive_setup_finished_(false, false) { -} - -DirectoryWatcherImpl::~DirectoryWatcherImpl() { - if (watch_ == InotifyReader::kInvalidWatch) - return; - - if (recursive_) - recursive_setup_finished_.Wait(); - for (WatchSet::iterator watch = watches_.begin(); - watch != watches_.end(); - ++watch) { - Singleton<InotifyReader>::get()->RemoveWatch(*watch, this); - } - watches_.clear(); - inodes_watched_.clear(); -} - -void DirectoryWatcherImpl::OnInotifyEvent(const inotify_event* event) { - loop_->PostTask(FROM_HERE, - new DirectoryWatcherImplNotifyTask(delegate_, root_path_)); - - if (!(event->mask & IN_ISDIR)) - return; - - if (event->mask & IN_CREATE || event->mask & IN_MOVED_TO) { - // TODO(phajdan.jr): add watch for this new directory. - NOTIMPLEMENTED(); - } else if (event->mask & IN_DELETE || event->mask & IN_MOVED_FROM) { - // TODO(phajdan.jr): remove our watch for this directory. - NOTIMPLEMENTED(); - } -} - -bool DirectoryWatcherImpl::IsInodeWatched(ino_t inode) const { - return inodes_watched_.find(inode) != inodes_watched_.end(); -} - -bool DirectoryWatcherImpl::OnEnumeratedSubtree(const FilePathSet& subtree) { - DCHECK(recursive_); - - if (watch_ == InotifyReader::kInvalidWatch) { - recursive_setup_finished_.Signal(); - return false; - } - - bool success = true; - - { - // Limit the scope of auto_lock so it releases lock_ before we signal - // recursive_setup_finished_. Our dtor waits on recursive_setup_finished_ - // and could otherwise destroy the lock before we release it. - AutoLock auto_lock(lock_); - - for (FilePathSet::iterator subdirectory = subtree.begin(); - subdirectory != subtree.end(); - ++subdirectory) { - ino_t inode; - if (!file_util::GetInode(*subdirectory, &inode)) { - success = false; - continue; - } - if (IsInodeWatched(inode)) - continue; - InotifyReader::Watch watch = - Singleton<InotifyReader>::get()->AddWatch(*subdirectory, this); - if (watch != InotifyReader::kInvalidWatch) { - watches_.insert(watch); - inodes_watched_.insert(inode); - } - } - } - - recursive_setup_finished_.Signal(); - return success; -} - -bool DirectoryWatcherImpl::Watch(const FilePath& path, - DirectoryWatcher::Delegate* delegate, - MessageLoop* backend_loop, bool recursive) { - - // Can only watch one path. - DCHECK(watch_ == InotifyReader::kInvalidWatch); - - ino_t inode; - if (!file_util::GetInode(path, &inode)) - return false; - - delegate_ = delegate; - recursive_ = recursive; - root_path_ = path; - loop_ = MessageLoop::current(); - watch_ = Singleton<InotifyReader>::get()->AddWatch(path, this); - if (watch_ == InotifyReader::kInvalidWatch) - return false; - - { - AutoLock auto_lock(lock_); - inodes_watched_.insert(inode); - watches_.insert(watch_); - } - - if (recursive_) { - Task* subtree_task = new RegisterSubtreeWatchesTask(this, root_path_); - if (backend_loop) { - backend_loop->PostTask(FROM_HERE, subtree_task); - } else { - subtree_task->Run(); - delete subtree_task; - } - } - - return true; -} - -} // namespace - -DirectoryWatcher::DirectoryWatcher() { - impl_ = new DirectoryWatcherImpl(); -} diff --git a/base/directory_watcher_mac.cc b/base/directory_watcher_mac.cc deleted file mode 100644 index dc3eba6..0000000 --- a/base/directory_watcher_mac.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2009 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 "base/directory_watcher.h" - -#include <CoreServices/CoreServices.h> - -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "base/scoped_cftyperef.h" - -namespace { - -const CFAbsoluteTime kEventLatencySeconds = 0.3; - -class DirectoryWatcherImpl : public DirectoryWatcher::PlatformDelegate { - public: - DirectoryWatcherImpl() {} - ~DirectoryWatcherImpl() { - if (!path_.value().empty()) { - FSEventStreamStop(fsevent_stream_); - FSEventStreamInvalidate(fsevent_stream_); - FSEventStreamRelease(fsevent_stream_); - } - } - - virtual bool Watch(const FilePath& path, DirectoryWatcher::Delegate* delegate, - MessageLoop* backend_loop, bool recursive); - - void OnFSEventsCallback(const FilePath& event_path) { - DCHECK(!path_.value().empty()); - if (!recursive_) { - FilePath absolute_event_path = event_path; - if (!file_util::AbsolutePath(&absolute_event_path)) - return; - if (absolute_event_path != path_) - return; - } - delegate_->OnDirectoryChanged(path_); - } - - private: - // Delegate to notify upon changes. - DirectoryWatcher::Delegate* delegate_; - - // Path we're watching (passed to delegate). - FilePath path_; - - // Indicates recursive watch. - bool recursive_; - - // Backend stream we receive event callbacks from (strong reference). - FSEventStreamRef fsevent_stream_; - - DISALLOW_COPY_AND_ASSIGN(DirectoryWatcherImpl); -}; - -void FSEventsCallback(ConstFSEventStreamRef stream, - void* event_watcher, size_t num_events, - void* event_paths, const FSEventStreamEventFlags flags[], - const FSEventStreamEventId event_ids[]) { - char** paths = reinterpret_cast<char**>(event_paths); - DirectoryWatcherImpl* watcher = - reinterpret_cast<DirectoryWatcherImpl*> (event_watcher); - for (size_t i = 0; i < num_events; i++) { - watcher->OnFSEventsCallback(FilePath(paths[i])); - } -} - -bool DirectoryWatcherImpl::Watch(const FilePath& path, - DirectoryWatcher::Delegate* delegate, - MessageLoop* backend_loop, - bool recursive) { - DCHECK(path_.value().empty()); // Can only watch one path. - - DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); - - if (!file_util::PathExists(path)) - return false; - - path_ = path; - if (!file_util::AbsolutePath(&path_)) { - path_ = FilePath(); // Make sure we're marked as not-in-use. - return false; - } - delegate_ = delegate; - recursive_ = recursive; - - scoped_cftyperef<CFStringRef> cf_path(CFStringCreateWithCString( - NULL, path.value().c_str(), kCFStringEncodingMacHFS)); - CFStringRef path_for_array = cf_path.get(); - scoped_cftyperef<CFArrayRef> watched_paths(CFArrayCreate( - NULL, reinterpret_cast<const void**>(&path_for_array), 1, - &kCFTypeArrayCallBacks)); - - FSEventStreamContext context; - context.version = 0; - context.info = this; - context.retain = NULL; - context.release = NULL; - context.copyDescription = NULL; - - fsevent_stream_ = FSEventStreamCreate(NULL, &FSEventsCallback, &context, - watched_paths, - kFSEventStreamEventIdSinceNow, - kEventLatencySeconds, - kFSEventStreamCreateFlagNone); - FSEventStreamScheduleWithRunLoop(fsevent_stream_, CFRunLoopGetCurrent(), - kCFRunLoopDefaultMode); - FSEventStreamStart(fsevent_stream_); - - return true; -} - -} // namespace - -DirectoryWatcher::DirectoryWatcher() { - impl_ = new DirectoryWatcherImpl(); -} diff --git a/base/directory_watcher_stub.cc b/base/directory_watcher_stub.cc deleted file mode 100644 index 92cc5ff..0000000 --- a/base/directory_watcher_stub.cc +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2009 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. - -// This file exists for Linux systems which don't have the inotify headers, and -// thus cannot build directory_watcher_inotify.cc - -#include "base/directory_watcher.h" - -class DirectoryWatcherImpl : public DirectoryWatcher::PlatformDelegate { - public: - virtual bool Watch(const FilePath& path, DirectoryWatcher::Delegate* delegate, - MessageLoop* backend_loop, bool recursive) { - return false; - } -}; - -DirectoryWatcher::DirectoryWatcher() { - impl_ = new DirectoryWatcherImpl(); -} diff --git a/base/directory_watcher_unittest.cc b/base/directory_watcher_unittest.cc deleted file mode 100644 index 9d4c9f6..0000000 --- a/base/directory_watcher_unittest.cc +++ /dev/null @@ -1,426 +0,0 @@ -// Copyright (c) 2008 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 "base/directory_watcher.h" - -#include <limits> - -#include "base/basictypes.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/message_loop.h" -#include "base/path_service.h" -#include "base/platform_thread.h" -#include "base/string_util.h" -#include "base/thread.h" -#if defined(OS_WIN) -#include "base/win_util.h" -#endif // defined(OS_WIN) -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -// For tests where we wait a bit to verify nothing happened -const int kWaitForEventTime = 500; - -class DirectoryWatcherTest : public testing::Test { - public: - // Implementation of DirectoryWatcher on Mac requires UI loop. - DirectoryWatcherTest() - : loop_(MessageLoop::TYPE_UI), - notified_delegates_(0), - expected_notified_delegates_(0) { - } - - void OnTestDelegateFirstNotification(const FilePath& path) { - notified_delegates_++; - if (notified_delegates_ >= expected_notified_delegates_) - MessageLoop::current()->Quit(); - } - - protected: - virtual void SetUp() { - // Name a subdirectory of the temp directory. - FilePath path; - ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path)); - test_dir_ = path.Append(FILE_PATH_LITERAL("DirectoryWatcherTest")); - - // Create a fresh, empty copy of this directory. - file_util::Delete(test_dir_, true); - file_util::CreateDirectory(test_dir_); - } - - virtual void TearDown() { - // Make sure there are no tasks in the loop. - loop_.RunAllPending(); - - // Clean up test directory. - ASSERT_TRUE(file_util::Delete(test_dir_, true)); - ASSERT_FALSE(file_util::PathExists(test_dir_)); - } - - // Write |content| to the |filename|. Returns true on success. - bool WriteTestFile(const FilePath& filename, - const std::string& content) { - return (file_util::WriteFile(filename, content.c_str(), content.length()) == - static_cast<int>(content.length())); - } - - // Create directory |name| under test_dir_. If |sync| is true, runs - // SyncIfPOSIX. Returns path to the created directory, including test_dir_. - FilePath CreateTestDirDirectoryASCII(const std::string& name, bool sync) { - FilePath path(test_dir_.AppendASCII(name)); - EXPECT_TRUE(file_util::CreateDirectory(path)); - if (sync) - SyncIfPOSIX(); - return path; - } - - void SetExpectedNumberOfNotifiedDelegates(int n) { - notified_delegates_ = 0; - expected_notified_delegates_ = n; - } - - void VerifyExpectedNumberOfNotifiedDelegates() { - // Check that we get at least the expected number of notified delegates. - if (expected_notified_delegates_ - notified_delegates_ > 0) - loop_.Run(); - EXPECT_EQ(expected_notified_delegates_, notified_delegates_); - } - - void VerifyNoExtraNotifications() { - // Check that we get no more than the expected number of notified delegates. - loop_.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, - kWaitForEventTime); - loop_.Run(); - EXPECT_EQ(expected_notified_delegates_, notified_delegates_); - } - - // We need this function for reliable tests on Mac OS X. FSEvents API - // has a latency interval and can merge multiple events into one, - // and we need a clear distinction between events triggered by test setup code - // and test code. - void SyncIfPOSIX() { -#if defined(OS_POSIX) - sync(); -#endif // defined(OS_POSIX) - } - - MessageLoop loop_; - - // The path to a temporary directory used for testing. - FilePath test_dir_; - - // The number of test delegates which received their notification. - int notified_delegates_; - - // The number of notified test delegates after which we quit the message loop. - int expected_notified_delegates_; -}; - -class TestDelegate : public DirectoryWatcher::Delegate { - public: - explicit TestDelegate(DirectoryWatcherTest* test) - : test_(test), - got_notification_(false), - original_thread_id_(PlatformThread::CurrentId()) { - } - - bool got_notification() const { - return got_notification_; - } - - void reset() { - got_notification_ = false; - } - - virtual void OnDirectoryChanged(const FilePath& path) { - EXPECT_EQ(original_thread_id_, PlatformThread::CurrentId()); - if (!got_notification_) - test_->OnTestDelegateFirstNotification(path); - got_notification_ = true; - } - - private: - // Hold a pointer to current test fixture to inform it on first notification. - DirectoryWatcherTest* test_; - - // Set to true after first notification. - bool got_notification_; - - // Keep track of original thread id to verify that callbacks are called - // on the same thread. - PlatformThreadId original_thread_id_; -}; - -// Basic test: add a file and verify we notice it. -TEST_F(DirectoryWatcherTest, NewFile) { - DirectoryWatcher watcher; - TestDelegate delegate(this); - ASSERT_TRUE(watcher.Watch(test_dir_, &delegate, NULL, false)); - - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(WriteTestFile(test_dir_.AppendASCII("test_file"), "content")); - VerifyExpectedNumberOfNotifiedDelegates(); -} - -// Verify that modifying a file is caught. -TEST_F(DirectoryWatcherTest, ModifiedFile) { - // Write a file to the test dir. - ASSERT_TRUE(WriteTestFile(test_dir_.AppendASCII("test_file"), "content")); - SyncIfPOSIX(); - - DirectoryWatcher watcher; - TestDelegate delegate(this); - ASSERT_TRUE(watcher.Watch(test_dir_, &delegate, NULL, false)); - - // Now make sure we get notified if the file is modified. - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(WriteTestFile(test_dir_.AppendASCII("test_file"), "new content")); - VerifyExpectedNumberOfNotifiedDelegates(); -} - -TEST_F(DirectoryWatcherTest, DeletedFile) { - // Write a file to the test dir. - ASSERT_TRUE(WriteTestFile(test_dir_.AppendASCII("test_file"), "content")); - SyncIfPOSIX(); - - DirectoryWatcher watcher; - TestDelegate delegate(this); - ASSERT_TRUE(watcher.Watch(test_dir_, &delegate, NULL, false)); - - // Now make sure we get notified if the file is deleted. - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(file_util::Delete(test_dir_.AppendASCII("test_file"), false)); - VerifyExpectedNumberOfNotifiedDelegates(); -} - -// Verify that letting the watcher go out of scope stops notifications. -TEST_F(DirectoryWatcherTest, Unregister) { - TestDelegate delegate(this); - - { - DirectoryWatcher watcher; - ASSERT_TRUE(watcher.Watch(test_dir_, &delegate, NULL, false)); - - // And then let it fall out of scope, clearing its watch. - } - - // Write a file to the test dir. - SetExpectedNumberOfNotifiedDelegates(0); - ASSERT_TRUE(WriteTestFile(test_dir_.AppendASCII("test_file"), "content")); - VerifyExpectedNumberOfNotifiedDelegates(); - VerifyNoExtraNotifications(); -} - -TEST_F(DirectoryWatcherTest, SubDirRecursive) { - FilePath subdir(CreateTestDirDirectoryASCII("SubDir", true)); - - // Verify that modifications to a subdirectory are noticed by recursive watch. - TestDelegate delegate(this); - DirectoryWatcher watcher; - ASSERT_TRUE(watcher.Watch(test_dir_, &delegate, NULL, true)); - // Write a file to the subdir. - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(WriteTestFile(subdir.AppendASCII("test_file"), "some content")); - VerifyExpectedNumberOfNotifiedDelegates(); -} - -TEST_F(DirectoryWatcherTest, SubDirNonRecursive) { -#if defined(OS_WIN) - // Disable this test for earlier version of Windows. It turned out to be - // very difficult to create a reliable test for them. - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) - return; -#endif // defined(OS_WIN) - - FilePath subdir(CreateTestDirDirectoryASCII("SubDir", false)); - - // Create a test file before the test. On Windows we get a notification - // when creating a file in a subdir even with a non-recursive watch. - ASSERT_TRUE(WriteTestFile(subdir.AppendASCII("test_file"), "some content")); - - SyncIfPOSIX(); - - // Verify that modifications to a subdirectory are not noticed - // by a not-recursive watch. - DirectoryWatcher watcher; - TestDelegate delegate(this); - ASSERT_TRUE(watcher.Watch(test_dir_, &delegate, NULL, false)); - - // Modify the test file. There should be no notifications. - SetExpectedNumberOfNotifiedDelegates(0); - ASSERT_TRUE(WriteTestFile(subdir.AppendASCII("test_file"), "other content")); - VerifyExpectedNumberOfNotifiedDelegates(); - VerifyNoExtraNotifications(); -} - -namespace { -// Used by the DeleteDuringNotify test below. -// Deletes the DirectoryWatcher when it's notified. -class Deleter : public DirectoryWatcher::Delegate { - public: - Deleter(DirectoryWatcher* watcher, MessageLoop* loop) - : watcher_(watcher), - loop_(loop) { - } - - virtual void OnDirectoryChanged(const FilePath& path) { - watcher_.reset(NULL); - loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); - } - - scoped_ptr<DirectoryWatcher> watcher_; - MessageLoop* loop_; -}; -} // anonymous namespace - -// Verify that deleting a watcher during the callback -TEST_F(DirectoryWatcherTest, DeleteDuringNotify) { - DirectoryWatcher* watcher = new DirectoryWatcher; - Deleter deleter(watcher, &loop_); // Takes ownership of watcher. - ASSERT_TRUE(watcher->Watch(test_dir_, &deleter, NULL, false)); - - ASSERT_TRUE(WriteTestFile(test_dir_.AppendASCII("test_file"), "content")); - loop_.Run(); - - // We win if we haven't crashed yet. - // Might as well double-check it got deleted, too. - ASSERT_TRUE(deleter.watcher_.get() == NULL); -} - -TEST_F(DirectoryWatcherTest, BackendLoop) { - base::Thread thread("test"); - ASSERT_TRUE(thread.Start()); - - DirectoryWatcher watcher; - TestDelegate delegate(this); - ASSERT_TRUE(watcher.Watch(test_dir_, &delegate, thread.message_loop(), - true)); -} - -TEST_F(DirectoryWatcherTest, MultipleWatchersSingleFile) { - DirectoryWatcher watcher1, watcher2; - TestDelegate delegate1(this), delegate2(this); - ASSERT_TRUE(watcher1.Watch(test_dir_, &delegate1, NULL, false)); - ASSERT_TRUE(watcher2.Watch(test_dir_, &delegate2, NULL, false)); - - SetExpectedNumberOfNotifiedDelegates(2); - ASSERT_TRUE(WriteTestFile(test_dir_.AppendASCII("test_file"), "content")); - VerifyExpectedNumberOfNotifiedDelegates(); -} - -TEST_F(DirectoryWatcherTest, MultipleWatchersDifferentFiles) { - const int kNumberOfWatchers = 3; - DirectoryWatcher watchers[kNumberOfWatchers]; - TestDelegate delegates[kNumberOfWatchers] = { - TestDelegate(this), - TestDelegate(this), - TestDelegate(this), - }; - FilePath subdirs[kNumberOfWatchers]; - for (int i = 0; i < kNumberOfWatchers; i++) { - subdirs[i] = CreateTestDirDirectoryASCII("Dir" + IntToString(i), false); - ASSERT_TRUE(watchers[i].Watch(subdirs[i], &delegates[i], - NULL, ((i % 2) == 0))); - } - for (int i = 0; i < kNumberOfWatchers; i++) { - // Verify that we only get modifications from one watcher (each watcher has - // different directory). - - for (int j = 0; j < kNumberOfWatchers; j++) - delegates[j].reset(); - - // Write a file to the subdir. - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(WriteTestFile(subdirs[i].AppendASCII("test_file"), "content")); - VerifyExpectedNumberOfNotifiedDelegates(); - VerifyNoExtraNotifications(); - - loop_.RunAllPending(); - } -} - -#if defined(OS_WIN) || defined(OS_MACOSX) -// TODO(phajdan.jr): Enable when support for Linux recursive watches is added. - -TEST_F(DirectoryWatcherTest, WatchCreatedDirectory) { - TestDelegate delegate(this); - DirectoryWatcher watcher; - ASSERT_TRUE(watcher.Watch(test_dir_, &delegate, NULL, true)); - - SetExpectedNumberOfNotifiedDelegates(1); - FilePath subdir(CreateTestDirDirectoryASCII("SubDir", true)); - VerifyExpectedNumberOfNotifiedDelegates(); - - delegate.reset(); - - // Verify that changes inside the subdir are noticed. - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(WriteTestFile(subdir.AppendASCII("test_file"), "some content")); - VerifyExpectedNumberOfNotifiedDelegates(); -} - -TEST_F(DirectoryWatcherTest, RecursiveWatchDeletedSubdirectory) { - FilePath subdir(CreateTestDirDirectoryASCII("SubDir", true)); - - TestDelegate delegate(this); - DirectoryWatcher watcher; - ASSERT_TRUE(watcher.Watch(test_dir_, &delegate, NULL, true)); - - // Write a file to the subdir. - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(WriteTestFile(subdir.AppendASCII("test_file"), "some content")); - VerifyExpectedNumberOfNotifiedDelegates(); - - delegate.reset(); - - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(file_util::Delete(subdir, true)); - VerifyExpectedNumberOfNotifiedDelegates(); -} - -TEST_F(DirectoryWatcherTest, MoveFileAcrossWatches) { - FilePath subdir1(CreateTestDirDirectoryASCII("SubDir1", true)); - FilePath subdir2(CreateTestDirDirectoryASCII("SubDir2", true)); - - TestDelegate delegate1(this), delegate2(this); - DirectoryWatcher watcher1, watcher2; - ASSERT_TRUE(watcher1.Watch(subdir1, &delegate1, NULL, true)); - ASSERT_TRUE(watcher2.Watch(subdir2, &delegate2, NULL, true)); - - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(WriteTestFile(subdir1.AppendASCII("file"), "some content")); - SyncIfPOSIX(); - VerifyExpectedNumberOfNotifiedDelegates(); - VerifyNoExtraNotifications(); - - delegate1.reset(); - delegate2.reset(); - - SetExpectedNumberOfNotifiedDelegates(2); - ASSERT_TRUE(file_util::Move(subdir1.AppendASCII("file"), - subdir2.AppendASCII("file"))); - VerifyExpectedNumberOfNotifiedDelegates(); - - delegate1.reset(); - delegate2.reset(); - - SetExpectedNumberOfNotifiedDelegates(1); - ASSERT_TRUE(WriteTestFile(subdir2.AppendASCII("file"), "other content")); - VerifyExpectedNumberOfNotifiedDelegates(); - VerifyNoExtraNotifications(); -} -#endif // defined(OS_WIN) || defined(OS_MACOSX) - -// Verify that watching a directory that doesn't exist fails, but doesn't -// asssert. -// Basic test: add a file and verify we notice it. -TEST_F(DirectoryWatcherTest, NonExistentDirectory) { - DirectoryWatcher watcher; - ASSERT_FALSE(watcher.Watch(test_dir_.AppendASCII("does-not-exist"), - NULL, NULL, false)); -} - -} // namespace diff --git a/base/directory_watcher_win.cc b/base/directory_watcher_win.cc deleted file mode 100644 index e318d4b..0000000 --- a/base/directory_watcher_win.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2009 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 "base/directory_watcher.h" - -#include "base/file_path.h" -#include "base/logging.h" -#include "base/object_watcher.h" -#include "base/ref_counted.h" - -namespace { - -class DirectoryWatcherImpl : public DirectoryWatcher::PlatformDelegate, - public base::ObjectWatcher::Delegate { - public: - DirectoryWatcherImpl() : delegate_(NULL), handle_(INVALID_HANDLE_VALUE) {} - - virtual bool Watch(const FilePath& path, DirectoryWatcher::Delegate* delegate, - MessageLoop* backend_loop, bool recursive); - - // Callback from MessageLoopForIO. - virtual void OnObjectSignaled(HANDLE object); - - private: - virtual ~DirectoryWatcherImpl(); - - // Delegate to notify upon changes. - DirectoryWatcher::Delegate* delegate_; - // Path we're watching (passed to delegate). - FilePath path_; - // Handle for FindFirstChangeNotification. - HANDLE handle_; - // ObjectWatcher to watch handle_ for events. - base::ObjectWatcher watcher_; - - DISALLOW_COPY_AND_ASSIGN(DirectoryWatcherImpl); -}; - -DirectoryWatcherImpl::~DirectoryWatcherImpl() { - if (handle_ != INVALID_HANDLE_VALUE) { - watcher_.StopWatching(); - FindCloseChangeNotification(handle_); - } -} - -bool DirectoryWatcherImpl::Watch(const FilePath& path, - DirectoryWatcher::Delegate* delegate, - MessageLoop* backend_loop, bool recursive) { - DCHECK(path_.value().empty()); // Can only watch one path. - - handle_ = FindFirstChangeNotification( - path.value().c_str(), - recursive, - FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE | - FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_DIR_NAME); - if (handle_ == INVALID_HANDLE_VALUE) - return false; - - delegate_ = delegate; - path_ = path; - watcher_.StartWatching(handle_, this); - - return true; -} - -void DirectoryWatcherImpl::OnObjectSignaled(HANDLE object) { - DCHECK(object == handle_); - // Make sure we stay alive through the body of this function. - scoped_refptr<DirectoryWatcherImpl> keep_alive(this); - - delegate_->OnDirectoryChanged(path_); - - // Register for more notifications on file change. - BOOL ok = FindNextChangeNotification(object); - DCHECK(ok); - watcher_.StartWatching(object, this); -} - -} // namespace - -DirectoryWatcher::DirectoryWatcher() { - impl_ = new DirectoryWatcherImpl(); -} diff --git a/base/dynamic_annotations.cc b/base/dynamic_annotations.cc deleted file mode 100644 index 2ee0975..0000000 --- a/base/dynamic_annotations.cc +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2006-2008 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 "base/dynamic_annotations.h" - -#ifndef NVALGRIND -// Each function is empty and called (via a macro) only in debug mode. -// The arguments are captured by dynamic tools at runtime. - -extern "C" void AnnotateRWLockCreate(const char *file, int line, - const volatile void *lock) {} -extern "C" void AnnotateRWLockDestroy(const char *file, int line, - const volatile void *lock) {} -extern "C" void AnnotateRWLockAcquired(const char *file, int line, - const volatile void *lock, long is_w) {} -extern "C" void AnnotateRWLockReleased(const char *file, int line, - const volatile void *lock, long is_w) {} -extern "C" void AnnotateCondVarWait(const char *file, int line, - const volatile void *cv, - const volatile void *lock) {} -extern "C" void AnnotateCondVarSignal(const char *file, int line, - const volatile void *cv) {} -extern "C" void AnnotateCondVarSignalAll(const char *file, int line, - const volatile void *cv) {} -extern "C" void AnnotatePublishMemoryRange(const char *file, int line, - const volatile void *address, - long size) {} -extern "C" void AnnotatePCQCreate(const char *file, int line, - const volatile void *pcq) {} -extern "C" void AnnotatePCQDestroy(const char *file, int line, - const volatile void *pcq) {} -extern "C" void AnnotatePCQPut(const char *file, int line, - const volatile void *pcq) {} -extern "C" void AnnotatePCQGet(const char *file, int line, - const volatile void *pcq) {} -extern "C" void AnnotateNewMemory(const char *file, int line, - const volatile void *mem, - long size) {} -extern "C" void AnnotateExpectRace(const char *file, int line, - const volatile void *mem, - const char *description) {} -extern "C" void AnnotateBenignRace(const char *file, int line, - const volatile void *mem, - const char *description) {} -extern "C" void AnnotateMutexIsUsedAsCondVar(const char *file, int line, - const volatile void *mu) {} -extern "C" void AnnotateTraceMemory(const char *file, int line, - const volatile void *arg) {} -extern "C" void AnnotateThreadName(const char *file, int line, - const char *name) {} -extern "C" void AnnotateIgnoreReadsBegin(const char *file, int line) {} -extern "C" void AnnotateIgnoreReadsEnd(const char *file, int line) {} -extern "C" void AnnotateIgnoreWritesBegin(const char *file, int line) {} -extern "C" void AnnotateIgnoreWritesEnd(const char *file, int line) {} -extern "C" void AnnotateNoOp(const char *file, int line, - const volatile void *arg) {} -#endif // NVALGRIND - -// When running under valgrind, a non-zero value will be returned. -extern "C" int RunningOnValgrind() { -#if defined(NVALGRIND) - return 0; -#else - return RUNNING_ON_VALGRIND; -#endif -} diff --git a/base/dynamic_annotations.h b/base/dynamic_annotations.h deleted file mode 100644 index 23a2a27..0000000 --- a/base/dynamic_annotations.h +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright (c) 2006-2008 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. - -// This file defines dynamic annotations for use with dynamic analysis -// tool such as valgrind, PIN, etc. -// -// Dynamic annotation is a source code annotation that affects -// the generated code (that is, the annotation is not a comment). -// Each such annotation is attached to a particular -// instruction and/or to a particular object (address) in the program. -// -// The annotations that should be used by users are macros in all upper-case -// (e.g., ANNOTATE_NEW_MEMORY). -// -// Actual implementation of these macros may differ depending on the -// dynamic analysis tool being used. -// -// This file supports the following dynamic analysis tools: -// - None (NVALGRIND is defined). -// Macros are defined empty. -// - ThreadSanitizer (NVALGRIND is not defined). -// Macros are defined as calls to non-inlinable empty functions -// that are intercepted by ThreadSanitizer. -// -#ifndef BASE_DYNAMIC_ANNOTATIONS_H_ -#define BASE_DYNAMIC_ANNOTATIONS_H_ - -#include "base/third_party/valgrind/valgrind.h" - -#ifndef NVALGRIND -// ------------------------------------------------------------- -// Annotations useful when implementing condition variables such as CondVar, -// using conditional critical sections (Await/LockWhen) and when constructing -// user-defined synchronization mechanisms. -// -// The annotations ANNOTATE_HAPPENS_BEFORE() and ANNOTATE_HAPPENS_AFTER() can -// be used to define happens-before arcs in user-defined synchronization -// mechanisms: the race detector will infer an arc from the former to the -// latter when they share the same argument pointer. -// -// Example 1 (reference counting): -// -// void Unref() { -// ANNOTATE_HAPPENS_BEFORE(&refcount_); -// if (AtomicDecrementByOne(&refcount_) == 0) { -// ANNOTATE_HAPPENS_AFTER(&refcount_); -// delete this; -// } -// } -// -// Example 2 (message queue): -// -// void MyQueue::Put(Type *e) { -// MutexLock lock(&mu_); -// ANNOTATE_HAPPENS_BEFORE(e); -// PutElementIntoMyQueue(e); -// } -// -// Type *MyQueue::Get() { -// MutexLock lock(&mu_); -// Type *e = GetElementFromMyQueue(); -// ANNOTATE_HAPPENS_AFTER(e); -// return e; -// } -// -// Note: when possible, please use the existing reference counting and message -// queue implementations instead of inventing new ones. - -// Report that wait on the condition variable at address "cv" has succeeded -// and the lock at address "lock" is held. -#define ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) \ - AnnotateCondVarWait(__FILE__, __LINE__, cv, lock) - -// Report that wait on the condition variable at "cv" has succeeded. Variant -// w/o lock. -#define ANNOTATE_CONDVAR_WAIT(cv) \ - AnnotateCondVarWait(__FILE__, __LINE__, cv, NULL) - -// Report that we are about to signal on the condition variable at address -// "cv". -#define ANNOTATE_CONDVAR_SIGNAL(cv) \ - AnnotateCondVarSignal(__FILE__, __LINE__, cv) - -// Report that we are about to signal_all on the condition variable at "cv". -#define ANNOTATE_CONDVAR_SIGNAL_ALL(cv) \ - AnnotateCondVarSignalAll(__FILE__, __LINE__, cv) - -// Annotations for user-defined synchronization mechanisms. -#define ANNOTATE_HAPPENS_BEFORE(obj) ANNOTATE_CONDVAR_SIGNAL(obj) -#define ANNOTATE_HAPPENS_AFTER(obj) ANNOTATE_CONDVAR_WAIT(obj) - -// Report that the bytes in the range [pointer, pointer+size) are about -// to be published safely. The race checker will create a happens-before -// arc from the call ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) to -// subsequent accesses to this memory. -#define ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) \ - AnnotatePublishMemoryRange(__FILE__, __LINE__, pointer, size) - -// Instruct the tool to create a happens-before arc between mu->Unlock() and -// mu->Lock(). This annotation may slow down the race detector; normally it -// is used only when it would be difficult to annotate each of the mutex's -// critical sections individually using the annotations above. -#define ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) \ - AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu) - -// ------------------------------------------------------------- -// Annotations useful when defining memory allocators, or when memory that -// was protected in one way starts to be protected in another. - -// Report that a new memory at "address" of size "size" has been allocated. -// This might be used when the memory has been retrieved from a free list and -// is about to be reused, or when a the locking discipline for a variable -// changes. -#define ANNOTATE_NEW_MEMORY(address, size) \ - AnnotateNewMemory(__FILE__, __LINE__, address, size) - -// ------------------------------------------------------------- -// Annotations useful when defining FIFO queues that transfer data between -// threads. - -// Report that the producer-consumer queue (such as ProducerConsumerQueue) at -// address "pcq" has been created. The ANNOTATE_PCQ_* annotations -// should be used only for FIFO queues. For non-FIFO queues use -// ANNOTATE_HAPPENS_BEFORE (for put) and ANNOTATE_HAPPENS_AFTER (for get). -#define ANNOTATE_PCQ_CREATE(pcq) \ - AnnotatePCQCreate(__FILE__, __LINE__, pcq) - -// Report that the queue at address "pcq" is about to be destroyed. -#define ANNOTATE_PCQ_DESTROY(pcq) \ - AnnotatePCQDestroy(__FILE__, __LINE__, pcq) - -// Report that we are about to put an element into a FIFO queue at address -// "pcq". -#define ANNOTATE_PCQ_PUT(pcq) \ - AnnotatePCQPut(__FILE__, __LINE__, pcq) - -// Report that we've just got an element from a FIFO queue at address "pcq". -#define ANNOTATE_PCQ_GET(pcq) \ - AnnotatePCQGet(__FILE__, __LINE__, pcq) - -// ------------------------------------------------------------- -// Annotations that suppress errors. It is usually better to express the -// program's synchronization using the other annotations, but these can -// be used when all else fails. - -// Report that we may have a benign race on at "address". -// Insert at the point where "address" has been allocated, preferably close -// to the point where the race happens. -// See also ANNOTATE_BENIGN_RACE_STATIC. -#define ANNOTATE_BENIGN_RACE(address, description) \ - AnnotateBenignRace(__FILE__, __LINE__, address, description) - -// Request the analysis tool to ignore all reads in the current thread -// until ANNOTATE_IGNORE_READS_END is called. -// Useful to ignore intentional racey reads, while still checking -// other reads and all writes. -// See also ANNOTATE_UNPROTECTED_READ. -#define ANNOTATE_IGNORE_READS_BEGIN() \ - AnnotateIgnoreReadsBegin(__FILE__, __LINE__) - -// Stop ignoring reads. -#define ANNOTATE_IGNORE_READS_END() \ - AnnotateIgnoreReadsEnd(__FILE__, __LINE__) - -// Similar to ANNOTATE_IGNORE_READS_BEGIN, but ignore writes. -#define ANNOTATE_IGNORE_WRITES_BEGIN() \ - AnnotateIgnoreWritesBegin(__FILE__, __LINE__) - -// Stop ignoring writes. -#define ANNOTATE_IGNORE_WRITES_END() \ - AnnotateIgnoreWritesEnd(__FILE__, __LINE__) - -// Start ignoring all memory accesses (reads and writes). -#define ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \ - do {\ - ANNOTATE_IGNORE_READS_BEGIN();\ - ANNOTATE_IGNORE_WRITES_BEGIN();\ - }while(0)\ - -// Stop ignoring all memory accesses. -#define ANNOTATE_IGNORE_READS_AND_WRITES_END() \ - do {\ - ANNOTATE_IGNORE_WRITES_END();\ - ANNOTATE_IGNORE_READS_END();\ - }while(0)\ - -// ------------------------------------------------------------- -// Annotations useful for debugging. - -// Request to trace every access to "address". -#define ANNOTATE_TRACE_MEMORY(address) \ - AnnotateTraceMemory(__FILE__, __LINE__, address) - -// Report the current thread name to a race detector. -#define ANNOTATE_THREAD_NAME(name) \ - AnnotateThreadName(__FILE__, __LINE__, name) - -// ------------------------------------------------------------- -// Annotations useful when implementing locks. They are not -// normally needed by modules that merely use locks. -// The "lock" argument is a pointer to the lock object. - -// Report that a lock has been created at address "lock". -#define ANNOTATE_RWLOCK_CREATE(lock) \ - AnnotateRWLockCreate(__FILE__, __LINE__, lock) - -// Report that the lock at address "lock" is about to be destroyed. -#define ANNOTATE_RWLOCK_DESTROY(lock) \ - AnnotateRWLockDestroy(__FILE__, __LINE__, lock) - -// Report that the lock at address "lock" has been acquired. -// is_w=1 for writer lock, is_w=0 for reader lock. -#define ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) \ - AnnotateRWLockAcquired(__FILE__, __LINE__, lock, is_w) - -// Report that the lock at address "lock" is about to be released. -#define ANNOTATE_RWLOCK_RELEASED(lock, is_w) \ - AnnotateRWLockReleased(__FILE__, __LINE__, lock, is_w) - -// ------------------------------------------------------------- -// Annotations useful for testing race detectors. - -// Report that we expect a race on the variable at "address". -// Use only in unit tests for a race detector. -#define ANNOTATE_EXPECT_RACE(address, description) \ - AnnotateExpectRace(__FILE__, __LINE__, address, description) - -// A no-op. Insert where you like to test the interceptors. -#define ANNOTATE_NO_OP(arg) \ - AnnotateNoOp(__FILE__, __LINE__, arg) - -// Use the macros above rather than using these functions directly. -extern "C" void AnnotateRWLockCreate(const char *file, int line, - const volatile void *lock); -extern "C" void AnnotateRWLockDestroy(const char *file, int line, - const volatile void *lock); -extern "C" void AnnotateRWLockAcquired(const char *file, int line, - const volatile void *lock, long is_w); -extern "C" void AnnotateRWLockReleased(const char *file, int line, - const volatile void *lock, long is_w); -extern "C" void AnnotateCondVarWait(const char *file, int line, - const volatile void *cv, - const volatile void *lock); -extern "C" void AnnotateCondVarSignal(const char *file, int line, - const volatile void *cv); -extern "C" void AnnotateCondVarSignalAll(const char *file, int line, - const volatile void *cv); -extern "C" void AnnotatePublishMemoryRange(const char *file, int line, - const volatile void *address, - long size); -extern "C" void AnnotatePCQCreate(const char *file, int line, - const volatile void *pcq); -extern "C" void AnnotatePCQDestroy(const char *file, int line, - const volatile void *pcq); -extern "C" void AnnotatePCQPut(const char *file, int line, - const volatile void *pcq); -extern "C" void AnnotatePCQGet(const char *file, int line, - const volatile void *pcq); -extern "C" void AnnotateNewMemory(const char *file, int line, - const volatile void *address, - long size); -extern "C" void AnnotateExpectRace(const char *file, int line, - const volatile void *address, - const char *description); -extern "C" void AnnotateBenignRace(const char *file, int line, - const volatile void *address, - const char *description); -extern "C" void AnnotateMutexIsUsedAsCondVar(const char *file, int line, - const volatile void *mu); -extern "C" void AnnotateTraceMemory(const char *file, int line, - const volatile void *arg); -extern "C" void AnnotateThreadName(const char *file, int line, - const char *name); -extern "C" void AnnotateIgnoreReadsBegin(const char *file, int line); -extern "C" void AnnotateIgnoreReadsEnd(const char *file, int line); -extern "C" void AnnotateIgnoreWritesBegin(const char *file, int line); -extern "C" void AnnotateIgnoreWritesEnd(const char *file, int line); -extern "C" void AnnotateNoOp(const char *file, int line, - const volatile void *arg); - -// ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads. -// -// Instead of doing -// ANNOTATE_IGNORE_READS_BEGIN(); -// ... = x; -// ANNOTATE_IGNORE_READS_END(); -// one can use -// ... = ANNOTATE_UNPROTECTED_READ(x); -template <class T> -inline T ANNOTATE_UNPROTECTED_READ(const volatile T &x) { - ANNOTATE_IGNORE_READS_BEGIN(); - T res = x; - ANNOTATE_IGNORE_READS_END(); - return res; -} - -// Apply ANNOTATE_BENIGN_RACE to a static variable. -#define ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \ - namespace { \ - class static_var ## _annotator { \ - public: \ - static_var ## _annotator() { \ - ANNOTATE_BENIGN_RACE(&static_var, \ - # static_var ": " description); \ - } \ - }; \ - static static_var ## _annotator the ## static_var ## _annotator;\ - } - -#else -// NVALGRIND is defined, empty macros. - -#define ANNOTATE_RWLOCK_CREATE(lock) // empty -#define ANNOTATE_RWLOCK_DESTROY(lock) // empty -#define ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) // empty -#define ANNOTATE_RWLOCK_RELEASED(lock, is_w) // empty -#define ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) // empty -#define ANNOTATE_CONDVAR_WAIT(cv) // empty -#define ANNOTATE_CONDVAR_SIGNAL(cv) // empty -#define ANNOTATE_CONDVAR_SIGNAL_ALL(cv) // empty -#define ANNOTATE_HAPPENS_BEFORE(obj) // empty -#define ANNOTATE_HAPPENS_AFTER(obj) // empty -#define ANNOTATE_PUBLISH_MEMORY_RANGE(address, size) // empty -#define ANNOTATE_PUBLISH_OBJECT(address) // empty -#define ANNOTATE_PCQ_CREATE(pcq) // empty -#define ANNOTATE_PCQ_DESTROY(pcq) // empty -#define ANNOTATE_PCQ_PUT(pcq) // empty -#define ANNOTATE_PCQ_GET(pcq) // empty -#define ANNOTATE_NEW_MEMORY(address, size) // empty -#define ANNOTATE_EXPECT_RACE(address, description) // empty -#define ANNOTATE_BENIGN_RACE(address, description) // empty -#define ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) // empty -#define ANNOTATE_TRACE_MEMORY(arg) // empty -#define ANNOTATE_THREAD_NAME(name) // empty -#define ANNOTATE_IGNORE_READS_BEGIN() // empty -#define ANNOTATE_IGNORE_READS_END() // empty -#define ANNOTATE_IGNORE_WRITES_BEGIN() // empty -#define ANNOTATE_IGNORE_WRITES_END() // empty -#define ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() // empty -#define ANNOTATE_IGNORE_READS_AND_WRITES_END() // empty -#define ANNOTATE_NO_OP(arg) // empty -#define ANNOTATE_UNPROTECTED_READ(x) (x) -#define ANNOTATE_BENIGN_RACE_STATIC(static_var, description) // empty - -#endif // NVALGRIND - -// Return non-zero value if running under valgrind. -extern "C" int RunningOnValgrind(); - -#endif // BASE_DYNAMIC_ANNOTATIONS_H_ diff --git a/base/file_version_info.cc b/base/file_version_info.cc deleted file mode 100644 index f9bee21..0000000 --- a/base/file_version_info.cc +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright (c) 2006-2008 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 "base/file_version_info.h" - -#include <windows.h> - -#include "base/file_path.h" -#include "base/logging.h" -#include "base/path_service.h" - -// This has to be last. -#include <strsafe.h> - -FileVersionInfo::FileVersionInfo(void* data, int language, int code_page) - : language_(language), code_page_(code_page) { - data_.reset((char*) data); - fixed_file_info_ = NULL; - UINT size; - ::VerQueryValue(data_.get(), L"\\", (LPVOID*)&fixed_file_info_, &size); -} - -FileVersionInfo::~FileVersionInfo() { - DCHECK(data_.get()); -} - -typedef struct { - WORD language; - WORD code_page; -} LanguageAndCodePage; - -// static -FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { - FilePath app_path; - if (!PathService::Get(base::FILE_MODULE, &app_path)) - return NULL; - - return CreateFileVersionInfo(app_path); -} - -// static -FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( - const FilePath& file_path) { - DWORD dummy; - const wchar_t* path = file_path.value().c_str(); - DWORD length = ::GetFileVersionInfoSize(path, &dummy); - if (length == 0) - return NULL; - - void* data = calloc(length, 1); - if (!data) - return NULL; - - if (!::GetFileVersionInfo(path, dummy, length, data)) { - free(data); - return NULL; - } - - LanguageAndCodePage* translate = NULL; - uint32 page_count; - BOOL query_result = VerQueryValue(data, L"\\VarFileInfo\\Translation", - (void**) &translate, &page_count); - - if (query_result && translate) { - return new FileVersionInfo(data, translate->language, - translate->code_page); - - } else { - free(data); - return NULL; - } -} - -FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( - const std::wstring& file_path) { - FilePath file_path_fp = FilePath::FromWStringHack(file_path); - return CreateFileVersionInfo(file_path_fp); -} - -std::wstring FileVersionInfo::company_name() { - return GetStringValue(L"CompanyName"); -} - -std::wstring FileVersionInfo::company_short_name() { - return GetStringValue(L"CompanyShortName"); -} - -std::wstring FileVersionInfo::internal_name() { - return GetStringValue(L"InternalName"); -} - -std::wstring FileVersionInfo::product_name() { - return GetStringValue(L"ProductName"); -} - -std::wstring FileVersionInfo::product_short_name() { - return GetStringValue(L"ProductShortName"); -} - -std::wstring FileVersionInfo::comments() { - return GetStringValue(L"Comments"); -} - -std::wstring FileVersionInfo::legal_copyright() { - return GetStringValue(L"LegalCopyright"); -} - -std::wstring FileVersionInfo::product_version() { - return GetStringValue(L"ProductVersion"); -} - -std::wstring FileVersionInfo::file_description() { - return GetStringValue(L"FileDescription"); -} - -std::wstring FileVersionInfo::legal_trademarks() { - return GetStringValue(L"LegalTrademarks"); -} - -std::wstring FileVersionInfo::private_build() { - return GetStringValue(L"PrivateBuild"); -} - -std::wstring FileVersionInfo::file_version() { - return GetStringValue(L"FileVersion"); -} - -std::wstring FileVersionInfo::original_filename() { - return GetStringValue(L"OriginalFilename"); -} - -std::wstring FileVersionInfo::special_build() { - return GetStringValue(L"SpecialBuild"); -} - -std::wstring FileVersionInfo::last_change() { - return GetStringValue(L"LastChange"); -} - -bool FileVersionInfo::is_official_build() { - return (GetStringValue(L"Official Build").compare(L"1") == 0); -} - -bool FileVersionInfo::GetValue(const wchar_t* name, std::wstring* value_str) { - - WORD lang_codepage[8]; - int i = 0; - // Use the language and codepage from the DLL. - lang_codepage[i++] = language_; - lang_codepage[i++] = code_page_; - // Use the default language and codepage from the DLL. - lang_codepage[i++] = ::GetUserDefaultLangID(); - lang_codepage[i++] = code_page_; - // Use the language from the DLL and Latin codepage (most common). - lang_codepage[i++] = language_; - lang_codepage[i++] = 1252; - // Use the default language and Latin codepage (most common). - lang_codepage[i++] = ::GetUserDefaultLangID(); - lang_codepage[i++] = 1252; - - i = 0; - while (i < arraysize(lang_codepage)) { - wchar_t sub_block[MAX_PATH]; - WORD language = lang_codepage[i++]; - WORD code_page = lang_codepage[i++]; - _snwprintf_s(sub_block, MAX_PATH, MAX_PATH, - L"\\StringFileInfo\\%04x%04x\\%ls", language, code_page, name); - LPVOID value = NULL; - uint32 size; - BOOL r = ::VerQueryValue(data_.get(), sub_block, &value, &size); - if (r && value) { - value_str->assign(static_cast<wchar_t*>(value)); - return true; - } - } - return false; -} - -std::wstring FileVersionInfo::GetStringValue(const wchar_t* name) { - std::wstring str; - if (GetValue(name, &str)) - return str; - else - return L""; -} diff --git a/base/file_version_info_linux.cc b/base/file_version_info_linux.cc deleted file mode 100644 index 55e1bd2..0000000 --- a/base/file_version_info_linux.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2008 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 "base/file_version_info.h" -#include "base/file_version_info_linux.h" - -#include <string> - -// TODO(mmoss) This only provides version info for the current binary, but it's -// also called for arbitrary files (e.g. plugins). -// See http://code.google.com/p/chromium/issues/detail?id=8132 for a discussion -// on what we should do with this module. - -FileVersionInfo::FileVersionInfo() {} - -FileVersionInfo::~FileVersionInfo() {} - -// static -FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { - return new FileVersionInfo(); -} - -std::wstring FileVersionInfo::company_name() { - return COMPANY_NAME; -} - -std::wstring FileVersionInfo::company_short_name() { - return COMPANY_SHORT_NAME; -} - -std::wstring FileVersionInfo::product_name() { - return PRODUCT_NAME; -} - -std::wstring FileVersionInfo::product_short_name() { - return PRODUCT_SHORT_NAME; -} - -std::wstring FileVersionInfo::internal_name() { - return INTERNAL_NAME; -} - -std::wstring FileVersionInfo::product_version() { - return PRODUCT_VERSION; -} - -std::wstring FileVersionInfo::private_build() { - return PRIVATE_BUILD; -} - -std::wstring FileVersionInfo::special_build() { - return SPECIAL_BUILD; -} - -std::wstring FileVersionInfo::comments() { - return COMMENTS; -} - -std::wstring FileVersionInfo::original_filename() { - return ORIGINAL_FILENAME; -} - -std::wstring FileVersionInfo::file_description() { - return FILE_DESCRIPTION; -} - -std::wstring FileVersionInfo::file_version() { - return FILE_VERSION; -} - -std::wstring FileVersionInfo::legal_copyright() { - return LEGAL_COPYRIGHT; -} - -std::wstring FileVersionInfo::legal_trademarks() { - return LEGAL_TRADEMARKS; -} - -std::wstring FileVersionInfo::last_change() { - return LAST_CHANGE; -} - -bool FileVersionInfo::is_official_build() { - return OFFICIAL_BUILD; -} diff --git a/base/file_version_info_linux.h.version b/base/file_version_info_linux.h.version deleted file mode 100644 index 88bf234..0000000 --- a/base/file_version_info_linux.h.version +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2009 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. - -#ifndef BASE_FILE_VERSION_INFO_LINUX_H_ -#define BASE_FILE_VERSION_INFO_LINUX_H_ - -#define COMPANY_NAME L"@COMPANY_FULLNAME@" -#define FILE_DESCRIPTION L"@PRODUCT_FULLNAME@" -#define FILE_VERSION L"@MAJOR@.@MINOR@.@BUILD@.@PATCH@" -#define LEGAL_COPYRIGHT L"@COPYRIGHT@" -#define PRODUCT_NAME L"@PRODUCT_FULLNAME@" -#define PRODUCT_VERSION L"@MAJOR@.@MINOR@.@BUILD@.@PATCH@" -#define COMPANY_SHORT_NAME L"@COMPANY_SHORTNAME@" -#define PRODUCT_SHORT_NAME L"@PRODUCT_SHORTNAME@" -#define LAST_CHANGE L"@LASTCHANGE@" -#define OFFICIAL_BUILD @OFFICIAL_BUILD@ -// TODO(mmoss) Do these have values for Linux? -#define INTERNAL_NAME L"" -#define ORIGINAL_FILENAME L"" -#define PRIVATE_BUILD L"" -#define SPECIAL_BUILD L"" -#define COMMENTS L"" -#define LEGAL_TRADEMARKS L"" - -#endif // BASE_FILE_VERSION_INFO_LINUX_H_ diff --git a/base/gfx/point.cc b/base/gfx/point.cc deleted file mode 100644 index 05b7596..0000000 --- a/base/gfx/point.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2006-2008 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 "base/gfx/point.h" - -#if defined(OS_WIN) -#include <windows.h> -#endif - -#include <iostream> - -namespace gfx { - -Point::Point() : x_(0), y_(0) { -} - -Point::Point(int x, int y) : x_(x), y_(y) { -} - -#if defined(OS_WIN) -Point::Point(DWORD point) { - POINTS points = MAKEPOINTS(point); - x_ = points.x; - y_ = points.y; -} - -Point::Point(const POINT& point) : x_(point.x), y_(point.y) { -} - -Point& Point::operator=(const POINT& point) { - x_ = point.x; - y_ = point.y; - return *this; -} - -POINT Point::ToPOINT() const { - POINT p; - p.x = x_; - p.y = y_; - return p; -} -#elif defined(OS_MACOSX) -Point::Point(const CGPoint& point) : x_(point.x), y_(point.y) { -} - -CGPoint Point::ToCGPoint() const { - return CGPointMake(x_, y_); -} -#endif - -} // namespace gfx - -std::ostream& operator<<(std::ostream& out, const gfx::Point& p) { - return out << p.x() << "," << p.y(); -} diff --git a/base/gfx/point.h b/base/gfx/point.h deleted file mode 100644 index 513d555..0000000 --- a/base/gfx/point.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#ifndef BASE_GFX_POINT_H__ -#define BASE_GFX_POINT_H__ - -#include "build/build_config.h" - -#include <iosfwd> - -#if defined(OS_WIN) -typedef unsigned long DWORD; -typedef struct tagPOINT POINT; -#elif defined(OS_MACOSX) -#include <ApplicationServices/ApplicationServices.h> -#endif - -namespace gfx { - -// -// A point has an x and y coordinate. -// -class Point { - public: - Point(); - Point(int x, int y); -#if defined(OS_WIN) - // |point| is a DWORD value that contains a coordinate. The x-coordinate is - // the low-order short and the y-coordinate is the high-order short. This - // value is commonly acquired from GetMessagePos/GetCursorPos. - explicit Point(DWORD point); - explicit Point(const POINT& point); - Point& operator=(const POINT& point); -#elif defined(OS_MACOSX) - explicit Point(const CGPoint& point); -#endif - - ~Point() {} - - int x() const { return x_; } - int y() const { return y_; } - - void SetPoint(int x, int y) { - x_ = x; - y_ = y; - } - - void set_x(int x) { x_ = x; } - void set_y(int y) { y_ = y; } - - void Offset(int delta_x, int delta_y) { - x_ += delta_x; - y_ += delta_y; - } - - bool operator==(const Point& rhs) const { - return x_ == rhs.x_ && y_ == rhs.y_; - } - - bool operator!=(const Point& rhs) const { - return !(*this == rhs); - } - -#if defined(OS_WIN) - POINT ToPOINT() const; -#elif defined(OS_MACOSX) - CGPoint ToCGPoint() const; -#endif - - private: - int x_; - int y_; -}; - -} // namespace gfx - -std::ostream& operator<<(std::ostream& out, const gfx::Point& p); - -#endif // BASE_GFX_POINT_H__ diff --git a/base/gfx/rect.cc b/base/gfx/rect.cc deleted file mode 100644 index 961fa03..0000000 --- a/base/gfx/rect.cc +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright (c) 2009 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 "base/gfx/rect.h" - -#if defined(OS_WIN) -#include <windows.h> -#elif defined(OS_MACOSX) -#include <CoreGraphics/CGGeometry.h> -#elif defined(OS_POSIX) -#include <gdk/gdk.h> -#endif - -#include <iostream> - -#include "base/logging.h" - -namespace { - -void AdjustAlongAxis(int dst_origin, int dst_size, int* origin, int* size) { - if (*origin < dst_origin) { - *origin = dst_origin; - *size = std::min(dst_size, *size); - } else { - *size = std::min(dst_size, *size); - *origin = std::min(dst_origin + dst_size, *origin + *size) - *size; - } -} - -} // namespace - -namespace gfx { - -Rect::Rect() { -} - -Rect::Rect(int width, int height) { - set_width(width); - set_height(height); -} - -Rect::Rect(int x, int y, int width, int height) - : origin_(x, y) { - set_width(width); - set_height(height); -} - -Rect::Rect(const gfx::Point& origin, const gfx::Size& size) - : origin_(origin), size_(size) { -} - -#if defined(OS_WIN) -Rect::Rect(const RECT& r) - : origin_(r.left, r.top) { - set_width(r.right - r.left); - set_height(r.bottom - r.top); -} - -Rect& Rect::operator=(const RECT& r) { - origin_.SetPoint(r.left, r.top); - set_width(r.right - r.left); - set_height(r.bottom - r.top); - return *this; -} -#elif defined(OS_MACOSX) -Rect::Rect(const CGRect& r) - : origin_(r.origin.x, r.origin.y) { - set_width(r.size.width); - set_height(r.size.height); -} - -Rect& Rect::operator=(const CGRect& r) { - origin_.SetPoint(r.origin.x, r.origin.y); - set_width(r.size.width); - set_height(r.size.height); - return *this; -} -#elif defined(OS_POSIX) -Rect::Rect(const GdkRectangle& r) - : origin_(r.x, r.y) { - set_width(r.width); - set_height(r.height); -} - -Rect& Rect::operator=(const GdkRectangle& r) { - origin_.SetPoint(r.x, r.y); - set_width(r.width); - set_height(r.height); - return *this; -} -#endif - -void Rect::set_width(int width) { - size_.set_width(width); -} -void Rect::set_height(int height) { - size_.set_height(height); -} - -void Rect::SetRect(int x, int y, int width, int height) { - origin_.SetPoint(x, y); - set_width(width); - set_height(height); -} - -void Rect::Inset(int left, int top, int right, int bottom) { - Offset(left, top); - set_width(std::max(width() - left - right, 0)); - set_height(std::max(height() - top - bottom, 0)); -} - -void Rect::Offset(int horizontal, int vertical) { - set_x(x() + horizontal); - set_y(y() + vertical); -} - -bool Rect::operator==(const Rect& other) const { - return origin_ == other.origin_ && size_ == other.size_; -} - -#if defined(OS_WIN) -RECT Rect::ToRECT() const { - RECT r; - r.left = x(); - r.right = right(); - r.top = y(); - r.bottom = bottom(); - return r; -} -#elif defined(OS_MACOSX) -CGRect Rect::ToCGRect() const { - return CGRectMake(x(), y(), width(), height()); -} -#elif defined(OS_POSIX) -GdkRectangle Rect::ToGdkRectangle() const { - GdkRectangle r = {x(), y(), width(), height()}; - return r; -} -#endif - -bool Rect::Contains(int point_x, int point_y) const { - return (point_x >= x()) && (point_x < right()) && - (point_y >= y()) && (point_y < bottom()); -} - -bool Rect::Contains(const Rect& rect) const { - return (rect.x() >= x() && rect.right() <= right() && - rect.y() >= y() && rect.bottom() <= bottom()); -} - -bool Rect::Intersects(const Rect& rect) const { - return !(rect.x() >= right() || rect.right() <= x() || - rect.y() >= bottom() || rect.bottom() <= y()); -} - -Rect Rect::Intersect(const Rect& rect) const { - int rx = std::max(x(), rect.x()); - int ry = std::max(y(), rect.y()); - int rr = std::min(right(), rect.right()); - int rb = std::min(bottom(), rect.bottom()); - - if (rx >= rr || ry >= rb) - rx = ry = rr = rb = 0; // non-intersecting - - return Rect(rx, ry, rr - rx, rb - ry); -} - -Rect Rect::Union(const Rect& rect) const { - // special case empty rects... - if (IsEmpty()) - return rect; - if (rect.IsEmpty()) - return *this; - - int rx = std::min(x(), rect.x()); - int ry = std::min(y(), rect.y()); - int rr = std::max(right(), rect.right()); - int rb = std::max(bottom(), rect.bottom()); - - return Rect(rx, ry, rr - rx, rb - ry); -} - -Rect Rect::Subtract(const Rect& rect) const { - // boundary cases: - if (!Intersects(rect)) - return *this; - if (rect.Contains(*this)) - return Rect(); - - int rx = x(); - int ry = y(); - int rr = right(); - int rb = bottom(); - - if (rect.y() <= y() && rect.bottom() >= bottom()) { - // complete intersection in the y-direction - if (rect.x() <= x()) { - rx = rect.right(); - } else { - rr = rect.x(); - } - } else if (rect.x() <= x() && rect.right() >= right()) { - // complete intersection in the x-direction - if (rect.y() <= y()) { - ry = rect.bottom(); - } else { - rb = rect.y(); - } - } - return Rect(rx, ry, rr - rx, rb - ry); -} - -Rect Rect::AdjustToFit(const Rect& rect) const { - int new_x = x(); - int new_y = y(); - int new_width = width(); - int new_height = height(); - AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width); - AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height); - return Rect(new_x, new_y, new_width, new_height); -} - -Point Rect::CenterPoint() const { - return Point(x() + (width() + 1) / 2, y() + (height() + 1) / 2); -} - -bool Rect::SharesEdgeWith(const gfx::Rect& rect) const { - return (y() == rect.y() && height() == rect.height() && - (x() == rect.right() || right() == rect.x())) || - (x() == rect.x() && width() == rect.width() && - (y() == rect.bottom() || bottom() == rect.y())); -} - -} // namespace gfx - -std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) { - return out << r.origin() << " " << r.size(); -} diff --git a/base/gfx/rect.h b/base/gfx/rect.h deleted file mode 100644 index c3c01ad..0000000 --- a/base/gfx/rect.h +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (c) 2009 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. - -// Defines a simple integer rectangle class. The containment semantics -// are array-like; that is, the coordinate (x, y) is considered to be -// contained by the rectangle, but the coordinate (x + width, y) is not. -// The class will happily let you create malformed rectangles (that is, -// rectangles with negative width and/or height), but there will be assertions -// in the operations (such as contain()) to complain in this case. - -#ifndef BASE_GFX_RECT_H__ -#define BASE_GFX_RECT_H__ - -#include <iosfwd> - -#include "base/gfx/point.h" -#include "base/gfx/size.h" - -#if defined(OS_WIN) -typedef struct tagRECT RECT; -#elif defined(USE_X11) -typedef struct _GdkRectangle GdkRectangle; -#endif - -namespace gfx { - -class Rect { - public: - Rect(); - Rect(int width, int height); - Rect(int x, int y, int width, int height); -#if defined(OS_WIN) - explicit Rect(const RECT& r); -#elif defined(OS_MACOSX) - explicit Rect(const CGRect& r); -#elif defined(USE_X11) - explicit Rect(const GdkRectangle& r); -#endif - Rect(const gfx::Point& origin, const gfx::Size& size); - - ~Rect() {} - -#if defined(OS_WIN) - Rect& operator=(const RECT& r); -#elif defined(OS_MACOSX) - Rect& operator=(const CGRect& r); -#elif defined(USE_X11) - Rect& operator=(const GdkRectangle& r); -#endif - - int x() const { return origin_.x(); } - void set_x(int x) { origin_.set_x(x); } - - int y() const { return origin_.y(); } - void set_y(int y) { origin_.set_y(y); } - - int width() const { return size_.width(); } - void set_width(int width); - - int height() const { return size_.height(); } - void set_height(int height); - - const gfx::Point& origin() const { return origin_; } - void set_origin(const gfx::Point& origin) { origin_ = origin; } - - const gfx::Size& size() const { return size_; } - void set_size(const gfx::Size& size) { size_ = size; } - - int right() const { return x() + width(); } - int bottom() const { return y() + height(); } - - void SetRect(int x, int y, int width, int height); - - // Shrink the rectangle by a horizontal and vertical distance on all sides. - void Inset(int horizontal, int vertical) { - Inset(horizontal, vertical, horizontal, vertical); - } - - // Shrink the rectangle by the specified amount on each side. - void Inset(int left, int top, int right, int bottom); - - // Move the rectangle by a horizontal and vertical distance. - void Offset(int horizontal, int vertical); - void Offset(const gfx::Point& point) { - Offset(point.x(), point.y()); - } - - // Returns true if the area of the rectangle is zero. - bool IsEmpty() const { return size_.IsEmpty(); } - - bool operator==(const Rect& other) const; - - bool operator!=(const Rect& other) const { - return !(*this == other); - } - -#if defined(OS_WIN) - // Construct an equivalent Win32 RECT object. - RECT ToRECT() const; -#elif defined(USE_X11) - GdkRectangle ToGdkRectangle() const; -#elif defined(OS_MACOSX) - // Construct an equivalent CoreGraphics object. - CGRect ToCGRect() const; -#endif - - // Returns true if the point identified by point_x and point_y falls inside - // this rectangle. The point (x, y) is inside the rectangle, but the - // point (x + width, y + height) is not. - bool Contains(int point_x, int point_y) const; - - // Returns true if the specified point is contained by this rectangle. - bool Contains(const gfx::Point& point) const { - return Contains(point.x(), point.y()); - } - - // Returns true if this rectangle contains the specified rectangle. - bool Contains(const Rect& rect) const; - - // Returns true if this rectangle intersects the specified rectangle. - bool Intersects(const Rect& rect) const; - - // Computes the intersection of this rectangle with the given rectangle. - Rect Intersect(const Rect& rect) const; - - // Computes the union of this rectangle with the given rectangle. The union - // is the smallest rectangle containing both rectangles. - Rect Union(const Rect& rect) const; - - // Computes the rectangle resulting from subtracting |rect| from |this|. If - // |rect| does not intersect completely in either the x- or y-direction, then - // |*this| is returned. If |rect| contains |this|, then an empty Rect is - // returned. - Rect Subtract(const Rect& rect) const; - - // Returns true if this rectangle equals that of the supplied rectangle. - bool Equals(const Rect& rect) const { - return *this == rect; - } - - // Fits as much of the receiving rectangle into the supplied rectangle as - // possible, returning the result. For example, if the receiver had - // a x-location of 2 and a width of 4, and the supplied rectangle had - // an x-location of 0 with a width of 5, the returned rectangle would have - // an x-location of 1 with a width of 4. - Rect AdjustToFit(const Rect& rect) const; - - // Returns the center of this rectangle. - Point CenterPoint() const; - - // Returns true if this rectangle shares an entire edge (i.e., same width or - // same height) with the given rectangle, and the rectangles do not overlap. - bool SharesEdgeWith(const gfx::Rect& rect) const; - - private: - gfx::Point origin_; - gfx::Size size_; -}; - -} // namespace gfx - -std::ostream& operator<<(std::ostream& out, const gfx::Rect& r); - -#endif // BASE_GFX_RECT_H__ diff --git a/base/gfx/rect_unittest.cc b/base/gfx/rect_unittest.cc deleted file mode 100644 index 3562883..0000000 --- a/base/gfx/rect_unittest.cc +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright (c) 2006-2008 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 "base/basictypes.h" -#include "base/gfx/rect.h" -#include "testing/gtest/include/gtest/gtest.h" - -typedef testing::Test RectTest; - -TEST(RectTest, Contains) { - static const struct ContainsCase { - int rect_x; - int rect_y; - int rect_width; - int rect_height; - int point_x; - int point_y; - bool contained; - } contains_cases[] = { - {0, 0, 10, 10, 0, 0, true}, - {0, 0, 10, 10, 5, 5, true}, - {0, 0, 10, 10, 9, 9, true}, - {0, 0, 10, 10, 5, 10, false}, - {0, 0, 10, 10, 10, 5, false}, - {0, 0, 10, 10, -1, -1, false}, - {0, 0, 10, 10, 50, 50, false}, - #ifdef NDEBUG - {0, 0, -10, -10, 0, 0, false}, - #endif // NDEBUG - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(contains_cases); ++i) { - const ContainsCase& value = contains_cases[i]; - gfx::Rect rect(value.rect_x, value.rect_y, - value.rect_width, value.rect_height); - EXPECT_EQ(value.contained, rect.Contains(value.point_x, value.point_y)); - } -} - -TEST(RectTest, Intersects) { - static const struct { - int x1; // rect 1 - int y1; - int w1; - int h1; - int x2; // rect 2 - int y2; - int w2; - int h2; - bool intersects; - } tests[] = { - { 0, 0, 0, 0, 0, 0, 0, 0, false }, - { 0, 0, 10, 10, 0, 0, 10, 10, true }, - { 0, 0, 10, 10, 10, 10, 10, 10, false }, - { 10, 10, 10, 10, 0, 0, 10, 10, false }, - { 10, 10, 10, 10, 5, 5, 10, 10, true }, - { 10, 10, 10, 10, 15, 15, 10, 10, true }, - { 10, 10, 10, 10, 20, 15, 10, 10, false }, - { 10, 10, 10, 10, 21, 15, 10, 10, false } - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - EXPECT_EQ(tests[i].intersects, r1.Intersects(r2)); - } -} - -TEST(RectTest, Intersect) { - static const struct { - int x1; // rect 1 - int y1; - int w1; - int h1; - int x2; // rect 2 - int y2; - int w2; - int h2; - int x3; // rect 3: the union of rects 1 and 2 - int y3; - int w3; - int h3; - } tests[] = { - { 0, 0, 0, 0, // zeros - 0, 0, 0, 0, - 0, 0, 0, 0 }, - { 0, 0, 4, 4, // equal - 0, 0, 4, 4, - 0, 0, 4, 4 }, - { 0, 0, 4, 4, // neighboring - 4, 4, 4, 4, - 0, 0, 0, 0 }, - { 0, 0, 4, 4, // overlapping corners - 2, 2, 4, 4, - 2, 2, 2, 2 }, - { 0, 0, 4, 4, // T junction - 3, 1, 4, 2, - 3, 1, 1, 2 }, - { 3, 0, 2, 2, // gap - 0, 0, 2, 2, - 0, 0, 0, 0 } - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - gfx::Rect ir = r1.Intersect(r2); - EXPECT_EQ(r3.x(), ir.x()); - EXPECT_EQ(r3.y(), ir.y()); - EXPECT_EQ(r3.width(), ir.width()); - EXPECT_EQ(r3.height(), ir.height()); - } -} - -TEST(RectTest, Union) { - static const struct Test { - int x1; // rect 1 - int y1; - int w1; - int h1; - int x2; // rect 2 - int y2; - int w2; - int h2; - int x3; // rect 3: the union of rects 1 and 2 - int y3; - int w3; - int h3; - } tests[] = { - { 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 }, - { 0, 0, 4, 4, - 0, 0, 4, 4, - 0, 0, 4, 4 }, - { 0, 0, 4, 4, - 4, 4, 4, 4, - 0, 0, 8, 8 }, - { 0, 0, 4, 4, - 0, 5, 4, 4, - 0, 0, 4, 9 }, - { 0, 0, 2, 2, - 3, 3, 2, 2, - 0, 0, 5, 5 }, - { 3, 3, 2, 2, // reverse r1 and r2 from previous test - 0, 0, 2, 2, - 0, 0, 5, 5 }, - { 0, 0, 0, 0, // union with empty rect - 2, 2, 2, 2, - 2, 2, 2, 2 } - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - gfx::Rect u = r1.Union(r2); - EXPECT_EQ(r3.x(), u.x()); - EXPECT_EQ(r3.y(), u.y()); - EXPECT_EQ(r3.width(), u.width()); - EXPECT_EQ(r3.height(), u.height()); - } -} - -TEST(RectTest, Equals) { - ASSERT_TRUE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(0, 0, 0, 0))); - ASSERT_TRUE(gfx::Rect(1, 2, 3, 4).Equals(gfx::Rect(1, 2, 3, 4))); - ASSERT_FALSE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(0, 0, 0, 1))); - ASSERT_FALSE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(0, 0, 1, 0))); - ASSERT_FALSE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(0, 1, 0, 0))); - ASSERT_FALSE(gfx::Rect(0, 0, 0, 0).Equals(gfx::Rect(1, 0, 0, 0))); -} - -TEST(RectTest, AdjustToFit) { - static const struct Test { - int x1; // source - int y1; - int w1; - int h1; - int x2; // target - int y2; - int w2; - int h2; - int x3; // rect 3: results of invoking AdjustToFit - int y3; - int w3; - int h3; - } tests[] = { - { 0, 0, 2, 2, - 0, 0, 2, 2, - 0, 0, 2, 2 }, - { 2, 2, 3, 3, - 0, 0, 4, 4, - 1, 1, 3, 3 }, - { -1, -1, 5, 5, - 0, 0, 4, 4, - 0, 0, 4, 4 }, - { 2, 2, 4, 4, - 0, 0, 3, 3, - 0, 0, 3, 3 }, - { 2, 2, 1, 1, - 0, 0, 3, 3, - 2, 2, 1, 1 } - }; - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - gfx::Rect u(r1.AdjustToFit(r2)); - EXPECT_EQ(r3.x(), u.x()); - EXPECT_EQ(r3.y(), u.y()); - EXPECT_EQ(r3.width(), u.width()); - EXPECT_EQ(r3.height(), u.height()); - } -} - -TEST(RectTest, Subtract) { - // Matching - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(10, 10, 20, 20)).Equals( - gfx::Rect(0, 0, 0, 0))); - - // Contains - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 5, 30, 30)).Equals( - gfx::Rect(0, 0, 0, 0))); - - // No intersection - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(30, 30, 20, 20)).Equals( - gfx::Rect(10, 10, 20, 20))); - - // Not a complete intersection in either direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(15, 15, 20, 20)).Equals( - gfx::Rect(10, 10, 20, 20))); - - // Complete intersection in the x-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(10, 15, 20, 20)).Equals( - gfx::Rect(10, 10, 20, 5))); - - // Complete intersection in the x-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 15, 30, 20)).Equals( - gfx::Rect(10, 10, 20, 5))); - - // Complete intersection in the x-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 5, 30, 20)).Equals( - gfx::Rect(10, 25, 20, 5))); - - // Complete intersection in the y-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(10, 10, 10, 30)).Equals( - gfx::Rect(20, 10, 10, 20))); - - // Complete intersection in the y-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 5, 20, 30)).Equals( - gfx::Rect(25, 10, 5, 20))); -} - -TEST(RectTest, IsEmpty) { - EXPECT_TRUE(gfx::Rect(0, 0, 0, 0).IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 0, 0).size().IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 10, 0).IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 10, 0).size().IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 0, 10).IsEmpty()); - EXPECT_TRUE(gfx::Rect(0, 0, 0, 10).size().IsEmpty()); - EXPECT_FALSE(gfx::Rect(0, 0, 10, 10).IsEmpty()); - EXPECT_FALSE(gfx::Rect(0, 0, 10, 10).size().IsEmpty()); -} - -TEST(RectTest, SharesEdgeWith) { - gfx::Rect r(2, 3, 4, 5); - - // Must be non-overlapping - EXPECT_FALSE(r.SharesEdgeWith(r)); - - gfx::Rect just_above(2, 1, 4, 2); - gfx::Rect just_below(2, 8, 4, 2); - gfx::Rect just_left(0, 3, 2, 5); - gfx::Rect just_right(6, 3, 2, 5); - - EXPECT_TRUE(r.SharesEdgeWith(just_above)); - EXPECT_TRUE(r.SharesEdgeWith(just_below)); - EXPECT_TRUE(r.SharesEdgeWith(just_left)); - EXPECT_TRUE(r.SharesEdgeWith(just_right)); - - // Wrong placement - gfx::Rect same_height_no_edge(0, 0, 1, 5); - gfx::Rect same_width_no_edge(0, 0, 4, 1); - - EXPECT_FALSE(r.SharesEdgeWith(same_height_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(same_width_no_edge)); - - gfx::Rect just_above_no_edge(2, 1, 5, 2); // too wide - gfx::Rect just_below_no_edge(2, 8, 3, 2); // too narrow - gfx::Rect just_left_no_edge(0, 3, 2, 6); // too tall - gfx::Rect just_right_no_edge(6, 3, 2, 4); // too short - - EXPECT_FALSE(r.SharesEdgeWith(just_above_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(just_below_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(just_left_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(just_right_no_edge)); -} diff --git a/base/gfx/size.cc b/base/gfx/size.cc deleted file mode 100644 index 91f39c0..0000000 --- a/base/gfx/size.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2006-2008 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 "base/gfx/size.h" - -#if defined(OS_WIN) -#include <windows.h> -#elif defined(OS_MACOSX) -#include <CoreGraphics/CGGeometry.h> -#endif - -#include <iostream> - -#include "base/logging.h" - -namespace gfx { - -Size::Size(int width, int height) { - set_width(width); - set_height(height); -} - -#if defined(OS_MACOSX) -Size::Size(const CGSize& s) { - set_width(s.width); - set_height(s.height); -} - -Size& Size::operator=(const CGSize& s) { - set_width(s.width); - set_height(s.height); - return *this; -} -#endif - -#if defined(OS_WIN) -SIZE Size::ToSIZE() const { - SIZE s; - s.cx = width_; - s.cy = height_; - return s; -} -#elif defined(OS_MACOSX) -CGSize Size::ToCGSize() const { - return CGSizeMake(width_, height_); -} -#endif - -void Size::set_width(int width) { - if (width < 0) { - NOTREACHED(); - width = 0; - } - width_ = width; -} - -void Size::set_height(int height) { - if (height < 0) { - NOTREACHED(); - height = 0; - } - height_ = height; -} - -} // namespace gfx - -std::ostream& operator<<(std::ostream& out, const gfx::Size& s) { - return out << s.width() << "x" << s.height(); -} diff --git a/base/gfx/size.h b/base/gfx/size.h deleted file mode 100644 index 896908e..0000000 --- a/base/gfx/size.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#ifndef BASE_GFX_SIZE_H_ -#define BASE_GFX_SIZE_H_ - -#include "build/build_config.h" - -#include <iosfwd> - -#if defined(OS_WIN) -typedef struct tagSIZE SIZE; -#elif defined(OS_MACOSX) -#include <ApplicationServices/ApplicationServices.h> -#endif - -namespace gfx { - -// -// A size has width and height values. -// -class Size { - public: - Size() : width_(0), height_(0) {} - Size(int width, int height); -#if defined(OS_MACOSX) - explicit Size(const CGSize& s); -#endif - - ~Size() {} - -#if defined(OS_MACOSX) - Size& operator=(const CGSize& s); -#endif - - int width() const { return width_; } - int height() const { return height_; } - - int GetArea() const { return width_ * height_; } - - void SetSize(int width, int height) { - set_width(width); - set_height(height); - } - - void Enlarge(int width, int height) { - set_width(width_ + width); - set_height(height_ + height); - } - - void set_width(int width); - void set_height(int height); - - bool operator==(const Size& s) const { - return width_ == s.width_ && height_ == s.height_; - } - - bool operator!=(const Size& s) const { - return !(*this == s); - } - - bool IsEmpty() const { - // Size doesn't allow negative dimensions, so testing for 0 is enough. - return (width_ == 0) || (height_ == 0); - } - -#if defined(OS_WIN) - SIZE ToSIZE() const; -#elif defined(OS_MACOSX) - CGSize ToCGSize() const; -#endif - - private: - int width_; - int height_; -}; - -} // namespace gfx - -std::ostream& operator<<(std::ostream& out, const gfx::Size& s); - -#endif // BASE_GFX_SIZE_H_ diff --git a/base/i18n/char_iterator.cc b/base/i18n/char_iterator.cc new file mode 100644 index 0000000..a6cf944 --- /dev/null +++ b/base/i18n/char_iterator.cc @@ -0,0 +1,74 @@ +// Copyright (c) 2010 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 "base/i18n/char_iterator.h" + +#include "unicode/utf8.h" +#include "unicode/utf16.h" + +namespace base { + +UTF8CharIterator::UTF8CharIterator(const std::string* str) + : str_(reinterpret_cast<const uint8_t*>(str->data())), + len_(str->size()), + array_pos_(0), + next_pos_(0), + char_pos_(0), + char_(0) { + if (len_) + U8_NEXT(str_, next_pos_, len_, char_); +} + +bool UTF8CharIterator::Advance() { + if (array_pos_ >= len_) + return false; + + array_pos_ = next_pos_; + char_pos_++; + if (next_pos_ < len_) + U8_NEXT(str_, next_pos_, len_, char_); + + return true; +} + +UTF16CharIterator::UTF16CharIterator(const string16* str) + : str_(reinterpret_cast<const char16*>(str->data())), + len_(str->size()), + array_pos_(0), + next_pos_(0), + char_pos_(0), + char_(0) { + if (len_) + ReadChar(); +} + +UTF16CharIterator::UTF16CharIterator(const char16* str, size_t str_len) + : str_(str), + len_(str_len), + array_pos_(0), + next_pos_(0), + char_pos_(0), + char_(0) { + if (len_) + ReadChar(); +} + +bool UTF16CharIterator::Advance() { + if (array_pos_ >= len_) + return false; + + array_pos_ = next_pos_; + char_pos_++; + if (next_pos_ < len_) + ReadChar(); + + return true; +} + +void UTF16CharIterator::ReadChar() { + // This is actually a huge macro, so is worth having in a separate function. + U16_NEXT(str_, next_pos_, len_, char_); +} + +} // namespace base diff --git a/base/i18n/char_iterator.h b/base/i18n/char_iterator.h new file mode 100644 index 0000000..835ac06 --- /dev/null +++ b/base/i18n/char_iterator.h @@ -0,0 +1,128 @@ +// Copyright (c) 2010 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. + +#ifndef BASE_I18N_CHAR_ITERATOR_H_ +#define BASE_I18N_CHAR_ITERATOR_H_ +#pragma once + +#include <string> + +#include "base/basictypes.h" +#include "base/string16.h" + +// The CharIterator classes iterate through the characters in UTF8 and +// UTF16 strings. Example usage: +// +// UTF8CharIterator iter(&str); +// while (!iter.End()) { +// LOG(INFO) << iter.get(); +// iter.Advance(); +// } + +#if defined(OS_WIN) +typedef unsigned char uint8_t; +#endif + +namespace base { + +class UTF8CharIterator { + public: + // Requires |str| to live as long as the UTF8CharIterator does. + UTF8CharIterator(const std::string* str); + ~UTF8CharIterator() {} + + // Return the starting array index of the current character within the + // string. + int32 array_pos() const { return array_pos_; } + + // Return the logical index of the current character, independent of the + // number of bytes each character takes. + int32 char_pos() const { return char_pos_; } + + // Return the current char. + int32 get() const { return char_; } + + // Returns true if we're at the end of the string. + bool end() const { return array_pos_ == len_; } + + // Advance to the next actual character. Returns false if we're at the + // end of the string. + bool Advance(); + + private: + // The string we're iterating over. + const uint8_t* str_; + + // The length of the encoded string. + int32 len_; + + // Array index. + int32 array_pos_; + + // The next array index. + int32 next_pos_; + + // Character index. + int32 char_pos_; + + // The current character. + int32 char_; + + DISALLOW_COPY_AND_ASSIGN(UTF8CharIterator); +}; + +class UTF16CharIterator { + public: + // Requires |str| to live as long as the UTF16CharIterator does. + UTF16CharIterator(const string16* str); + UTF16CharIterator(const char16* str, size_t str_len); + ~UTF16CharIterator() {} + + // Return the starting array index of the current character within the + // string. + int32 array_pos() const { return array_pos_; } + + // Return the logical index of the current character, independent of the + // number of codewords each character takes. + int32 char_pos() const { return char_pos_; } + + // Return the current char. + int32 get() const { return char_; } + + // Returns true if we're at the end of the string. + bool end() const { return array_pos_ == len_; } + + // Advance to the next actual character. Returns false if we're at the + // end of the string. + bool Advance(); + + private: + // Fills in the current character we found and advances to the next + // character, updating all flags as necessary. + void ReadChar(); + + // The string we're iterating over. + const char16* str_; + + // The length of the encoded string. + int32 len_; + + // Array index. + int32 array_pos_; + + // The next array index. + int32 next_pos_; + + // Character index. + int32 char_pos_; + + // The current character. + int32 char_; + + DISALLOW_COPY_AND_ASSIGN(UTF16CharIterator); +}; + +} // namespace base + +#endif // BASE_I18N_CHAR_ITERATOR_H_ diff --git a/base/i18n/char_iterator_unittest.cc b/base/i18n/char_iterator_unittest.cc new file mode 100644 index 0000000..4fe7ebb --- /dev/null +++ b/base/i18n/char_iterator_unittest.cc @@ -0,0 +1,95 @@ +// Copyright (c) 2010 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 "base/i18n/char_iterator.h" + +#include "base/utf_string_conversions.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(CharIteratorsTest, TestUTF8) { + std::string empty(""); + base::UTF8CharIterator empty_iter(&empty); + ASSERT_TRUE(empty_iter.end()); + ASSERT_EQ(0, empty_iter.array_pos()); + ASSERT_EQ(0, empty_iter.char_pos()); + ASSERT_FALSE(empty_iter.Advance()); + + std::string str("s\303\273r"); // [u with circumflex] + base::UTF8CharIterator iter(&str); + ASSERT_FALSE(iter.end()); + ASSERT_EQ(0, iter.array_pos()); + ASSERT_EQ(0, iter.char_pos()); + ASSERT_EQ('s', iter.get()); + ASSERT_TRUE(iter.Advance()); + + ASSERT_FALSE(iter.end()); + ASSERT_EQ(1, iter.array_pos()); + ASSERT_EQ(1, iter.char_pos()); + ASSERT_EQ(251, iter.get()); + ASSERT_TRUE(iter.Advance()); + + ASSERT_FALSE(iter.end()); + ASSERT_EQ(3, iter.array_pos()); + ASSERT_EQ(2, iter.char_pos()); + ASSERT_EQ('r', iter.get()); + ASSERT_TRUE(iter.Advance()); + + ASSERT_TRUE(iter.end()); + ASSERT_EQ(4, iter.array_pos()); + ASSERT_EQ(3, iter.char_pos()); + + // Don't care what it returns, but this shouldn't crash + iter.get(); + + ASSERT_FALSE(iter.Advance()); +} + +TEST(CharIteratorsTest, TestUTF16) { + string16 empty = UTF8ToUTF16(""); + base::UTF16CharIterator empty_iter(&empty); + ASSERT_TRUE(empty_iter.end()); + ASSERT_EQ(0, empty_iter.array_pos()); + ASSERT_EQ(0, empty_iter.char_pos()); + ASSERT_FALSE(empty_iter.Advance()); + + // This test string contains 4 characters: + // x + // u with circumflex - 2 bytes in UTF8, 1 codeword in UTF16 + // math double-struck A - 4 bytes in UTF8, 2 codewords in UTF16 + // z + string16 str = UTF8ToUTF16("x\303\273\360\235\224\270z"); + base::UTF16CharIterator iter(&str); + ASSERT_FALSE(iter.end()); + ASSERT_EQ(0, iter.array_pos()); + ASSERT_EQ(0, iter.char_pos()); + ASSERT_EQ('x', iter.get()); + ASSERT_TRUE(iter.Advance()); + + ASSERT_FALSE(iter.end()); + ASSERT_EQ(1, iter.array_pos()); + ASSERT_EQ(1, iter.char_pos()); + ASSERT_EQ(251, iter.get()); + ASSERT_TRUE(iter.Advance()); + + ASSERT_FALSE(iter.end()); + ASSERT_EQ(2, iter.array_pos()); + ASSERT_EQ(2, iter.char_pos()); + ASSERT_EQ(120120, iter.get()); + ASSERT_TRUE(iter.Advance()); + + ASSERT_FALSE(iter.end()); + ASSERT_EQ(4, iter.array_pos()); + ASSERT_EQ(3, iter.char_pos()); + ASSERT_EQ('z', iter.get()); + ASSERT_TRUE(iter.Advance()); + + ASSERT_TRUE(iter.end()); + ASSERT_EQ(5, iter.array_pos()); + ASSERT_EQ(4, iter.char_pos()); + + // Don't care what it returns, but this shouldn't crash + iter.get(); + + ASSERT_FALSE(iter.Advance()); +} diff --git a/base/linux_versioninfo.scons b/base/linux_versioninfo.scons deleted file mode 100644 index 0893110..0000000 --- a/base/linux_versioninfo.scons +++ /dev/null @@ -1,321 +0,0 @@ -# This file is generated; do not edit. - -import os - -Import("env") - -env = env.Clone(COMPONENT_NAME='base', - TARGET_NAME='linux_versioninfo') - -configurations = { - 'Debug' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-O0', - '-g' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - '_DEBUG' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/..'), - env.Dir('${SHARED_INTERMEDIATE_DIR}') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-rdynamic' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, - 'Release' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-O2', - '-fno-ident', - '-fdata-sections', - '-ffunction-sections' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'NDEBUG', - 'NVALGRIND' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/..'), - env.Dir('${SHARED_INTERMEDIATE_DIR}') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-Wl,--gc-sections' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, -} - -config = configurations[env['CONFIG_NAME']] -env.Append(**config['Append']) -env.FilterOut(**config['FilterOut']) -env.Replace(**config['Replace']) - -# Scons forces -fPIC for SHCCFLAGS on some platforms. -# Disable that so we can control it from cflags in gyp. -# Note that Scons itself is inconsistent with its -fPIC -# setting. SHCCFLAGS forces -fPIC, and SHCFLAGS does not. -# This will make SHCCFLAGS consistent with SHCFLAGS. -env['SHCCFLAGS'] = ['$CCFLAGS'] - -for _var in config['ImportExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env[_var] = os.environ[_var] -for _var in config['PropagateExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env['ENV'][_var] = os.environ[_var] - -env['ENV']['LD_LIBRARY_PATH'] = env.subst('$LIB_DIR') - -if ARGUMENTS.get('COVERAGE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-fprofile-arcs', - '-ftest-coverage' - ], - LINKFLAGS = [ - '-fprofile-arcs' - ], - ) - -if ARGUMENTS.get('PROFILE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-pg', - '-g' - ], - LINKFLAGS = [ - '-pg' - ], - ) - -if ARGUMENTS.get('SYMBOLS') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-g' - ], - ) - -input_files = [ - 'file_version_info_linux.cc', -] - -target_files = [] -prerequisites = [] - -if GetOption('verbose'): - _action = Action([['cd', - '$SRC_DIR/base', - '&&', - 'python', - '../chrome/tools/build/version.py', - '-f', - '../chrome/VERSION', - '-f', - '../chrome/app/theme/chromium/BRANDING', - '-f', - '${SHARED_INTERMEDIATE_DIR}/build/LASTCHANGE', - 'file_version_info_linux.h.version', - '${SHARED_INTERMEDIATE_DIR}/base/file_version_info_linux.h']]) -else: - _action = Action([['cd', - '$SRC_DIR/base', - '&&', - 'python', - '../chrome/tools/build/version.py', - '-f', - '../chrome/VERSION', - '-f', - '../chrome/app/theme/chromium/BRANDING', - '-f', - '${SHARED_INTERMEDIATE_DIR}/build/LASTCHANGE', - 'file_version_info_linux.h.version', - '${SHARED_INTERMEDIATE_DIR}/base/file_version_info_linux.h']], 'Generating version information') -_outputs = env.Command( - ['${SHARED_INTERMEDIATE_DIR}/base/file_version_info_linux.h'], - ['$SRC_DIR/base/file_version_info_linux.h.version', - '$SRC_DIR/base/../chrome/VERSION', - '$SRC_DIR/base/../chrome/app/theme/chromium/BRANDING', - '${SHARED_INTERMEDIATE_DIR}/build/LASTCHANGE'], - _action -) -prerequisites.extend(_outputs) -target_files.extend(_outputs) - -_result = [] -for infile in input_files: - if env.compilable(infile): - if (type(infile) == type('') - and (infile.startswith('$SRC_DIR/base/') - or not os.path.isabs(env.subst(infile)))): - # Force files below the build directory by replacing all '..' - # elements in the path with '__': - base, ext = os.path.splitext(os.path.normpath(infile)) - base = [d == '..' and '__' or d for d in base.split('/')] - base = os.path.join(*base) - object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base - if not infile.startswith('$SRC_DIR/base/'): - infile = '$SRC_DIR/base/' + infile - infile = env.StaticObject(object, infile)[0] - else: - infile = env.StaticObject(infile)[0] - _result.append(infile) -input_files = _result - -_outputs = env.GypStaticLibrary('linux_versioninfo', input_files) -target_files.extend(_outputs) - -gyp_target = env.Alias('linux_versioninfo', target_files) -env.Requires(gyp_target, prerequisites) -Return("gyp_target") diff --git a/base/mime_util_linux.cc b/base/mime_util_linux.cc deleted file mode 100644 index b42122f..0000000 --- a/base/mime_util_linux.cc +++ /dev/null @@ -1,618 +0,0 @@ -// Copyright (c) 2009 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 "base/mime_util.h" - -#include <gtk/gtk.h> -#include <sys/time.h> -#include <time.h> - -#include <cstdlib> -#include <list> -#include <map> -#include <vector> - -#include "base/file_util.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "base/scoped_ptr.h" -#include "base/singleton.h" -#include "base/string_util.h" -#include "base/third_party/xdg_mime/xdgmime.h" - -namespace { - -class IconTheme; - -class MimeUtilConstants { - public: - - // In seconds, specified by icon theme specs. - const int kUpdateInterval; - - // Store icon directories and their mtimes. - std::map<FilePath, int>* icon_dirs_; - - // Store icon formats. - std::vector<std::string> icon_formats_; - - // Store loaded icon_theme. - std::map<std::string, IconTheme*>* icon_themes_; - - static const size_t kDefaultThemeNum = 4; - - // The default theme. - IconTheme* default_themes_[kDefaultThemeNum]; - - time_t last_check_time_; - - // This is set by DetectGtkTheme(). We cache it so that we can access the - // theme name from threads that aren't allowed to call - // gtk_settings_get_default(). - std::string gtk_theme_name_; - - private: - MimeUtilConstants() - : kUpdateInterval(5), - icon_dirs_(NULL), - icon_themes_(NULL), - last_check_time_(0) { - icon_formats_.push_back(".png"); - icon_formats_.push_back(".svg"); - icon_formats_.push_back(".xpm"); - - for (size_t i = 0; i < kDefaultThemeNum; ++i) - default_themes_[i] = NULL; - } - ~MimeUtilConstants(); - - friend struct DefaultSingletonTraits<MimeUtilConstants>; - - DISALLOW_COPY_AND_ASSIGN(MimeUtilConstants); -}; - -// IconTheme represents an icon theme as defined by the xdg icon theme spec. -// Example themes on GNOME include 'Human' and 'Mist'. -// Example themes on KDE include 'crystalsvg' and 'kdeclassic'. -class IconTheme { - public: - // A theme consists of multiple sub-directories, like '32x32' and 'scalable'. - class SubDirInfo { - public: - // See spec for details. - enum Type { - Fixed, - Scalable, - Threshold - }; - SubDirInfo() - : size(0), - type(Threshold), - max_size(0), - min_size(0), - threshold(2) { - } - size_t size; // Nominal size of the icons in this directory. - Type type; // Type of the icon size. - size_t max_size; // Maximum size that the icons can be scaled to. - size_t min_size; // Minimum size that the icons can be scaled to. - size_t threshold; // Maximum difference from desired size. 2 by default. - }; - - explicit IconTheme(const std::string& name); - - ~IconTheme() { - delete[] info_array_; - } - - // Returns the path to an icon with the name |icon_name| and a size of |size| - // pixels. If the icon does not exist, but |inherits| is true, then look for - // the icon in the parent theme. - FilePath GetIconPath(const std::string& icon_name, int size, bool inherits); - - // Load a theme with the name |theme_name| into memory. Returns null if theme - // is invalid. - static IconTheme* LoadTheme(const std::string& theme_name); - - private: - // Returns the path to an icon with the name |icon_name| in |subdir|. - FilePath GetIconPathUnderSubdir(const std::string& icon_name, - const std::string& subdir); - - // Whether the theme loaded properly. - bool IsValid() { - return index_theme_loaded_; - } - - // Read and parse |file| which is usually named 'index.theme' per theme spec. - bool LoadIndexTheme(const FilePath& file); - - // Checks to see if the icons in |info| matches |size| (in pixels). Returns - // 0 if they match, or the size difference in pixels. - size_t MatchesSize(SubDirInfo* info, size_t size); - - // Yet another function to read a line. - std::string ReadLine(FILE* fp); - - // Set directories to search for icons to the comma-separated list |dirs|. - bool SetDirectories(const std::string& dirs); - - bool index_theme_loaded_; // True if an instance is properly loaded. - // store the scattered directories of this theme. - std::list<FilePath> dirs_; - - // store the subdirs of this theme and array index of |info_array_|. - std::map<std::string, int> subdirs_; - SubDirInfo* info_array_; // List of sub-directories. - std::string inherits_; // Name of the theme this one inherits from. -}; - -IconTheme::IconTheme(const std::string& name) - : index_theme_loaded_(false), - info_array_(NULL) { - // Iterate on all icon directories to find directories of the specified - // theme and load the first encountered index.theme. - std::map<FilePath, int>::iterator iter; - FilePath theme_path; - std::map<FilePath, int>* icon_dirs = - Singleton<MimeUtilConstants>::get()->icon_dirs_; - for (iter = icon_dirs->begin(); iter != icon_dirs->end(); ++iter) { - theme_path = iter->first.Append(name); - if (!file_util::DirectoryExists(theme_path)) - continue; - FilePath theme_index = theme_path.Append("index.theme"); - if (!index_theme_loaded_ && file_util::PathExists(theme_index)) { - if (!LoadIndexTheme(theme_index)) - return; - index_theme_loaded_ = true; - } - dirs_.push_back(theme_path); - } -} - -FilePath IconTheme::GetIconPath(const std::string& icon_name, int size, - bool inherits) { - std::map<std::string, int>::iterator subdir_iter; - FilePath icon_path; - - for (subdir_iter = subdirs_.begin(); - subdir_iter != subdirs_.end(); - ++subdir_iter) { - SubDirInfo* info = &info_array_[subdir_iter->second]; - if (MatchesSize(info, size) == 0) { - icon_path = GetIconPathUnderSubdir(icon_name, subdir_iter->first); - if (!icon_path.empty()) - return icon_path; - } - } - // Now looking for the mostly matched. - int min_delta_seen = 9999; - - for (subdir_iter = subdirs_.begin(); - subdir_iter != subdirs_.end(); - ++subdir_iter) { - SubDirInfo* info = &info_array_[subdir_iter->second]; - int delta = abs(MatchesSize(info, size)); - if (delta < min_delta_seen) { - FilePath path = GetIconPathUnderSubdir(icon_name, subdir_iter->first); - if (!path.empty()) { - min_delta_seen = delta; - icon_path = path; - } - } - } - - if (!icon_path.empty() || !inherits || inherits_ == "") - return icon_path; - - IconTheme* theme = LoadTheme(inherits_); - if (theme) - return theme->GetIconPath(icon_name, size, inherits); - else - return FilePath(); -} - -IconTheme* IconTheme::LoadTheme(const std::string& theme_name) { - scoped_ptr<IconTheme> theme; - std::map<std::string, IconTheme*>* icon_themes = - Singleton<MimeUtilConstants>::get()->icon_themes_; - if (icon_themes->find(theme_name) != icon_themes->end()) { - theme.reset((*icon_themes)[theme_name]); - } else { - theme.reset(new IconTheme(theme_name)); - if (!theme->IsValid()) - theme.reset(); - (*icon_themes)[theme_name] = theme.get(); - } - return theme.release(); -} - -FilePath IconTheme::GetIconPathUnderSubdir(const std::string& icon_name, - const std::string& subdir) { - FilePath icon_path; - std::list<FilePath>::iterator dir_iter; - std::vector<std::string>* icon_formats = - &Singleton<MimeUtilConstants>::get()->icon_formats_; - for (dir_iter = dirs_.begin(); dir_iter != dirs_.end(); ++dir_iter) { - for (size_t i = 0; i < icon_formats->size(); ++i) { - icon_path = dir_iter->Append(subdir); - icon_path = icon_path.Append(icon_name + (*icon_formats)[i]); - if (file_util::PathExists(icon_path)) - return icon_path; - } - } - return FilePath(); -} - -bool IconTheme::LoadIndexTheme(const FilePath& file) { - FILE* fp = file_util::OpenFile(file, "r"); - SubDirInfo* current_info = NULL; - if (!fp) - return false; - - // Read entries. - while (!feof(fp) && !ferror(fp)) { - std::string buf = ReadLine(fp); - if (buf == "") - break; - - std::string entry; - TrimWhitespaceASCII(buf, TRIM_ALL, &entry); - if (entry.length() == 0 || entry[0] == '#') { - // Blank line or Comment. - continue; - } else if (entry[0] == '[' && info_array_) { - current_info = NULL; - std::string subdir = entry.substr(1, entry.length() - 2); - if (subdirs_.find(subdir) != subdirs_.end()) - current_info = &info_array_[subdirs_[subdir]]; - } - - std::string key, value; - std::vector<std::string> r; - SplitStringDontTrim(entry, '=', &r); - if (r.size() < 2) - continue; - - TrimWhitespaceASCII(r[0], TRIM_ALL, &key); - for (size_t i = 1; i < r.size(); i++) - value.append(r[i]); - TrimWhitespaceASCII(value, TRIM_ALL, &value); - - if (current_info) { - if (key == "Size") { - current_info->size = atoi(value.c_str()); - } else if (key == "Type") { - if (value == "Fixed") - current_info->type = SubDirInfo::Fixed; - else if (value == "Scalable") - current_info->type = SubDirInfo::Scalable; - else if (value == "Threshold") - current_info->type = SubDirInfo::Threshold; - } else if (key == "MaxSize") { - current_info->max_size = atoi(value.c_str()); - } else if (key == "MinSize") { - current_info->min_size = atoi(value.c_str()); - } else if (key == "Threshold") { - current_info->threshold = atoi(value.c_str()); - } - } else { - if (key.compare("Directories") == 0 && !info_array_) { - if (!SetDirectories(value)) break; - } else if (key.compare("Inherits") == 0) { - if (value != "hicolor") - inherits_ = value; - } - } - } - - file_util::CloseFile(fp); - return info_array_ != NULL; -} - -size_t IconTheme::MatchesSize(SubDirInfo* info, size_t size) { - if (info->type == SubDirInfo::Fixed) { - return size - info->size; - } else if (info->type == SubDirInfo::Scalable) { - if (size >= info->min_size && size <= info->max_size) { - return 0; - } else { - return abs(size - info->min_size) < abs(size - info->max_size) ? - (size - info->min_size) : (size - info->max_size); - } - } else { - if (size >= info->size - info->threshold && - size <= info->size + info->threshold) { - return 0; - } else { - return abs(size - info->size - info->threshold) < - abs(size - info->size + info->threshold) - ? size - info->size - info->threshold - : size - info->size + info->threshold; - } - } -} - -std::string IconTheme::ReadLine(FILE* fp) { - if (!fp) - return ""; - - std::string result = ""; - const size_t kBufferSize = 100; - char buffer[kBufferSize]; - while ((fgets(buffer, kBufferSize - 1, fp)) != NULL) { - result += buffer; - size_t len = result.length(); - if (len == 0) - break; - char end = result[len - 1]; - if (end == '\n' || end == '\0') - break; - } - - return result; -} - -bool IconTheme::SetDirectories(const std::string& dirs) { - int num = 0; - std::string::size_type pos = 0, epos; - std::string dir; - while ((epos = dirs.find(',', pos)) != std::string::npos) { - TrimWhitespaceASCII(dirs.substr(pos, epos - pos), TRIM_ALL, &dir); - if (dir.length() == 0) { - LOG(WARNING) << "Invalid index.theme: blank subdir"; - return false; - } - subdirs_[dir] = num++; - pos = epos + 1; - } - TrimWhitespaceASCII(dirs.substr(pos), TRIM_ALL, &dir); - if (dir.length() == 0) { - LOG(WARNING) << "Invalid index.theme: blank subdir"; - return false; - } - subdirs_[dir] = num++; - info_array_ = new SubDirInfo[num]; - return true; -} - -// Make sure |dir| exists and add it to the list of icon directories. -void TryAddIconDir(const FilePath& dir) { - if (!file_util::DirectoryExists(dir)) - return; - (*Singleton<MimeUtilConstants>::get()->icon_dirs_)[dir] = 0; -} - -// For a xdg directory |dir|, add the appropriate icon sub-directories. -void AddXDGDataDir(const FilePath& dir) { - if (!file_util::DirectoryExists(dir)) - return; - TryAddIconDir(dir.Append("icons")); - TryAddIconDir(dir.Append("pixmaps")); -} - -// Add all the xdg icon directories. -void InitIconDir() { - Singleton<MimeUtilConstants>::get()->icon_dirs_->clear(); - const char* home = getenv("HOME"); - if (home) { - FilePath legacy_data_dir(home); - legacy_data_dir = legacy_data_dir.AppendASCII(".icons"); - if (file_util::DirectoryExists(legacy_data_dir)) - TryAddIconDir(legacy_data_dir); - } - const char* env = getenv("XDG_DATA_HOME"); - if (env) { - AddXDGDataDir(FilePath(env)); - } else if (home) { - FilePath local_data_dir(home); - local_data_dir = local_data_dir.AppendASCII(".local"); - local_data_dir = local_data_dir.AppendASCII("share"); - AddXDGDataDir(local_data_dir); - } - - env = getenv("XDG_DATA_DIRS"); - if (!env) { - AddXDGDataDir(FilePath("/usr/local/share")); - AddXDGDataDir(FilePath("/usr/share")); - } else { - std::string xdg_data_dirs = env; - std::string::size_type pos = 0, epos; - while ((epos = xdg_data_dirs.find(':', pos)) != std::string::npos) { - AddXDGDataDir(FilePath(xdg_data_dirs.substr(pos, epos - pos))); - pos = epos + 1; - } - AddXDGDataDir(FilePath(xdg_data_dirs.substr(pos))); - } -} - -// Per xdg theme spec, we should check the icon directories every so often for -// newly added icons. This isn't quite right. -void EnsureUpdated() { - struct timeval t; - gettimeofday(&t, NULL); - time_t now = t.tv_sec; - MimeUtilConstants* constants = Singleton<MimeUtilConstants>::get(); - - if (constants->last_check_time_ == 0) { - constants->icon_dirs_ = new std::map<FilePath, int>; - constants->icon_themes_ = new std::map<std::string, IconTheme*>; - InitIconDir(); - constants->last_check_time_ = now; - } else { - // TODO(thestig): something changed. start over. Upstream fix to Google - // Gadgets for Linux. - if (now > constants->last_check_time_ + constants->kUpdateInterval) { - } - } -} - -// Find a fallback icon if we cannot find it in the default theme. -FilePath LookupFallbackIcon(const std::string& icon_name) { - FilePath icon; - MimeUtilConstants* constants = Singleton<MimeUtilConstants>::get(); - std::map<FilePath, int>::iterator iter; - std::map<FilePath, int>* icon_dirs = constants->icon_dirs_; - std::vector<std::string>* icon_formats = &constants->icon_formats_; - for (iter = icon_dirs->begin(); iter != icon_dirs->end(); ++iter) { - for (size_t i = 0; i < icon_formats->size(); ++i) { - icon = iter->first.Append(icon_name + (*icon_formats)[i]); - if (file_util::PathExists(icon)) - return icon; - } - } - return FilePath(); -} - -// Initialize the list of default themes. -void InitDefaultThemes() { - IconTheme** default_themes = - Singleton<MimeUtilConstants>::get()->default_themes_; - - char* env = getenv("KDE_FULL_SESSION"); - if (env) { - // KDE - std::string kde_default_theme; - std::string kde_fallback_theme; - - // TODO(thestig): Figure out how to get the current icon theme on KDE. - // Setting stored in ~/.kde/share/config/kdeglobals under Icons -> Theme. - default_themes[0] = NULL; - - // Try some reasonable defaults for KDE. - env = getenv("KDE_SESSION_VERSION"); - if (!env || env[0] != '4') { - // KDE 3 - kde_default_theme = "default.kde"; - kde_fallback_theme = "crystalsvg"; - } else { - // KDE 4 - kde_default_theme = "default.kde4"; - kde_fallback_theme = "oxygen"; - } - default_themes[1] = IconTheme::LoadTheme(kde_default_theme); - default_themes[2] = IconTheme::LoadTheme(kde_fallback_theme); - } else { - // Assume it's Gnome and use GTK to figure out the theme. - default_themes[1] = IconTheme::LoadTheme( - Singleton<MimeUtilConstants>::get()->gtk_theme_name_); - default_themes[2] = IconTheme::LoadTheme("gnome"); - } - // hicolor needs to be last per icon theme spec. - default_themes[3] = IconTheme::LoadTheme("hicolor"); - - for (size_t i = 0; i < MimeUtilConstants::kDefaultThemeNum; i++) { - if (default_themes[i] == NULL) - continue; - // NULL out duplicate pointers. - for (size_t j = i + 1; j < MimeUtilConstants::kDefaultThemeNum; j++) { - if (default_themes[j] == default_themes[i]) - default_themes[j] = NULL; - } - } -} - -// Try to find an icon with the name |icon_name| that's |size| pixels. -FilePath LookupIconInDefaultTheme(const std::string& icon_name, int size) { - EnsureUpdated(); - MimeUtilConstants* constants = Singleton<MimeUtilConstants>::get(); - std::map<std::string, IconTheme*>* icon_themes = constants->icon_themes_; - if (icon_themes->size() == 0) - InitDefaultThemes(); - - FilePath icon_path; - IconTheme** default_themes = constants->default_themes_; - for (size_t i = 0; i < MimeUtilConstants::kDefaultThemeNum; i++) { - if (default_themes[i]) { - icon_path = default_themes[i]->GetIconPath(icon_name, size, true); - if (!icon_path.empty()) - return icon_path; - } - } - return LookupFallbackIcon(icon_name); -} - -MimeUtilConstants::~MimeUtilConstants() { - delete icon_dirs_; - delete icon_themes_; - for (size_t i = 0; i < kDefaultThemeNum; i++) - delete default_themes_[i]; -} - -} // namespace - -namespace mime_util { - -std::string GetFileMimeType(const FilePath& filepath) { - return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); -} - -std::string GetDataMimeType(const std::string& data) { - return xdg_mime_get_mime_type_for_data(data.data(), data.length(), NULL); -} - -void DetectGtkTheme() { - // If the theme name is already loaded, do nothing. Chrome doesn't respond - // to changes in the system theme, so we never need to set this more than - // once. - if (!Singleton<MimeUtilConstants>::get()->gtk_theme_name_.empty()) - return; - - // We should only be called on the UI thread. - DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); - - gchar* gtk_theme_name; - g_object_get(gtk_settings_get_default(), - "gtk-icon-theme-name", - >k_theme_name, NULL); - Singleton<MimeUtilConstants>::get()->gtk_theme_name_.assign(gtk_theme_name); - g_free(gtk_theme_name); -} - -FilePath GetMimeIcon(const std::string& mime_type, size_t size) { - std::vector<std::string> icon_names; - std::string icon_name; - FilePath icon_file; - - const char* icon = xdg_mime_get_icon(mime_type.c_str()); - icon_name = std::string(icon ? icon : ""); - if (icon_name.length()) - icon_names.push_back(icon_name); - - // For text/plain, try text-plain. - icon_name = mime_type; - for (size_t i = icon_name.find('/', 0); i != std::string::npos; - i = icon_name.find('/', i + 1)) { - icon_name[i] = '-'; - } - icon_names.push_back(icon_name); - // Also try gnome-mime-text-plain. - icon_names.push_back("gnome-mime-" + icon_name); - - // Try "deb" for "application/x-deb" in KDE 3. - icon_name = mime_type.substr(mime_type.find("/x-") + 3); - icon_names.push_back(icon_name); - - // Try generic name like text-x-generic. - icon_name = mime_type.substr(0, mime_type.find('/')) + "-x-generic"; - icon_names.push_back(icon_name); - - // Last resort - icon_names.push_back("unknown"); - - for (size_t i = 0; i < icon_names.size(); i++) { - if (icon_names[i][0] == '/') { - icon_file = FilePath(icon_names[i]); - if (file_util::PathExists(icon_file)) - return icon_file; - } else { - icon_file = LookupIconInDefaultTheme(icon_names[i], size); - if (!icon_file.empty()) - return icon_file; - } - } - return FilePath(); -} - -} // namespace mime_util diff --git a/base/sha1.cc b/base/sha1.cc deleted file mode 100644 index 620dd56..0000000 --- a/base/sha1.cc +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) 2009 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 "base/sha1.h" - -#include "base/basictypes.h" - -namespace base { - -// Implementation of SHA-1. Only handles data in byte-sized blocks, -// which simplifies the code a fair bit. - -// This file also contains an HMAC implementation using SHA-1 - -// Identifier names follow notation in FIPS PUB 180-3, where you'll -// also find a description of the algorithm: -// http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf - -// Usage example: -// -// SecureHashAlgorithm sha; -// while(there is data to hash) -// sha.Update(moredata, size of data); -// sha.Final(); -// memcpy(somewhere, sha.Digest(), 20); -// -// to reuse the instance of sha, call sha.Init(); - -// TODO(jhawkins): Replace this implementation with a per-platform -// implementation using each platform's crypto library. - -class SecureHashAlgorithm { - public: - SecureHashAlgorithm() { Init(); } - - static const int kDigestSizeBytes; - - void Init(); - void Update(const void* data, size_t nbytes); - void Final(); - - // 20 bytes of message digest. - const unsigned char* Digest() const { - return reinterpret_cast<const unsigned char*>(H); - } - - private: - void Pad(); - void Process(); - - uint32 A, B, C, D, E; - - uint32 H[5]; - - union { - uint32 W[80]; - uint8 M[64]; - }; - - uint32 cursor; - uint32 l; -}; - -static inline uint32 f(uint32 t, uint32 B, uint32 C, uint32 D) { - if (t < 20) { - return (B & C) | ((~B) & D); - } else if (t < 40) { - return B ^ C ^ D; - } else if (t < 60) { - return (B & C) | (B & D) | (C & D); - } else { - return B ^ C ^ D; - } -} - -static inline uint32 S(uint32 n, uint32 X) { - return (X << n) | (X >> (32-n)); -} - -static inline uint32 K(uint32 t) { - if (t < 20) { - return 0x5a827999; - } else if (t < 40) { - return 0x6ed9eba1; - } else if (t < 60) { - return 0x8f1bbcdc; - } else { - return 0xca62c1d6; - } -} - -static inline void swapends(uint32& t) { - t = ((t & 0xff000000) >> 24) | - ((t & 0xff0000) >> 8) | - ((t & 0xff00) << 8) | - ((t & 0xff) << 24); -} - -const int SecureHashAlgorithm::kDigestSizeBytes = 20; - -void SecureHashAlgorithm::Init() { - cursor = 0; - l = 0; - H[0] = 0x67452301; - H[1] = 0xefcdab89; - H[2] = 0x98badcfe; - H[3] = 0x10325476; - H[4] = 0xc3d2e1f0; -} - -void SecureHashAlgorithm::Final() { - Pad(); - Process(); - - for (int t = 0; t < 5; ++t) - swapends(H[t]); -} - -void SecureHashAlgorithm::Update(const void* data, size_t nbytes) { - const uint8* d = reinterpret_cast<const uint8*>(data); - while (nbytes--) { - M[cursor++] = *d++; - if (cursor >= 64) - Process(); - l += 8; - } -} - -void SecureHashAlgorithm::Pad() { - M[cursor++] = 0x80; - - if (cursor > 64-8) { - // pad out to next block - while (cursor < 64) - M[cursor++] = 0; - - Process(); - } - - while (cursor < 64-4) - M[cursor++] = 0; - - M[64-4] = (l & 0xff000000) >> 24; - M[64-3] = (l & 0xff0000) >> 16; - M[64-2] = (l & 0xff00) >> 8; - M[64-1] = (l & 0xff); -} - -void SecureHashAlgorithm::Process() { - uint32 t; - - // Each a...e corresponds to a section in the FIPS 180-3 algorithm. - - // a. - // - // W and M are in a union, so no need to memcpy. - // memcpy(W, M, sizeof(M)); - for (t = 0; t < 16; ++t) - swapends(W[t]); - - // b. - for (t = 16; t < 80; ++t) - W[t] = S(1, W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16]); - - // c. - A = H[0]; - B = H[1]; - C = H[2]; - D = H[3]; - E = H[4]; - - // d. - for (t = 0; t < 80; ++t) { - uint32 TEMP = S(5, A) + f(t, B, C, D) + E + W[t] + K(t); - E = D; - D = C; - C = S(30, B); - B = A; - A = TEMP; - } - - // e. - H[0] += A; - H[1] += B; - H[2] += C; - H[3] += D; - H[4] += E; - - cursor = 0; -} - -std::string SHA1HashString(const std::string& str) { - SecureHashAlgorithm sha; - sha.Update(str.c_str(), str.length()); - sha.Final(); - std::string out(reinterpret_cast<const char*>(sha.Digest()), - SecureHashAlgorithm::kDigestSizeBytes); - return out; -} - -} // namespace base diff --git a/base/symbolize.scons b/base/symbolize.scons deleted file mode 100644 index 89445dd..0000000 --- a/base/symbolize.scons +++ /dev/null @@ -1,280 +0,0 @@ -# This file is generated; do not edit. - -import os - -Import("env") - -env = env.Clone(COMPONENT_NAME='base', - TARGET_NAME='symbolize') - -configurations = { - 'Release' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-fvisibility=hidden', - '-fno-strict-aliasing', - '-Wno-sign-compare', - '-O2', - '-fno-ident', - '-fdata-sections', - '-ffunction-sections', - '-fno-asynchronous-unwind-tables' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'ENABLE_GPU=1', - 'NDEBUG', - 'NVALGRIND' - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-Wl,--gc-sections' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, - 'Debug' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-fvisibility=hidden', - '-fno-strict-aliasing', - '-Wno-sign-compare', - '-O0', - '-g' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'ENABLE_GPU=1', - '_DEBUG' - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-rdynamic' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, -} - -config = configurations[env['CONFIG_NAME']] -env.Append(**config['Append']) -env.FilterOut(**config['FilterOut']) -env.Replace(**config['Replace']) - -# Scons forces -fPIC for SHCCFLAGS on some platforms. -# Disable that so we can control it from cflags in gyp. -# Note that Scons itself is inconsistent with its -fPIC -# setting. SHCCFLAGS forces -fPIC, and SHCFLAGS does not. -# This will make SHCCFLAGS consistent with SHCFLAGS. -env['SHCCFLAGS'] = ['$CCFLAGS'] - -for _var in config['ImportExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env[_var] = os.environ[_var] -for _var in config['PropagateExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env['ENV'][_var] = os.environ[_var] - -env['ENV']['LD_LIBRARY_PATH'] = env.subst('$LIB_DIR') - -if ARGUMENTS.get('COVERAGE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-fprofile-arcs', - '-ftest-coverage' - ], - LINKFLAGS = [ - '-fprofile-arcs' - ], - ) - -if ARGUMENTS.get('PROFILE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-pg', - '-g' - ], - LINKFLAGS = [ - '-pg' - ], - ) - -if ARGUMENTS.get('SYMBOLS') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-g' - ], - ) - -input_files = [ - 'third_party/symbolize/symbolize.cc', - 'third_party/symbolize/demangle.cc', -] - -target_files = [] -prerequisites = [] - -_result = [] -for infile in input_files: - if env.compilable(infile): - if (type(infile) == type('') - and (infile.startswith('$SRC_DIR/base/') - or not os.path.isabs(env.subst(infile)))): - # Force files below the build directory by replacing all '..' - # elements in the path with '__': - base, ext = os.path.splitext(os.path.normpath(infile)) - base = [d == '..' and '__' or d for d in base.split('/')] - base = os.path.join(*base) - object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base - if not infile.startswith('$SRC_DIR/base/'): - infile = '$SRC_DIR/base/' + infile - infile = env.StaticObject(object, infile)[0] - else: - infile = env.StaticObject(infile)[0] - _result.append(infile) -input_files = _result - -_outputs = env.GypStaticLibrary(env.File('${LIB_DIR}/${LIBPREFIX}symbolize${LIBSUFFIX}'), input_files) -target_files.extend(_outputs) - -gyp_target = env.Alias('symbolize', target_files) -env.Requires(gyp_target, prerequisites) -Return("gyp_target") diff --git a/base/symbolize.target.mk b/base/symbolize.target.mk deleted file mode 100644 index affac99..0000000 --- a/base/symbolize.target.mk +++ /dev/null @@ -1,120 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := symbolize -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -Wno-sign-compare \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -Wno-sign-compare \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := - -OBJS := $(obj).target/$(TARGET)/base/third_party/symbolize/symbolize.o \ - $(obj).target/$(TARGET)/base/third_party/symbolize/demangle.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := - -$(obj).target/base/libsymbolize.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/base/libsymbolize.a: LIBS := $(LIBS) -$(obj).target/base/libsymbolize.a: TOOLSET := $(TOOLSET) -$(obj).target/base/libsymbolize.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/base/libsymbolize.a -# Add target alias -.PHONY: symbolize -symbolize: $(obj).target/base/libsymbolize.a - -# Add target alias to "all" target. -.PHONY: all -all: symbolize - diff --git a/base/task_unittest.cc b/base/task_unittest.cc deleted file mode 100644 index 1fa7c9d..0000000 --- a/base/task_unittest.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2009 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 "base/scoped_ptr.h" -#include "base/task.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -class HelperObject { - public: - HelperObject() : next_number_(0) { } - int GetNextNumber() { return ++next_number_; } - void GetNextNumberArg(int* number) { *number = GetNextNumber(); } - - private: - int next_number_; -}; - -} // namespace - -TEST(Task, OneArg) { - HelperObject obj; - scoped_ptr<Callback1<int*>::Type> callback( - NewCallback(&obj, &HelperObject::GetNextNumberArg)); - - int number = 0; - callback->Run(&number); - EXPECT_EQ(number, 1); -} - -TEST(Task, ReturnValue) { - HelperObject obj; - scoped_ptr<CallbackWithReturnValue<int>::Type> callback( - NewCallbackWithReturnValue(&obj, &HelperObject::GetNextNumber)); - - EXPECT_EQ(callback->Run(), 1); -} diff --git a/base/test/multiprocess_test.cc b/base/test/multiprocess_test.cc new file mode 100644 index 0000000..a1a3bbe --- /dev/null +++ b/base/test/multiprocess_test.cc @@ -0,0 +1,74 @@ +// Copyright (c) 2010 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 "base/test/multiprocess_test.h" + +#include "base/base_switches.h" +#include "base/command_line.h" + +#if defined(OS_POSIX) +#include <sys/types.h> +#include <unistd.h> +#endif + +namespace base { + +MultiProcessTest::MultiProcessTest() { +} + +ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname, + bool debug_on_start) { +#if defined(OS_WIN) + return SpawnChildImpl(procname, debug_on_start); +#elif defined(OS_POSIX) + file_handle_mapping_vector empty_file_list; + return SpawnChildImpl(procname, empty_file_list, debug_on_start); +#endif +} + +#if defined(OS_POSIX) +ProcessHandle MultiProcessTest::SpawnChild( + const std::string& procname, + const file_handle_mapping_vector& fds_to_map, + bool debug_on_start) { + return SpawnChildImpl(procname, fds_to_map, debug_on_start); +} +#endif + +CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname, + bool debug_on_start) { + CommandLine cl(*CommandLine::ForCurrentProcess()); + cl.AppendSwitchASCII(switches::kTestChildProcess, procname); + if (debug_on_start) + cl.AppendSwitch(switches::kDebugOnStart); + return cl; +} + +#if defined(OS_WIN) + +ProcessHandle MultiProcessTest::SpawnChildImpl(const std::string& procname, + bool debug_on_start) { + ProcessHandle handle = static_cast<ProcessHandle>(NULL); + LaunchApp(MakeCmdLine(procname, debug_on_start), + false, true, &handle); + return handle; +} + +#elif defined(OS_POSIX) + +// TODO(port): with the CommandLine refactoring, this code is very similar +// to the Windows code. Investigate whether this can be made shorter. +ProcessHandle MultiProcessTest::SpawnChildImpl( + const std::string& procname, + const file_handle_mapping_vector& fds_to_map, + bool debug_on_start) { + ProcessHandle handle = kNullProcessHandle; + LaunchApp(MakeCmdLine(procname, debug_on_start).argv(), + fds_to_map, false, &handle); + return handle; +} + +#endif + +} // namespace base diff --git a/base/test/multiprocess_test.h b/base/test/multiprocess_test.h new file mode 100644 index 0000000..5126abe --- /dev/null +++ b/base/test/multiprocess_test.h @@ -0,0 +1,86 @@ +// Copyright (c) 2010 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. + +#ifndef BASE_TEST_MULTIPROCESS_TEST_H_ +#define BASE_TEST_MULTIPROCESS_TEST_H_ +#pragma once + +#include <string> + +#include "base/basictypes.h" +#include "base/process.h" +#include "base/process_util.h" +#include "build/build_config.h" +#include "testing/platform_test.h" + +class CommandLine; + +namespace base { + +// A MultiProcessTest is a test class which makes it easier to +// write a test which requires code running out of process. +// +// To create a multiprocess test simply follow these steps: +// +// 1) Derive your test from MultiProcessTest. Example: +// +// class MyTest : public MultiProcessTest { +// }; +// +// TEST_F(MyTest, TestCaseName) { +// ... +// } +// +// 2) Create a mainline function for the child processes and include +// testing/multiprocess_func_list.h. +// See the declaration of the MULTIPROCESS_TEST_MAIN macro +// in that file for an example. +// 3) Call SpawnChild("foo"), where "foo" is the name of +// the function you wish to run in the child processes. +// That's it! +class MultiProcessTest : public PlatformTest { + public: + MultiProcessTest(); + + protected: + // Run a child process. + // 'procname' is the name of a function which the child will + // execute. It must be exported from this library in order to + // run. + // + // Example signature: + // extern "C" int __declspec(dllexport) FooBar() { + // // do client work here + // } + // + // Returns the handle to the child, or NULL on failure + ProcessHandle SpawnChild(const std::string& procname, bool debug_on_start); + +#if defined(OS_POSIX) + ProcessHandle SpawnChild(const std::string& procname, + const file_handle_mapping_vector& fds_to_map, + bool debug_on_start); +#endif + + CommandLine MakeCmdLine(const std::string& procname, bool debug_on_start); + + private: +#if defined(OS_WIN) + ProcessHandle SpawnChildImpl(const std::string& procname, + bool debug_on_start); + +#elif defined(OS_POSIX) + // TODO(port): with the CommandLine refactoring, this code is very similar + // to the Windows code. Investigate whether this can be made shorter. + ProcessHandle SpawnChildImpl(const std::string& procname, + const file_handle_mapping_vector& fds_to_map, + bool debug_on_start); +#endif + + DISALLOW_COPY_AND_ASSIGN(MultiProcessTest); +}; + +} // namespace base + +#endif // BASE_TEST_MULTIPROCESS_TEST_H_ diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc new file mode 100644 index 0000000..6df1fb9 --- /dev/null +++ b/base/test/test_suite.cc @@ -0,0 +1,214 @@ +// Copyright (c) 2009 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 "base/test/test_suite.h" + +#include "base/at_exit.h" +#include "base/base_paths.h" +#include "base/base_switches.h" +#include "base/command_line.h" +#include "base/debug_on_start.h" +#include "base/debug_util.h" +#include "base/file_path.h" +#include "base/i18n/icu_util.h" +#include "base/logging.h" +#include "base/nss_util.h" +#include "base/path_service.h" +#include "base/process_util.h" +#include "base/scoped_nsautorelease_pool.h" +#include "base/scoped_ptr.h" +#include "base/test/multiprocess_test.h" +#include "base/time.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/multiprocess_func_list.h" + +#if defined(TOOLKIT_USES_GTK) +#include <gtk/gtk.h> +#endif + +namespace { + +class MaybeTestDisabler : public testing::EmptyTestEventListener { + public: + virtual void OnTestStart(const testing::TestInfo& test_info) { + ASSERT_FALSE(TestSuite::IsMarkedMaybe(test_info)) + << "Probably the OS #ifdefs don't include all of the necessary " + "platforms.\nPlease ensure that no tests have the MAYBE_ prefix " + "after the code is preprocessed."; + } +}; + +} // namespace + +const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; + +TestSuite::TestSuite(int argc, char** argv) { + base::EnableTerminationOnHeapCorruption(); + CommandLine::Init(argc, argv); + testing::InitGoogleTest(&argc, argv); +#if defined(TOOLKIT_USES_GTK) + g_thread_init(NULL); + gtk_init_check(&argc, &argv); +#endif // defined(TOOLKIT_USES_GTK) + // Don't add additional code to this constructor. Instead add it to + // Initialize(). See bug 6436. +} + +TestSuite::~TestSuite() { + CommandLine::Reset(); +} + +// static +bool TestSuite::IsMarkedFlaky(const testing::TestInfo& test) { + return strncmp(test.name(), "FLAKY_", 6) == 0; +} + +// static +bool TestSuite::IsMarkedFailing(const testing::TestInfo& test) { + return strncmp(test.name(), "FAILS_", 6) == 0; +} + +// static +bool TestSuite::IsMarkedMaybe(const testing::TestInfo& test) { + return strncmp(test.name(), "MAYBE_", 6) == 0; +} + +// static +bool TestSuite::ShouldIgnoreFailure(const testing::TestInfo& test) { + if (CommandLine::ForCurrentProcess()->HasSwitch(kStrictFailureHandling)) + return false; + return IsMarkedFlaky(test) || IsMarkedFailing(test); +} + +// static +bool TestSuite::NonIgnoredFailures(const testing::TestInfo& test) { + return test.should_run() && test.result()->Failed() && + !ShouldIgnoreFailure(test); +} + +int TestSuite::GetTestCount(TestMatch test_match) { + testing::UnitTest* instance = testing::UnitTest::GetInstance(); + int count = 0; + + for (int i = 0; i < instance->total_test_case_count(); ++i) { + const testing::TestCase& test_case = *instance->GetTestCase(i); + for (int j = 0; j < test_case.total_test_count(); ++j) { + if (test_match(*test_case.GetTestInfo(j))) { + count++; + } + } + } + + return count; +} + +void TestSuite::CatchMaybeTests() { + testing::TestEventListeners& listeners = + testing::UnitTest::GetInstance()->listeners(); + listeners.Append(new MaybeTestDisabler); +} + +// Don't add additional code to this method. Instead add it to +// Initialize(). See bug 6436. +int TestSuite::Run() { + base::ScopedNSAutoreleasePool scoped_pool; + + Initialize(); + std::string client_func = + CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kTestChildProcess); + // Check to see if we are being run as a client process. + if (!client_func.empty()) + return multi_process_function_list::InvokeChildProcessTest(client_func); + int result = RUN_ALL_TESTS(); + + // If there are failed tests, see if we should ignore the failures. + if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0) + result = 0; + + // Display the number of flaky tests. + int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky); + if (flaky_count) { + printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count, + flaky_count == 1 ? "TEST" : "TESTS"); + } + + // Display the number of tests with ignored failures (FAILS). + int failing_count = GetTestCount(&TestSuite::IsMarkedFailing); + if (failing_count) { + printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n", + failing_count, failing_count == 1 ? "test" : "tests"); + } + + // This MUST happen before Shutdown() since Shutdown() tears down + // objects (such as NotificationService::current()) that Cocoa + // objects use to remove themselves as observers. + scoped_pool.Recycle(); + + Shutdown(); + + return result; +} + +// static +void TestSuite::UnitTestAssertHandler(const std::string& str) { + RAW_LOG(FATAL, str.c_str()); +} + +void TestSuite::SuppressErrorDialogs() { +#if defined(OS_WIN) + UINT new_flags = SEM_FAILCRITICALERRORS | + SEM_NOGPFAULTERRORBOX | + SEM_NOOPENFILEERRORBOX; + + // Preserve existing error mode, as discussed at + // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx + UINT existing_flags = SetErrorMode(new_flags); + SetErrorMode(existing_flags | new_flags); +#endif // defined(OS_WIN) +} + +void TestSuite::Initialize() { + // Initialize logging. + FilePath exe; + PathService::Get(base::FILE_EXE, &exe); + FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); + logging::InitLogging(log_filename.value().c_str(), + logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, + logging::LOCK_LOG_FILE, + logging::DELETE_OLD_LOG_FILE); + // We want process and thread IDs because we may have multiple processes. + // Note: temporarily enabled timestamps in an effort to catch bug 6361. + logging::SetLogItems(true, true, true, true); + + CHECK(base::EnableInProcessStackDumping()); +#if defined(OS_WIN) + // Make sure we run with high resolution timer to minimize differences + // between production code and test code. + base::Time::EnableHighResolutionTimer(true); +#endif // defined(OS_WIN) + + // In some cases, we do not want to see standard error dialogs. + if (!DebugUtil::BeingDebugged() && + !CommandLine::ForCurrentProcess()->HasSwitch("show-error-dialogs")) { + SuppressErrorDialogs(); + DebugUtil::SuppressDialogs(); + logging::SetLogAssertHandler(UnitTestAssertHandler); + } + + icu_util::Initialize(); + +#if defined(USE_NSS) + // Trying to repeatedly initialize and cleanup NSS and NSPR may result in + // a deadlock. Such repeated initialization will happen when using test + // isolation. Prevent problems by initializing NSS here, so that the cleanup + // will be done only on process exit. + base::EnsureNSSInit(); +#endif // defined(USE_NSS) + + CatchMaybeTests(); +} + +void TestSuite::Shutdown() { +} diff --git a/base/test_support_base.scons b/base/test_support_base.scons deleted file mode 100644 index 5df080c..0000000 --- a/base/test_support_base.scons +++ /dev/null @@ -1,306 +0,0 @@ -# This file is generated; do not edit. - -import os - -Import("env") - -env = env.Clone(COMPONENT_NAME='base', - TARGET_NAME='test_support_base') - -configurations = { - 'Debug' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-O0', - '-g' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - '_DEBUG' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/..') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-rdynamic' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, - 'Release' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-O2', - '-fno-ident', - '-fdata-sections', - '-ffunction-sections' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'NDEBUG', - 'NVALGRIND' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/..') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-Wl,--gc-sections' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, -} - -config = configurations[env['CONFIG_NAME']] -env.Append(**config['Append']) -env.FilterOut(**config['FilterOut']) -env.Replace(**config['Replace']) - -# Scons forces -fPIC for SHCCFLAGS on some platforms. -# Disable that so we can control it from cflags in gyp. -# Note that Scons itself is inconsistent with its -fPIC -# setting. SHCCFLAGS forces -fPIC, and SHCFLAGS does not. -# This will make SHCCFLAGS consistent with SHCFLAGS. -env['SHCCFLAGS'] = ['$CCFLAGS'] - -for _var in config['ImportExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env[_var] = os.environ[_var] -for _var in config['PropagateExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env['ENV'][_var] = os.environ[_var] - -env['ENV']['LD_LIBRARY_PATH'] = env.subst('$LIB_DIR') - -if ARGUMENTS.get('COVERAGE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-fprofile-arcs', - '-ftest-coverage' - ], - LINKFLAGS = [ - '-fprofile-arcs' - ], - ) - -if ARGUMENTS.get('PROFILE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-pg', - '-g' - ], - LINKFLAGS = [ - '-pg' - ], - ) - -if ARGUMENTS.get('SYMBOLS') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-g' - ], - ) - -input_files = [ - 'test/test_file_util.h', - 'test/test_file_util_linux.cc', - 'test/test_file_util_posix.cc', -] - -target_files = [] -prerequisites = [] - -_result = [] -for infile in input_files: - if env.compilable(infile): - if (type(infile) == type('') - and (infile.startswith('$SRC_DIR/base/') - or not os.path.isabs(env.subst(infile)))): - # Force files below the build directory by replacing all '..' - # elements in the path with '__': - base, ext = os.path.splitext(os.path.normpath(infile)) - base = [d == '..' and '__' or d for d in base.split('/')] - base = os.path.join(*base) - object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base - if not infile.startswith('$SRC_DIR/base/'): - infile = '$SRC_DIR/base/' + infile - infile = env.StaticObject(object, infile)[0] - else: - infile = env.StaticObject(infile)[0] - _result.append(infile) -input_files = _result - -_outputs = env.GypStaticLibrary('test_support_base', input_files) -target_files.extend(_outputs) - -gyp_target = env.Alias('test_support_base', target_files) -env.Requires(gyp_target, prerequisites) -Return("gyp_target") diff --git a/base/test_support_base.target.mk b/base/test_support_base.target.mk deleted file mode 100644 index 18e068d..0000000 --- a/base/test_support_base.target.mk +++ /dev/null @@ -1,162 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := test_support_base -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DUNIT_TEST' \ - '-DGTEST_HAS_RTTI=0' \ - '-D__STDC_FORMAT_MACROS' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := -I. \ - -Itesting/gmock/include \ - -Itesting/gtest/include - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DUNIT_TEST' \ - '-DGTEST_HAS_RTTI=0' \ - '-D__STDC_FORMAT_MACROS' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := -I. \ - -Itesting/gmock/include \ - -Itesting/gtest/include - -OBJS := $(obj).target/$(TARGET)/base/test/multiprocess_test.o \ - $(obj).target/$(TARGET)/base/test/test_file_util_linux.o \ - $(obj).target/$(TARGET)/base/test/test_file_util_posix.o \ - $(obj).target/$(TARGET)/base/test/test_suite.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := - -$(obj).target/base/libtest_support_base.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/base/libtest_support_base.a: LIBS := $(LIBS) -$(obj).target/base/libtest_support_base.a: TOOLSET := $(TOOLSET) -$(obj).target/base/libtest_support_base.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/base/libtest_support_base.a -# Add target alias -.PHONY: test_support_base -test_support_base: $(obj).target/base/libtest_support_base.a - -# Add target alias to "all" target. -.PHONY: all -all: test_support_base - diff --git a/base/test_support_perf.scons b/base/test_support_perf.scons deleted file mode 100644 index ed4baa1..0000000 --- a/base/test_support_perf.scons +++ /dev/null @@ -1,318 +0,0 @@ -# This file is generated; do not edit. - -import os - -Import("env") - -env = env.Clone(COMPONENT_NAME='base', - TARGET_NAME='test_support_perf') - -configurations = { - 'Debug' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-O0', - '-g' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'UNIT_TEST', - 'GTEST_HAS_RTTI=0', - '_DEBUG' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/..'), - env.Dir('$SRC_DIR/base/../testing/gtest/include') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-rdynamic' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, - 'Release' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-fno-asynchronous-unwind-tables', - '-fvisibility=hidden', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-DPNG_NO_MMX_CODE', - '-pthread', - '-I/usr/include/gtk-2.0', - '-I/usr/lib/gtk-2.0/include', - '-I/usr/include/atk-1.0', - '-I/usr/include/cairo', - '-I/usr/include/pango-1.0', - '-I/usr/include/glib-2.0', - '-I/usr/lib/glib-2.0/include', - '-I/usr/include/freetype2', - '-I/usr/include/libpng12', - '-I/usr/include/pixman-1', - '-O2', - '-fno-ident', - '-fdata-sections', - '-ffunction-sections' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'UNIT_TEST', - 'GTEST_HAS_RTTI=0', - 'NDEBUG', - 'NVALGRIND' - ], - CPPPATH = [ - env.Dir('$SRC_DIR/base/..'), - env.Dir('$SRC_DIR/base/../testing/gtest/include') - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-Wl,--gc-sections' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, -} - -config = configurations[env['CONFIG_NAME']] -env.Append(**config['Append']) -env.FilterOut(**config['FilterOut']) -env.Replace(**config['Replace']) - -# Scons forces -fPIC for SHCCFLAGS on some platforms. -# Disable that so we can control it from cflags in gyp. -# Note that Scons itself is inconsistent with its -fPIC -# setting. SHCCFLAGS forces -fPIC, and SHCFLAGS does not. -# This will make SHCCFLAGS consistent with SHCFLAGS. -env['SHCCFLAGS'] = ['$CCFLAGS'] - -for _var in config['ImportExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env[_var] = os.environ[_var] -for _var in config['PropagateExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env['ENV'][_var] = os.environ[_var] - -env['ENV']['LD_LIBRARY_PATH'] = env.subst('$LIB_DIR') - -if ARGUMENTS.get('COVERAGE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-fprofile-arcs', - '-ftest-coverage' - ], - LINKFLAGS = [ - '-fprofile-arcs' - ], - ) - -if ARGUMENTS.get('PROFILE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-pg', - '-g' - ], - LINKFLAGS = [ - '-pg' - ], - ) - -if ARGUMENTS.get('SYMBOLS') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-g' - ], - ) - -input_files = [ - 'perftimer.cc', - 'test/run_all_perftests.cc', -] - -target_files = [] -prerequisites = [] - -_result = [] -for infile in input_files: - if env.compilable(infile): - if (type(infile) == type('') - and (infile.startswith('$SRC_DIR/base/') - or not os.path.isabs(env.subst(infile)))): - # Force files below the build directory by replacing all '..' - # elements in the path with '__': - base, ext = os.path.splitext(os.path.normpath(infile)) - base = [d == '..' and '__' or d for d in base.split('/')] - base = os.path.join(*base) - object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base - if not infile.startswith('$SRC_DIR/base/'): - infile = '$SRC_DIR/base/' + infile - infile = env.StaticObject(object, infile)[0] - else: - infile = env.StaticObject(infile)[0] - _result.append(infile) -input_files = _result - -_outputs = env.GypStaticLibrary('test_support_perf', input_files) -target_files.extend(_outputs) - -gyp_target = env.Alias('test_support_perf', target_files) -dependencies = [ - Alias('gtk') -] -env.Requires(target_files, dependencies) -env.Requires(gyp_target, dependencies) -for prerequisite in prerequisites: - env.Requires(prerequisite, dependencies) -env.Requires(gyp_target, prerequisites) -Return("gyp_target") diff --git a/base/test_support_perf.target.mk b/base/test_support_perf.target.mk deleted file mode 100644 index b18c953..0000000 --- a/base/test_support_perf.target.mk +++ /dev/null @@ -1,158 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := test_support_perf -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DUNIT_TEST' \ - '-DGTEST_HAS_RTTI=0' \ - '-D__STDC_FORMAT_MACROS' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := -I. \ - -Itesting/gtest/include - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DUNIT_TEST' \ - '-DGTEST_HAS_RTTI=0' \ - '-D__STDC_FORMAT_MACROS' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -Werror \ - -pthread \ - -fno-exceptions \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -pthread \ - -D_REENTRANT \ - -I/usr/include/gtk-2.0 \ - -I/usr/lib/gtk-2.0/include \ - -I/usr/include/atk-1.0 \ - -I/usr/include/cairo \ - -I/usr/include/pango-1.0 \ - -I/usr/include/gio-unix-2.0/ \ - -I/usr/include/glib-2.0 \ - -I/usr/lib/glib-2.0/include \ - -I/usr/include/pixman-1 \ - -I/usr/include/freetype2 \ - -I/usr/include/directfb \ - -I/usr/include/libpng12 \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := -I. \ - -Itesting/gtest/include - -OBJS := $(obj).target/$(TARGET)/base/perftimer.o \ - $(obj).target/$(TARGET)/base/test/run_all_perftests.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := - -$(obj).target/base/libtest_support_perf.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/base/libtest_support_perf.a: LIBS := $(LIBS) -$(obj).target/base/libtest_support_perf.a: TOOLSET := $(TOOLSET) -$(obj).target/base/libtest_support_perf.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/base/libtest_support_perf.a -# Add target alias -.PHONY: test_support_perf -test_support_perf: $(obj).target/base/libtest_support_perf.a - -# Add target alias to "all" target. -.PHONY: all -all: test_support_perf - diff --git a/base/third_party/dynamic_annotations/dynamic_annotations.Makefile b/base/third_party/dynamic_annotations/dynamic_annotations.Makefile deleted file mode 100644 index bec0f1c..0000000 --- a/base/third_party/dynamic_annotations/dynamic_annotations.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= /usr/local/google/src/chromium-merge/src/base/third_party/dynamic_annotations/out -.PHONY: all -all: - $(MAKE) -C ../../.. dynamic_annotations diff --git a/base/third_party/dynamic_annotations/dynamic_annotations.target.mk b/base/third_party/dynamic_annotations/dynamic_annotations.target.mk deleted file mode 100644 index 7e74f64..0000000 --- a/base/third_party/dynamic_annotations/dynamic_annotations.target.mk +++ /dev/null @@ -1,117 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := dynamic_annotations -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := -I. - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := -I. - -OBJS := $(obj).target/$(TARGET)/base/third_party/dynamic_annotations/dynamic_annotations.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := - -$(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a: LIBS := $(LIBS) -$(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a: TOOLSET := $(TOOLSET) -$(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a -# Add target alias -.PHONY: dynamic_annotations -dynamic_annotations: $(obj).target/base/third_party/dynamic_annotations/libdynamic_annotations.a - -# Add target alias to "all" target. -.PHONY: all -all: dynamic_annotations - diff --git a/base/third_party/icu/README b/base/third_party/icu/README deleted file mode 100644 index faeb5ef..0000000 --- a/base/third_party/icu/README +++ /dev/null @@ -1,8 +0,0 @@ -This file has the relevant components from ICU copied to handle basic -UTF8/16/32 conversions. Components are copied from utf.h utf8.h utf16.h and -utf_impl.c - -The main change is that U_/U8_/U16_ prefixes have been replaced with -CBU_/CBU8_/CBU16_ (for "Chrome Base") to avoid confusion with the "real" ICU -macros should ICU be in use on the system. For the same reason, the functions -and types have been put in the "base_icu" namespace. diff --git a/base/third_party/valgrind/README b/base/third_party/valgrind/README deleted file mode 100644 index ce8c47b..0000000 --- a/base/third_party/valgrind/README +++ /dev/null @@ -1,8 +0,0 @@ -The single header file (valgrind.h) in this directory defines runtime -macros that determine whether the current process is running under -Valgrind. - -This header file was taken from Valgrind source code (version 3.4.1, -available at http://valgrind.org/downloads/valgrind-3.4.1.tar.bz2, dated -28 Feb 2009). The file is covered under BSD license as described within -the file. diff --git a/base/xdg_mime.scons b/base/xdg_mime.scons deleted file mode 100644 index 62dfdb9..0000000 --- a/base/xdg_mime.scons +++ /dev/null @@ -1,292 +0,0 @@ -# This file is generated; do not edit. - -import os - -Import("env") - -env = env.Clone(COMPONENT_NAME='base', - TARGET_NAME='xdg_mime') - -configurations = { - 'Release' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-fvisibility=hidden', - '-fno-strict-aliasing', - '-O2', - '-fno-ident', - '-fdata-sections', - '-ffunction-sections', - '-fno-asynchronous-unwind-tables' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'ENABLE_GPU=1', - 'NDEBUG', - 'NVALGRIND' - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-Wl,--gc-sections' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, - 'Debug' : { - 'Append' : dict( - CCFLAGS = [ - '-Werror', - '-pthread', - '-fno-exceptions', - '-Wall', - '-D_FILE_OFFSET_BITS=64', - '-fvisibility=hidden', - '-fno-strict-aliasing', - '-O0', - '-g' - ], - CPPDEFINES = [ - '__STDC_FORMAT_MACROS', - 'CHROMIUM_BUILD', - 'ENABLE_GPU=1', - '_DEBUG' - ], - CXXFLAGS = [ - '-fno-rtti', - '-fno-threadsafe-statics', - '-fvisibility-inlines-hidden' - ], - LINKFLAGS = [ - '-pthread', - '-rdynamic' - ], - ), - 'FilterOut' : dict( - ), - 'Replace' : dict( - FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'], - FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'], - FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'], - IMPLICIT_COMMAND_DEPENDENCIES = '0', - LDMODULECOM = [['$FLOCK_LDMODULE', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LDMODULEFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - LIBPATH = ['$LIB_DIR'], - LINKCOM = [['$FLOCK_LINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$LINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - SHLINKCOM = [['$FLOCK_SHLINK', - '-o', - '$TARGET', - '$_LIBDIRFLAGS', - '$SHLINKFLAGS', - '$SOURCES', - '-Wl,--start-group', - '$_LIBFLAGS', - '-Wl,--end-group']], - ), - 'ImportExternal' : [ - 'AS', - 'CC', - 'CXX', - 'LINK', - ], - 'PropagateExternal' : [ - 'AS', - 'CC', - 'CCACHE_DIR', - 'CXX', - 'DISTCC_DIR', - 'DISTCC_HOSTS', - 'HOME', - 'INCLUDE_SERVER_ARGS', - 'INCLUDE_SERVER_PORT', - 'LINK', - 'CHROME_BUILD_TYPE', - 'CHROMIUM_BUILD', - 'OFFICIAL_BUILD', - ], - }, -} - -config = configurations[env['CONFIG_NAME']] -env.Append(**config['Append']) -env.FilterOut(**config['FilterOut']) -env.Replace(**config['Replace']) - -# Scons forces -fPIC for SHCCFLAGS on some platforms. -# Disable that so we can control it from cflags in gyp. -# Note that Scons itself is inconsistent with its -fPIC -# setting. SHCCFLAGS forces -fPIC, and SHCFLAGS does not. -# This will make SHCCFLAGS consistent with SHCFLAGS. -env['SHCCFLAGS'] = ['$CCFLAGS'] - -for _var in config['ImportExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env[_var] = os.environ[_var] -for _var in config['PropagateExternal']: - if _var in ARGUMENTS: - env[_var] = ARGUMENTS[_var] - elif _var in os.environ: - env['ENV'][_var] = os.environ[_var] - -env['ENV']['LD_LIBRARY_PATH'] = env.subst('$LIB_DIR') - -if ARGUMENTS.get('COVERAGE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-fprofile-arcs', - '-ftest-coverage' - ], - LINKFLAGS = [ - '-fprofile-arcs' - ], - ) - -if ARGUMENTS.get('PROFILE') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-pg', - '-g' - ], - LINKFLAGS = [ - '-pg' - ], - ) - -if ARGUMENTS.get('SYMBOLS') not in (None, '0'): - env.AppendUnique( - CCFLAGS = [ - '-g' - ], - ) - -input_files = [ - 'third_party/xdg_mime/xdgmime.c', - 'third_party/xdg_mime/xdgmime.h', - 'third_party/xdg_mime/xdgmimealias.c', - 'third_party/xdg_mime/xdgmimealias.h', - 'third_party/xdg_mime/xdgmimecache.c', - 'third_party/xdg_mime/xdgmimecache.h', - 'third_party/xdg_mime/xdgmimeglob.c', - 'third_party/xdg_mime/xdgmimeglob.h', - 'third_party/xdg_mime/xdgmimeicon.c', - 'third_party/xdg_mime/xdgmimeicon.h', - 'third_party/xdg_mime/xdgmimeint.c', - 'third_party/xdg_mime/xdgmimeint.h', - 'third_party/xdg_mime/xdgmimemagic.c', - 'third_party/xdg_mime/xdgmimemagic.h', - 'third_party/xdg_mime/xdgmimeparent.c', - 'third_party/xdg_mime/xdgmimeparent.h', -] - -target_files = [] -prerequisites = [] - -_result = [] -for infile in input_files: - if env.compilable(infile): - if (type(infile) == type('') - and (infile.startswith('$SRC_DIR/base/') - or not os.path.isabs(env.subst(infile)))): - # Force files below the build directory by replacing all '..' - # elements in the path with '__': - base, ext = os.path.splitext(os.path.normpath(infile)) - base = [d == '..' and '__' or d for d in base.split('/')] - base = os.path.join(*base) - object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base - if not infile.startswith('$SRC_DIR/base/'): - infile = '$SRC_DIR/base/' + infile - infile = env.StaticObject(object, infile)[0] - else: - infile = env.StaticObject(infile)[0] - _result.append(infile) -input_files = _result - -_outputs = env.GypStaticLibrary(env.File('${LIB_DIR}/${LIBPREFIX}xdg_mime${LIBSUFFIX}'), input_files) -target_files.extend(_outputs) - -gyp_target = env.Alias('xdg_mime', target_files) -env.Requires(gyp_target, prerequisites) -Return("gyp_target") diff --git a/base/xdg_mime.target.mk b/base/xdg_mime.target.mk deleted file mode 100644 index 5f6d825..0000000 --- a/base/xdg_mime.target.mk +++ /dev/null @@ -1,124 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := xdg_mime -DEFS_Debug := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-D_DEBUG' - -# Flags passed to both C and C++ files. -CFLAGS_Debug := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -O0 \ - -g - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Debug := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Debug := - -DEFS_Release := '-DNO_HEAPCHECKER' \ - '-DCHROMIUM_BUILD' \ - '-DENABLE_REMOTING=1' \ - '-DENABLE_GPU=1' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' - -# Flags passed to both C and C++ files. -CFLAGS_Release := -pthread \ - -fno-exceptions \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -D_FILE_OFFSET_BITS=64 \ - -fvisibility=hidden \ - -pipe \ - -fno-strict-aliasing \ - -O2 \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C (and not C++) files. -CFLAGS_C_Release := - -# Flags passed to only C++ (and not C) files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden - -INCS_Release := - -OBJS := $(obj).target/$(TARGET)/base/third_party/xdg_mime/xdgmime.o \ - $(obj).target/$(TARGET)/base/third_party/xdg_mime/xdgmimealias.o \ - $(obj).target/$(TARGET)/base/third_party/xdg_mime/xdgmimecache.o \ - $(obj).target/$(TARGET)/base/third_party/xdg_mime/xdgmimeglob.o \ - $(obj).target/$(TARGET)/base/third_party/xdg_mime/xdgmimeicon.o \ - $(obj).target/$(TARGET)/base/third_party/xdg_mime/xdgmimeint.o \ - $(obj).target/$(TARGET)/base/third_party/xdg_mime/xdgmimemagic.o \ - $(obj).target/$(TARGET)/base/third_party/xdg_mime/xdgmimeparent.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread \ - -Wl,-z,noexecstack - -LDFLAGS_Release := -pthread \ - -Wl,-z,noexecstack \ - -Wl,-O1 \ - -Wl,--as-needed \ - -Wl,--gc-sections - -LIBS := - -$(obj).target/base/libxdg_mime.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/base/libxdg_mime.a: LIBS := $(LIBS) -$(obj).target/base/libxdg_mime.a: TOOLSET := $(TOOLSET) -$(obj).target/base/libxdg_mime.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/base/libxdg_mime.a -# Add target alias -.PHONY: xdg_mime -xdg_mime: $(obj).target/base/libxdg_mime.a - -# Add target alias to "all" target. -.PHONY: all -all: xdg_mime - |