Browse Source

add leptonica, tesseract, osqp, partio, libfive and amgcl (#365)

* update glfw

* add leptonica and tesseract

* add osqp

* add partio

* fix boost

* update freeglut

* add libfive

* add amgcl

* fix some packages

* fix libfive
Hoildkv 4 years ago
parent
commit
3242cfd9ea

+ 52 - 0
packages/a/amgcl/xmake.lua

@@ -0,0 +1,52 @@
+package("amgcl")
+
+    set_homepage("https://github.com/ddemidov/amgcl/")
+    set_description("C++ library for solving large sparse linear systems with algebraic multigrid method")
+    set_license("MIT")
+
+    add_urls("https://github.com/ddemidov/amgcl/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/ddemidov/amgcl.git")
+    add_versions("1.4.0", "018b824396494c8958faa6337cebcaba48a2584d828f279eef0bbf9e05f900a7")
+
+    add_deps("cmake")
+    add_deps("boost", {configs = {serialization = true, program_options = true}})
+    on_install("windows", "macosx", "linux", function (package)
+        io.replace("CMakeLists.txt", "unit_test_framework", "", {plain = true})
+        local configs = {"-DBoost_USE_STATIC_LIBS=ON"}
+        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"))
+        if package:is_plat("windows") then
+            table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
+        else
+            table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=OFF")
+        end
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            #include <vector>
+            #include <amgcl/backend/builtin.hpp>
+            #include <amgcl/adapter/crs_tuple.hpp>
+            #include <amgcl/make_solver.hpp>
+            #include <amgcl/amg.hpp>
+            #include <amgcl/coarsening/smoothed_aggregation.hpp>
+            #include <amgcl/relaxation/spai0.hpp>
+            #include <amgcl/solver/bicgstab.hpp>
+            void test() {
+                typedef amgcl::backend::builtin<double> Backend;
+                typedef amgcl::make_solver<
+                    amgcl::amg<
+                        Backend,
+                        amgcl::coarsening::smoothed_aggregation,
+                        amgcl::relaxation::spai0
+                    >,
+                    amgcl::solver::bicgstab<Backend>
+                > Solver;
+                ptrdiff_t           rows, cols;
+                std::vector<int>    ptr, col;
+                std::vector<double> val;
+                Solver solve(std::tie(rows, ptr, col, val));
+            }
+        ]]}, {configs = {languages = "c++17"}}))
+    end)

+ 13 - 0
packages/b/boost/patches/1.75.0/warning.patch

@@ -0,0 +1,13 @@
+diff --git a/boost/concept_check.hpp b/boost/concept_check.hpp
+index abbadb7..cab58e5 100644
+--- a/boost/concept_check.hpp
++++ b/boost/concept_check.hpp
+@@ -352,7 +352,7 @@ 
+     private:
+         void test(boost::false_type)
+         {
+-            f(first,second);
++            (void) f(first,second);
+             Return r = f(first, second); // require operator()
+             (void)r;
+         }

+ 4 - 1
packages/b/boost/xmake.lua

@@ -16,6 +16,8 @@ package("boost")
     add_versions("1.72.0", "59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722")
     add_versions("1.70.0", "430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778")
 
+    add_patches("1.75.0", path.join(os.scriptdir(), "patches", "1.75.0", "warning.patch"), "43ff97d338c78b5c3596877eed1adc39d59a000cf651d0bcc678cf6cd6d4ae2e")
+
     if is_plat("linux") then
         add_deps("bzip2", "zlib")
     elseif is_plat("windows") then
@@ -39,7 +41,8 @@ package("boost")
                       "wave",
                       "date_time",
                       "locale",
-                      "iostreams"}
+                      "iostreams",
+                      "program_options"}
 
     add_configs("multi",        { description = "Enable multi-thread support.",  default = true, type = "boolean"})
     for _, libname in ipairs(libnames) do

+ 31 - 0
packages/f/freeglut/patches/3.2.1/gcc10.patch

@@ -0,0 +1,31 @@
+diff --git a/src/fg_gl2.h b/src/fg_gl2.h
+index ab8ba5c..a1a52da 100644
+--- a/src/fg_gl2.h
++++ b/src/fg_gl2.h
+@@ -67,12 +67,18 @@ 
+ typedef void (APIENTRY *FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
+ typedef void (APIENTRY *FGH_PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+ 
+-FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
+-FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
+-FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
+-FGH_PFNGLBUFFERDATAPROC fghBufferData;
+-FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
+-FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
+-FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
++#if __GNUC__ > 9
++#define FG_ATTRIBUTE_COMMON __attribute__((__common__))
++#else
++#define FG_ATTRIBUTE_COMMON
++#endif
++
++FGH_PFNGLGENBUFFERSPROC FG_ATTRIBUTE_COMMON fghGenBuffers;
++FGH_PFNGLDELETEBUFFERSPROC FG_ATTRIBUTE_COMMON fghDeleteBuffers;
++FGH_PFNGLBINDBUFFERPROC FG_ATTRIBUTE_COMMON fghBindBuffer;
++FGH_PFNGLBUFFERDATAPROC FG_ATTRIBUTE_COMMON fghBufferData;
++FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC FG_ATTRIBUTE_COMMON fghEnableVertexAttribArray;
++FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC FG_ATTRIBUTE_COMMON fghDisableVertexAttribArray;
++FGH_PFNGLVERTEXATTRIBPOINTERPROC FG_ATTRIBUTE_COMMON fghVertexAttribPointer;
+ 
+ #    endif
+ 

+ 13 - 2
packages/f/freeglut/xmake.lua

@@ -6,13 +6,16 @@ package("freeglut")
     set_urls("https://github.com/dcnieho/FreeGLUT/archive/FG_$(version).zip",
             {version = function (version) return (version:gsub("%.", "_")) end})
     add_versions("3.0.0", "050e09f17630249a7d2787c21691e4b7d7b86957a06b3f3f34fa887b561d8e04")
+    add_versions("3.2.1", "501324c27a3ee809ac4a6374f63c5049c1c0d342d93fdb5db12b8c1c84760fa4")
+
+    add_patches("3.2.1", path.join(os.scriptdir(), "patches", "3.2.1", "gcc10.patch"), "26cf5026249c9e288080a75a1e9b40b3fa74a4048321cc93907f1476c5a6508b")
 
     if is_plat("linux", "windows") then
         add_deps("cmake")
     end
 
     if is_plat("linux") then
-        add_deps("libx11", "libxi", "libxxf86vm", "libxrandr")
+        add_deps("libx11", "libxi", "libxxf86vm", "libxrandr", "libxrender")
         add_syslinks("GLU", "GL")
     end
 
@@ -40,7 +43,15 @@ package("freeglut")
                 table.insert(configs, "-DCMAKE_C_FLAGS=-DFREEGLUT_LIB_PRAGMAS=0 -DFREEGLUT_STATIC=1")
             end
         end
-        import("package.tools.cmake").install(package, configs)
+        if package:config("pic") ~= false then
+            table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+        end
+        if package:is_plat("linux") then
+            import("package.tools.cmake").install(package, configs, {packagedeps = {"libxi", "libxxf86vm", "libxrandr", "libxrender"}})
+        else
+            import("package.tools.cmake").install(package, configs)
+        end
+        os.trycp(path.join("include", "GL", "glut.h"), package:installdir("include", "GL"))
     end)
 
     on_test(function (package)

+ 5 - 1
packages/g/giflib/xmake.lua

@@ -59,7 +59,11 @@ package("giflib")
             end
         end
         io.writefile("xmake.lua", xmake_lua)
-        import("package.tools.xmake").install(package)
+        local configs = {}
+        if package:is_plat("linux") and package:config("pic") ~= false then
+            configs.cxflags = "-fPIC"
+        end
+        import("package.tools.xmake").install(package, configs)
     end)
 
     on_test(function (package)

+ 9 - 0
packages/g/glfw/xmake.lua

@@ -6,9 +6,18 @@ package("glfw")
     add_urls("https://github.com/glfw/glfw/archive/$(version).tar.gz",
              "https://github.com/glfw/glfw.git")
     add_versions("3.3.2", "98768e12e615fbe9f3386f5bbfeb91b5a3b45a8c4c77159cef06b1f6ff749537")
+    add_versions("3.3.4", "cc8ac1d024a0de5fd6f68c4133af77e1918261396319c24fd697775a6bc93b63")
 
     add_configs("glfw_include", {description = "Choose submodules enabled in glfw", default = "none", type = "string", values = {"none", "vulkan", "glu", "glext", "es2", "es3"}})
 
+    on_fetch(function (package, opt) 
+        if opt.system and package.find_package then
+            if package:is_plat("linux") then
+                return package:find_package("apt::libglfw3-dev", opt)
+            end
+        end
+    end)
+
     add_deps("cmake")
 
     if is_plat("macosx") then

+ 27 - 0
packages/l/leptonica/xmake.lua

@@ -0,0 +1,27 @@
+package("leptonica")
+
+    set_homepage("http://www.leptonica.org/")
+    set_description("Leptonica is a pedagogically-oriented open source site containing software that is broadly useful for image processing and image analysis applications.")
+    set_license("BSD-2-Clause")
+
+    add_urls("https://github.com/DanBloomberg/leptonica/archive/$(version).tar.gz",
+             "https://github.com/DanBloomberg/leptonica.git")
+    add_versions("1.80.0", "3952b974ec057d24267aae48c54bca68ead8275604bf084a73a4b953ff79196e")
+
+    add_deps("cmake")
+    add_deps("libwebp", {configs = {img2webp = true, webpmux = true}})
+    add_deps("zlib", "libtiff", "libpng", "libjpeg", "giflib")
+    on_install("windows", "linux", function (package)
+        local configs = {"-DSW_BUILD=OFF"}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        if package:config("pic") ~= false then
+            table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+        end
+        import("package.tools.cmake").install(package, configs, {buildir = "build"})
+        -- will be removed in 2.5.4
+        os.trymv(path.join("build", "install", "cmake"), package:installdir())
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("pixCleanBackgroundToWhite", {includes = "leptonica/allheaders.h"}))
+    end)

+ 33 - 0
packages/l/libfive/xmake.lua

@@ -0,0 +1,33 @@
+package("libfive")
+
+    set_homepage("https://libfive.com/")
+    set_description("libfive is a software library and set of tools for solid modeling, especially suited for parametric and procedural design.")
+
+    add_urls("https://github.com/libfive/libfive.git")
+    add_versions("20210408", "e6a6448694f2204b003e29bba45754461261b9b2")
+
+    add_deps("cmake", "eigen", "libpng", "boost")
+    if not is_plat("windows") then
+        add_deps("pkg-config")
+    end
+    on_install("windows", "macosx", "linux", function (package)
+        if package:is_plat("windows") then
+            io.replace("libfive/src/CMakeLists.txt", "EIGEN_INCLUDE_DIRS", "EIGEN3_INCLUDE_DIRS", {plain = true})
+            io.replace("libfive/src/CMakeLists.txt", "if (UNIX)", "if (true)", {plain = true})
+            io.replace("CMakeLists.txt", "%/MD.", "")
+        end
+        io.replace("libfive/include/libfive.h", "[[deprecated(\"use libfive_tree_nullary instead\")]]", "", {plain = true})
+        io.replace("libfive/src/CMakeLists.txt", "bash -c \"git diff --quiet --exit-code || echo +\"", "echo +", {plain = true})
+        local configs = {"-DBUILD_GUILE_BINDINGS=OFF", "-DBUILD_PYTHON_BINDINGS=OFF", "-DBUILD_STUDIO_APP=OFF", "-DBUILD_TESTS=OFF"}
+        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"))
+        if package:config("pic") ~= false then
+            table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+        end
+        import("package.tools.cmake").install(package, configs)
+        os.trycp("libfive/include", package:installdir("include"))
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("libfive_mesh_delete", {includes = "libfive.h"}))
+    end)

+ 23 - 0
packages/o/osqp/xmake.lua

@@ -0,0 +1,23 @@
+package("osqp")
+
+    set_homepage("https://osqp.org/")
+    set_description("The Operator Splitting QP Solver")
+    set_license("Apache-2.0")
+
+    add_urls("https://github.com/oxfordcontrol/osqp.git")
+    add_versions("v0.6.2", "f9fc23d3436e4b17dd2cb95f70cfa1f37d122c24")
+
+    add_deps("cmake")
+    on_install("windows", "macosx", "linux", "mingw", function (package)
+        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"))
+        if package:config("pic") ~= false then
+            table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+        end
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("osqp_solve", {includes = "osqp/osqp.h"}))
+    end)

+ 30 - 0
packages/p/partio/xmake.lua

@@ -0,0 +1,30 @@
+package("partio")
+
+    set_homepage("http://partio.us/")
+    set_description("Partio is an open source C++ library for reading, writing and manipulating a variety of standard particle formats (GEO, BGEO, PTC, PDB, PDA).")
+    set_license("BSD-3-Clause")
+
+    add_urls("https://github.com/wdas/partio/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/wdas/partio.git")
+    add_versions("v1.14.0", "f98874b781e92ab9b5d0575cabc437d27274cd91cb581f80960918efa491f902")
+
+    add_deps("cmake", "python", "zlib")
+    on_install("windows", "macosx", "linux", function (package)
+        io.gsub("CMakeLists.txt", "add%_subdirectory%(.+%)", "add_subdirectory(src/lib)")
+        io.gsub("CMakeLists.txt", "find%_package%(GLUT REQUIRED%)", "")
+        local configs = {}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        if package:config("pic") ~= false then
+            table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+        end
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            void test() {
+                Partio::ParticlesDataMutable* particles=Partio::createInterleave();
+                particles->addParticles(10);
+            }
+        ]]}, {configs = {languages = "c++11"}, includes = "Partio.h"}))
+    end)

+ 40 - 0
packages/t/tesseract/xmake.lua

@@ -0,0 +1,40 @@
+package("tesseract")
+
+    set_homepage("https://tesseract-ocr.github.io/")
+    set_description("Tesseract Open Source OCR Engine")
+    set_license("Apache-2.0")
+
+    add_urls("https://github.com/tesseract-ocr/tesseract/archive/$(version).tar.gz",
+             "https://github.com/tesseract-ocr/tesseract.git")
+    add_versions("4.1.1", "2a66ff0d8595bff8f04032165e6c936389b1e5727c3ce5a27b3e059d218db1cb")
+
+    add_configs("training", {description = "Build training tools.", default = false, type = "boolean"})
+
+    add_deps("cmake")
+    add_deps("leptonica")
+    add_deps("libarchive", {optional = true})
+    on_load(function (package)
+        if package:config("training") then
+            package:add("deps", "icu4c")
+        end
+    end)
+
+    on_install("windows", "linux", function (package)
+        io.replace("CMakeLists.txt", "find_package(PkgConfig)", "", {plain = true})
+        io.replace("src/training/CMakeLists.txt", "find_package(PkgConfig)", "", {plain = true})
+        local configs = {"-DSW_BUILD=OFF", "-DBUILD_TESTS=OFF", "-DUSE_SYSTEM_ICU=ON"}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=OFF")
+        table.insert(configs, "-DWIN32_MT_BUILD=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
+        table.insert(configs, "-DBUILD_TRAINING_TOOLS=" .. (package:config("training") and "ON" or "OFF"))
+        if package:config("pic") ~= false then
+            table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+        end
+        import("package.tools.cmake").install(package, configs)
+        package:addenv("PATH", "bin")
+    end)
+
+    on_test(function (package)
+        os.vrun("tesseract --version")
+        assert(package:has_cxxtypes("tesseract::TessBaseAPI", {configs = {languages = "c++11"}, includes = "tesseract/baseapi.h"}))
+    end)