1 CFLAGS
= "/O2 /Os /Oy /GF /GS- /GR- /EHs-c- /fp:fast /GL /QIfist /Gr /arch:IA32 /DAUTOBUILD"
2 LDFLAGS
= "/section:.bss,E /fixed:no /subsystem:native /merge:.data=.text /merge:.rdata=.text /merge:.1seg=.text /entry:crtStartUp /ltcg /nodefaultlib"
4 THISDIR
= tup
.getcwd() -- here it points to use_msvc.lua, inside rules it would be just "."
7 function compile_msvc(input
, output
)
8 if not output
then output
= '%B.obj' end
10 tup
.foreach_rule(input
, "cl /c " .. CFLAGS
.. " /Fo%o %f >&2", output
)
14 if tup
.getconfig("TUP_PLATFORM") == "win32"
15 then env_prefix
= "set EXENAME=%f&&" -- note that there should be no space between value and "&&"
16 else env_prefix
= "EXENAME=%f "
19 function link_msvc(input
, output
)
20 if not output
then input
,output
= OBJS
,input
end
22 if type(output
) ~= "string" then error("output for link_msvc should be simple string") end
23 local exename
= tup
.getvariantdir() .. "/" .. output
.. ".exe"
24 local mapname
= tup
.getvariantdir() .. "/" .. output
.. ".map"
26 tup
.rule(input
, "link.exe " .. LDFLAGS
.. " /out:%o /Map:" .. mapname
.. " %f", {exename
, extra_outputs
= {mapname
}})
27 tup
.rule(exename
, env_prefix
.. "fasm " .. THISDIR
.. "/../data/common/doexe2.asm %o " .. tup
.getconfig("KPACK_CMD"), output
)