Skip to content

Commit

Permalink
feat: add API JSON generator (lvgl#5677)
Browse files Browse the repository at this point in the history
Co-authored-by: Liam <[email protected]>
  • Loading branch information
kdschlosser and liamHowatt authored Jun 20, 2024
1 parent 25e993a commit ec80fe4
Show file tree
Hide file tree
Showing 12 changed files with 3,627 additions and 71 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/gen_json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test API JSON generator
on:
push:
pull_request:

jobs:
test_api_json:
if: github.repository == 'lvgl/lvgl'
runs-on: ubuntu-22.04
name: Test API JSON
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install Doxygen and Latex dependencies
run: |
sudo apt-get update
sudo apt-get install doxygen texlive-xetex texlive-binaries texlive-lang-english latexmk fonts-freefont-otf
- name: Install requirements
run: pip install -r scripts/gen_json/requirements.txt

- name: Run test
run: python3 tests/gen_json/test_gen_json.py
10 changes: 6 additions & 4 deletions docs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import tempfile
import config_builder
import add_translation
from docbuilder_utils import spawn

# due to the modifications that take place to the documentation files
# when the documentaation builds it is better to copy the source files to a
Expand Down Expand Up @@ -70,10 +71,11 @@ def cmd(s):
print("")
print(s)
print("-------------------------------------")
r = os.system(s)
if r != 0:

result = os.system(s)
if result != 0:
print("Exit build due to previous error")
exit(-1)
sys.exit(result)


# Get the current branch name
Expand Down Expand Up @@ -140,7 +142,7 @@ def cmd(s):
add_translation.exec(temp_directory)

print("Running doxygen")
cmd('cd "{0}" && doxygen Doxyfile'.format(temp_directory))
cmd('cd "{temp_directory}" && doxygen Doxyfile'.format(temp_directory=temp_directory))

print('Reading Doxygen output')

Expand Down
18 changes: 16 additions & 2 deletions docs/config_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,34 @@
))


def run():
def run(c_path=None):
global dst_config

if c_path is not None:
dst_config = c_path

with open(src_config, 'r') as f:
data = f.read()

data = data.split('\n')

for i, line in enumerate(data):
if 'LV_USE' in line or 'LV_FONT' in line:
if 'LV_USE_PROFILER' in line:
continue

if 'LV_USE' in line or 'LV_FONT' in line and '#define' in line:
line = [item for item in line.split(' ') if item]

for j, item in enumerate(line):
if item == '0':
line[j] = '1'

line = ' '.join(line)
data[i] = line
elif line.startswith('#if 0'):
line = line.replace('#if 0', '#if 1')
data[i] = line

data = '\n'.join(data)

with open(dst_config, 'w') as f:
Expand Down
Loading

0 comments on commit ec80fe4

Please sign in to comment.