xmake.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. package("lvgl")
  2. set_homepage("https://lvgl.io")
  3. set_description("Light and Versatile Graphics Library")
  4. set_license("MIT")
  5. add_urls("https://github.com/lvgl/lvgl/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/lvgl/lvgl.git")
  7. add_versions("v8.0.2", "7136edd6c968b60f0554130c6903f16870fa26cda11a2290bc86d09d7138a6b4")
  8. add_versions("v8.2.0", "dd1cb1955ded3789c99e2dee7ac367393e87b5870cbce6b88930e378c3e91829")
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. add_configs("color_depth", {description = "Set color depth.", default = "32", type = "string", values = {"1", "8", "16", "32"}})
  11. add_configs("use_log", {description = "Enable the log module.", default = false, type = "boolean"})
  12. add_deps("cmake")
  13. on_install(function (package)
  14. os.mv("lv_conf_template.h", "src/lv_conf.h")
  15. io.replace("src/lv_conf.h", "#if 0", "#if 1")
  16. io.replace("src/lv_conf.h", "#define LV_BUILD_EXAMPLES -1", "#define LV_BUILD_EXAMPLES 0")
  17. io.replace("src/lv_conf.h", "#define LV_COLOR_DEPTH -16", "#define LV_COLOR_DEPTH " .. package:config("color_depth"))
  18. io.replace("src/lv_conf.h", "#define LV_USE_LOG -0", "#define LV_USE_LOG " .. (package:config("use_log") and "1" or "0"))
  19. if package:version():le("8.1.0") then
  20. io.replace("CMakeLists.txt", "add_library(lvgl STATIC ${SOURCES})", "add_library(lvgl STATIC ${SOURCES})\ninstall(TARGETS lvgl)\ninstall(FILES lvgl.h DESTINATION include/lvgl)\ninstall(DIRECTORY src DESTINATION include/lvgl FILES_MATCHING PATTERN \"*.h\")", {plain = true})
  21. io.replace("CMakeLists.txt", "if(ESP_PLATFORM)", "cmake_minimum_required(VERSION 3.15)\nif(ESP_PLATFORM)", {plain = true})
  22. end
  23. local configs = {}
  24. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  25. import("package.tools.cmake").install(package, configs)
  26. end)
  27. on_test(function (package)
  28. assert(package:has_cfuncs("lv_version_info", {includes = "lvgl/lvgl.h"}))
  29. end)