build.py 1.6 KB

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