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 testspull/149/head
parent
48baf57fc4
commit
488d8c512c
4 changed files with 154 additions and 5 deletions
@ -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) |
@ -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…
Reference in new issue