Browse Source

update pcl (#3054)

* switch to xmake port for macosx arm

* update pcl

* improve boost logging

* improve boost logging

* check macosx

* fix boost

* disable libusb

* use os.execv in boost
Hoildkv 1 year ago
parent
commit
1847810a6f
4 changed files with 45 additions and 21 deletions
  1. 29 4
      packages/b/boost/xmake.lua
  2. 5 15
      packages/l/libpng/xmake.lua
  3. 2 1
      packages/p/pcl/xmake.lua
  4. 9 1
      packages/z/zlib/xmake.lua

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

@@ -264,6 +264,7 @@ package("boost")
         else
             table.insert(argv, "address-model=32")
         end
+        local cxxflags
         if package:is_plat("windows") then
             local vs_runtime = package:config("vs_runtime")
             if package:config("shared") then
@@ -273,16 +274,37 @@ package("boost")
             else
                 table.insert(argv, "runtime-link=shared")
             end
-            table.insert(argv, "cxxflags=-std:c++14")
             table.insert(argv, "toolset=" .. build_toolset)
+            cxxflags = "-std:c++14"
         elseif package:is_plat("mingw") then
             table.insert(argv, "toolset=gcc")
+        elseif package:is_plat("macosx") then
+            table.insert(argv, "toolset=darwin")
+
+            -- fix macosx arm64 build issue https://github.com/microsoft/vcpkg/pull/18529
+            cxxflags = "-std=c++14 -arch " .. package:arch()
+            local xcode = package:toolchain("xcode") or import("core.tool.toolchain").load("xcode", {plat = package:plat(), arch = package:arch()})
+            if xcode:check() then
+                local xcode_dir = xcode:config("xcode")
+                local xcode_sdkver = xcode:config("xcode_sdkver")
+                local target_minver = xcode:config("target_minver")
+                if xcode_dir and xcode_sdkver then
+                    local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk"
+                    cxxflags = cxxflags .. " -isysroot " .. xcode_sdkdir
+                end
+                if target_minver then
+                    cxxflags = cxxflags .. " -mmacosx-version-min=" .. target_minver
+                end
+            end
         else
-            table.insert(argv, "cxxflags=-std=c++14")
+            cxxflags = "-std=c++14"
             if package:config("pic") ~= false then
-                table.insert(argv, "cxxflags=-fPIC")
+                cxxflags = cxxflags .. " -fPIC"
             end
         end
+        if cxxflags then
+            table.insert(argv, "cxxflags=" .. cxxflags)
+        end
         for _, libname in ipairs(libnames) do
             if package:config("all") or package:config(libname) then
                 table.insert(argv, "--with-" .. libname)
@@ -293,7 +315,10 @@ package("boost")
             table.insert(argv, "pch=off")
         end
 
-        os.vrunv("./b2", argv, {envs = runenvs})
+        local ok = os.execv("./b2", argv, {envs = runenvs, try = true, stdout = "boost-log.txt"})
+        if ok ~= 0 then
+            raise("boost build failed, please check log in " .. path.join(os.curdir(), "boost-log.txt"))
+        end
     end)
 
     on_test(function (package)

+ 5 - 15
packages/l/libpng/xmake.lua

@@ -29,7 +29,7 @@ package("libpng")
         add_extsources("brew::libpng")
     end
 
-    on_install("windows", "mingw", "android", "iphoneos", "cross", "bsd", "wasm", function (package)
+    on_install("windows", "mingw", "macosx|arm64", "android", "iphoneos", "cross", "bsd", "wasm", function (package)
         io.writefile("xmake.lua", [[
             add_rules("mode.debug", "mode.release")
             add_requires("zlib")
@@ -76,27 +76,17 @@ package("libpng")
         import("package.tools.xmake").install(package, configs)
     end)
 
-    on_install("macosx", "linux", function (package)
+    on_install("macosx|x86_64", "linux", function (package)
         local configs = {}
         table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
         table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
         if package:config("pic") ~= false then
             table.insert(configs, "--with-pic")
         end
-        local cppflags = {}
-        local ldflags = {}
-        for _, dep in ipairs(package:orderdeps()) do
-            local fetchinfo = dep:fetch()
-            if fetchinfo then
-                for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
-                    table.insert(cppflags, "-I" .. includedir)
-                end
-                for _, linkdir in ipairs(fetchinfo.linkdirs) do
-                    table.insert(ldflags, "-L" .. linkdir)
-                end
-            end
+        if not package:dep("zlib"):is_system() then
+            table.insert(configs, "--with-zlib-prefix=" .. package:dep("zlib"):installdir())
         end
-        import("package.tools.autoconf").install(package, configs, {cppflags = cppflags, ldflags = ldflags})
+        import("package.tools.autoconf").install(package, configs)
     end)
 
     on_test(function (package)

+ 2 - 1
packages/p/pcl/xmake.lua

@@ -8,6 +8,7 @@ package("pcl")
              "https://github.com/PointCloudLibrary/pcl.git")
     add_versions("1.12.0", "21dfa9a268de9675c1f94d54d9402e4e02120a0aa4215d064436c52b7d5bd48f")
     add_versions("1.12.1", "dc0ac26f094eafa7b26c3653838494cc0a012bd1bdc1f1b0dc79b16c2de0125a")
+    add_versions("1.14.0", "de297b929eafcb93747f12f98a196efddf3d55e4edf1b6729018b436d5be594d")
 
     add_configs("vtk", {description = "Build with vtk.", default = false, type = "boolean"})
     add_configs("cuda", {description = "Build with cuda.", default = false, type = "boolean"})
@@ -33,7 +34,7 @@ package("pcl")
             io.replace("cmake/pcl_options.cmake", "set(CMAKE_FIND_LIBRARY_SUFFIXES", "#set(CMAKE_FIND_LIBRARY_SUFFIXES", {plain = true})
         end
 
-        local configs = {"-DWITH_OPENGL=OFF", "-DWITH_PCAP=OFF", "-DWITH_QT=OFF", "-DBoost_USE_STATIC_LIBS=ON", "-DPCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES=ON"}
+        local configs = {"-DWITH_OPENGL=OFF", "-DWITH_PCAP=OFF", "-DWITH_QT=OFF", "-DWITH_LIBUSB=OFF", "-DBoost_USE_STATIC_LIBS=ON", "-DPCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES=ON"}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
         table.insert(configs, "-DPCL_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         table.insert(configs, "-DWITH_VTK=" .. (package:config("vtk") and "ON" or "OFF"))

+ 9 - 1
packages/z/zlib/xmake.lua

@@ -21,9 +21,17 @@ package("zlib")
         add_extsources("brew::zlib")
     end
 
+    on_fetch(function (package, opt)
+        if opt.system then
+            if not package:is_plat("windows", "mingw") then
+                return package:find_package("system::z", {includes = "zlib.h"})
+            end
+        end
+    end)
+
     on_install(function (package)
         io.writefile("xmake.lua", [[
-            includes("check_cincludes.lua")
+            includes("@builtin/check")
             add_rules("mode.debug", "mode.release")
             target("zlib")
                 set_kind("$(kind)")