add package piex, re2 and effcee (#147)

* add package piex

* update expat

* add package re2

* add package effcee

* improve expat

* fix piex

* fix config vulnerability

* disable expat static runtime

* disable static build on windows

* improve tests
pull/149/head
Hoildkv 4 years ago committed by GitHub
parent 48baf57fc4
commit 488d8c512c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 37
      packages/e/effcee/xmake.lua
  2. 21
      packages/e/expat/xmake.lua
  3. 55
      packages/p/piex/xmake.lua
  4. 46
      packages/r/re2/xmake.lua

@ -0,0 +1,37 @@
package("effcee")
set_homepage("https://github.com/google/effcee")
set_description("Effcee is a C++ library for stateful pattern matching of strings.")
set_license("Apache-2.0")
add_urls("https://github.com/google/effcee/archive/v$(version).tar.gz")
add_versions("2019.1", "0c49849859d356f39273fa01f674eaf687fd5e5fe83c94510784c2279bfb793d")
add_deps("cmake")
add_deps("re2")
on_install("macosx", "linux", "windows", function (package)
-- add re2 include
local fetchinfo = package:dep("re2"):fetch()
local cxflags = {}
for _, includedir in ipairs(fetchinfo.sysincludedirs or fetchinfo.includedirs) do
table.insert(cxflags, "-I" .. includedir)
end
io.gsub(path.join("cmake", "setup_build.cmake"), "find_host_package%(", "#")
io.gsub("CMakeLists.txt", "add_subdirectory%(third_party%)", "#")
local configs = {"-DEFFCEE_BUILD_SAMPLES=OFF", "-DEFFCEE_BUILD_TESTING=OFF"}
table.insert(configs, "-DCMAKE_C_FLAGS=" .. table.concat(cxflags, ";"))
table.insert(configs, "-DCMAKE_CXX_FLAGS=" .. table.concat(cxflags, ";"))
table.insert(configs, "-DEFFCEE_ENABLE_SHARED_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "OFF" or "ON"))
import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
void test() {
auto opt = effcee::Options().SetChecksName("checks");
}
]]}, {configs = {languages = "c++11"}, includes = "effcee/effcee.h"}))
end)

@ -2,23 +2,34 @@ package("expat")
set_homepage("https://libexpat.github.io")
set_description("XML 1.0 parser")
set_license("MIT")
set_urls("https://github.com/libexpat/libexpat/releases/download/R_2_2_6/expat-$(version).tar.bz2")
set_urls("https://github.com/libexpat/libexpat/releases/download/R_$(version).tar.bz2", {version = function (version) return version:gsub("%.", "_") .. "/expat-" .. version end})
add_versions("2.2.10", "b2c160f1b60e92da69de8e12333096aeb0c3bf692d41c60794de278af72135a5")
add_versions("2.2.6", "17b43c2716d521369f82fc2dc70f359860e90fa440bea65b3b85f0b246ea81f2")
if is_host("windows") then
if is_plat("windows") then
add_deps("cmake")
end
on_install("windows", function (package)
import("package.tools.cmake").install(package)
local configs = {"-DEXPAT_BUILD_EXAMPLES=OFF", "-DEXPAT_BUILD_TESTS=OFF", "-DEXPAT_BUILD_DOCS=OFF"}
import("package.tools.cmake").install(package, configs)
end)
on_install("linux", "macosx", function (package)
import("package.tools.autoconf").install(package)
local configs = {"--without-examples", "--without-tests", "--without-docbook"}
if package:config("shared") then
table.insert(configs, "--enable-shared=yes")
table.insert(configs, "--enable-static=no")
else
table.insert(configs, "--enable-shared=no")
table.insert(configs, "--enable-static=yes")
end
import("package.tools.autoconf").install(package, configs)
end)
on_test(function (package)
assert(package:has_cfuncs("XML_ParserCreate", {includes = "expat.h"}))
assert(package:has_cfuncs("XML_ParserCreate(NULL)", {includes = "expat.h"}))
end)

@ -0,0 +1,55 @@
package("piex")
set_homepage("https://github.com/google/piex")
set_description("Preview Image Extractor (PIEX)")
set_license("Apache-2.0")
add_urls("https://github.com/google/piex.git")
-- version 20201107 is buggy
-- add_versions("20201107", "a1b85d566521a4a03c7c715d2851c4272da4e301")
add_versions("20190530", "84e9cdf11cd8dac8a4977dd1a6a874ddf884d322")
add_links("piex", "image_type_recognition", "tiff_directory", "binary_parse")
on_install("macosx", "linux", "windows", "mingw", "android", "iphoneos", function (package)
for _, folder in ipairs({"binary_parse", "image_type_recognition", "tiff_directory"}) do
for _, file in ipairs(os.files(path.join("src", folder, "*.*"))) do
io.gsub(file, "#include \"src/", "#include \"../")
end
end
for _, file in ipairs(os.files(path.join("src", "*.*"))) do
io.gsub(file, "#include \"src/", "#include \"")
end
io.gsub("src/image_type_recognition/image_type_recognition_lite.cc", "#include <string>", "#include <string>\n#include <cstring>")
io.gsub("src/image_type_recognition/image_type_recognition_lite.cc", "kSignatureOffset %+ strlen", "kSignatureOffset + std::strlen")
io.writefile("xmake.lua", [[
add_rules("mode.debug", "mode.release")
target("binary_parse")
set_kind("static")
set_languages("c++11")
add_files("src/binary_parse/cached_paged_byte_array.cc", "src/binary_parse/range_checked_byte_ptr.cc")
add_headerfiles("src/(binary_parse/cached_paged_byte_array.h)", "src/(binary_parse/range_checked_byte_ptr.h)")
target("image_type_recognition")
set_kind("static")
set_languages("c++11")
add_deps("binary_parse")
add_files("src/image_type_recognition/image_type_recognition_lite.cc")
add_headerfiles("src/(image_type_recognition/image_type_recognition_lite.h)")
target("tiff_directory")
set_kind("static")
set_languages("c++11")
add_deps("binary_parse")
add_files("src/tiff_directory/tiff_directory.cc")
add_headerfiles("src/(tiff_directory/tiff_directory.h)")
target("piex")
set_kind("static")
set_languages("c++11")
add_deps("binary_parse", "image_type_recognition", "tiff_directory")
add_files("src/piex.cc", "src/tiff_parser.cc")
add_headerfiles("src/(piex.h)", "src/(piex_types.h)", "src/(tiff_parser.h)")
]])
import("package.tools.xmake").install(package)
end)
on_test(function (package)
assert(package:has_cxxfuncs("piex::BytesRequiredForIsRaw()", {configs = {languages = "c++11"}, includes = "piex.h"}))
end)

@ -0,0 +1,46 @@
package("re2")
set_homepage("https://github.com/google/re2")
set_description("RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.")
set_license("BSD-3-Clause")
add_urls("https://github.com/google/re2/archive/$(version).tar.gz", {version = function (version) return version:gsub("%.", "-") end})
add_versions("2020.11.01", "8903cc66c9d34c72e2bc91722288ebc7e3ec37787ecfef44d204b2d6281954d7")
if is_plat("windows") then
add_deps("cmake")
end
if is_plat("linux") then
add_syslinks("pthread")
end
on_install("windows", function (package)
local configs = {"-DRE2_BUILD_TESTING=OFF"}
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
import("package.tools.cmake").install(package, configs)
end)
on_install("macosx", "linux", function (package)
local configs = {"prefix=" .. package:installdir()}
import("package.tools.make").build(package, configs)
if package:config("shared") then
os.vrunv("make shared-install ", configs)
else
os.vrunv("make static-install ", configs)
end
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <string>
#include <cassert>
void test() {
int i;
std::string s;
assert(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i));
assert(s == "ruby");
assert(i == 1234);
}
]]}, {configs = {languages = "c++11"}, includes = "re2/re2.h"}))
end)
Loading…
Cancel
Save