xmake.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("nsis")
  2. set_kind("binary")
  3. set_homepage("https://nsis.sourceforge.io/")
  4. set_description("NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers.")
  5. add_urls("https://sourceforge.net/projects/nsis/files/NSIS%203/$(version)/nsis-$(version).zip")
  6. add_urls("https://github.com/xmake-mirror/nsis/releases/download/$(version).zip", {version = function (version)
  7. return "v" .. (version:gsub("%.", "")) .. "/nsis-" .. version
  8. end})
  9. add_versions("3.09", "f5dc52eef1f3884230520199bac6f36b82d643d86b003ce51bd24b05c6ba7c91")
  10. add_resources("3.09", "uac", "https://github.com/xmake-mirror/nsis/releases/download/v309/UAC.zip", "20e3192af5598568887c16d88de59a52c2ce4a26e42c5fb8bee8105dcbbd1760")
  11. add_resources("3.09", "strlen_8192", "https://github.com/xmake-mirror/nsis/releases/download/v309/nsis-3.09-strlen_8192.zip", "9e3b8e77c97a46747201f95f89eba26714dd9c6dc06830c3934b3f5fbdb1beca")
  12. on_fetch(function (package, opt)
  13. if opt.system then
  14. local function _check_makensis(program)
  15. local tmpdir = os.tmpfile() .. ".dir"
  16. io.writefile(path.join(tmpdir, "test.nsis"), [[
  17. !include "MUI2.nsh"
  18. !include "WordFunc.nsh"
  19. !include "WinMessages.nsh"
  20. !include "FileFunc.nsh"
  21. !include "UAC.nsh"
  22. Name "test"
  23. OutFile "test.exe"
  24. Function .onInit
  25. FunctionEnd
  26. Section "test" InstallExeutable
  27. SectionEnd
  28. Function un.onInit
  29. FunctionEnd
  30. Section "Uninstall"
  31. SectionEnd]])
  32. os.runv(program, {"test.nsis"}, {curdir = tmpdir})
  33. os.tryrm(tmpdir)
  34. end
  35. -- we need return false to disable fallback fetch, it will stuck when call `nsis --version`
  36. return package:find_tool("makensis", table.join({check = _check_makensis}, opt)) or false
  37. end
  38. end)
  39. on_install("@windows|x64", "@windows|x86", function (package)
  40. os.cp("*", package:installdir())
  41. os.cp(path.join(package:resourcedir("strlen_8192"), "*"), package:installdir())
  42. os.cp(path.join(package:resourcedir("uac"), "UAC.nsh"), path.join(package:installdir(), "Include"))
  43. os.cp(path.join(package:resourcedir("uac"), "Plugins", "x86-ansi", "*.dll"), path.join(package:installdir(), "Plugins", "x86-ansi"))
  44. os.cp(path.join(package:resourcedir("uac"), "Plugins", "x86-unicode", "*.dll"), path.join(package:installdir(), "Plugins", "x86-unicode"))
  45. package:addenv("PATH", "Plugins/x86-unicode")
  46. end)
  47. on_test(function (package)
  48. os.runv("makensis", {"/CMDHELP"})
  49. end)