forked from openkylin/platform_build
fs_config: android_id header generator am: d7104bca65
am: 04fdcc9edf
Change-Id: If18da87d7010c49f26743f602dffd56745278cde
This commit is contained in:
commit
343bee6044
|
@ -16,6 +16,9 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
# Keep the tool in one file to make it easy to run.
|
||||||
|
# pylint: disable=too-many-lines
|
||||||
|
|
||||||
|
|
||||||
# Lowercase generator used to be inline with @staticmethod.
|
# Lowercase generator used to be inline with @staticmethod.
|
||||||
class generator(object): # pylint: disable=invalid-name
|
class generator(object): # pylint: disable=invalid-name
|
||||||
|
@ -360,7 +363,7 @@ class AIDHeaderParser(object):
|
||||||
Returns:
|
Returns:
|
||||||
A list of AID() objects.
|
A list of AID() objects.
|
||||||
"""
|
"""
|
||||||
return self._aid_name_to_value.values()
|
return self._aid_name_to_value
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _convert_lst_to_tup(name, lst):
|
def _convert_lst_to_tup(name, lst):
|
||||||
|
@ -942,6 +945,58 @@ class FSConfigGen(BaseGenerator):
|
||||||
print FSConfigGen._CLOSE_FILE_STRUCT
|
print FSConfigGen._CLOSE_FILE_STRUCT
|
||||||
|
|
||||||
|
|
||||||
|
@generator('aidarray')
|
||||||
|
class AIDArrayGen(BaseGenerator):
|
||||||
|
"""Generates the android_id static array."""
|
||||||
|
|
||||||
|
_GENERATED = ('/*\n'
|
||||||
|
' * THIS IS AN AUTOGENERATED FILE! DO NOT MODIFY!\n'
|
||||||
|
' */')
|
||||||
|
|
||||||
|
_INCLUDE = '#include <private/android_filesystem_config.h>'
|
||||||
|
|
||||||
|
_STRUCT_FS_CONFIG = textwrap.dedent("""
|
||||||
|
struct android_id_info {
|
||||||
|
const char *name;
|
||||||
|
unsigned aid;
|
||||||
|
};""")
|
||||||
|
|
||||||
|
_OPEN_ID_ARRAY = 'static const struct android_id_info android_ids[] = {'
|
||||||
|
|
||||||
|
_ID_ENTRY = ' { "%s", %s },'
|
||||||
|
|
||||||
|
_CLOSE_FILE_STRUCT = '};'
|
||||||
|
|
||||||
|
_COUNT = ('#define android_id_count \\\n'
|
||||||
|
' (sizeof(android_ids) / sizeof(android_ids[0]))')
|
||||||
|
|
||||||
|
def add_opts(self, opt_group):
|
||||||
|
|
||||||
|
opt_group.add_argument(
|
||||||
|
'hdrfile', help='The android_filesystem_config.h'
|
||||||
|
'file to parse')
|
||||||
|
|
||||||
|
def __call__(self, args):
|
||||||
|
|
||||||
|
hdr = AIDHeaderParser(args['hdrfile'])
|
||||||
|
|
||||||
|
print AIDArrayGen._GENERATED
|
||||||
|
print
|
||||||
|
print AIDArrayGen._INCLUDE
|
||||||
|
print
|
||||||
|
print AIDArrayGen._STRUCT_FS_CONFIG
|
||||||
|
print
|
||||||
|
print AIDArrayGen._OPEN_ID_ARRAY
|
||||||
|
|
||||||
|
for name, aid in hdr.aids.iteritems():
|
||||||
|
print AIDArrayGen._ID_ENTRY % (name, aid.identifier)
|
||||||
|
|
||||||
|
print AIDArrayGen._CLOSE_FILE_STRUCT
|
||||||
|
print
|
||||||
|
print AIDArrayGen._COUNT
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main entry point for execution."""
|
"""Main entry point for execution."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue