summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
author Sonny Sasaka <sonnysasaka@chromium.org> 2021-03-25 07:10:47 -0700
committer Abhishek Pandit-Subedi <abhishekpandit@google.com> 2021-04-07 04:53:04 +0000
commitc1335a27da035c7187df9bbfd54fb7c47ff75dfd (patch)
tree700a5e11be80caf772997fd63016c3e89cb04169 /build.py
parentaf873ba07c116344d0d51cf7fb1736185ddcd506 (diff)
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
Diffstat (limited to 'build.py')
-rwxr-xr-xbuild.py13
1 files changed, 10 insertions, 3 deletions
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()