summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2022-03-11 19:27:17 +0000
committerScott Lobdell <slobdell@google.com>2022-03-11 19:57:09 +0000
commitc9218ef1b82430a07d94f74c212a30e7ccc52975 (patch)
tree241b7fdeb6bdf1cf3af925ba8996f18faa8973d9 /build.py
parenta26bda4d37221f2f7ef750b413502091e3bcddd4 (diff)
parent480d2270b269a0e47bf475eb439111f3f966e2a9 (diff)
Merge TP1A.220225.003
Change-Id: Id71ac466dbfe3707fe2e544ce22b1da8f474ec2b
Diffstat (limited to 'build.py')
-rwxr-xr-xbuild.py43
1 files changed, 34 insertions, 9 deletions
diff --git a/build.py b/build.py
index 4bc51486b8..2bffdc3182 100755
--- a/build.py
+++ b/build.py
@@ -59,13 +59,14 @@ USE_DEFAULTS = {
}
VALID_TARGETS = [
+ 'all', # All targets except test and clean
+ 'clean', # Clean up output directory
+ 'docs', # Build Rust docs
+ 'main', # Build the main C++ codebase
'prepare', # Prepare the output directory (gn gen + rust setup)
- 'tools', # Build the host tools (i.e. packetgen)
'rust', # Build only the rust components + copy artifacts to output dir
- 'main', # Build the main C++ codebase
'test', # Run the unit tests
- 'clean', # Clean up output directory
- 'all', # All targets except test and clean
+ 'tools', # Build the host tools (i.e. packetgen)
]
# TODO(b/190750167) - Host tests are disabled until we are full bazel build
@@ -98,19 +99,24 @@ REQUIRED_APT_PACKAGES = [
'generate-ninja',
'gnupg',
'gperf',
+ 'libc++abi-dev',
'libc++-dev',
'libdbus-1-dev',
+ 'libdouble-conversion-dev',
'libevent-dev',
'libevent-dev',
'libflatbuffers-dev',
'libflatbuffers1',
'libgl1-mesa-dev',
'libglib2.0-dev',
+ 'libgtest-dev',
+ 'libgmock-dev',
'liblz4-tool',
'libncurses5',
'libnss3-dev',
'libprotobuf-dev',
'libre2-9',
+ 'libre2-dev',
'libssl-dev',
'libtinyxml2-dev',
'libx11-dev',
@@ -327,7 +333,7 @@ class HostBuild():
'libbase_ver': self._get_basever(),
'enable_exceptions': os.environ.get('CXXEXCEPTIONS', 0) == '1',
'external_cflags': [],
- 'external_cxxflags': [],
+ 'external_cxxflags': ["-DNDEBUG"],
'enable_werror': False,
}
@@ -413,6 +419,10 @@ class HostBuild():
shutil.copy(
os.path.join(self._gn_default_output(), 'bluetooth_packetgen'), os.path.join(self.env['CARGO_HOME'], 'bin'))
+ def _target_docs(self):
+ """Build the Rust docs."""
+ self.run_command('docs', ['cargo', 'doc'], cwd=os.path.join(self.platform_dir, 'bt'), env=self.env)
+
def _target_rust(self):
""" Build rust artifacts in an already prepared environment.
"""
@@ -427,7 +437,11 @@ class HostBuild():
""" Runs the host tests.
"""
# Rust tests first
- self.run_command('test', ['cargo', 'test'], cwd=os.path.join(self.platform_dir, 'bt'), env=self.env)
+ rust_test_cmd = ['cargo', 'test']
+ if self.args.test_name:
+ rust_test_cmd = rust_test_cmd + [self.args.test_name]
+
+ self.run_command('test', rust_test_cmd, cwd=os.path.join(self.platform_dir, 'bt'), env=self.env)
# Host tests second based on host test list
for t in HOST_TESTS:
@@ -502,7 +516,7 @@ class HostBuild():
pass
def _target_all(self):
- """ Build all common targets (skipping test and clean).
+ """ Build all common targets (skipping doc, test, and clean).
"""
self._target_prepare()
self._target_tools()
@@ -514,12 +528,19 @@ class HostBuild():
"""
print('Building target ', self.target)
+ # Validate that the target is valid
+ if self.target not in VALID_TARGETS:
+ print('Target {} is not valid. Must be in {}', self.target, VALID_TARGETS)
+ return
+
if self.target == 'prepare':
self._target_prepare()
elif self.target == 'tools':
self._target_tools()
elif self.target == 'rust':
self._target_rust()
+ elif self.target == 'docs':
+ self._target_docs()
elif self.target == 'main':
self._target_main()
elif self.target == 'test':
@@ -594,7 +615,10 @@ class Bootstrap():
# Create symlinks
for pairs in symlinks:
(src, dst) = pairs
- os.unlink(dst)
+ try:
+ os.unlink(dst)
+ except Exception as e:
+ print(e)
os.symlink(src, dst)
# Write to setup complete file so we don't repeat this step
@@ -759,7 +783,8 @@ if __name__ == '__main__':
parser.add_argument(
'--no-strip', help='Skip stripping binaries during install.', default=False, action='store_true')
parser.add_argument('--use', help='Set a specific use flag.')
- parser.add_argument('--notest', help="Don't compile test code.", default=False, action='store_true')
+ parser.add_argument('--notest', help='Don\'t compile test code.', default=False, action='store_true')
+ parser.add_argument('--test-name', help='Run test with this string in the name.', default=None)
parser.add_argument('--target', help='Run specific build target')
parser.add_argument('--sysroot', help='Set a specific sysroot path', default='/')
parser.add_argument('--libdir', help='Libdir - default = usr/lib', default='usr/lib')