From f94431e7687a5f60ebf33911923c79acc526a5aa Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Tue, 9 Nov 2021 00:45:09 +0800 Subject: [PATCH] add ptl and libcroco (#680) * add ptl * add libcroco * improve lz4 and zstd * update tbb --- packages/l/libcroco/port/xmake.lua | 71 ++++++++++++++++++++++++++++++ packages/l/libcroco/xmake.lua | 33 ++++++++++++++ packages/l/lz4/xmake.lua | 7 +-- packages/p/ptl/xmake.lua | 43 ++++++++++++++++++ packages/t/tbb/xmake.lua | 2 + packages/z/zstd/xmake.lua | 13 ++---- 6 files changed, 154 insertions(+), 15 deletions(-) create mode 100644 packages/l/libcroco/port/xmake.lua create mode 100644 packages/l/libcroco/xmake.lua create mode 100644 packages/p/ptl/xmake.lua diff --git a/packages/l/libcroco/port/xmake.lua b/packages/l/libcroco/port/xmake.lua new file mode 100644 index 000000000..c9adee8f3 --- /dev/null +++ b/packages/l/libcroco/port/xmake.lua @@ -0,0 +1,71 @@ +set_project("libcroco") +add_rules("mode.debug", "mode.release") + +add_requires("glib", "libxml2") + +option("installprefix") + set_default("") + set_showmenu(true) +option_end() +if has_config("installprefix") then + local prefix = get_config("installprefix") + set_configvar("prefix", prefix) + set_configvar("CROCO_CFLAGS", "-I" .. prefix .. "/include") + set_configvar("CROCO_LIBS", "-L" .. prefix .. "/lib -lglib-2.0 -pthread -lm -lpcre -lxml2") +end +set_configvar("exec_prefix", "${prefix}") +set_configvar("libdir", "${exec_prefix}/lib") +set_configvar("includedir", "${prefix}/include") +set_configvar("GLIB2_CFLAGS", "") +set_configvar("GLIB2_LIBS", "") +set_configvar("LIBXML2_CFLAGS", "") +set_configvar("LIBXML2_LIBS", "") + +local mver = "" +local major_ver = "" +local minor_ver = "" +option("vers") + set_default("") + set_showmenu(true) +option_end() +if has_config("vers") then + set_version(get_config("vers")) + set_configvar("VERSION", get_config("vers")) + set_configvar("LIBCROCO_VERSION", get_config("vers")) + set_configvar("LIBCROCO_VERSION_NUMBER", get_config("vers")) + local spvers = get_config("vers"):split("%.") + major_ver = spvers[1] or "" + minor_ver = spvers[2] or "" + mver = major_ver .. "." .. minor_ver + set_configvar("LIBCROCO_MAJOR_VERSION", major_ver) + set_configvar("LIBCROCO_MINOR_VERSION", minor_ver) +end + +set_configvar("G_DISABLE_CHECKS", 0) + +target("croco") + set_basename("croco-" .. mver) + set_kind("$(kind)") + add_files("src/*.c") + add_includedirs("src", {public = true}) + add_packages("glib", "libxml2", {public = true}) + set_configdir("src") + add_configfiles("src/libcroco-config.h.in", {pattern = "@(.-)@"}) + add_headerfiles("src/*.h", {prefixdir = "libcroco-" .. mver .. "/libcroco"}) +target_end() + +target("csslint") + set_basename("csslint-" .. mver) + set_kind("binary") + add_deps("croco") + add_files("csslint/csslint.c") + set_configdir(".") + if not is_plat("windows") then + add_configfiles("croco-config.in", {pattern = "@(.-)@"}) + add_configfiles("libcroco.pc.in", {pattern = "@(.-)@"}) + after_install(function (target) + os.cp("croco-config", path.join(target:installdir(), "bin", "croco-" .. mver .. "-config")) + os.cp("libcroco.pc", path.join(target:installdir(), "lib", "pkgconfig", "libcroco-" .. mver .. ".pc")) + end) + end +target_end() diff --git a/packages/l/libcroco/xmake.lua b/packages/l/libcroco/xmake.lua new file mode 100644 index 000000000..7571b1167 --- /dev/null +++ b/packages/l/libcroco/xmake.lua @@ -0,0 +1,33 @@ +package("libcroco") + + set_homepage("https://gitlab.com/inkscape/libcroco") + set_description("Libcroco is a standalone css2 parsing and manipulation library.") + set_license("LGPL-2.0") + + add_urls("https://download.gnome.org/sources/libcroco/$(version).tar.xz", {version = function (version) + return format("%d.%d/libcroco-%s", version:major(), version:minor(), version) + end}) + add_versions("0.6.13", "767ec234ae7aa684695b3a735548224888132e063f92db585759b422570621d4") + + if is_plat("windows") then + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + end + + add_deps("glib", "libxml2") + on_load("windows", "macosx", "linux", function (package) + local ver = package:version() + package:add("includedirs", format("include/libcroco-%d.%d", ver:major(), ver:minor())) + end) + + on_install("windows", "macosx", "linux", function (package) + os.cp(path.join(os.scriptdir(), "port", "xmake.lua"), "xmake.lua") + io.replace("src/cr-rgb.c", "#include \"config.h\"", "", {plain = true}) + import("package.tools.xmake").install(package, { + installprefix = package:installdir():gsub("\\", "\\\\"), + vers = package:version_str() + }) + end) + + on_test(function (package) + assert(package:has_cfuncs("cr_utils_is_newline", {includes = "libcroco/libcroco.h"})) + end) diff --git a/packages/l/lz4/xmake.lua b/packages/l/lz4/xmake.lua index db0aaf83b..74b9120f9 100644 --- a/packages/l/lz4/xmake.lua +++ b/packages/l/lz4/xmake.lua @@ -7,8 +7,6 @@ package("lz4") "https://github.com/lz4/lz4.git") add_versions("v1.9.3", "030644df4611007ff7dc962d981f390361e6c97a34e5cbc393ddfbe019ffe2c1") - add_deps("xxhash") - on_load("windows", function (package) if package:config("shared") then package:add("defines", "LZ4_DLL_IMPORT") @@ -18,12 +16,11 @@ package("lz4") on_install(function (package) io.writefile("xmake.lua", [[ add_rules("mode.debug", "mode.release") - add_requires("xxhash") target("lz4") set_kind("$(kind)") - add_files("lib/*.c|xxhash.c") + add_files("lib/*.c") add_headerfiles("lib/lz4.h", "lib/lz4hc.h", "lib/lz4frame.h") - add_packages("xxhash") + add_defines("XXH_NAMESPACE=LZ4_") if is_kind("shared") and is_plat("windows") then add_defines("LZ4_DLL_EXPORT") end diff --git a/packages/p/ptl/xmake.lua b/packages/p/ptl/xmake.lua new file mode 100644 index 000000000..c42067ead --- /dev/null +++ b/packages/p/ptl/xmake.lua @@ -0,0 +1,43 @@ +package("ptl") + + set_homepage("https://github.com/jrmadsen/PTL") + set_description("Lightweight C++11 multithreading tasking system featuring thread-pool, task-groups, and lock-free task queue") + set_license("MIT") + + add_urls("https://github.com/jrmadsen/PTL/archive/refs/tags/$(version).tar.gz", + "https://github.com/jrmadsen/PTL.git") + add_versions("v2.0.0", "58e561a3a1de75679faf4d8760d2ff045ced232d4367157b5b4e4f26c8474721") + + add_configs("tbb", {description = "Enable TBB support.", default = false, type = "boolean"}) + + add_deps("cmake") + if is_plat("linux") then + add_syslinks("pthread") + end + on_load("windows", "macosx", "linux", function (package) + if package:config("tbb") then + package:add("deps", "tbb") + end + end) + + on_install("windows", "macosx", "linux", function (package) + io.replace("cmake/Templates/PTLConfig.cmake.in", "if(WIN32)", "if(FALSE)", {plain = true}) + local configs = {} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON")) + table.insert(configs, "-DPTL_USE_TBB=" .. (package:config("tbb") and "ON" or "OFF")) + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + #include + void test() { + PTL::ThreadPool tp(4); + auto join = [](long& lhs, long rhs) { return lhs += rhs; }; + PTL::TaskGroup foo(join, &tp); + } + ]]}, {configs = {languages = "c++11"}})) + end) diff --git a/packages/t/tbb/xmake.lua b/packages/t/tbb/xmake.lua index f2436588c..6a57f6ff6 100644 --- a/packages/t/tbb/xmake.lua +++ b/packages/t/tbb/xmake.lua @@ -9,11 +9,13 @@ package("tbb") add_versions("2020.3", "cda37eed5209746a79c88a658f8c1bf3782f58bd9f9f6ba0da3a16624a9bfaa1") add_versions("2021.2.0", "9be37b1cb604a5905db0a15b2b893d85579fd0b2f1024859e1f75e96d7331a02") add_versions("2021.3.0", "90e2055cd4be55f79eedd3d50b2010bf05d1739309c4cdd219192d129e931093") + add_versions("2021.4.0", "3868c557739a7a5b74c985571648c066167fd7a0a8c63bdac00a6cfeeb58037f") else add_urls("https://github.com/oneapi-src/oneTBB/archive/v$(version).tar.gz") add_versions("2020.3", "ebc4f6aa47972daed1f7bf71d100ae5bf6931c2e3144cf299c8cc7d041dca2f3") add_versions("2021.2.0", "cee20b0a71d977416f3e3b4ec643ee4f38cedeb2a9ff015303431dd9d8d79854") add_versions("2021.3.0", "8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e") + add_versions("2021.4.0", "021796c7845e155e616f5ecda16daa606ebb4c6f90b996e5c08aebab7a8d3de3") add_patches("2021.2.0", path.join(os.scriptdir(), "patches", "2021.2.0", "gcc11.patch"), "181511cf4878460cb48ac0531d3ce8d1c57626d698e9001a0951c728fab176fb") diff --git a/packages/z/zstd/xmake.lua b/packages/z/zstd/xmake.lua index 949997d4b..39121dd5a 100644 --- a/packages/z/zstd/xmake.lua +++ b/packages/z/zstd/xmake.lua @@ -8,28 +8,21 @@ package("zstd") add_versions("v1.4.5", "734d1f565c42f691f8420c8d06783ad818060fc390dee43ae0a89f86d0a4f8c2") add_versions("v1.5.0", "0d9ade222c64e912d6957b11c923e214e2e010a18f39bec102f572e693ba2867") - add_deps("xxhash") - on_install(function (package) io.writefile("xmake.lua", [[ add_rules("mode.debug", "mode.release") - add_requires("xxhash") target("zstd") set_kind("$(kind)") - add_files("lib/common/*.c|xxhash.c") + add_files("lib/common/*.c") add_files("lib/compress/*.c") add_files("lib/decompress/*.c") - add_packages("xxhash") add_headerfiles("lib/zstd.h") + add_defines("XXH_NAMESPACE=ZSTD_") if is_kind("shared") and is_plat("windows") then add_defines("ZSTD_DLL_EXPORT") end ]]) - local configs = {} - if package:config("shared") then - configs.kind = "shared" - end - import("package.tools.xmake").install(package, configs) + import("package.tools.xmake").install(package) end) on_test(function (package)