link.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. rule("xp")
  2. on_config(function (target)
  3. local objectfile = "YY_Thunks_for_WinXP.obj"
  4. local thunks = target:pkg("yy-thunks")
  5. if thunks then
  6. local installdir = thunks:installdir()
  7. table.insert(target:objectfiles(), path.join(installdir, "lib", objectfile))
  8. end
  9. end)
  10. rule("vista")
  11. on_config(function (target)
  12. local objectfile = "YY_Thunks_for_Vista.obj"
  13. local thunks = target:pkg("yy-thunks")
  14. if thunks then
  15. local installdir = thunks:installdir()
  16. table.insert(target:objectfiles(), path.join(installdir, "lib", objectfile))
  17. end
  18. end)
  19. rule("2k")
  20. on_config(function (target)
  21. if not target:is_arch("x86") then
  22. raise("Win2K only supports x86 architecture")
  23. end
  24. local objectfile = "YY_Thunks_for_Win2K.obj"
  25. local thunks = target:pkg("yy-thunks")
  26. if thunks then
  27. local installdir = thunks:installdir()
  28. table.insert(target:objectfiles(), path.join(installdir, "lib", objectfile))
  29. end
  30. end)
  31. after_link(function (target, opt)
  32. import("core.project.depend")
  33. import("lib.detect.find_tool")
  34. import("utils.progress")
  35. depend.on_changed(function()
  36. local msvc = target:toolchain("msvc")
  37. local editbin = assert(find_tool("editbin", {envs = msvc:runenvs()}), "editbin not found!")
  38. -- osversion -> Major/Minor OperatingSystemVersion
  39. -- subsystem -> Major/Minor SubsystemVersion
  40. os.iorunv(editbin.program, {"/osversion:5.0", "/subsystem:console,5.0", target:targetfile()})
  41. progress.show(opt.progress, "${color.build.target}editing.$(mode) %s", target:filename())
  42. end, {files = {target:targetfile()}})
  43. end)