Pass --no-default-features to cargo build
* When --features is specified, pass --no-default-features to cargo. * When a dependent Rust package is imported to AOSP, if not all "default" features are needed, run cargo2android.py with empty or a list of specific features. Test: cargo2android.py --run # use default features Test: cargo2android.py --run --features='' # no default Test: cargo2android.py --run --features='default,std' Change-Id: I854f1ecb7d7466490ff34e229ec14a07c1273c6d
This commit is contained in:
@@ -876,8 +876,11 @@ class Runner(object):
|
|||||||
cmd_tail = ' --target-dir ' + TARGET_TMP + ' >> cargo.out 2>&1'
|
cmd_tail = ' --target-dir ' + TARGET_TMP + ' >> cargo.out 2>&1'
|
||||||
for c in self.cargo:
|
for c in self.cargo:
|
||||||
features = ''
|
features = ''
|
||||||
if self.args.features and c != 'clean':
|
if c != 'clean':
|
||||||
features = ' --features ' + self.args.features
|
if self.args.features is not None:
|
||||||
|
features = ' --no-default-features'
|
||||||
|
if self.args.features:
|
||||||
|
features += ' --features ' + self.args.features
|
||||||
cmd = 'cargo -vv ' if self.args.vv else 'cargo -v '
|
cmd = 'cargo -vv ' if self.args.vv else 'cargo -v '
|
||||||
cmd += c + features + cmd_tail
|
cmd += c + features + cmd_tail
|
||||||
if self.args.rustflags and c != 'clean':
|
if self.args.rustflags and c != 'clean':
|
||||||
@@ -1076,7 +1079,9 @@ def parse_args():
|
|||||||
default=False,
|
default=False,
|
||||||
help='run cargo also for a default device target')
|
help='run cargo also for a default device target')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--features', type=str, help='passing features to cargo build')
|
'--features', type=str,
|
||||||
|
help=('pass features to cargo build, ' +
|
||||||
|
'empty string means no default features'))
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--onefile',
|
'--onefile',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
|||||||
Reference in New Issue
Block a user