2
0

xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package("cppast")
  2. set_homepage("https://github.com/foonathan/cppast")
  3. set_description("Library to parse and work with the C++ AST")
  4. add_urls("https://github.com/foonathan/cppast.git")
  5. add_versions("2023.02.07", "3fb7c24bc22d129e9f5cce80c7358fd725b94105")
  6. add_deps("cmake", "debug_assert", "tiny-process-library", "type_safe")
  7. add_deps("llvm", {kind = "library"})
  8. add_links("cppast")
  9. on_install("linux", function (package)
  10. io.replace("CMakeLists.txt", [[ OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)]], "", { plain = true })
  11. io.replace("src/CMakeLists.txt", "-Werror -Wall -Wextra", "-Wall -Wextra", { plain = true })
  12. local configs = {"-DCPPAST_BUILD_TOOL=ON"}
  13. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  14. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  15. import("package.tools.cmake").install(package, configs)
  16. end)
  17. on_test(function (package)
  18. assert(package:check_cxxsnippets({test = [[
  19. #include <iostream>
  20. void test(const char* filepath)
  21. {
  22. cppast::libclang_compilation_database database(filepath); // the compilation database
  23. // simple_file_parser allows parsing multiple files and stores the results for us
  24. cppast::cpp_entity_index index;
  25. cppast::simple_file_parser<cppast::libclang_parser> parser(type_safe::ref(index));
  26. try
  27. {
  28. cppast::parse_database(parser, database); // parse all files in the database
  29. }
  30. catch (cppast::libclang_error& ex)
  31. {
  32. std::cerr << "fatal libclang error: " << ex.what() << '\n';
  33. }
  34. }
  35. ]]}, {configs = {languages = "c++11"}, includes = {"cppast/libclang_parser.hpp"}}))
  36. end)