summaryrefslogtreecommitdiffstats
path: root/o3d/base
diff options
context:
space:
mode:
authorgspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 23:15:42 +0000
committergspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 23:15:42 +0000
commit05b47f7a8c5451f858dc220df0e3a97542edace6 (patch)
treea2273d619f0625c9d44d40842845ccce2eac1045 /o3d/base
parent5cdc8bdb4c847cefe7f4542bd10c9880c2c557a0 (diff)
downloadchromium_src-05b47f7a8c5451f858dc220df0e3a97542edace6.zip
chromium_src-05b47f7a8c5451f858dc220df0e3a97542edace6.tar.gz
chromium_src-05b47f7a8c5451f858dc220df0e3a97542edace6.tar.bz2
This is the O3D source tree's initial commit to the Chromium tree. It
is not built or referenced at all by the chrome build yet, and doesn't yet build in it's new home. We'll change that shortly. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/base')
-rw-r--r--o3d/base/build.scons137
-rw-r--r--o3d/base/cross/bits.h76
-rw-r--r--o3d/base/cross/bits_test.cc78
-rw-r--r--o3d/base/cross/std_functional.h76
-rw-r--r--o3d/base/cross/std_hash.h165
-rw-r--r--o3d/base/icu38_o3d.scons487
6 files changed, 1019 insertions, 0 deletions
diff --git a/o3d/base/build.scons b/o3d/base/build.scons
new file mode 100644
index 0000000..499b56d
--- /dev/null
+++ b/o3d/base/build.scons
@@ -0,0 +1,137 @@
+# Copyright 2009, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import socket
+import time
+
+Import('env')
+
+env.SConscript('icu38_o3d.scons', exports=['env'])
+env.ApplySConscript([
+ '$ICU38_DIR/using_icu38.scons',
+])
+
+chrome_base_inputs = [
+ 'at_exit',
+ 'base_paths',
+ 'base_switches',
+ 'command_line',
+ 'debug_util',
+ 'file_path',
+ 'file_util',
+ 'lock',
+ 'logging',
+ 'path_service',
+ 'string_piece',
+ 'string_util',
+ 'string_util_icu',
+ 'third_party/dmg_fp/dtoa',
+ 'third_party/dmg_fp/g_fmt',
+ 'third_party/nspr/prtime',
+ 'thread',
+]
+
+inputs = [
+]
+
+if env.Bit('windows'):
+ env.Append(CCFLAGS=['/FIstdlib.h'])
+ chrome_base_inputs += [
+ 'base_paths_win',
+ 'debug_util_win',
+ 'file_util_win',
+ 'lock_impl_win',
+ 'message_pump_win',
+ 'platform_thread_win',
+ 'process_util_win',
+ 'registry',
+ 'shared_memory_win',
+ 'sys_string_conversions_win',
+ 'system_monitor_win',
+ 'thread_local_storage_win',
+ 'thread_local_win',
+ 'time_win',
+ 'waitable_event_win',
+ 'win_util',
+ ]
+ # The following are cross-platform, but are not needed on linux or mac, and
+ # pull in more third-party dependencies (libevent) on those platforms, so
+ # they are not built on all platforms currently.
+ # TODO: get the dependencies straightened out.
+ chrome_base_inputs += [
+ 'cpu',
+ 'histogram',
+ 'lazy_instance',
+ 'message_loop',
+ 'message_pump_default',
+ 'ref_counted',
+ 'stats_table',
+ 'system_monitor',
+ 'thread_collision_warner',
+ 'time',
+ 'timer',
+ 'tracked',
+ 'tracked_objects',
+ ]
+
+chrome_base_inputs_posix = [
+ 'atomicops_internals_x86_gcc',
+ 'debug_util_posix',
+ 'file_util_posix',
+ 'lock_impl_posix',
+ 'platform_thread_posix',
+ 'string16',
+ 'thread_local_posix',
+ 'thread_local_storage_posix',
+]
+chrome_base_inputs_mm = []
+
+if env.Bit('linux'):
+ chrome_base_inputs += chrome_base_inputs_posix
+ chrome_base_inputs += [
+ 'base_paths_linux',
+ 'file_util_linux',
+ 'sys_string_conversions_linux',
+ ]
+
+if env.Bit('mac'):
+ chrome_base_inputs += chrome_base_inputs_posix
+ chrome_base_inputs_mm += [
+ 'base_paths_mac',
+ 'file_util_mac',
+ 'platform_thread_mac',
+ 'sys_string_conversions_mac',
+ ]
+
+inputs += env.MakeObjects(chrome_base_inputs, '$CHROME_SRC_DIR/base', 'cc')
+inputs += env.MakeObjects(chrome_base_inputs_mm, '$CHROME_SRC_DIR/base', 'mm')
+
+# Build a library called 'o3d_base' from the input sources.
+o3d_base_lib = env.ComponentLibrary('o3d_base', inputs)
diff --git a/o3d/base/cross/bits.h b/o3d/base/cross/bits.h
new file mode 100644
index 0000000..ffb3ccb
--- /dev/null
+++ b/o3d/base/cross/bits.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// This file defines some bit utilities.
+
+#ifndef O3D_BASE_CROSS_BITS_H_
+#define O3D_BASE_CROSS_BITS_H_
+
+#include "base/logging.h"
+
+namespace o3d {
+namespace base {
+namespace bits {
+
+// Returns the integer i such as 2^i <= n < 2^(i+1)
+static inline int Log2Floor(unsigned int n) {
+ if (n == 0)
+ return -1;
+ int log = 0;
+ unsigned int value = n;
+ for (int i = 4; i >= 0; --i) {
+ int shift = (1 << i);
+ unsigned int x = value >> shift;
+ if (x != 0) {
+ value = x;
+ log += shift;
+ }
+ }
+ DCHECK_EQ(value, 1);
+ return log;
+}
+
+// Returns the integer i such as 2^(i-1) < n <= 2^i
+static inline int Log2Ceiling(unsigned int n) {
+ if (n == 0) {
+ return -1;
+ } else {
+ // Log2Floor returns -1 for 0, so the following works correctly for n=1.
+ return 1 + Log2Floor(n - 1);
+ }
+}
+
+} // namespace bits
+} // namespace base
+} // namespace o3d
+
+#endif // O3D_BASE_CROSS_BITS_H_
diff --git a/o3d/base/cross/bits_test.cc b/o3d/base/cross/bits_test.cc
new file mode 100644
index 0000000..4db01a0
--- /dev/null
+++ b/o3d/base/cross/bits_test.cc
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// This file contains the unit tests for the bit utilities.
+
+#include "base/cross/bits.h"
+#include "tests/common/win/testing_common.h"
+
+namespace o3d {
+namespace base {
+namespace bits {
+
+TEST(Bits, TestLog2Floor) {
+ EXPECT_EQ(-1, Log2Floor(0));
+ EXPECT_EQ(0, Log2Floor(1));
+ EXPECT_EQ(1, Log2Floor(2));
+ EXPECT_EQ(1, Log2Floor(3));
+ EXPECT_EQ(2, Log2Floor(4));
+ for (unsigned int i = 3; i < 31; ++i) {
+ unsigned int value = 1U << i;
+ EXPECT_EQ(i, Log2Floor(value));
+ EXPECT_EQ(i, Log2Floor(value + 1));
+ EXPECT_EQ(i, Log2Floor(value + 2));
+ EXPECT_EQ(i - 1, Log2Floor(value - 1));
+ EXPECT_EQ(i - 1, Log2Floor(value - 2));
+ }
+ EXPECT_EQ(31, Log2Floor(0xffffffffU));
+}
+
+TEST(Bits, TestLog2Ceiling) {
+ EXPECT_EQ(-1, Log2Ceiling(0));
+ EXPECT_EQ(0, Log2Ceiling(1));
+ EXPECT_EQ(1, Log2Ceiling(2));
+ EXPECT_EQ(2, Log2Ceiling(3));
+ EXPECT_EQ(2, Log2Ceiling(4));
+ for (unsigned int i = 3; i < 31; ++i) {
+ unsigned int value = 1U << i;
+ EXPECT_EQ(i, Log2Ceiling(value));
+ EXPECT_EQ(i + 1, Log2Ceiling(value + 1));
+ EXPECT_EQ(i + 1, Log2Ceiling(value + 2));
+ EXPECT_EQ(i, Log2Ceiling(value - 1));
+ EXPECT_EQ(i, Log2Ceiling(value - 2));
+ }
+ EXPECT_EQ(32, Log2Ceiling(0xffffffffU));
+}
+
+} // namespace bits
+} // namespace base
+} // namespace o3d
diff --git a/o3d/base/cross/std_functional.h b/o3d/base/cross/std_functional.h
new file mode 100644
index 0000000..884028a
--- /dev/null
+++ b/o3d/base/cross/std_functional.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// This file declares STL functional classes in a cross-compiler way.
+
+#ifndef O3D_BASE_CROSS_STD_FUNCTIONAL_H_
+#define O3D_BASE_CROSS_STD_FUNCTIONAL_H_
+
+#include <build/build_config.h>
+
+#if defined(COMPILER_GCC)
+#include <ext/functional>
+namespace o3d {
+namespace base {
+using __gnu_cxx::select1st;
+using __gnu_cxx::select2nd;
+} // namespace base
+} // namespace o3d
+#elif defined(COMPILER_MSVC)
+#include <functional>
+#include <utility>
+namespace o3d {
+namespace base {
+
+template <class Pair>
+class select1st : public std::unary_function<Pair, typename Pair::first_type> {
+ public:
+ const result_type &operator()(const argument_type &value) const {
+ return value.first;
+ }
+};
+
+template <class Pair>
+class select2nd : public std::unary_function<Pair, typename Pair::second_type> {
+ public:
+ const result_type &operator()(const argument_type &value) const {
+ return value.second;
+ }
+};
+
+} // namespace base
+} // namespace o3d
+#else
+#error Unsupported compiler
+#endif
+
+#endif // O3D_BASE_CROSS_STD_FUNCTIONAL_H_
diff --git a/o3d/base/cross/std_hash.h b/o3d/base/cross/std_hash.h
new file mode 100644
index 0000000..ceac439
--- /dev/null
+++ b/o3d/base/cross/std_hash.h
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// This file declares STL hash map classes in a cross-compiler way, providing a
+// GCC-compatible (not MSVC) interface.
+
+#ifndef O3D_BASE_CROSS_STD_HASH_H_
+#define O3D_BASE_CROSS_STD_HASH_H_
+
+#include <build/build_config.h>
+
+#if defined(COMPILER_MSVC)
+#include <hash_map>
+#include <hash_set>
+namespace o3d {
+namespace base {
+
+struct PortableHashBase {
+ // These two public members are required by msvc. 4 and 8 are the
+ // default values.
+ static const size_t bucket_size = 4;
+ static const size_t min_buckets = 8;
+};
+
+template <typename Key>
+struct hash;
+
+// These are missing from MSVC.
+template<> struct hash<int> {
+ size_t operator()(int n) const {
+ return static_cast<size_t>(n);
+ }
+};
+
+template<> struct hash<unsigned int> {
+ size_t operator()(unsigned int n) const {
+ return static_cast<size_t>(n);
+ }
+};
+
+template<typename T> struct hash<T*> {
+ size_t operator()(T* t) const {
+ return reinterpret_cast<size_t>(t);
+ }
+};
+
+// If the 3rd template parameter of the GNU interface (KeyEqual) is
+// omitted, then we know that it's using the == operator, so we can
+// safely use the < operator.
+//
+// If the third parameter is specified, then we get a compile time
+// error, and we know we have to go back and add some #ifdefs.
+template <typename Key, typename Hash>
+struct HashAndLessOperator : PortableHashBase {
+ bool operator()(const Key& a, const Key& b) const {
+ return a < b;
+ }
+ size_t operator()(const Key& key) const {
+ return hasher_(key);
+ }
+ Hash hasher_;
+};
+
+template <class Key, class Hash = hash<Key> >
+class hash_set : public stdext::hash_set<Key, HashAndLessOperator<Key, Hash> > {
+ public:
+ hash_set() {}
+ explicit hash_set(int buckets) {}
+ typedef std::equal_to<Key> key_equal;
+ size_type bucket_count() const {
+ return size() / bucket_size;
+ }
+};
+
+template <class Key, class Val, class Hash = hash<Key> >
+class hash_map : public stdext::hash_map<
+ Key, Val, HashAndLessOperator<Key, Hash> > {
+ public:
+ hash_map() {}
+ explicit hash_map(int buckets) {}
+ typedef std::equal_to<Key> key_equal;
+ size_type bucket_count() const {
+ return size() / bucket_size;
+ }
+};
+
+template <class Key, class Hash = hash<Key> >
+class hash_multiset : public stdext::hash_multiset<
+ Key, HashAndLessOperator<Key, Hash> > {
+ public:
+ hash_multiset() {}
+ explicit hash_multiset(int buckets) {}
+ typedef std::equal_to<Key> key_equal;
+ size_type bucket_count() const {
+ return size() / bucket_size;
+ }
+};
+
+template <class Key, class Val, class Hash = hash<Key> >
+class hash_multimap : public stdext::hash_multimap<
+ Key, Val, HashAndLessOperator<Key, Hash> > {
+ public:
+ hash_multimap() {}
+ explicit hash_multimap(int buckets) {}
+ typedef std::equal_to<Key> key_equal;
+ size_type bucket_count() const {
+ return size() / bucket_size;
+ }
+};
+
+} // namespace base
+} // namespace o3d
+#elif defined COMPILER_GCC
+#include <ext/hash_map>
+#include <ext/hash_set>
+#include <tr1/functional>
+namespace __gnu_cxx {
+template <class T> struct hash<T*> {
+ size_t operator() (const T* x) const {
+ return hash<size_t>()(reinterpret_cast<size_t>(x));
+ }
+};
+} // namespace __gnu_cxx
+
+namespace o3d {
+namespace base {
+using __gnu_cxx::hash_map;
+using __gnu_cxx::hash_multimap;
+using __gnu_cxx::hash_set;
+using __gnu_cxx::hash_multiset;
+using __gnu_cxx::hash;
+} // namespace base
+} // namespace o3d
+#endif // COMPILER_MSVC
+
+#endif // O3D_BASE_CROSS_STD_HASH_H_
diff --git a/o3d/base/icu38_o3d.scons b/o3d/base/icu38_o3d.scons
new file mode 100644
index 0000000..701e511
--- /dev/null
+++ b/o3d/base/icu38_o3d.scons
@@ -0,0 +1,487 @@
+# Copyright 2009, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#
+# This file is based on the icu38.scons file from the Chrome project,
+# Copyright (c) 2006-2008 The Chromium Authors.
+
+# Variables to control what does or doesn't get built here:
+#
+# CombinedLib
+# When True, builds a combined libicu.a (or icu.lib) containing
+# the common, i18n, stubdata and toolutil parts of ICU. When
+# False, builds those as separate libraries.
+#
+# GeneratedDataLib
+# When True, specifies that we want to build a libicudata.a
+# (or icudata.lib) library containing the data. When False,
+# we copy out the icudt38l.dat file or the Chromium icudt38.dll
+# file.
+#
+# Note that we've only verified the behavior that each platform
+# needs to build the way it currently wants, so don't expect that
+# you can just change the way a given platform builds without maybe
+# having to fix things. For example, attempts to set GenerateDataLib
+# on Windows will need to fix problems executing the utilities that
+# handle the generation.
+
+import os
+
+CombinedLib = True
+GenerateDataLib = False
+
+Import('env')
+
+env = env.Clone(
+ GENERATED_DIR = env.Dir('$ICU38_DIR/generated'),
+ GENCCODE = env.File('$ICU38_DIR/generated/genccode$PROGSUFFIX'),
+ ICUPKG = env.File('$ICU38_DIR/generated/icupkg$PROGSUFFIX'),
+)
+
+env.ApplySConscript([
+ '$CHROME_SRC_DIR/build/external_code.scons',
+])
+
+env.Prepend(
+ CPPPATH = [
+ '$ICU38_DIR/source/common',
+ '$ICU38_DIR/public/common',
+ '$ICU38_DIR/source/i18n',
+ '$ICU38_DIR/public/i18n',
+ '$ICU38_DIR/source/tools/toolutil',
+ ],
+ CPPDEFINES = [
+ 'U_STATIC_IMPLEMENTATION',
+ ],
+)
+
+if env.Bit('mac'):
+ env.FilterOut(CCFLAGS=['-Werror'],
+ CPPDEFINES=['DEBUG'])
+ env['GENCCODE_NAME'] = 'icudt38l'
+ env['GENCCODE_FLAGS'] = '-a gcc-darwin -n $GENCCODE_NAME -e icudt38'
+ env['GENCCODE_SUFFIX'] = '.s'
+
+if env.Bit('linux'):
+ env['GENCCODE_NAME'] = 'icudt38l'
+ env['GENCCODE_FLAGS'] = '-a gcc -n $GENCCODE_NAME -e icudt38'
+ env['GENCCODE_SUFFIX'] = '.s'
+
+if env.Bit('windows'):
+ env['GENCCODE_NAME'] = 'icudt38'
+ env['GENCCODE_FLAGS'] = '-e icudt38'
+ env['GENCCODE_SUFFIX'] = '.c'
+
+if env.Bit('windows'):
+ # /Wd4996 to silence warning about strncpy
+ env.Append(CCFLAGS = ['/WX', '/wd4996'])
+else:
+ env.Append(
+ CCFLAGS = [
+ # TODO: fix ICU to not depend on this flag.
+ '-fno-strict-aliasing',
+
+ '-Wno-parentheses',
+
+ # See uprv_UnicodeStringDummy at end of source/common/unistr.cpp.
+ '-Wno-unused-function',
+ ]
+ )
+
+if 'WIN32_LEAN_AND_MEAN' in env['CPPDEFINES']:
+ env['CPPDEFINES'].remove('WIN32_LEAN_AND_MEAN')
+
+common_input_files = [
+ 'source/common/bmpset.cpp',
+ 'source/common/brkeng.cpp',
+ 'source/common/brkiter.cpp',
+ 'source/common/caniter.cpp',
+ 'source/common/chariter.cpp',
+ 'source/common/cmemory.c',
+ 'source/common/cstring.c',
+ 'source/common/cwchar.c',
+ 'source/common/dictbe.cpp',
+ 'source/common/locbased.cpp',
+ 'source/common/locid.cpp',
+ 'source/common/locmap.c',
+ 'source/common/locutil.cpp',
+ 'source/common/normlzr.cpp',
+ 'source/common/parsepos.cpp',
+ 'source/common/propname.cpp',
+ 'source/common/punycode.c',
+ 'source/common/putil.c',
+ 'source/common/rbbi.cpp',
+ 'source/common/rbbidata.cpp',
+ 'source/common/rbbinode.cpp',
+ 'source/common/rbbirb.cpp',
+ 'source/common/rbbiscan.cpp',
+ 'source/common/rbbisetb.cpp',
+ 'source/common/rbbistbl.cpp',
+ 'source/common/rbbitblb.cpp',
+ 'source/common/resbund.cpp',
+ 'source/common/resbund_cnv.cpp',
+ 'source/common/ruleiter.cpp',
+ 'source/common/schriter.cpp',
+ 'source/common/serv.cpp',
+ 'source/common/servlk.cpp',
+ 'source/common/servlkf.cpp',
+ 'source/common/servls.cpp',
+ 'source/common/servnotf.cpp',
+ 'source/common/servrbf.cpp',
+ 'source/common/servslkf.cpp',
+ 'source/common/triedict.cpp',
+ 'source/common/uarrsort.c',
+ 'source/common/ubidi.c',
+ 'source/common/ubidi_props.c',
+ 'source/common/ubidiln.c',
+ 'source/common/ubidiwrt.c',
+ 'source/common/ubrk.cpp',
+ 'source/common/ucase.c',
+ 'source/common/ucasemap.c',
+ 'source/common/ucat.c',
+ 'source/common/uchar.c',
+ 'source/common/uchriter.cpp',
+ 'source/common/ucln_cmn.c',
+ 'source/common/ucmndata.c',
+ 'source/common/ucnv.c',
+ 'source/common/ucnv_bld.c',
+ 'source/common/ucnv_cb.c',
+ 'source/common/ucnv_cnv.c',
+ 'source/common/ucnv_err.c',
+ 'source/common/ucnv_ext.c',
+ 'source/common/ucnv_io.c',
+ 'source/common/ucnv_lmb.c',
+ 'source/common/ucnv_set.c',
+ 'source/common/ucnv_u16.c',
+ 'source/common/ucnv_u32.c',
+ 'source/common/ucnv_u7.c',
+ 'source/common/ucnv_u8.c',
+ 'source/common/ucnv2022.c',
+ 'source/common/ucnvbocu.c',
+ 'source/common/ucnvdisp.c',
+ 'source/common/ucnvhz.c',
+ 'source/common/ucnvisci.c',
+ 'source/common/ucnvlat1.c',
+ 'source/common/ucnvmbcs.c',
+ 'source/common/ucnvscsu.c',
+ 'source/common/ucol_swp.c',
+ 'source/common/udata.c',
+ 'source/common/udatamem.c',
+ 'source/common/udataswp.c',
+ 'source/common/uenum.c',
+ 'source/common/uhash.c',
+ 'source/common/uhash_us.cpp',
+ 'source/common/uidna.cpp',
+ 'source/common/uinit.c',
+ 'source/common/uinvchar.c',
+ 'source/common/uiter.cpp',
+ 'source/common/uloc.c',
+ 'source/common/umapfile.c',
+ 'source/common/umath.c',
+ 'source/common/umutex.c',
+ 'source/common/unames.c',
+ 'source/common/unifilt.cpp',
+ 'source/common/unifunct.cpp',
+ 'source/common/uniset.cpp',
+ 'source/common/uniset_props.cpp',
+ 'source/common/unisetspan.cpp',
+ 'source/common/unistr.cpp',
+ 'source/common/unistr_case.cpp',
+ 'source/common/unistr_cnv.cpp',
+ 'source/common/unistr_props.cpp',
+ 'source/common/unorm.cpp',
+ 'source/common/unorm_it.c',
+ 'source/common/unormcmp.cpp',
+ 'source/common/uobject.cpp',
+ 'source/common/uprops.c',
+ 'source/common/ures_cnv.c',
+ 'source/common/uresbund.c',
+ 'source/common/uresdata.c',
+ 'source/common/usc_impl.c',
+ 'source/common/uscript.c',
+ 'source/common/uset.cpp',
+ 'source/common/uset_props.cpp',
+ 'source/common/usetiter.cpp',
+ 'source/common/ushape.c',
+ 'source/common/usprep.cpp',
+ 'source/common/ustack.cpp',
+ 'source/common/ustr_cnv.c',
+ 'source/common/ustr_wcs.c',
+ 'source/common/ustrcase.c',
+ 'source/common/ustrenum.cpp',
+ 'source/common/ustrfmt.c',
+ 'source/common/ustring.c',
+ 'source/common/ustrtrns.c',
+ 'source/common/utext.cpp',
+ 'source/common/utf_impl.c',
+ 'source/common/util.cpp',
+ 'source/common/util_props.cpp',
+ 'source/common/utrace.c',
+ 'source/common/utrie.c',
+ 'source/common/utypes.c',
+ 'source/common/uvector.cpp',
+ 'source/common/uvectr32.cpp',
+ 'source/common/wintz.c',
+]
+
+i18n_input_files = [
+ 'source/i18n/anytrans.cpp',
+ 'source/i18n/astro.cpp',
+ 'source/i18n/basictz.cpp',
+ 'source/i18n/bocsu.c',
+ 'source/i18n/buddhcal.cpp',
+ 'source/i18n/calendar.cpp',
+ 'source/i18n/casetrn.cpp',
+ 'source/i18n/choicfmt.cpp',
+ 'source/i18n/coleitr.cpp',
+ 'source/i18n/coll.cpp',
+ 'source/i18n/cpdtrans.cpp',
+ 'source/i18n/csdetect.cpp',
+ 'source/i18n/csmatch.cpp',
+ 'source/i18n/csr2022.cpp',
+ 'source/i18n/csrecog.cpp',
+ 'source/i18n/csrmbcs.cpp',
+ 'source/i18n/csrsbcs.cpp',
+ 'source/i18n/csrucode.cpp',
+ 'source/i18n/csrutf8.cpp',
+ 'source/i18n/curramt.cpp',
+ 'source/i18n/currfmt.cpp',
+ 'source/i18n/currunit.cpp',
+ 'source/i18n/datefmt.cpp',
+ 'source/i18n/dcfmtsym.cpp',
+ 'source/i18n/decimfmt.cpp',
+ 'source/i18n/digitlst.cpp',
+ 'source/i18n/dtfmtsym.cpp',
+ 'source/i18n/dtrule.cpp',
+ 'source/i18n/esctrn.cpp',
+ 'source/i18n/fmtable.cpp',
+ 'source/i18n/fmtable_cnv.cpp',
+ 'source/i18n/format.cpp',
+ 'source/i18n/funcrepl.cpp',
+ 'source/i18n/gregocal.cpp',
+ 'source/i18n/gregoimp.cpp',
+ 'source/i18n/hebrwcal.cpp',
+ 'source/i18n/indiancal.cpp',
+ 'source/i18n/inputext.cpp',
+ 'source/i18n/islamcal.cpp',
+ 'source/i18n/japancal.cpp',
+ 'source/i18n/measfmt.cpp',
+ 'source/i18n/measure.cpp',
+ 'source/i18n/msgfmt.cpp',
+ 'source/i18n/name2uni.cpp',
+ 'source/i18n/nfrs.cpp',
+ 'source/i18n/nfrule.cpp',
+ 'source/i18n/nfsubs.cpp',
+ 'source/i18n/nortrans.cpp',
+ 'source/i18n/nultrans.cpp',
+ 'source/i18n/numfmt.cpp',
+ 'source/i18n/olsontz.cpp',
+ 'source/i18n/persncal.cpp',
+ 'source/i18n/plurfmt.cpp',
+ 'source/i18n/plurrule.cpp',
+ 'source/i18n/quant.cpp',
+ 'source/i18n/rbnf.cpp',
+ 'source/i18n/rbt.cpp',
+ 'source/i18n/rbt_data.cpp',
+ 'source/i18n/rbt_pars.cpp',
+ 'source/i18n/rbt_rule.cpp',
+ 'source/i18n/rbt_set.cpp',
+ 'source/i18n/rbtz.cpp',
+ 'source/i18n/regexcmp.cpp',
+ 'source/i18n/regexst.cpp',
+ 'source/i18n/reldtfmt.cpp',
+ 'source/i18n/rematch.cpp',
+ 'source/i18n/remtrans.cpp',
+ 'source/i18n/repattrn.cpp',
+ 'source/i18n/search.cpp',
+ 'source/i18n/simpletz.cpp',
+ 'source/i18n/smpdtfmt.cpp',
+ 'source/i18n/sortkey.cpp',
+ 'source/i18n/strmatch.cpp',
+ 'source/i18n/strrepl.cpp',
+ 'source/i18n/stsearch.cpp',
+ 'source/i18n/taiwncal.cpp',
+ 'source/i18n/tblcoll.cpp',
+ 'source/i18n/timezone.cpp',
+ 'source/i18n/titletrn.cpp',
+ 'source/i18n/tolowtrn.cpp',
+ 'source/i18n/toupptrn.cpp',
+ 'source/i18n/translit.cpp',
+ 'source/i18n/transreg.cpp',
+ 'source/i18n/tridpars.cpp',
+ 'source/i18n/tzrule.cpp',
+ 'source/i18n/tztrans.cpp',
+ 'source/i18n/ucal.cpp',
+ 'source/i18n/ucln_in.c',
+ 'source/i18n/ucol.cpp',
+ 'source/i18n/ucol_bld.cpp',
+ 'source/i18n/ucol_cnt.cpp',
+ 'source/i18n/ucol_elm.cpp',
+ 'source/i18n/ucol_res.cpp',
+ 'source/i18n/ucol_sit.cpp',
+ 'source/i18n/ucol_tok.cpp',
+ 'source/i18n/ucol_wgt.c',
+ 'source/i18n/ucoleitr.cpp',
+ 'source/i18n/ucsdet.cpp',
+ 'source/i18n/ucurr.cpp',
+ 'source/i18n/udat.cpp',
+ 'source/i18n/ulocdata.c',
+ 'source/i18n/umsg.cpp',
+ 'source/i18n/unesctrn.cpp',
+ 'source/i18n/uni2name.cpp',
+ 'source/i18n/unum.cpp',
+ 'source/i18n/uregex.cpp',
+ 'source/i18n/uregexc.cpp',
+ 'source/i18n/usearch.cpp',
+ 'source/i18n/utmscale.c',
+ 'source/i18n/utrans.cpp',
+ 'source/i18n/vtzone.cpp',
+ 'source/i18n/windtfmt.cpp',
+ 'source/i18n/winnmfmt.cpp',
+]
+
+stubdata_input_files = [
+ 'source/stubdata/stubdata.c',
+]
+
+toolutil_input_files = [
+ 'source/tools/toolutil/filestrm.c',
+ 'source/tools/toolutil/package.cpp',
+ 'source/tools/toolutil/pkgitems.cpp',
+ 'source/tools/toolutil/propsvec.c',
+ 'source/tools/toolutil/swapimpl.cpp',
+ 'source/tools/toolutil/toolutil.c',
+ 'source/tools/toolutil/toolutil.vcproj',
+ 'source/tools/toolutil/ucbuf.c',
+ 'source/tools/toolutil/ucm.c',
+ 'source/tools/toolutil/ucmstate.c',
+ 'source/tools/toolutil/unewdata.c',
+ 'source/tools/toolutil/uoptions.c',
+ 'source/tools/toolutil/uparse.c',
+ 'source/tools/toolutil/writesrc.c',
+ 'source/tools/toolutil/xmlparser.cpp',
+]
+
+def MakeObject(env, source, extra_defines):
+ base, ext = os.path.splitext(source)
+ return env.ComponentObject(base, '$ICU38_DIR/' + source,
+ CPPDEFINES = env['CPPDEFINES'] + extra_defines)
+
+
+
+if CombinedLib:
+
+ # These empirically fail to build when U_COMMON_IMPLEMENTATION
+ # isn't defined in addition to U_COMBINED_IMPLEMENTATION. Remove
+ # them from the source file list and re-append them with Nodes
+ # for custom-built object files with both defined.
+
+ need_common_implementation = [
+ 'source/common/ubidi.c',
+ 'source/common/ubidiln.c',
+ ]
+
+ objects = []
+ for n in need_common_implementation:
+ common_input_files.remove(n)
+ o = MakeObject(env, n, ['U_COMMON_IMPLEMENTATION',
+ 'U_COMBINED_IMPLEMENTATION'])
+ objects.append(o)
+
+ sources = common_input_files + i18n_input_files + stubdata_input_files
+ objects += [MakeObject(env, n, ['U_COMBINED_IMPLEMENTATION'])
+ for n in sources]
+
+ icu_lib = env.ComponentLibrary('icu', objects);
+
+else:
+
+ common_objects = [MakeObject(env, n, ['U_COMMON_IMPLEMENTATION'])
+ for n in common_input_files]
+ icu_lib = env.ComponentLibrary('icuuc', common_objects)
+
+ i18n_objects = [MakeObject(env, n, ['U_I18N_IMPLEMENTATION'])
+ for n in i18n_input_files]
+ env.ComponentLibrary('icui18n', i18n_objects)
+
+ stubdata_objects = [MakeObject(env, n, []) for n in stubdata_input_files]
+ env.ComponentLibrary('icudata_stub', stubdata_objects)
+
+ toolutil_objects = [MakeObject(env, n, ['U_TOOLUTIL_IMPLEMENTATION'])
+ for n in toolutil_input_files]
+
+ env.ComponentLibrary('icutu', toolutil_objects)
+
+
+if GenerateDataLib:
+
+ icudata_lst = env.Command(['$GENERATED_DIR/icudata.lst',
+ '$GENERATED_DIR/icudt38l/ucadata.icu'],
+ ['source/data/in/icudt38l.dat'],
+ ('$ICUPKG -d ${TARGETS[1].dir} --list -x "*"'
+ ' $SOURCE > $TARGET'))
+ env.Depends(icudata_lst, '$ICUPKG')
+
+ icudt38_dat = env.Command(['$GENERATED_DIR/${GENCCODE_NAME}.dat'],
+ icudata_lst,
+ ('$ICUPKG -tl -c -s ${SOURCES[1].dir}'
+ ' -a $SOURCE new $TARGET'))
+ env.Depends(icudt38_dat, '$ICUPKG')
+
+ icudt38_src = env.Command(
+ '$GENERATED_DIR/${GENCCODE_NAME}_dat${GENCCODE_SUFFIX}',
+ icudt38_dat,
+ '$GENCCODE $GENCCODE_FLAGS -d ${TARGET.dir} $SOURCE')
+ env.Depends(icudt38_src, '$GENCCODE')
+
+ icu_data = env.ComponentLibrary('icudata', icudt38_src)
+
+ if CombinedLib:
+ lib_list = ['icu']
+ else:
+ lib_list = ['icui18n', 'icutu', 'icuuc', 'icudata_stub']
+
+ env_tools = env.Clone(LIBS = lib_list)
+
+ env_tools.Program(env['GENCCODE'],
+ '$ICU38_DIR/source/tools/genccode/genccode.c')
+ env_tools.Program(env['ICUPKG'], '$ICU38_DIR/source/tools/icupkg/icupkg.cpp')
+
+else:
+
+ icu_data = None
+
+ # The ICU library isn't useful without the data properly installed.
+ if env.Bit('windows'):
+ icu_data = env.Replicate('$ARTIFACTS_DIR', 'icudt38.dll')
+ else:
+ icu_data = env.Replicate('$ARTIFACTS_DIR',
+ '$ICU38_DIR/source/data/in/icudt38l.dat')
+
+ env.Requires(icu_lib, icu_data)