Commit 0ca99052 authored by Arman Uguray's avatar Arman Uguray
Browse files

gn-build: Add BUILD files for libchrome

This CL adds GN build files for libchrome, which is the ChromeOS/Brillo library
for many C++ tools, include libbase. I added a new GN build target for "base"
under secondary sources with a GN build file for libchrome which currently lives
in platform/external/libchrome in AOSP.

To build, clone libchrome into third_party/libchrome and remove
third_party/libchrome/base/BUILD.gn. Also clone external/modp_b64 into
third_party/modp_b64. Eventually I will have scripts set up to do
this automatically.

This means that we can start developing against libbase while running GN builds
on Goobuntu but this would break the tree until libchrome is buildable within
the Android build system (http://r.android.com/158392). So Brillo/Android builds
will depend on libchrome using the conventional Android.mk means.

Bug: 22175181
Change-Id: I9a737aa785488e5bc0ca1adc087d1d5dfcdf3bea
parent 49120dc8
Building with GN+ninja
======================
system/bt is buildable using the GN and and ninja buildtools from the Chromium
project. After setting up these tools, several third_party packages need to be
set up to build the stack. It's a simple matter of copying (or sym-linking) some
packages out of AOSP into "system/bt/third_party":
From AOSP:
1. "platform/external/libevent" => third_party/libevent. The relevant
headers here are "event.h" and "event-config.h". event-config.h from
external/libevent is only compatible on Android; this means that you will need
to generate a new one based on the current platform. Please follow the
instructions in external/libevent/README.android for instructions on how to
generate this file.
2. "platform/external/libchrome" => third_party/libchrome. After that, remove
the BUILD.gn file that's in libchrome/base. This is a legacy file that only
works inside the Chromium project and we're using our own from secondary build
sources.
3. "platform/external/modp_b64" => third_party/modp_b64
4. "platform/external/tinyxml2" => third_party/tinyxml2
From Chromium:
1. "src/testing/gtest" => third_party/gtest
You will also need a fresh checkout of platform/hardware/libhardware and
platform/system/core for some include dependencies.
BUILD.gn files for all of these packages have already been set up under
"system/bt/build/secondary/third_party" (note: we don't have a BUILD.gn file for
modp_b64 since it comes with its own; as the package was imported into AOSP from
Chromium). To build, run:
1. 'gn args out/Default': This will prompt you to fill the contents of your
"args.gn" file. Set the two following variables:
a. libhw_include_path=<path to your "platform/hardware/libhardware/include">
b. core_include_path=<path to your "platform/system/core/include">
Once done, this will create the *.ninja files for the entire project.
2. 'ninja -C out/Default all': This will build all targets (the shared library,
executables, tests, etc) and put them in out/Default (or whatever you named the
output directory. To build an individual target, replace "all" with the target
of your choice, e.g. 'ninja -C out/Default net_test_osi'.
......@@ -49,6 +49,10 @@ config("linux") {
"-std=c99"
]
cflags_cc = [
"-std=c++11"
]
defines = [
"_FORTIFY_SOURCE=2",
"_GNU_SOURCE",
......
#
# Copyright (C) 2015 Google, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
source_set("base_sources") {
sources = [
"base/allocator/type_profiler_control.cc",
"base/at_exit.cc",
"base/atomic_ref_count.h",
"base/atomic_sequence_num.h",
"base/atomicops.h",
"base/atomicops_internals_x86_gcc.cc",
"base/base64.cc",
"base/base64.h",
"base/base_export.h",
"base/base_switches.cc",
"base/bind_helpers.cc",
"base/build_time.cc",
"base/callback_helpers.cc",
"base/callback_internal.cc",
"base/command_line.cc",
"base/cpu.cc",
"base/debug/alias.cc",
"base/debug/debugger.cc",
"base/debug/debugger_posix.cc",
"base/debug/stack_trace.cc",
"base/debug/stack_trace_posix.cc",
"base/debug/task_annotator.cc",
"base/environment.cc",
"base/files/file.cc",
"base/files/file_enumerator.cc",
"base/files/file_enumerator_posix.cc",
"base/files/file_path.cc",
"base/files/file_path_constants.cc",
"base/files/file_path_watcher.cc",
"base/files/file_path_watcher_linux.cc",
"base/files/file_posix.cc",
"base/files/file_tracing.cc",
"base/files/file_util.cc",
"base/files/file_util_linux.cc",
"base/files/file_util_posix.cc",
"base/files/important_file_writer.cc",
"base/files/scoped_file.cc",
"base/files/scoped_temp_dir.cc",
"base/guid.cc",
"base/guid_posix.cc",
"base/hash.cc",
"base/json/json_parser.cc",
"base/json/json_reader.cc",
"base/json/json_string_value_serializer.cc",
"base/json/json_writer.cc",
"base/json/string_escape.cc",
"base/lazy_instance.cc",
"base/location.cc",
"base/logging.cc",
"base/md5.cc",
"base/memory/ref_counted.cc",
"base/memory/ref_counted_memory.cc",
"base/memory/singleton.cc",
"base/memory/weak_ptr.cc",
"base/message_loop/incoming_task_queue.cc",
"base/message_loop/message_loop.cc",
"base/message_loop/message_loop_proxy.cc",
"base/message_loop/message_loop_proxy_impl.cc",
"base/message_loop/message_pump.cc",
"base/message_loop/message_pump_default.cc",
"base/message_loop/message_pump_libevent.cc",
"base/metrics/bucket_ranges.cc",
"base/metrics/field_trial.cc",
"base/metrics/histogram_base.cc",
"base/metrics/histogram.cc",
"base/metrics/histogram_samples.cc",
"base/metrics/histogram_snapshot_manager.cc",
"base/metrics/sample_map.cc",
"base/metrics/sample_vector.cc",
"base/metrics/sparse_histogram.cc",
"base/metrics/statistics_recorder.cc",
"base/pending_task.cc",
"base/pickle.cc",
"base/posix/file_descriptor_shuffle.cc",
"base/posix/safe_strerror.cc",
"base/posix/unix_domain_socket_linux.cc",
"base/process/internal_linux.cc",
"base/process/kill.cc",
"base/process/kill_posix.cc",
"base/process/launch.cc",
"base/process/launch_posix.cc",
"base/process/process_handle_linux.cc",
"base/process/process_handle_posix.cc",
"base/process/process_iterator.cc",
"base/process/process_iterator_linux.cc",
"base/process/process_metrics.cc",
"base/process/process_metrics_linux.cc",
"base/process/process_metrics_posix.cc",
"base/process/process_posix.cc",
"base/profiler/alternate_timer.cc",
"base/profiler/scoped_profile.cc",
"base/profiler/scoped_tracker.cc",
"base/profiler/tracked_time.cc",
"base/rand_util.cc",
"base/rand_util_posix.cc",
"base/run_loop.cc",
"base/sequence_checker_impl.cc",
"base/sequenced_task_runner.cc",
"base/sha1_portable.cc",
"base/strings/safe_sprintf.cc",
"base/strings/string16.cc",
"base/strings/string_number_conversions.cc",
"base/strings/string_piece.cc",
"base/strings/stringprintf.cc",
"base/strings/string_split.cc",
"base/strings/string_util.cc",
"base/strings/string_util_constants.cc",
"base/strings/sys_string_conversions_posix.cc",
"base/strings/utf_string_conversions.cc",
"base/strings/utf_string_conversion_utils.cc",
"base/synchronization/cancellation_flag.cc",
"base/synchronization/condition_variable_posix.cc",
"base/synchronization/lock.cc",
"base/synchronization/lock_impl_posix.cc",
"base/synchronization/waitable_event_posix.cc",
"base/sync_socket_posix.cc",
"base/sys_info.cc",
# TODO(armansito): For our GN builds these platform-specific implementations
# don't really make that much sense but instead of removing the line I'm
# commenting it out in case we want to re-add it later (it's included in the
# libchrome Android.mk).
#"sys_info_chromeos.cc",
"base/sys_info_linux.cc",
"base/sys_info_posix.cc",
"base/task/cancelable_task_tracker.cc",
"base/task_runner.cc",
"base/third_party/dmg_fp/dtoa.cc",
"base/third_party/dmg_fp/g_fmt.cc",
"base/third_party/dynamic_annotations/dynamic_annotations.c",
"base/third_party/icu/icu_utf.cc",
"base/third_party/nspr/prtime.cc",
"base/third_party/superfasthash/superfasthash.c",
"base/threading/non_thread_safe_impl.cc",
"base/threading/platform_thread_internal_posix.cc",
"base/threading/platform_thread_linux.cc",
"base/threading/platform_thread_posix.cc",
"base/threading/post_task_and_reply_impl.cc",
"base/threading/sequenced_worker_pool.cc",
"base/threading/simple_thread.cc",
"base/threading/thread.cc",
"base/threading/thread_checker_impl.cc",
"base/threading/thread_collision_warner.cc",
"base/threading/thread_id_name_manager.cc",
"base/threading/thread_local_posix.cc",
"base/threading/thread_local_storage.cc",
"base/threading/thread_local_storage_posix.cc",
"base/threading/thread_restrictions.cc",
"base/threading/worker_pool.cc",
"base/threading/worker_pool_posix.cc",
"base/thread_task_runner_handle.cc",
"base/time/clock.cc",
"base/time/default_clock.cc",
"base/time/default_tick_clock.cc",
"base/timer/elapsed_timer.cc",
"base/timer/timer.cc",
"base/time/tick_clock.cc",
"base/time/time.cc",
"base/time/time_posix.cc",
"base/trace_event/malloc_dump_provider.cc",
"base/trace_event/memory_allocator_dump.cc",
"base/trace_event/memory_allocator_dump_guid.cc",
"base/trace_event/memory_dump_manager.cc",
"base/trace_event/memory_dump_session_state.cc",
"base/trace_event/process_memory_dump.cc",
"base/trace_event/process_memory_maps.cc",
"base/trace_event/process_memory_maps_dump_provider.cc",
"base/trace_event/process_memory_totals.cc",
"base/trace_event/process_memory_totals_dump_provider.cc",
"base/trace_event/trace_config.cc",
"base/trace_event/trace_event_argument.cc",
"base/trace_event/trace_event_impl.cc",
"base/trace_event/trace_event_impl_constants.cc",
"base/trace_event/trace_event_memory.cc",
"base/trace_event/trace_event_memory_overhead.cc",
"base/trace_event/trace_event_synthetic_delay.cc",
"base/tracked_objects.cc",
"base/tracking_info.cc",
"base/values.cc",
"base/vlog.cc",
]
defines = [ "BASE_IMPLEMENTATION" ]
include_dirs = [
"//",
"//third_party/libchrome",
"//third_party/libchrome/base",
"//third_party/modp_b64",
]
}
static_library("base") {
deps = [
":base_sources",
]
cflags = [
"-Wno-char-subscripts",
"-Wno-missing-field-initializers",
"-Wno-unused-function",
"-Wno-unused_parameter",
]
cflags_cc = [
"-Wno-deprecated-register",
"-Wno-non-virtual-dtor",
"-Wno-sign-promo",
]
libs = [ "-levent", "-levent_core" ]
}
......@@ -17,7 +17,13 @@
#define DUMMY_COUNTER(c) CONCAT(__osi_dummy_, c)
#define DUMMY_PTR DUMMY_COUNTER(__COUNTER__)
// base/macros.h defines a COMPILE_ASSERT macro to the C++11 keyword
// "static_assert" (it undef's COMPILE_ASSERT before redefining it).
// C++ code that includes base and osi/include/osi.h can thus easily default to
// the definition from libbase but we should check here to avoid compile errors.
#ifndef COMPILE_ASSERT
#define COMPILE_ASSERT(x) char * DUMMY_PTR = !(x)
#endif // COMPILE_ASSERT
typedef uint32_t timeout_t;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment