xmake.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package("gzip-hpp")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/mapbox/gzip-hpp")
  4. set_description("Gzip header-only C++ library")
  5. set_license("MIT")
  6. add_urls("https://github.com/mapbox/gzip-hpp/archive/$(version).tar.gz",
  7. "https://github.com/mapbox/gzip-hpp.git")
  8. add_versions("v0.1.0", "7ce3908cd13f186987820be97083fc5e62a7c6df0877af44b334a92e868eff06")
  9. add_deps("zlib")
  10. on_install(function (package)
  11. io.replace("include/gzip/utils.hpp", "#include <cstdlib>", "#include <cstdlib>\n#include <stdint.h>", {plain = true})
  12. os.cp("include", package:installdir())
  13. end)
  14. on_test(function (package)
  15. assert(package:check_cxxsnippets({test = [[
  16. #include <gzip/compress.hpp>
  17. #include <gzip/decompress.hpp>
  18. #include <gzip/utils.hpp>
  19. #include <cassert>
  20. void test() {
  21. const std::string data("Hello World");
  22. for (int level = Z_BEST_SPEED; level <= Z_BEST_COMPRESSION; ++level)
  23. {
  24. std::string compressed_data = gzip::compress(data.data(), data.size());
  25. assert(gzip::is_compressed(compressed_data.data(), compressed_data.size()));
  26. std::string new_data = gzip::decompress(compressed_data.data(), compressed_data.size());
  27. assert(data == new_data);
  28. }
  29. }
  30. ]]}, {configs = {languages = "cxx11"}}))
  31. end)