Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit96aac81

Browse files
committed
Step 1 of LVGL update complete.
1 parenta44c215 commit96aac81

File tree

2 files changed

+218
-95
lines changed

2 files changed

+218
-95
lines changed

‎gen/fixed_gen_json.py‎

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
importos
2+
importsys
3+
importshutil
4+
importsubprocess
5+
importtempfile
6+
7+
base_path=os.path.abspath(os.path.dirname(__file__))
8+
9+
project_path=os.path.abspath(os.path.join(base_path,'..','lib','lvgl'))
10+
docs_path=os.path.join(project_path,'docs')
11+
sys.path.insert(0,docs_path)
12+
13+
14+
importcreate_fake_lib_c# NOQA
15+
importpycparser_monkeypatch# NOQA
16+
importpycparser# NOQA
17+
18+
temp_directory=tempfile.mkdtemp(suffix='.lvgl_json')
19+
20+
21+
defrun(lvgl_config_path,target_header,filter_private):
22+
23+
pycparser_monkeypatch.FILTER_PRIVATE=filter_private
24+
25+
lvgl_path=project_path
26+
lvgl_src_path=os.path.join(lvgl_path,'src')
27+
temp_lvgl=os.path.join(temp_directory,'lvgl')
28+
target_header_base_name= (
29+
os.path.splitext(os.path.split(target_header)[-1])[0]
30+
)
31+
32+
os.mkdir(temp_lvgl)
33+
shutil.copytree(lvgl_src_path,os.path.join(temp_lvgl,'src'))
34+
shutil.copyfile(os.path.join(lvgl_path,'lvgl.h'),os.path.join(temp_lvgl,'lvgl.h'))
35+
36+
pp_file=os.path.join(temp_directory,target_header_base_name+'.pp')
37+
38+
src=lvgl_config_path
39+
dst=os.path.join(temp_directory,'lv_conf.h')
40+
shutil.copyfile(src,dst)
41+
42+
include_dirs= [temp_directory,project_path]
43+
44+
ifsys.platform.startswith('darwin'):
45+
include_path_env_key='C_INCLUDE_PATH'
46+
cpp_cmd= [
47+
'clang','-std=c11','-E','-DINT32_MIN=0x80000000',
48+
]
49+
output_pp=f' >> "{pp_file}"'
50+
else:
51+
include_path_env_key='C_INCLUDE_PATH'
52+
cpp_cmd= [
53+
'gcc','-std=c11','-E','-Wno-incompatible-pointer-types',
54+
]
55+
output_pp=f' >> "{pp_file}"'
56+
57+
fake_libc_path=create_fake_lib_c.run(temp_directory)
58+
59+
ifinclude_path_env_keynotinos.environ:
60+
os.environ[include_path_env_key]=''
61+
62+
os.environ[include_path_env_key]= (
63+
f'{fake_libc_path}{os.pathsep}{os.environ[include_path_env_key]}'
64+
)
65+
66+
if'PATH'notinos.environ:
67+
os.environ['PATH']=''
68+
69+
os.environ['PATH']= (
70+
f'{fake_libc_path}{os.pathsep}{os.environ["PATH"]}'
71+
)
72+
73+
cpp_cmd.extend([
74+
'-DLV_LVGL_H_INCLUDE_SIMPLE',
75+
'-DLV_CONF_INCLUDE_SIMPLE',
76+
'-DLV_USE_DEV_VERSION'
77+
])
78+
79+
cpp_cmd.extend(['-DPYCPARSER',f'"-I{fake_libc_path}"'])
80+
cpp_cmd.extend([f'"-I{item}"'foritemininclude_dirs])
81+
cpp_cmd.append(f'"{target_header}"')
82+
83+
ifsys.platform.startswith('win'):
84+
cpp_cmd.insert(len(cpp_cmd)-2,output_pp)
85+
else:
86+
cpp_cmd.append(output_pp)
87+
88+
cpp_cmd=' '.join(cpp_cmd)
89+
90+
p=subprocess.Popen(
91+
cpp_cmd,
92+
stdout=subprocess.PIPE,
93+
stderr=subprocess.PIPE,
94+
env=os.environ,
95+
shell=True
96+
)
97+
out,err=p.communicate()
98+
exit_code=p.returncode
99+
100+
ifnotos.path.exists(pp_file):
101+
sys.stdout.write(out.decode('utf-8').strip()+'\n')
102+
sys.stdout.write('EXIT CODE: '+str(exit_code)+'\n')
103+
sys.stderr.write(err.decode('utf-8').strip()+'\n')
104+
sys.stdout.flush()
105+
sys.stderr.flush()
106+
107+
raiseRuntimeError('Unknown Failure')
108+
109+
withopen(pp_file,'r')asf:
110+
pp_data=f.read()
111+
112+
cparser=pycparser.CParser()
113+
ast=cparser.parse(pp_data,target_header)
114+
115+
ast.setup_docs(temp_directory)
116+
117+
shutil.rmtree(temp_directory)
118+
119+
returnast
120+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp