Przeglądaj źródła

improve check nsis (#6472)

ruki 5 miesięcy temu
rodzic
commit
00c0bcead7
1 zmienionych plików z 27 dodań i 1 usunięć
  1. 27 1
      packages/n/nsis/xmake.lua

+ 27 - 1
packages/n/nsis/xmake.lua

@@ -15,8 +15,34 @@ package("nsis")
 
     on_fetch(function (package, opt)
         if opt.system then
+            local function _check_makensis(program)
+                local tmpdir = os.tmpfile() .. ".dir"
+                io.writefile(path.join(tmpdir, "test.nsis"), [[
+                    !include "MUI2.nsh"
+                    !include "WordFunc.nsh"
+                    !include "WinMessages.nsh"
+                    !include "FileFunc.nsh"
+                    !include "UAC.nsh"
+
+                    Name "test"
+                    OutFile "test.exe"
+
+                    Function .onInit
+                    FunctionEnd
+
+                    Section "test" InstallExeutable
+                    SectionEnd
+
+                    Function un.onInit
+                    FunctionEnd
+
+                    Section "Uninstall"
+                    SectionEnd]])
+                os.runv(program, {"test.nsis"}, {curdir = tmpdir})
+                os.tryrm(tmpdir)
+            end
             -- we need return false to disable fallback fetch, it will stuck when call `nsis --version`
-            return package:find_tool("makensis", table.join({check = "/CMDHELP"}, opt)) or false
+            return package:find_tool("makensis", table.join({check = _check_makensis}, opt)) or false
         end
     end)