diff --git a/Living_SDK/build/scripts/gen_auto_code.py b/Living_SDK/build/scripts/gen_auto_code.py index 0abce6a6..8236981a 100755 --- a/Living_SDK/build/scripts/gen_auto_code.py +++ b/Living_SDK/build/scripts/gen_auto_code.py @@ -44,8 +44,8 @@ def process_component_test(source_directory): for root, dirs, files in chain.from_iterable(os.walk(path.strip()) for path in \ re.findall(location, config_mk_str)[0].split(":= ")[1:]): for source in [source for source in files if source.endswith(".c")]: - with open(os.path.join(root, source), "r") as head: - codes = head.read() + with open(os.path.join(root, source), "rb") as head: + codes = head.read().decode("utf-8", errors="ignore") # find AOS_TESTCASE macro function for code in re.findall("AOS_TESTCASE\s*\((.+\)\s*;)", codes): code_list.append(code[:len(code)-2]) @@ -94,8 +94,8 @@ def process_component_init(init_dir): for root, dirs, files in chain.from_iterable(os.walk(path.strip()) for path in \ re.findall("AOS_SDK_INCLUDES\s+\+\=\s+(.+\n)", config_mk_str)[0].split("-I")[1:]): for include in [include for include in files if include.endswith(".h")]: - with open(os.path.join(root, include), "r") as head: - code = head.read() + with open(os.path.join(root, include), "rb") as head: + code = head.read().decode("utf-8", errors="ignore") # find AOS_COMPONENT_INIT macro function for init in re.findall("AOS_COMPONENT_INIT\s*\((.+\)\s*;)", code): init_code = init.replace(',', '(', 1) @@ -125,4 +125,3 @@ if __name__ == "__main__": main() -