OSDN Git Service

Snap for 7989966 from 20eb7061133f3dae931c3c66bb40f3fb70b1ce86 to sc-v2-release
[android-x86/system-bt.git] / README.md
1 # Fluoride Bluetooth stack
2
3 ## Building and running on AOSP
4 Just build AOSP - Fluoride is there by default.
5
6 ## Building and running on Linux
7
8 Instructions for a Debian based distribution:
9 * Debian Bullseye or newer
10 * Ubuntu 20.10 or newer
11 * Clang-11 or Clang-12
12 * Flex 2.6.x
13 * Bison 3.x.x (tested with 3.0.x, 3.2.x and 3.7.x)
14
15 You'll want to download some pre-requisite packages as well. If you're currently
16 configured for AOSP development, you should have all required packages.
17 Otherwise, you can use the following apt-get list:
18
19 ```sh
20 sudo apt-get install repo git-core gnupg flex bison gperf build-essential \
21   zip curl zlib1g-dev gcc-multilib g++-multilib \
22   x11proto-core-dev libx11-dev lib32z-dev libncurses5 \
23   libgl1-mesa-dev libxml2-utils xsltproc unzip liblz4-tool libssl-dev \
24   libc++-dev libevent-dev \
25   flatbuffers-compiler libflatbuffers1 \
26   openssl openssl-dev
27 ```
28
29 You will also need a recent-ish version of Rust and Cargo. Please follow the
30 instructions on [Rustup](https://rustup.rs/) to install a recent version.
31
32 ### Download source
33
34 ```sh
35 mkdir ~/fluoride
36 cd ~/fluoride
37 git clone https://android.googlesource.com/platform/system/bt
38 ```
39
40 Install dependencies (require sudo access). This adds some Ubuntu dependencies
41 and also installs GN (which is the build tool we're using).
42
43 ```sh
44 cd ~/fluoride/bt
45 build/install_deps.sh
46 ```
47
48 The following third-party dependencies are necessary but currently unavailable
49 via a package manager. You may have to build these from source and install them
50 to your local environment.
51
52 * libchrome
53 * modp_b64
54
55 We provide a script to produce debian packages for those components, please
56 follow the instructions in build/dpkg/README.txt.
57
58 The googletest packages provided by Debian/Ubuntu (libgmock-dev and
59 libgtest-dev) do not provide pkg-config files, so you can build your own
60 googletest using the steps below:
61
62 ```
63 $ git clone https://github.com/google/googletest.git -b release-1.10.0
64 $ cd googletest        # Main directory of the cloned repository.
65 $ mkdir build          # Create a directory to hold the build output.
66 $ cd build
67 $ cmake ..             # Generate native build scripts for GoogleTest.
68 $ sudo make install -DCMAKE_INSTALL_PREFIX=/usr
69 ```
70
71 ### Stage your build environment
72
73 For host build, we depend on a few other repositories:
74 * [Platform2](https://chromium.googlesource.com/chromiumos/platform2/)
75 * [Rust crates](https://chromium.googlesource.com/chromiumos/third_party/rust_crates/)
76 * [Proto logging](https://android.googlesource.com/platform/frameworks/proto_logging/)
77
78 Clone these all somewhere and create your staging environment.
79 ```sh
80 export STAGING_DIR=path/to/your/staging/dir
81 mkdir ${STAGING_DIR}
82 mkdir -p ${STAGING_DIR}/external
83 ln -s $(readlink -f ${PLATFORM2_DIR}/common-mk) ${STAGING_DIR}/common-mk
84 ln -s $(readlink -f ${PLATFORM2_DIR}/.gn) ${STAGING_DIR}/.gn
85 ln -s $(readlink -f ${RUST_CRATE_DIR}) ${STAGING_DIR}/external/rust
86 ln -s $(readlink -f ${PROTO_LOG_DIR}) ${STAGING_DIR}/external/proto_logging
87 ```
88
89 ### Build
90
91 We provide a build script to automate building assuming you've staged your build
92 environment already as above.
93
94
95 ```sh
96 ./build.py --output ${OUTPUT_DIR} --platform-dir ${STAGING_DIR} --clang
97 ```
98
99 This will build all targets to the output directory you've given. You can also
100 build each stage separately (if you want to iterate on something specific):
101
102 * prepare - Generate the GN rules
103 * tools - Generate host tools
104 * rust - Build the rust portion of the build
105 * main - Build all the C/C++ code
106 * test - Build all targets and run the tests
107 * clean - Clean the output directory
108
109 You can choose to run only a specific stage by passing an arg via `--target`.
110
111 Currently, Rust builds are a separate stage that uses Cargo to build. See
112 [gd/rust/README.md](gd/rust/README.md) for more information.
113
114 ### Run
115
116 By default on Linux, we statically link libbluetooth so you can just run the
117 binary directly:
118
119 ```sh
120 cd ~/fluoride/bt/out/Default
121 ./bluetoothtbd -create-ipc-socket=fluoride
122 ```