diff options
Diffstat (limited to 'build.py')
-rwxr-xr-x | build.py | 67 |
1 files changed, 43 insertions, 24 deletions
@@ -67,12 +67,13 @@ VALID_TARGETS = [ 'all', # All targets except test and clean 'clean', # Clean up output directory 'docs', # Build Rust docs + 'hosttools', # Build the host tools (i.e. packetgen) 'main', # Build the main C++ codebase 'prepare', # Prepare the output directory (gn gen + rust setup) 'rootcanal', # Build Rust targets for RootCanal 'rust', # Build only the rust components + copy artifacts to output dir 'test', # Run the unit tests - 'tools', # Build the host tools (i.e. packetgen) + 'utils', # Build Floss utils ] # TODO(b/190750167) - Host tests are disabled until we are full bazel build @@ -440,14 +441,14 @@ class HostBuild(): self._gn_configure() self._rust_configure() - def _target_tools(self): + def _target_hosttools(self): """ Build the tools target in an already prepared environment. """ self._gn_build('tools') # Also copy bluetooth_packetgen to CARGO_HOME so it's available - shutil.copy( - os.path.join(self._gn_default_output(), 'bluetooth_packetgen'), os.path.join(self.env['CARGO_HOME'], 'bin')) + 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.""" @@ -488,10 +489,20 @@ class HostBuild(): # Host tests second based on host test list for t in HOST_TESTS: - self.run_command( - 'test', [os.path.join(self.output_dir, 'out/Default', t)], - cwd=os.path.join(self.output_dir), - env=self.env) + self.run_command('test', [os.path.join(self.output_dir, 'out/Default', t)], + cwd=os.path.join(self.output_dir), + env=self.env) + + def _target_utils(self): + """ Builds the utility applications. + """ + rust_targets = ['hcidoc'] + + # Build targets + for target in rust_targets: + self.run_command('utils', ['cargo', 'build', '-p', target], + cwd=os.path.join(self.platform_dir, 'bt'), + env=self.env) def _target_install(self): """ Installs files required to run Floss to install directory. @@ -568,7 +579,7 @@ class HostBuild(): """ Build all common targets (skipping doc, test, and clean). """ self._target_prepare() - self._target_tools() + self._target_hosttools() self._target_main() self._target_rust() @@ -584,8 +595,8 @@ class HostBuild(): if self.target == 'prepare': self._target_prepare() - elif self.target == 'tools': - self._target_tools() + elif self.target == 'hosttools': + self._target_hosttools() elif self.target == 'rootcanal': self._target_rootcanal() elif self.target == 'rust': @@ -600,6 +611,8 @@ class HostBuild(): self._target_clean() elif self.target == 'install': self._target_install() + elif self.target == 'utils': + self._target_utils() elif self.target == 'all': self._target_all() @@ -846,18 +859,22 @@ class Bootstrap(): if __name__ == '__main__': parser = argparse.ArgumentParser(description='Simple build for host.') - parser.add_argument( - '--bootstrap-dir', help='Directory to run bootstrap on (or was previously run on).', default="~/.floss") - parser.add_argument( - '--run-bootstrap', - help='Run bootstrap code to verify build env is ok to build.', - default=False, - action='store_true') - parser.add_argument( - '--print-env', help='Print environment variables used for build.', default=False, action='store_true') + parser.add_argument('--bootstrap-dir', + help='Directory to run bootstrap on (or was previously run on).', + default="~/.floss") + parser.add_argument('--run-bootstrap', + help='Run bootstrap code to verify build env is ok to build.', + default=False, + action='store_true') + parser.add_argument('--print-env', + help='Print environment variables used for build.', + default=False, + action='store_true') parser.add_argument('--no-clang', help='Don\'t use clang compiler.', default=False, action='store_true') - parser.add_argument( - '--no-strip', help='Skip stripping binaries during install.', default=False, action='store_true') + 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('--test-name', help='Run test with this string in the name.', default=None) @@ -865,8 +882,10 @@ if __name__ == '__main__': parser.add_argument('--sysroot', help='Set a specific sysroot path', default='/') parser.add_argument('--libdir', help='Libdir - default = usr/lib', default='usr/lib') parser.add_argument('--jobs', help='Number of jobs to run', default=0, type=int) - parser.add_argument( - '--no-vendored-rust', help='Do not use vendored rust crates', default=False, action='store_true') + parser.add_argument('--no-vendored-rust', + help='Do not use vendored rust crates', + default=False, + action='store_true') parser.add_argument('--verbose', help='Verbose logs for build.') parser.add_argument('--rust-debug', help='Build Rust code as debug.', default=False, action='store_true') parser.add_argument( |