diff options
Diffstat (limited to 'src/actions/make/make_csharp.lua')
-rw-r--r-- | src/actions/make/make_csharp.lua | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/actions/make/make_csharp.lua b/src/actions/make/make_csharp.lua index 102db6e..12dfda5 100644 --- a/src/actions/make/make_csharp.lua +++ b/src/actions/make/make_csharp.lua @@ -8,12 +8,12 @@ -- Given a .resx resource file, builds the path to corresponding .resource -- file, matching the behavior and naming of Visual Studio. -- - + local function getresourcefilename(cfg, fname) if path.getextension(fname) == ".resx" then local name = cfg.buildtarget.basename .. "." local dir = path.getdirectory(fname) - if dir ~= "." then + if dir ~= "." then name = name .. path.translate(dir, ".") .. "." end return "$(OBJDIR)/" .. _MAKE.esc(name .. path.getbasename(fname)) .. ".resources" @@ -27,7 +27,7 @@ -- -- Main function -- - + function premake.make_csharp(prj) local csc = premake.dotnet @@ -47,12 +47,12 @@ end end end - + -- sort the files into categories, based on their build action local sources = {} local embedded = { } local copypairs = { } - + for fcfg in premake.project.eachfile(prj) do local action = csc.getbuildaction(fcfg) if action == "Compile" then @@ -78,29 +78,29 @@ copypairs[target] = _MAKE.esc(source) end end - + -- end of preprocessing -- -- set up the environment _p('# %s project makefile autogenerated by Premake', premake.action.current().shortname) _p('') - + _p('ifndef config') _p(' config=%s', _MAKE.esc(prj.configurations[1]:lower())) _p('endif') _p('') - + _p('ifndef verbose') _p(' SILENT = @') _p('endif') _p('') - + _p('ifndef CSC') _p(' CSC=%s', csc.getcompilervar(prj)) _p('endif') _p('') - + _p('ifndef RESGEN') _p(' RESGEN=resgen') _p('endif') @@ -123,14 +123,14 @@ _p('FLAGS += /t:%s %s', csc.getkind(prj):lower(), table.implode(_MAKE.esc(prj.libdirs), "/lib:", "", " ")) _p('REFERENCES += %s', table.implode(_MAKE.esc(premake.getlinks(prj, "system", "basename")), "/r:", ".dll", " ")) _p('') - + -- list source files _p('SOURCES := \\') for _, fname in ipairs(sources) do _p('\t%s \\', _MAKE.esc(path.translate(fname))) end _p('') - + _p('EMBEDFILES := \\') for _, fname in ipairs(embedded) do _p('\t%s \\', getresourcefilename(prj, fname)) @@ -159,10 +159,10 @@ -- main build rule(s) _p('.PHONY: clean prebuild prelink') _p('') - + _p('all: $(TARGETDIR) $(OBJDIR) prebuild $(EMBEDFILES) $(COPYFILES) prelink $(TARGET)') _p('') - + _p('$(TARGET): $(SOURCES) $(EMBEDFILES) $(DEPENDS)') _p('\t$(SILENT) $(CSC) /nologo /out:$@ $(FLAGS) $(REFERENCES) $(SOURCES) $(patsubst %%,/resource:%%,$(EMBEDFILES))') _p('\t$(POSTBUILDCMDS)') @@ -172,7 +172,7 @@ -- escaping, causing issues with spaces and parenthesis _p('$(TARGETDIR):') premake.make_mkdirrule("$(TARGETDIR)") - + _p('$(OBJDIR):') premake.make_mkdirrule("$(OBJDIR)") @@ -198,7 +198,7 @@ _p('prebuild:') _p('\t$(PREBUILDCMDS)') _p('') - + _p('prelink:') _p('\t$(PRELINKCMDS)') _p('') @@ -213,21 +213,21 @@ _p('endif') _p('') end - + _p('# Copied file rules') for target, source in pairs(copypairs) do premake.make_copyrule(source, target) end _p('# Embedded file rules') - for _, fname in ipairs(embedded) do + for _, fname in ipairs(embedded) do if path.getextension(fname) == ".resx" then _p('%s: %s', getresourcefilename(prj, fname), _MAKE.esc(fname)) _p('\t$(SILENT) $(RESGEN) $^ $@') end _p('') end - + end @@ -236,35 +236,35 @@ -- function premake.gmake_cs_config(cfg, csc, cfglibs) - + _p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower())) _p(' TARGETDIR := %s', _MAKE.esc(cfg.buildtarget.directory)) _p(' OBJDIR := %s', _MAKE.esc(cfg.objectsdir)) _p(' DEPENDS := %s', table.concat(_MAKE.esc(premake.getlinks(cfg, "dependencies", "fullpath")), " ")) _p(' REFERENCES := %s', table.implode(_MAKE.esc(cfglibs[cfg]), "/r:", "", " ")) _p(' FLAGS += %s %s', table.implode(cfg.defines, "/d:", "", " "), table.concat(table.join(csc.getflags(cfg), cfg.buildoptions), " ")) - + _p(' define PREBUILDCMDS') if #cfg.prebuildcommands > 0 then _p('\t@echo Running pre-build commands') _p('\t%s', table.implode(cfg.prebuildcommands, "", "", "\n\t")) end _p(' endef') - + _p(' define PRELINKCMDS') if #cfg.prelinkcommands > 0 then _p('\t@echo Running pre-link commands') _p('\t%s', table.implode(cfg.prelinkcommands, "", "", "\n\t")) end _p(' endef') - + _p(' define POSTBUILDCMDS') if #cfg.postbuildcommands > 0 then _p('\t@echo Running post-build commands') _p('\t%s', table.implode(cfg.postbuildcommands, "", "", "\n\t")) end _p(' endef') - + _p('endif') _p('') |