Browse Source

add proj version and add gdal package (#1573)

* add package proj 8.2.1

* add package gdal

* add gdal test

* fix openjpeg version tag, add gdal package

* fix about pr

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* modify gdal config param

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* add openjpeg patch for windows arm64

* add openjpeg patch for windows arm64

* update gdal xmake.lua

* update gdal xmake.lua

Co-authored-by: ruki <[email protected]>
Scially 2 years ago
parent
commit
25f20be0f5

+ 34 - 0
packages/g/gdal/xmake.lua

@@ -0,0 +1,34 @@
+package("gdal")
+    set_homepage("https://gdal.org/")
+    set_description("L is a translator library for raster and vector geospatial data formats that is released under an MIT style Open Source License by the Open Source Geospatial Foundation")
+    set_license("MIT")
+
+    add_urls("https://github.com/OSGeo/gdal/releases/download/v$(version)/gdal-$(version).tar.gz")
+    add_versions("3.5.1", "7c4406ca010dc8632703a0a326f39e9db25d9f1f6ebaaeca64a963e3fac123d1")
+
+    add_configs("apps", {description = "Build GDAL applications.", default = false, type = "boolean"})
+    add_deps("cmake", "proj", "openjpeg")
+
+    if is_plat("windows") then
+        add_syslinks("wsock32", "ws2_32")
+    end
+
+    on_install("windows|x86", "windows|x64", "macosx", "linux", function (package)
+        local configs = {"-DBUILD_TESTING=OFF", "-DGDAL_USE_EXTERNAL_LIBS=OFF", "-DGDAL_USE_OPENJPEG=ON",
+                         "-DBUILD_JAVA_BINDINGS=OFF", "-DBUILD_CSHARP_BINDINGS=OFF", "-DBUILD_PYTHON_BINDINGS=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"))
+        table.insert(configs, "-DBUILD_APPS=" .. (package:config("apps") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs, {packagedeps = {"openjpeg", "proj"}})
+        if package:config("apps") then
+            package:addenv("PATH", "bin")
+        end
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            #include <ogrsf_frmts.h>
+            void test(int argc, char** argv) {
+                GDALAllRegister();
+            }]]}, {configs = {languages = "c++11"}, includes = "ogrsf_frmts.h"}))
+    end)

+ 11 - 0
packages/o/openjpeg/patches/2.5.0/build.patch

@@ -0,0 +1,11 @@
+--- a/src/lib/openjp2/ht_dec.c
++++ b/src/lib/openjp2/ht_dec.c
+@@ -69,7 +69,7 @@ static OPJ_BOOL only_cleanup_pass_is_decoded = OPJ_FALSE;
+ static INLINE
+ OPJ_UINT32 population_count(OPJ_UINT32 val)
+ {
+-#ifdef OPJ_COMPILER_MSVC
++#if defined(OPJ_COMPILER_MSVC) && (defined(_M_IX86) || defined(_M_AMD64))
+     return (OPJ_UINT32)__popcnt(val);
+ #elif (defined OPJ_COMPILER_GNUC)
+     return (OPJ_UINT32)__builtin_popcount(val);

+ 8 - 6
packages/o/openjpeg/xmake.lua

@@ -4,10 +4,12 @@ package("openjpeg")
     set_description("OpenJPEG is an open-source JPEG 2000 codec written in C language.")
     set_license("BSD-2-Clause")
 
-    add_urls("https://github.com/uclouvain/openjpeg/archive/v$(version).tar.gz",
+    add_urls("https://github.com/uclouvain/openjpeg/archive/refs/tags/$(version).tar.gz",
              "https://github.com/uclouvain/openjpeg.git")
-    add_versions("2.3.1", "63f5a4713ecafc86de51bfad89cc07bb788e9bba24ebbf0c4ca637621aadb6a9")
-    add_versions("2.4.0", "8702ba68b442657f11aaeb2b338443ca8d5fb95b0d845757968a7be31ef7f16d")
+    add_versions("v2.3.1", "63f5a4713ecafc86de51bfad89cc07bb788e9bba24ebbf0c4ca637621aadb6a9")
+    add_versions("v2.4.0", "8702ba68b442657f11aaeb2b338443ca8d5fb95b0d845757968a7be31ef7f16d")
+    add_versions("v2.5.0", "0333806d6adecc6f7a91243b2b839ff4d2053823634d4f6ed7a59bc87409122a")
+    add_patches("v2.5.0", path.join(os.scriptdir(), "patches", "2.5.0", "build.patch"), "0842372f2f8c941865edeb5ac98b9a05cfa59e66fd6f16e3e014866a6965a7d6")
 
     add_deps("cmake")
     add_deps("lcms", "libtiff", "libpng")
@@ -24,13 +26,13 @@ package("openjpeg")
     end)
 
     on_install("windows", "linux", "macosx", function (package)
-        local configs = {"-DBUILD_TESTING=OFF", "-DBUILD_DOC=OFF"}
+        local configs = {"-DBUILD_TESTING=OFF", "-DBUILD_DOC=OFF", "-DBUILD_CODEC=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"))
         table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON"))
         import("package.tools.cmake").install(package, configs)
-        package:add("PATH", "bin")
-        
+        package:addenv("PATH", "bin")
+
         -- fix cmake import files
         local ver = package:version():major() .. "." .. package:version():minor()
         io.gsub(package:installdir("lib", "openjpeg-" .. ver, "OpenJPEGConfig.cmake"), "set%(INC_DIR .-%)", format("set(INC_DIR ${SELF_DIR}/../../include/openjpeg-%s)", ver))

+ 10 - 1
packages/p/proj/xmake.lua

@@ -6,8 +6,9 @@ package("proj")
 
     add_urls("https://download.osgeo.org/proj/proj-$(version).tar.gz")
     add_versions("9.0.1", "737eaacbe7906d0d6ff43f0d9ebedc5c734cccc9e6b8d7beefdec3ab22d9a6a3")
+    add_versions("8.2.1", "76ed3d0c3a348a6693dfae535e5658bbfd47f71cb7ff7eb96d9f12f7e068b1cf")
 
-    add_configs("apps", {description = "Build PROJ applications.", default = true, type = "boolean"})
+    add_configs("apps", {description = "Build PROJ applications.", default = false, type = "boolean"})
     add_configs("tiff", {description = "Enable TIFF support.", default = false, type = "boolean"})
     add_configs("curl", {description = "Enable Curl support.", default = false, type = "boolean"})
 
@@ -18,6 +19,7 @@ package("proj")
     elseif is_plat("linux") then
         add_syslinks("pthread")
     end
+
     on_load("windows", "macosx", "linux", function (package)
         if package:config("tiff") then
             package:add("deps", "libtiff")
@@ -28,9 +30,16 @@ package("proj")
                 package:add("deps", "openssl")
             end
         end
+        if package:config("apps") then
+            package:addenv("PATH", "bin")
+        end
     end)
 
     on_install("windows", "macosx", "linux", function (package)
+        -- windows@arm64 cann't generate proj.db
+        if package:is_plat("windows") and package:is_arch("arm64") then
+            io.replace("CMakeLists.txt", "add_subdirectory(data)", "", {plain = true})
+        end
         if package:config("curl") and package:is_plat("linux") then
             io.replace("src/lib_proj.cmake", "${CURL_LIBRARIES}", "CURL::libcurl ssl crypto", {plain = true})
         else