From c1335a27da035c7187df9bbfd54fb7c47ff75dfd Mon Sep 17 00:00:00 2001 From: Sonny Sasaka Date: Thu, 25 Mar 2021 07:10:47 -0700 Subject: Fix rust build in build.py This copies the rust build result to the gn output directory to be accessible when linking from C++. Also adds an option to use crates.io for rust crates. Bug: 176846220 Tag: #floss Test: atest --host bluetooth_test_gd Change-Id: I9f7732878a2aced6f80f363c25aff3243d34f0d5 --- build.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'build.py') diff --git a/build.py b/build.py index 27332cf934..131cbb299e 100755 --- a/build.py +++ b/build.py @@ -318,9 +318,11 @@ class HostBuild(): replace-with = "systembt" local-registry = "/nonexistent" """ - contents = template.format(self.platform_dir) - with open(os.path.join(self.env['CARGO_HOME'], 'config'), 'w') as f: - f.write(contents) + + if self.args.vendored_rust: + contents = template.format(self.platform_dir) + with open(os.path.join(self.env['CARGO_HOME'], 'config'), 'w') as f: + f.write(contents) def _rust_build(self): """ Run `cargo build` from platform2/bt directory. @@ -349,6 +351,10 @@ class HostBuild(): """ Build rust artifacts in an already prepared environment. """ self._rust_build() + rust_dir = os.path.join(self._gn_default_output(), 'rust') + if os.path.exists(rust_dir): + shutil.rmtree(rust_dir) + shutil.copytree(os.path.join(self.output_dir, 'debug'), rust_dir) def _target_main(self): """ Build the main GN artifacts in an already prepared environment. @@ -407,6 +413,7 @@ if __name__ == '__main__': parser.add_argument('--libdir', help='Libdir - default = usr/lib64', default='usr/lib64') parser.add_argument('--use-board', help='Use a built x86 board for dependencies. Provide path.') parser.add_argument('--jobs', help='Number of jobs to run', default=0, type=int) + parser.add_argument('--vendored-rust', help='Use vendored rust crates', default=False, action="store_true") parser.add_argument('--verbose', help='Verbose logs for build.') args = parser.parse_args() -- cgit v1.2.3-59-g8ed1b