Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4e20db0 authored by Jack He's avatar Jack He
Browse files

Fix x86_64 compilation on Ubuntu 14.04

* Add necessary includes in bt_trace.h
* Add toolchain specific configs
* Add libc++ import for clang
* Add libc++abi include for clang
* Add ipc_handler_linux.cc in service/BUILD.gn
* Use shared_mutex when _LIBCPP_VERSION < 3500
* Updated the build instructions

Test: ninja -C out/Default
Change-Id: I362ebf33f62910be817339cc6bdc62830f57db30
parent 85defca0
Loading
Loading
Loading
Loading
+49 −6
Original line number Diff line number Diff line
@@ -5,12 +5,13 @@ Just build AOSP - Fluoride is there by default.

## Building and running on Linux

Instructions for Ubuntu, tested on 15.10 with GCC 5.2.1.
Instructions for Ubuntu, tested on 14.04 with Clang 3.5.0 and 16.10 with Clang
 3.8.0

### Install required libraries

```sh
sudo apt-get install libevent-dev
sudo apt-get install libevent-dev libc++-dev libc++abi-dev
```

### Install build tools
@@ -23,16 +24,19 @@ sudo apt-get install ninja-build

or download binary from https://github.com/ninja-build/ninja/releases

  - Install [gn](https://chromium.googlesource.com/chromium/src/tools/gn/) -  meta-build system that generates NinjaBuild files.
  - Install [gn](https://chromium.googlesource.com/chromium/src/tools/gn/) -
 meta-build system that generates NinjaBuild files.

Get sha1 of current version from [here](
https://chromium.googlesource.com/chromium/buildtools/+/master/linux64/gn.sha1) and then download corresponding executable:
https://chromium.googlesource.com/chromium/buildtools/+/master/linux64/gn.sha1)
 and then download corresponding executable:

```sh
wget -O gn http://storage.googleapis.com/chromium-gn/<gn.sha1>
```

i.e. if sha1 is "3491f6687bd9f19946035700eb84ce3eed18c5fa" (value from 24 Feb 2016) do
i.e. if sha1 is "3491f6687bd9f19946035700eb84ce3eed18c5fa" (value from 24 Feb
 2016) do

```sh
wget -O gn http://storage.googleapis.com/chromium-gn/3491f6687bd9f19946035700eb84ce3eed18c5fa
@@ -76,6 +80,20 @@ curl https://chromium.googlesource.com/chromium/src/base/+/master/third_party/va
curl https://chromium.googlesource.com/chromium/src/base/+/master/third_party/valgrind/memcheck.h?format=TEXT | base64 -d > memcheck.h
```

NOTE: If packages/modules/Bluetooth/system is checked out under AOSP, then create symbolic links instead
of downloading sources

```
cd packages/modules/Bluetooth/system
mkdir third_party
cd third_party
ln -s ../../../external/libchrome libchrome
ln -s ../../../external/modp_b64 modp_b64
ln -s ../../../external/tinyxml2 tinyxml2
ln -s ../../../hardware/libhardware libhardware
ln -s ../../../external/googletest googletest
```

### Generate your build files

```sh
@@ -90,7 +108,9 @@ cd ~/fluoride/bt
ninja -C out/Default all
```

This will build all targets (the shared library, executables, tests, etc) and put them in out/Default. To build an individual target, replace "all" with the target of your choice, e.g. ```ninja -C out/Default net_test_osi```.
This will build all targets (the shared library, executables, tests, etc) and
 put them in out/Default. To build an individual target, replace "all" with the
 target of your choice, e.g. ```ninja -C out/Default net_test_osi```.

### Run

@@ -98,3 +118,26 @@ This will build all targets (the shared library, executables, tests, etc) and pu
cd ~/fluoride/bt/out/Default
LD_LIBRARY_PATH=./ ./bluetoothtbd -create-ipc-socket=fluoride
```

### Eclipse IDE Support

1. Follows the Chromium project
 [Eclipse Setup Instructions](https://chromium.googlesource.com/chromium/src/+/master/docs/linux_eclipse_dev.md)
 until "Optional: Building inside Eclipse" section (don't do that section, we
 will set it up differently)

2. Generate Eclipse settings:

  ```sh
  cd packages/modules/Bluetooth/system
  gn gen --ide=eclipse out/Default
  ```

3. In Eclipse, do File->Import->C/C++->C/C++ Project Settings, choose the XML
 location under packages/modules/Bluetooth/system/out/Default

4. Right click on the project. Go to Preferences->C/C++ Build->Builder Settings.
 Uncheck "Use default build command", but instead using "ninja -C out/Default"

5. Goto Behaviour tab, change clean command to "-t clean"
+5 −0
Original line number Diff line number Diff line
@@ -15,12 +15,14 @@
#

set_default_toolchain("//build/toolchain/clang")
toolchain_config="//build/toolchain/clang:clang_config"

set_defaults("executable") {
  configs = [
    "//build:linux",
    "//build:gc",
    "//build:default_include_dirs",
    toolchain_config,
  ]
}

@@ -29,6 +31,7 @@ set_defaults("shared_library") {
    "//build:linux",
    "//build:gc",
    "//build:default_include_dirs",
    toolchain_config,
  ]
}

@@ -37,6 +40,7 @@ set_defaults("source_set") {
    "//build:linux",
    "//build:gc",
    "//build:default_include_dirs",
    toolchain_config,
  ]
}

@@ -45,5 +49,6 @@ set_defaults("static_library") {
    "//build:linux",
    "//build:gc",
    "//build:default_include_dirs",
    toolchain_config,
  ]
}
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,18 @@
clang = "clang"
clangxx = "clang++"

config("clang_config") {
  include_dirs = [
    "/usr/include/libcxxabi",
  ]
  cflags_cc = [
    "-stdlib=libc++",
  ]
  ldflags = [
    "-stdlib=libc++",
  ]
}

toolchain("clang") {
  tool("cc") {
    depfile = "{{output}}.d"
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@

#pragma once

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ source_set("service") {
    "hal/fake_bluetooth_gatt_interface.cc",
    "hal/fake_bluetooth_interface.cc",
    "ipc/ipc_handler.cc",
    "ipc/ipc_handler_linux.cc",
    "ipc/ipc_manager.cc",
    "ipc/linux_ipc_host.cc",
    "logging_helpers.cc",
Loading