소스 검색

support cross compilation for linux-headers (#752)

* Update xmake.lua

* Update xmake.lua
ruki 3 년 전
부모
커밋
ca291319f9
1개의 변경된 파일18개의 추가작업 그리고 4개의 파일을 삭제
  1. 18 4
      packages/l/linux-headers/xmake.lua

+ 18 - 4
packages/l/linux-headers/xmake.lua

@@ -26,7 +26,7 @@ package("linux-headers")
     end)
 
     on_fetch(function (package, opt)
-        if opt.system then
+        if opt.system and not package:is_cross() then
             import("lib.detect.find_path")
             local linux_headersdir = find_path("include/linux", "/usr/src/linux-headers-*")
             if linux_headersdir then
@@ -37,13 +37,27 @@ package("linux-headers")
         end
     end)
 
-    on_install("linux", function (package)
+    on_install("linux", "cross", function (package)
         import("package.tools.make")
         if package:config("driver_modules") then
             local installdir = package:installdir()
             os.cp("*", installdir)
-            make.make(package, {"allyesconfig"}, {curdir = installdir})
-            make.make(package, {"modules_prepare"}, {curdir = installdir})
+            if package:is_plat("cross") then
+                local arch
+                if package:is_arch("arm", "armv7") then
+                    arch = "arm"
+                elseif package:is_arch("arm64", "arm64-v8a") then
+                    arch = "arm64"
+                end
+                assert(arch, "unknown arch(%s)!", package:arch())
+                local cc = package:tool("cc")
+                local cross = cc:gsub("%-gcc$", "-")
+                make.make(package, {"ARCH=" .. arch, "CROSS_COMPILE=" .. cross, "allyesconfig"}, {curdir = installdir})
+                make.make(package, {"ARCH=" .. arch, "CROSS_COMPILE=" .. cross, "modules_prepare"}, {curdir = installdir})
+            else
+                make.make(package, {"allyesconfig"}, {curdir = installdir})
+                make.make(package, {"modules_prepare"}, {curdir = installdir})
+            end
             os.rm(path.join(installdir, "source"))
         else
             os.vrunv("make", {"headers_install", "INSTALL_HDR_PATH=" .. package:installdir()})