| import operator |
| import sys |
| import os |
| import platform |
| |
| from .src.initconfig import logical_data_item_table |
| from .src.initconfig import const_value |
| from .src.initconfig import global_value |
| from .src.initconfig import LtableEntry |
| from .src.initconfig import printf |
| from .src import tableconstructor |
| from .src import sys_cache_generator |
| from .src import gen_cache_info |
| from .src import gen_cat_file |
| from .src import gen_lid_information |
| from .src import gen_statistic |
| from .src import mcf_ota_helper |
| from .src import custpackhelper |
| from .src import secupackhelper |
| from .src import buildtimecheck |
| from .src import tableconstructor_win |
| |
| from .src import gen_assign_entry |
| |
| |
| def main(path): |
| """ |
| args: |
| path: gen file output path, path + "nvram_auto_gen" + filename |
| """ |
| # set path |
| global_value.logging_path = path |
| global_value.path = path |
| global_value.autogen_path = os.path.join(global_value.path, "nvram_auto_gen") |
| global_value.log_path = os.path.join(global_value.path, "bin", "log") |
| |
| # check path exist |
| if not os.access(global_value.autogen_path, os.F_OK): |
| printf("error: folder no exist: %s" % global_value.autogen_path) |
| sys.exit(2) |
| if not os.access(global_value.log_path, os.F_OK): |
| printf("error: folder no exist: %s" % global_value.log_path) |
| sys.exit(2) |
| |
| global_value.logger_config() |
| global_value.logger.info("========main========") |
| # set platform |
| global_value.platform = platform.system() |
| if global_value.platform != "Windows" and global_value.platform != "Linux": |
| printf("platform error: platform is not windows or linux!") |
| printf("platform.system() = %s" % platform.system()) |
| global_value.logger.error("platform error: platform is not windows or linux!") |
| global_value.logger.error("platform.system() = %s", platform.system()) |
| sys.exit(1) |
| |
| global_value.logger.info("path = %s, logging_path = %s, platform = %s", global_value.path, global_value.logging_path |
| , global_value.platform) |
| |
| global_value.pars_macro_info() |
| |
| if global_value.platform == "Windows": # windows |
| tableconstructor_win.parse_segment_info_win() |
| elif global_value.platform == "Linux": # linux |
| tableconstructor.pars_segment_info() |
| else: |
| pass |
| |
| tableconstructor.parse_lid_table() |
| tableconstructor.parse_lid_item_data() |
| tableconstructor.statistic_lid_item_data() |
| |
| # tmp write ltable for NVDB test |
| # tableconstructor.write_logical_table() |
| |
| # sort ,key is lid |
| sort_key = operator.attrgetter('lid') |
| logical_data_item_table.sort(key=sort_key) |
| |
| # # assign entry |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_assign_entry") |
| gen_assign_entry.nvram_gen_assign_entry() |
| |
| # gen nvram_cache_info.c and nvram_cache_info.h |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_cache_info") |
| gen_cache_info.nvram_gen_cache_info() |
| |
| # gen custom_nvram_lid_cat.xml |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_cat_xml") |
| gen_cat_file.nvram_gen_cat_xml() |
| |
| # gen ~nvram_lid_information.log and ~nvram_lid_size.log |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_info_size_log") |
| gen_lid_information.nvram_gen_info_size_log() |
| |
| # gen nvram_lid_statistics_bak.h |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_statistic") |
| gen_statistic.nvram_gen_statistic() |
| |
| # gen custom_nvram_restore.c and nvram_restore_dom_new.h |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_restore_function") |
| sys_cache_generator.nvram_gen_restore_function() # win || linux |
| |
| # gen nvram_custpack_table.c and nvram_custpack_table_lid.c |
| if (global_value.macro & const_value.__MMI_FMI__) and (not global_value.macro & const_value.__L1_STANDALONE__): |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_custpack_table") |
| custpackhelper.nvram_gen_custpack_table() |
| |
| # gen custom_nvram_secro.c and custom_nvram_secro_tbl.c |
| if True: # global_value.macro & const_value.__VENDOR_RELEASE__: |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_secro") |
| secupackhelper.nvram_gen_secro() # win || linux |
| |
| # gen nvram_ltable_List.h |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_ltable_list") |
| mcf_ota_helper.nvram_gen_ltable_list() |
| |
| # gen nvram_lid_list_for_mcf.h |
| global_value.logger.info("====================") |
| global_value.logger.info("nvram_gen_mcf_ota_lid_list") |
| mcf_ota_helper.nvram_gen_mcf_ota_lid_list() |
| |
| global_value.logger.info("====================") |
| global_value.logger.info("build time check: begin") |
| # build time check:lid enum overlapping |
| global_value.logger.info("build time check: lid enum overlapping") |
| buildtimecheck.check_lid_enum_overlapping() |
| buildtimecheck.check_lid_fileprefix_overlapping() |
| # build time check:write protect attr white list |
| global_value.logger.info("build time check: write protect attr white list ") |
| buildtimecheck.check_write_protect() |
| # build time check:cate attr confilicts |
| global_value.logger.info("build time check: cate attr confilicts") |
| buildtimecheck.nvram_gen_check_cate_attr_conflicts() |
| # build time check:hash key check |
| if (global_value.macro & const_value.__NVRAM_LID_HASH_CHECK__) and (global_value.macro & const_value.__MTK_INTERNAL__): |
| global_value.logger.info("build time check: hash key check") |
| buildtimecheck.check_lid_hash_key() |
| # build time check:special lid parameter |
| global_value.logger.info("build time check: special lid parameter") |
| buildtimecheck.check_special_lid_parameter() |
| global_value.logger.info("build time check: end") |
| |
| # gen custom_nvram_database.h |
| global_value.logger.info("build time check: gen custom_nvram_database") |
| tmp_path = os.path.join(path, "nvram_auto_gen", "custom_nvram_database.h") |
| print("custom_nvram database path: {}".format(tmp_path) ) |
| f = open(tmp_path, "w") |
| f.close() |
| global_value.logger.info("build time check: end") |
| |
| if __name__ == '__main__': |
| main() |