summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/genie/src/actions/make/make_csharp.lua
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/genie/src/actions/make/make_csharp.lua')
-rw-r--r--3rdparty/genie/src/actions/make/make_csharp.lua56
1 files changed, 29 insertions, 27 deletions
diff --git a/3rdparty/genie/src/actions/make/make_csharp.lua b/3rdparty/genie/src/actions/make/make_csharp.lua
index e241e11dc42..ea6a0fcf410 100644
--- a/3rdparty/genie/src/actions/make/make_csharp.lua
+++ b/3rdparty/genie/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
+ local name = cfg.buildtarget.basename .. "."
+ local dir = path.getdirectory(fname)
+ 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,19 +78,19 @@
copypairs[target] = _MAKE.esc(source)
end
end
-
+
-- end of preprocessing --
-- set up the environment
_p('# %s project makefile autogenerated by GENie', 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')
@@ -122,7 +122,7 @@
_p(' CSC=%s', csc.getcompilervar(prj))
_p('endif')
_p('')
-
+
_p('ifndef RESGEN')
_p(' RESGEN=resgen')
_p('endif')
@@ -145,14 +145,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))
@@ -184,10 +184,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)')
@@ -197,7 +197,7 @@
-- escaping, causing issues with spaces and parenthesis
_p('$(TARGETDIR):')
premake.make_mkdirrule("$(TARGETDIR)")
-
+
_p('$(OBJDIR):')
premake.make_mkdirrule("$(OBJDIR)")
@@ -205,7 +205,7 @@
_p('clean:')
_p('\t@echo Cleaning %s', prj.name)
_p('ifeq (posix,$(SHELLTYPE))')
- _p('\t$(SILENT) rm -f $(TARGETDIR)/%s.* $(COPYFILES)', prj.buildtarget.basename)
+ _p('\t$(SILENT) rm -f $(TARGET) $(COPYFILES)')
_p('\t$(SILENT) rm -rf $(OBJDIR)')
_p('else')
_p('\t$(SILENT) if exist $(subst /,\\\\,$(TARGETDIR)/%s.*) del $(subst /,\\\\,$(TARGETDIR)/%s.*)', prj.buildtarget.basename, prj.buildtarget.basename)
@@ -223,7 +223,7 @@
_p('prebuild:')
_p('\t$(PREBUILDCMDS)')
_p('')
-
+
_p('prelink:')
_p('\t$(PRELINKCMDS)')
_p('')
@@ -238,21 +238,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
@@ -261,35 +261,37 @@
--
function premake.gmake_cs_config(cfg, csc, cfglibs)
-
+
+ local targetDir = _MAKE.esc(cfg.buildtarget.directory)
+
_p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower()))
- _p(' TARGETDIR := %s', _MAKE.esc(cfg.buildtarget.directory))
+ _p(' TARGETDIR := %s', iif(targetDir == "", ".", targetDir))
_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('')