summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
author Abhishek Pandit-Subedi <abhishekpandit@google.com> 2022-10-17 13:41:09 -0700
committer Abhishek Pandit-Subedi <abhishekpandit@google.com> 2022-10-17 13:44:28 -0700
commit30e5730dad0147e0870a05f2efd60c8ff2b390a2 (patch)
treecf16480d6942cf027861ccecd0a1d019a105e21f /build.py
parent86ee3105f7f66c7b43cf3834d268bc50206aed6a (diff)
floss: Default build.py to release builds for Rust
Switch build.py to use release builds by default for Rust. This saves us ~5gb in generated files in the build output folder. Bug: 254085165 Tag: #floss Test: ./build.py && ./build.py --target test Change-Id: I5abc239afe97dfb7e0e80d8df75325451b1aaa49
Diffstat (limited to 'build.py')
-rwxr-xr-xbuild.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/build.py b/build.py
index 049189aba4..99912a8034 100755
--- a/build.py
+++ b/build.py
@@ -419,7 +419,11 @@ class HostBuild():
def _rust_build(self):
""" Run `cargo build` from platform2/bt directory.
"""
- self.run_command('rust', ['cargo', 'build'], cwd=os.path.join(self.platform_dir, 'bt'), env=self.env)
+ cmd = ['cargo', 'build']
+ if not self.args.rust_debug:
+ cmd.append('--release')
+
+ self.run_command('rust', cmd, cwd=os.path.join(self.platform_dir, 'bt'), env=self.env)
def _target_prepare(self):
""" Target to prepare the output directory for building.
@@ -451,8 +455,11 @@ class HostBuild():
def _target_rootcanal(self):
""" Build rust artifacts for RootCanal in an already prepared environment.
"""
- self.run_command(
- 'rust', ['cargo', 'build'], cwd=os.path.join(self.platform_dir, 'bt/tools/rootcanal'), env=self.env)
+ cmd = ['cargo', 'build']
+ if not self.args.rust_debug:
+ cmd.append('--release')
+
+ self.run_command('rust', cmd, cwd=os.path.join(self.platform_dir, 'bt/tools/rootcanal'), env=self.env)
def _target_main(self):
""" Build the main GN artifacts in an already prepared environment.
@@ -464,6 +471,9 @@ class HostBuild():
"""
# Rust tests first
rust_test_cmd = ['cargo', 'test']
+ if not self.args.rust_debug:
+ rust_test_cmd.append('--release')
+
if self.args.test_name:
rust_test_cmd = rust_test_cmd + [self.args.test_name, "--", "--test-threads=1", "--nocapture"]
@@ -830,6 +840,7 @@ if __name__ == '__main__':
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')
args = parser.parse_args()
# Make sure we get absolute path + expanded path for bootstrap directory