浏览代码

improve yy-thunks (#2105)

* improve yy-thunks

* improve code
star9029 2 年之前
父节点
当前提交
52715f90bb
共有 1 个文件被更改,包括 17 次插入0 次删除
  1. 17 0
      packages/y/yy-thunks/rules/link.lua

+ 17 - 0
packages/y/yy-thunks/rules/link.lua

@@ -24,9 +24,26 @@ rule("2k")
             raise("Win2K only supports x86 architecture")
             raise("Win2K only supports x86 architecture")
         end
         end
 
 
+        local objectfile = "YY_Thunks_for_Win2K.obj"
         local thunks = target:pkg("yy-thunks")
         local thunks = target:pkg("yy-thunks")
         if thunks then
         if thunks then
             local installdir = thunks:installdir()
             local installdir = thunks:installdir()
             table.insert(target:objectfiles(), path.join(installdir, "lib", objectfile))
             table.insert(target:objectfiles(), path.join(installdir, "lib", objectfile))
         end
         end
     end)
     end)
+
+    after_link(function (target, opt)
+        import("core.project.depend")
+        import("lib.detect.find_tool")
+        import("utils.progress")
+
+        depend.on_changed(function()
+            local msvc = target:toolchain("msvc")
+            local editbin = assert(find_tool("editbin", {envs = msvc:runenvs()}), "editbin not found!")
+
+            -- osversion -> Major/Minor OperatingSystemVersion
+            -- subsystem -> Major/Minor SubsystemVersion
+            os.iorunv(editbin.program, {"/osversion:5.0", "/subsystem:console,5.0", target:targetfile()})
+            progress.show(opt.progress, "${color.build.target}editing.$(mode) %s", target:filename())
+        end, {files = {target:targetfile()}})
+    end)