xmake.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package("leveldb")
  2. set_homepage("https://github.com/google/leveldb")
  3. set_description("LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/google/leveldb/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/google/leveldb.git", {submodules = false})
  7. add_versions("1.22", "55423cac9e3306f4a9502c738a001e4a339d1a38ffbee7572d4a07d5d63949b2")
  8. add_versions("1.23", "9a37f8a6174f09bd622bc723b55881dc541cd50747cbd08831c2a82d620f6d76")
  9. add_patches("*", path.join(os.scriptdir(), "patches", "fix-build-under-clang-msabi.patch"), "e90d3ac992e6b00aed529da53c37bca9a0fe77cd223ca0857848ccd66239f24a")
  10. add_patches("*", path.join(os.scriptdir(), "patches", "disable-crt-secure-warnings.patch"), "fbc769c1e0472aeeb2b6e8fddf21c84980142f0ab3896d0369e974bca982a2f9")
  11. add_deps("cmake")
  12. add_deps("snappy")
  13. if is_plat("linux", "bsd") then
  14. add_syslinks("pthread")
  15. end
  16. on_install(function (package)
  17. if package:config("shared") then
  18. package:add("defines", "LEVELDB_SHARED_LIBRARY")
  19. end
  20. local configs = {"-DLEVELDB_BUILD_TESTS=OFF", "-DLEVELDB_BUILD_BENCHMARKS=OFF"}
  21. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  22. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  23. import("package.tools.cmake").install(package, configs)
  24. end)
  25. on_test(function (package)
  26. assert(package:check_cxxsnippets({test = [[
  27. void test() {
  28. leveldb::DB* db;
  29. leveldb::Options options;
  30. options.create_if_missing = true;
  31. leveldb::Status status = leveldb::DB::Open(options, "./test", &db);
  32. }
  33. ]]}, {configs = {languages = package:is_plat("windows") and "c++14" or "c++11"}, includes = "leveldb/db.h"}))
  34. end)