1#!/usr/bin/env python3
2
3import sys
4import os
5import subprocess
6import re
7import example_list as ex
8
9langs = ['en']
10
11# Change to script directory for consistency
12abspath = os.path.abspath(__file__)
13dname = os.path.dirname(abspath)
14os.chdir(dname)
15
16def cmd(s):
17  print("")
18  print(s)
19  print("-------------------------------------")
20  r = os.system(s)
21  if r != 0:
22    print("Exit build due to previous error")
23    exit(-1)
24
25# Get the current branch name
26status, br = subprocess.getstatusoutput("git branch | grep '*'")
27_, gitcommit = subprocess.getstatusoutput("git rev-parse HEAD")
28br = re.sub('\* ', '', br)
29
30# Generate the list of examples
31ex.exec()
32
33urlpath = re.sub('release/', '', br)
34
35os.environ['LVGL_URLPATH'] = urlpath
36os.environ['LVGL_GITCOMMIT'] = gitcommit
37
38clean = 0
39trans = 0
40skip_latex = False
41args = sys.argv[1:]
42if len(args) >= 1:
43  if "clean" in args: clean = 1
44  if "skip_latex" in args: skip_latex = True
45
46lang = "en"
47print("")
48print("****************")
49print("Building")
50print("****************")
51if clean:
52  cmd("rm -rf " + lang)
53  cmd("mkdir " + lang)
54
55
56print("Running doxygen")
57cmd("cd ../scripts && doxygen Doxyfile")
58# BUILD PDF
59
60if not skip_latex:
61  # Silly workaround to include the more or less correct PDF download link in the PDF
62  #cmd("cp -f " + lang +"/latex/LVGL.pdf LVGL.pdf | true")
63  cmd("sphinx-build -b latex . out_latex")
64
65  # Generate PDF
66  cmd("cd out_latex && latexmk -pdf 'LVGL.tex'")
67  # Copy the result PDF to the main directory to make it available for the HTML build
68  cmd("cd out_latex && cp -f LVGL.pdf ../LVGL.pdf")
69else:
70  print("skipping latex build as requested")
71
72# BUILD HTML
73cmd("sphinx-build -b html . ../out_html")
74
75