From 4beba374dde2672eb80e4009a58722ca3ed6e45e Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Wed, 11 Aug 2021 23:03:14 +0800 Subject: [PATCH] add farmhash, mjson, xxhash (#559) * add farmhash * add mjson * add xxhash --- packages/f/farmhash/xmake.lua | 34 ++++++++++++++++++++++++++++++++++ packages/m/mjson/xmake.lua | 27 +++++++++++++++++++++++++++ packages/x/xxhash/xmake.lua | 26 ++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 packages/f/farmhash/xmake.lua create mode 100644 packages/m/mjson/xmake.lua create mode 100644 packages/x/xxhash/xmake.lua diff --git a/packages/f/farmhash/xmake.lua b/packages/f/farmhash/xmake.lua new file mode 100644 index 000000000..90e5a5ec6 --- /dev/null +++ b/packages/f/farmhash/xmake.lua @@ -0,0 +1,34 @@ +package("farmhash") + + set_homepage("https://github.com/google/farmhash") + set_description("FarmHash, a family of hash functions.") + set_license("MIT") + + add_urls("https://github.com/google/farmhash.git") + add_versions("2019.05.14", "0d859a811870d10f53a594927d0d0b97573ad06d") + + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + + on_install("windows", "macosx", "linux", "mingw", function (package) + os.cd("src") + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("farmhash") + set_kind("static") + set_languages("c++11") + add_defines("FARMHASH_NO_BUILTIN_EXPECT") + add_files("farmhash.cc") + add_headerfiles("farmhash.h") + ]]) + import("package.tools.xmake").install(package) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + void test() { + using namespace NAMESPACE_FOR_HASH_FUNCTIONS; + char data[] = "hash"; + auto result = Hash(data, 4); + } + ]]}, {configs = {languages = "c++11"}, includes = "farmhash.h"})) + end) diff --git a/packages/m/mjson/xmake.lua b/packages/m/mjson/xmake.lua new file mode 100644 index 000000000..e5bb4ec15 --- /dev/null +++ b/packages/m/mjson/xmake.lua @@ -0,0 +1,27 @@ +package("mjson") + + set_homepage("https://github.com/cesanta/mjson") + set_description("C/C++ JSON parser, emitter, JSON-RPC engine for embedded systems") + set_license("MIT") + + add_urls("https://github.com/cesanta/mjson/archive/refs/tags/$(version).zip", + "https://github.com/cesanta/mjson.git") + add_versions("1.2.6", "d801348c38c883802a540eec0b3ea14318837084cbdd32bd83041d03a8850fe6") + + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + + on_install(function (package) + os.cd("src") + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("mjson") + set_kind("static") + add_files("mjson.c") + add_headerfiles("mjson.h") + ]]) + import("package.tools.xmake").install(package) + end) + + on_test(function (package) + assert(package:has_cfuncs("mjson_find", {includes = "mjson.h"})) + end) diff --git a/packages/x/xxhash/xmake.lua b/packages/x/xxhash/xmake.lua new file mode 100644 index 000000000..5cd0f3510 --- /dev/null +++ b/packages/x/xxhash/xmake.lua @@ -0,0 +1,26 @@ +package("xxhash") + + set_homepage("http://cyan4973.github.io/xxHash/") + set_description("xxHash is an extremely fast non-cryptographic hash algorithm, working at RAM speed limit.") + set_license("BSD-2-Clause") + + add_urls("https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.0.tar.gz", + "https://github.com/Cyan4973/xxHash.git") + add_versions("v0.8.0", "7054c3ebd169c97b64a92d7b994ab63c70dd53a06974f1f630ab782c28db0f4f") + + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + + on_install("windows", "macosx", "linux", function (package) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("xxhash") + set_kind("static") + add_files("xxhash.c") + add_headerfiles("xxhash.h", "xxh3.h") + ]]) + import("package.tools.xmake").install(package) + end) + + on_test(function (package) + assert(package:has_cfuncs("XXH_versionNumber", {includes = "xxhash.h"})) + end)