link.lua 2.1 KB

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