Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30e5730d authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

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
parent 86ee3105
Loading
Loading
Loading
Loading
+14 −3
Original line number Original line Diff line number Diff line
@@ -419,7 +419,11 @@ class HostBuild():
    def _rust_build(self):
    def _rust_build(self):
        """ Run `cargo build` from platform2/bt directory.
        """ 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):
    def _target_prepare(self):
        """ Target to prepare the output directory for building.
        """ Target to prepare the output directory for building.
@@ -451,8 +455,11 @@ class HostBuild():
    def _target_rootcanal(self):
    def _target_rootcanal(self):
        """ Build rust artifacts for RootCanal in an already prepared environment.
        """ Build rust artifacts for RootCanal in an already prepared environment.
        """
        """
        self.run_command(
        cmd = ['cargo', 'build']
            'rust', ['cargo', 'build'], cwd=os.path.join(self.platform_dir, 'bt/tools/rootcanal'), env=self.env)
        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):
    def _target_main(self):
        """ Build the main GN artifacts in an already prepared environment.
        """ Build the main GN artifacts in an already prepared environment.
@@ -464,6 +471,9 @@ class HostBuild():
        """
        """
        # Rust tests first
        # Rust tests first
        rust_test_cmd = ['cargo', 'test']
        rust_test_cmd = ['cargo', 'test']
        if not self.args.rust_debug:
            rust_test_cmd.append('--release')

        if self.args.test_name:
        if self.args.test_name:
            rust_test_cmd = rust_test_cmd + [self.args.test_name, "--", "--test-threads=1", "--nocapture"]
            rust_test_cmd = rust_test_cmd + [self.args.test_name, "--", "--test-threads=1", "--nocapture"]


@@ -830,6 +840,7 @@ if __name__ == '__main__':
    parser.add_argument(
    parser.add_argument(
        '--no-vendored-rust', help='Do not use vendored rust crates', default=False, action='store_true')
        '--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('--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()
    args = parser.parse_args()


    # Make sure we get absolute path + expanded path for bootstrap directory
    # Make sure we get absolute path + expanded path for bootstrap directory