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
35# Be sure the GitHub links point to the right branch
36f = open("header.rst", "w")
37f.write(".. |github_link_base| replace:: https://github.com/lvgl/lvgl/blob/" + gitcommit + "/docs")
38f.close()
39
40base_html = "html_baseurl = 'https://docs.lvgl.io/" + urlpath + "/en/html/'"
41
42os.system("sed -i \"s|html_baseurl = .*|" + base_html +"|\" conf.py")
43
44clean = 0
45trans = 0
46skip_latex = False
47args = sys.argv[1:]
48if len(args) >= 1:
49  if "clean" in args: clean = 1
50  if "skip_latex" in args: skip_latex = True
51
52lang = "en"
53print("")
54print("****************")
55print("Building")
56print("****************")
57if clean:
58  cmd("rm -rf " + lang)
59  cmd("mkdir " + lang)
60
61
62print("Running doxygen")
63cmd("cd ../scripts && doxygen Doxyfile")
64# BUILD PDF
65
66if not skip_latex:
67  # Silly workaround to include the more or less correct PDF download link in the PDF
68  #cmd("cp -f " + lang +"/latex/LVGL.pdf LVGL.pdf | true")
69  cmd("sphinx-build -b latex . out_latex")
70
71  # Generate PDF
72  cmd("cd out_latex && latexmk -pdf 'LVGL.tex'")
73  # Copy the result PDF to the main directory to make it available for the HTML build
74  cmd("cd out_latex && cp -f LVGL.pdf ../LVGL.pdf")
75else:
76  print("skipping latex build as requested")
77
78# BUILD HTML
79cmd("sphinx-build -b html . ../out_html")
80
81