fs_config: generate oem AID header file

Generate an OEM AID_<name> header file seperate from fs_config
header file and provide details on how to export this interface
into native code.

Test: That ls, ps, chown and services function for built in
services as before.
Change-Id: Ie8ce6585e0721b52633ee50d62dcfe796e178f65
Signed-off-by: William Roberts <william.c.roberts@intel.com>
This commit is contained in:
William Roberts
2016-04-12 08:51:13 -07:00
committed by Dan Albert
parent d7104bca65
commit cfc51f5347
3 changed files with 116 additions and 4 deletions

View File

@@ -804,7 +804,9 @@ class FSConfigGen(BaseGenerator):
*/
""")
_INCLUDE = '#include <private/android_filesystem_config.h>'
_INCLUDES = [
'<private/android_filesystem_config.h>', '"generated_oem_aid.h"'
]
_DEFINE_NO_DIRS = '#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS'
_DEFINE_NO_FILES = '#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_FILES'
@@ -888,6 +890,15 @@ class FSConfigGen(BaseGenerator):
print FSConfigGen._FILE_COMMENT % fname
print ' ' + expanded
@staticmethod
def _gen_inc():
"""
Generate the include header lines and print to stdout.
Internal use only.
"""
for include in FSConfigGen._INCLUDES:
print '#include %s' % include
@staticmethod
def _generate(files, dirs, aids):
"""Generates an OEM android_filesystem_config.h header file to stdout.
@@ -899,7 +910,9 @@ class FSConfigGen(BaseGenerator):
aids ([AIDS]): A list of AID objects for Android Id entries.
"""
print FSConfigGen._GENERATED
print FSConfigGen._INCLUDE
print
FSConfigGen._gen_inc()
print
are_dirs = len(dirs) > 0
@@ -997,6 +1010,71 @@ class AIDArrayGen(BaseGenerator):
print
@generator('oemaid')
class OEMAidGen(BaseGenerator):
"""Generates the OEM AID_<name> value header file."""
_GENERATED = ('/*\n'
' * THIS IS AN AUTOGENERATED FILE! DO NOT MODIFY!\n'
' */')
_GENERIC_DEFINE = "#define %s\t%s"
_FILE_COMMENT = '// Defined in file: \"%s\"'
# Intentional trailing newline for readability.
_FILE_IFNDEF_DEFINE = ('#ifndef GENERATED_OEM_AIDS_H_\n'
'#define GENERATED_OEM_AIDS_H_\n')
_FILE_ENDIF = '#endif'
def __init__(self):
self._old_file = None
def add_opts(self, opt_group):
opt_group.add_argument(
'fsconfig', nargs='+', help='The list of fsconfig files to parse.')
opt_group.add_argument(
'--aid-header',
required=True,
help='An android_filesystem_config.h file'
'to parse AIDs and OEM Ranges from')
def __call__(self, args):
hdr_parser = AIDHeaderParser(args['aid_header'])
parser = FSConfigFileParser(args['fsconfig'], hdr_parser.oem_ranges)
print OEMAidGen._GENERATED
print OEMAidGen._FILE_IFNDEF_DEFINE
for aid in parser.aids:
self._print_aid(aid)
print
print OEMAidGen._FILE_ENDIF
def _print_aid(self, aid):
"""Prints a valid #define AID identifier to stdout.
Args:
aid to print
"""
# print the source file location of the AID
found_file = aid.found
if found_file != self._old_file:
print OEMAidGen._FILE_COMMENT % found_file
self._old_file = found_file
print OEMAidGen._GENERIC_DEFINE % (aid.identifier, aid.value)
def main():
"""Main entry point for execution."""