cargo2android: Support exported C headers
staticlib and cdylib crate types generally want to export header files for use by C code. Allow the location of these headers to be provided to c2a for inclusion in blueprint. Bug: 178565008 Test: Generate rustc-demangle-capi Change-Id: I0aa9acfb081ea39a7e13315bfc8029d06b8f55d3
This commit is contained in:
@@ -127,8 +127,12 @@ WARNING_FILE_PAT = re.compile('^ *--> ([^:]*):[0-9]+')
|
|||||||
# Rust package name with suffix -d1.d2.d3.
|
# Rust package name with suffix -d1.d2.d3.
|
||||||
VERSION_SUFFIX_PAT = re.compile(r'^(.*)-[0-9]+\.[0-9]+\.[0-9]+$')
|
VERSION_SUFFIX_PAT = re.compile(r'^(.*)-[0-9]+\.[0-9]+\.[0-9]+$')
|
||||||
|
|
||||||
# Rust crate_type values that correspond to a library
|
# Crate types corresponding to a C ABI library
|
||||||
LIBRARY_CRATE_TYPES = ['lib', 'rlib', 'dylib', 'staticlib', 'cdylib']
|
C_LIBRARY_CRATE_TYPES = ['staticlib', 'cdylib']
|
||||||
|
# Crate types corresponding to a Rust ABI library
|
||||||
|
RUST_LIBRARY_CRATE_TYPES = ['lib', 'rlib', 'dylib']
|
||||||
|
# Crate types corresponding to a library
|
||||||
|
LIBRARY_CRATE_TYPES = C_LIBRARY_CRATE_TYPES + RUST_LIBRARY_CRATE_TYPES
|
||||||
|
|
||||||
def altered_name(name):
|
def altered_name(name):
|
||||||
return RENAME_MAP[name] if (name in RENAME_MAP) else name
|
return RENAME_MAP[name] if (name in RENAME_MAP) else name
|
||||||
@@ -698,6 +702,11 @@ class Crate(object):
|
|||||||
self.dump_edition_flags_libs()
|
self.dump_edition_flags_libs()
|
||||||
if self.runner.args.host_first_multilib and self.host_supported and crate_type != 'test':
|
if self.runner.args.host_first_multilib and self.host_supported and crate_type != 'test':
|
||||||
self.write(' compile_multilib: "first",')
|
self.write(' compile_multilib: "first",')
|
||||||
|
if self.runner.args.exported_c_header_dir and crate_type in C_LIBRARY_CRATE_TYPES:
|
||||||
|
self.write(' include_dirs: [')
|
||||||
|
for header_dir in self.runner.args.exported_c_header_dir:
|
||||||
|
self.write(' "%s",' % header_dir)
|
||||||
|
self.write(' ],')
|
||||||
if self.runner.args.apex_available and crate_type in LIBRARY_CRATE_TYPES:
|
if self.runner.args.apex_available and crate_type in LIBRARY_CRATE_TYPES:
|
||||||
self.write(' apex_available: [')
|
self.write(' apex_available: [')
|
||||||
for apex in self.runner.args.apex_available:
|
for apex in self.runner.args.apex_available:
|
||||||
@@ -1646,6 +1655,11 @@ def get_parser():
|
|||||||
default=False,
|
default=False,
|
||||||
help=('run cargo build with existing Cargo.lock ' +
|
help=('run cargo build with existing Cargo.lock ' +
|
||||||
'(used when some latest dependent crates failed)'))
|
'(used when some latest dependent crates failed)'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--exported_c_header_dir',
|
||||||
|
nargs='*',
|
||||||
|
help='Directories with headers to export for C usage'
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--min-sdk-version',
|
'--min-sdk-version',
|
||||||
type=str,
|
type=str,
|
||||||
|
|||||||
Reference in New Issue
Block a user