From 8417e8007852450d3a7a42b9fe89d6dd726bd26c Mon Sep 17 00:00:00 2001 From: Inari0 <42310255+xq114@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:51:10 +0800 Subject: [PATCH] update ninja (#5624) * update ninja * fix ninja url * add bsd python2 * fix python2 * fix bsd * try fix * fix compiler setting * revert * use standard env --- packages/c/cli11/xmake.lua | 3 ++ packages/n/ninja/xmake.lua | 57 +++++++++++++++++++++++------------- packages/p/python2/xmake.lua | 45 +++++++++++----------------- 3 files changed, 57 insertions(+), 48 deletions(-) diff --git a/packages/c/cli11/xmake.lua b/packages/c/cli11/xmake.lua index 0c9f1c0e7..e080c4fd1 100644 --- a/packages/c/cli11/xmake.lua +++ b/packages/c/cli11/xmake.lua @@ -15,6 +15,9 @@ package("cli11") add_extsources("pkgconfig::CLI11") end + if is_plat("windows") then + add_syslinks("shell32") + end on_install("windows", "linux", "macosx", function (package) os.cp("include", package:installdir()) end) diff --git a/packages/n/ninja/xmake.lua b/packages/n/ninja/xmake.lua index 6e65a5559..3ed7c6250 100644 --- a/packages/n/ninja/xmake.lua +++ b/packages/n/ninja/xmake.lua @@ -3,33 +3,44 @@ package("ninja") set_kind("binary") set_homepage("https://ninja-build.org/") set_description("Small build system for use with gyp or CMake.") + set_license("Apache-2.0") if is_host("windows") then - set_urls("https://github.com/ninja-build/ninja/releases/download/v$(version)/ninja-win.zip") - add_versions("1.9.0", "2d70010633ddaacc3af4ffbd21e22fae90d158674a09e132e06424ba3ab036e9") - add_versions("1.10.1", "5d1211ea003ec9760ad7f5d313ebf0b659d4ffafa221187d2b4444bc03714a33") - add_versions("1.10.2", "bbde850d247d2737c5764c927d1071cbb1f1957dcabda4a130fa8547c12c695f") - add_versions("1.11.0", "d0ee3da143211aa447e750085876c9b9d7bcdd637ab5b2c5b41349c617f22f3b") - add_versions("1.11.1", "524b344a1a9a55005eaf868d991e090ab8ce07fa109f1820d40e74642e289abc") + if os.arch() == "arm64" then + set_urls("https://github.com/ninja-build/ninja/releases/download/$(version)/ninja-winarm64.zip") + add_versions("v1.12.1", "79c96a50e0deafec212cfa85aa57c6b74003f52d9d1673ddcd1eab1c958c5900") + else + set_urls("https://github.com/ninja-build/ninja/releases/download/$(version)/ninja-win.zip") + add_versions("v1.9.0", "2d70010633ddaacc3af4ffbd21e22fae90d158674a09e132e06424ba3ab036e9") + add_versions("v1.10.1", "5d1211ea003ec9760ad7f5d313ebf0b659d4ffafa221187d2b4444bc03714a33") + add_versions("v1.10.2", "bbde850d247d2737c5764c927d1071cbb1f1957dcabda4a130fa8547c12c695f") + add_versions("v1.11.0", "d0ee3da143211aa447e750085876c9b9d7bcdd637ab5b2c5b41349c617f22f3b") + add_versions("v1.11.1", "524b344a1a9a55005eaf868d991e090ab8ce07fa109f1820d40e74642e289abc") + add_versions("v1.12.1", "f550fec705b6d6ff58f2db3c374c2277a37691678d6aba463adcbb129108467a") + end elseif is_host("macosx") then - set_urls("https://github.com/ninja-build/ninja/releases/download/v$(version)/ninja-mac.zip") - add_versions("1.9.0", "26d32a79f786cca1004750f59e545199bf110e21e300d3c2424c1fddd78f28ab") - add_versions("1.10.1", "0bd650190d4405c15894055e349d9b59d5690b0389551d757c5ed2d3841972d1") - add_versions("1.10.2", "6fa359f491fac7e5185273c6421a000eea6a2f0febf0ac03ac900bd4d80ed2a5") - add_versions("1.11.0", "21915277db59756bfc61f6f281c1f5e3897760b63776fd3d360f77dd7364137f") - add_versions("1.11.1", "482ecb23c59ae3d4f158029112de172dd96bb0e97549c4b1ca32d8fad11f873e") + set_urls("https://github.com/ninja-build/ninja/releases/download/$(version)/ninja-mac.zip") + add_versions("v1.9.0", "26d32a79f786cca1004750f59e545199bf110e21e300d3c2424c1fddd78f28ab") + add_versions("v1.10.1", "0bd650190d4405c15894055e349d9b59d5690b0389551d757c5ed2d3841972d1") + add_versions("v1.10.2", "6fa359f491fac7e5185273c6421a000eea6a2f0febf0ac03ac900bd4d80ed2a5") + add_versions("v1.11.0", "21915277db59756bfc61f6f281c1f5e3897760b63776fd3d360f77dd7364137f") + add_versions("v1.11.1", "482ecb23c59ae3d4f158029112de172dd96bb0e97549c4b1ca32d8fad11f873e") + add_versions("v1.12.1", "89a287444b5b3e98f88a945afa50ce937b8ffd1dcc59c555ad9b1baf855298c9") elseif is_host("linux", "bsd") then - add_urls("https://github.com/ninja-build/ninja/archive/refs/tags/v$(version).tar.gz", + add_urls("https://github.com/ninja-build/ninja/archive/refs/tags/$(version).tar.gz", "https://github.com/ninja-build/ninja.git") - add_versions("1.9.0", "5d7ec75828f8d3fd1a0c2f31b5b0cea780cdfe1031359228c428c1a48bfcd5b9") - add_versions("1.10.1", "a6b6f7ac360d4aabd54e299cc1d8fa7b234cd81b9401693da21221c62569a23e") - add_versions("1.10.2", "ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed") - add_versions("1.11.0", "3c6ba2e66400fe3f1ae83deb4b235faf3137ec20bd5b08c29bfc368db143e4c6") - add_versions("1.11.1", "31747ae633213f1eda3842686f83c2aa1412e0f5691d1c14dbbcc67fe7400cea") + add_versions("v1.9.0", "5d7ec75828f8d3fd1a0c2f31b5b0cea780cdfe1031359228c428c1a48bfcd5b9") + add_versions("v1.10.1", "a6b6f7ac360d4aabd54e299cc1d8fa7b234cd81b9401693da21221c62569a23e") + add_versions("v1.10.2", "ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed") + add_versions("v1.11.0", "3c6ba2e66400fe3f1ae83deb4b235faf3137ec20bd5b08c29bfc368db143e4c6") + add_versions("v1.11.1", "31747ae633213f1eda3842686f83c2aa1412e0f5691d1c14dbbcc67fe7400cea") + add_versions("v1.12.1", "821bdff48a3f683bc4bb3b6f0b5fe7b2d647cf65d52aeb63328c91a6c6df285a") end on_load("linux", "bsd", function (package) - package:add("deps", package:version():ge("1.10.0") and "python" or "python2", {kind = "binary"}) + if package:is_built() then + package:add("deps", package:version():ge("1.10.0") and "python" or "python2", {kind = "binary"}) + end end) on_install("@windows", "@msys", "@cygwin", function (package) @@ -43,7 +54,13 @@ package("ninja") on_install("@linux", "@bsd", function (package) import("lib.detect.find_tool") local python = assert(find_tool("python"), "python not found!") - os.vrunv(python.program, {"configure.py", "--bootstrap"}) + local envs = {} + if package:has_tool("cxx", "gcc", "g++") then + envs.CXX = "g++" + elseif package:has_tool("cxx", "clang", "clang++") then + envs.CXX = "clang++" + end + os.vrunv(python.program, {"configure.py", "--bootstrap"}, {envs = envs}) os.cp("./ninja", package:installdir("bin")) end) diff --git a/packages/p/python2/xmake.lua b/packages/p/python2/xmake.lua index 053526429..11373b0f5 100644 --- a/packages/p/python2/xmake.lua +++ b/packages/p/python2/xmake.lua @@ -24,15 +24,15 @@ package("python2") add_versions("2.7.18", "da3080e3b488f648a3d7a4560ddee895284c3380b11d6de75edb986526b9a814") end - if not is_plat(os.host()) then + if not is_plat(os.host()) or not is_arch(os.arch()) then set_kind("binary") end - if is_host("macosx", "linux") then + if is_host("macosx", "linux", "bsd") then add_deps("openssl", "ca-certificates", {host = true}) end - if is_host("linux") then + if is_host("linux", "bsd") then add_deps("libffi", "zlib", {host = true}) add_syslinks("util", "pthread", "dl") end @@ -48,7 +48,7 @@ package("python2") package:addenv("PATH", "bin") end) - on_load("@macosx", "@linux", function (package) + on_load("@macosx", "@linux", "@bsd", function (package) -- set includedirs local version = package:version() @@ -72,10 +72,11 @@ package("python2") os.vrunv(python, {"-m", "pip", "install", "wheel"}) end) - on_install("@macosx", "@linux", function (package) + on_install("@macosx|x86_64", "@linux", "@bsd", function (package) -- init configs - local configs = {"--enable-ipv6", "--with-ensurepip"} + local configs = {"--enable-ipv6", "--with-ensurepip", "--enable-optimizations"} + table.insert(configs, "--libdir=" .. package:installdir("lib")) table.insert(configs, "--datadir=" .. package:installdir("share")) table.insert(configs, "--datarootdir=" .. package:installdir("share")) table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no")) @@ -83,6 +84,13 @@ package("python2") table.insert(configs, "--with-pic") end + -- add compiler settings + if package:has_tool("cxx", "gcc", "g++") then + table.insert(configs, "CXX=g++") + elseif package:has_tool("cxx", "clang", "clang++") then + table.insert(configs, "CXX=clang++") + end + -- add openssl libs path for detecting local openssl_dir local openssl = package:dep("openssl"):fetch() @@ -125,26 +133,6 @@ package("python2") xcode_sdkver = xcode_sdkver or get_config("xcode_sdkver") target_minver = target_minver or get_config("target_minver") - -- TODO will be deprecated after xmake v2.5.1 - xcode_sdkver = xcode_sdkver or get_config("xcode_sdkver_macosx") - if not xcode_dir or not xcode_sdkver then - -- maybe on cross platform, we need find xcode envs manually - local xcode = import("detect.sdks.find_xcode")(nil, {force = true, plat = package:plat(), arch = package:arch()}) - if xcode then - xcode_dir = xcode.sdkdir - xcode_sdkver = xcode.sdkver - end - end - - -- TODO will be deprecated after xmake v2.5.1 - target_minver = target_minver or get_config("target_minver_macosx") - if not target_minver then - local macos_ver = macos.version() - if macos_ver then - target_minver = macos_ver:major() .. "." .. macos_ver:minor() - end - end - if xcode_dir and xcode_sdkver then -- help Python's build system (setuptools/pip) to build things on SDK-based systems -- the setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot) @@ -199,12 +187,13 @@ package("python2") -- unset these so that installing pip and setuptools puts them where we want -- and not into some other Python the user has installed. - import("package.tools.autoconf").configure(package, configs, {envs = {PYTHONHOME = "", PYTHONPATH = ""}}) + import("package.tools.autoconf").configure(package, configs, {envs = {PYTHONHOME = "", PYTHONPATH = "", LD_LIBRARY_PATH = package:installdir("lib")}}) + os.vrunv("make", {"-j4", "PYTHONAPPSDIR=" .. package:installdir()}) os.vrunv("make", {"install", "-j4", "PYTHONAPPSDIR=" .. package:installdir()}) -- install wheel local python = path.join(package:installdir("bin"), "python") - os.vrunv(python, {"-m", "pip", "install", "wheel"}) + os.vrunv(python, {"-m", "pip", "install", "wheel"}, {envs = {LD_LIBRARY_PATH = package:installdir("lib")}}) end) on_test(function (package)