diff options
author | starkos <none@none> | 2008-12-06 00:18:47 +0300 |
---|---|---|
committer | starkos <none@none> | 2008-12-06 00:18:47 +0300 |
commit | 1c97171f69cd704db6e2aa0f93dec772d0e18792 (patch) | |
tree | 510d0446948106a73896c48f4a893039c23c4186 /src/tools | |
parent | bd14e9a2f368cc2ef858669a8431456480ab2990 (diff) |
Big refactoring, bug fixes bug and small, performance improvements (branches/csharp r607:628)
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/csc.lua | 49 | ||||
-rw-r--r-- | src/tools/gcc.lua | 140 | ||||
-rw-r--r-- | src/tools/ow.lua | 109 |
3 files changed, 298 insertions, 0 deletions
diff --git a/src/tools/csc.lua b/src/tools/csc.lua new file mode 100644 index 0000000..035246c --- /dev/null +++ b/src/tools/csc.lua @@ -0,0 +1,49 @@ +-- +-- csc.lua +-- Interface for the C# compilers, all of which are flag compatible. +-- Copyright (c) 2002-2008 Jason Perkins and the Premake project +-- + + + premake.csc = { } + + +-- +-- Translation of Premake flags into CSC flags +-- + + local flags = + { + FatalWarning = "/warnaserror", + Optimize = "/optimize", + OptimizeSize = "/optimize", + OptimizeSpeed = "/optimize", + Symbols = "/debug", + Unsafe = "/unsafe" + } + + + +-- +-- Returns the compiler filename (they all use the same arguments) +-- + + function premake.csc.getcompilervar(cfg) + if (_OPTIONS.dotnet == "ms") then + return "csc" + elseif (_OPTIONS.dotnet == "mono") then + return "mcs" + else + return "cscc" + end + end + + +-- +-- Returns a list of compiler flags, based on the supplied configuration. +-- + + function premake.csc.getflags(cfg) + local result = table.translate(cfg.flags, flags) + return result + end diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua new file mode 100644 index 0000000..9a8092f --- /dev/null +++ b/src/tools/gcc.lua @@ -0,0 +1,140 @@ +-- +-- gcc.lua +-- Provides GCC-specific configuration strings. +-- Copyright (c) 2002-2008 Jason Perkins and the Premake project +-- + + + premake.gcc = { } + premake.targetstyle = "linux" + + +-- +-- Translation of Premake flags into GCC flags +-- + + local cflags = + { + ExtraWarnings = "-Wall", + FatalWarning = "-Werror", + NoFramePointer = "-fomit-frame-pointer", + Optimize = "-O2", + OptimizeSize = "-Os", + OptimizeSpeed = "-O3", + Symbols = "-g", + } + + local cxxflags = + { + NoExceptions = "--no-exceptions", + NoRTTI = "--no-rtti", + } + + + + +-- +-- Returns a list of compiler flags, based on the supplied configuration. +-- + + function premake.gcc.getcppflags(cfg) + -- if $(ARCH) contains multiple targets, then disable the incompatible automatic + -- dependency generation. This allows building universal binaries on MacOSX, sorta. + return "$(if $(word 2, $(ARCH)), , -MMD)" + end + + function premake.gcc.getcflags(cfg) + local result = table.translate(cfg.flags, cflags) + if (cfg.kind == "SharedLib" and not os.is("windows")) then + table.insert(result, "-fPIC") + end + return result + end + + function premake.gcc.getcxxflags(cfg) + local result = table.translate(cfg.flags, cxxflags) + return result + end + + + +-- +-- Returns a list of linker flags, based on the supplied configuration. +-- + + function premake.gcc.getldflags(cfg) + local result = { } + + if (cfg.kind == "SharedLib") then + if os.is("macosx") then + result = table.join(result, { "-dynamiclib", "-flat_namespace" }) + else + table.insert(result, "-shared") + end + + -- create import library for DLLs under Windows + if (os.is("windows") and not cfg.flags.NoImportLib) then + table.insert(result, '-Wl,--out-implib="'..premake.gettarget(cfg, "link", "linux").fullpath..'"') + end + end + + if (os.is("windows") and cfg.kind == "WindowedApp") then + table.insert(result, "-mwindows") + end + + -- OS X has a bug, see http://lists.apple.com/archives/Darwin-dev/2006/Sep/msg00084.html + if (not cfg.flags.Symbols) then + if (os.is("macosx")) then + table.insert(result, "-Wl,-x") + else + table.insert(result, "-s") + end + end + + return result + end + + +-- +-- Returns a list of linker flags for library search directories and library +-- names. See bug #1729227 for background on why the path must be split. +-- + + function premake.gcc.getlinkflags(cfg) + local result = { } + for _, value in ipairs(premake.getlinks(cfg, "all", "directory")) do + table.insert(result, '-L' .. _MAKE.esc(value)) + end + for _, value in ipairs(premake.getlinks(cfg, "all", "basename")) do + table.insert(result, '-l' .. _MAKE.esc(value)) + end + return result + end + + + +-- +-- Decorate defines for the GCC command line. +-- + + function premake.gcc.getdefines(defines) + local result = { } + for _,def in ipairs(defines) do + table.insert(result, '-D' .. def) + end + return result + end + + + +-- +-- Decorate include file search paths for the GCC command line. +-- + + function premake.gcc.getincludedirs(includedirs) + local result = { } + for _,dir in ipairs(includedirs) do + table.insert(result, '-I "' .. dir .. '"') + end + return result + end diff --git a/src/tools/ow.lua b/src/tools/ow.lua new file mode 100644 index 0000000..f3b828e --- /dev/null +++ b/src/tools/ow.lua @@ -0,0 +1,109 @@ +-- +-- ow.lua +-- Provides Open Watcom-specific configuration strings. +-- Copyright (c) 2008 Jason Perkins and the Premake project +-- + + premake.ow = { } + premake.ow.targetstyle = "windows" + + +-- +-- Translation of Premake flags into OpenWatcom flags +-- + + local cflags = + { + ExtraWarnings = "-wx", + FatalWarning = "-we", + Optimize = "-ox", + OptimizeSize = "-os", + OptimizeSpeed = "-ot", + Symbols = "-d2", + } + + local cxxflags = + { + NoExceptions = "-xd", + NoRTTI = "-xr", + } + + + + +-- +-- Returns a list of compiler flags, based on the supplied configuration. +-- + + function premake.ow.getcppflags(cfg) + return "" + end + + function premake.ow.getcflags(cfg) + local result = table.translate(cfg.flags, cflags) + if (cfg.flags.Symbols) then + table.insert(result, "-hw") -- Watcom debug format for Watcom debugger + end + return result + end + + function premake.ow.getcxxflags(cfg) + local result = table.translate(cfg.flags, cxxflags) + return result + end + + + +-- +-- Returns a list of linker flags, based on the supplied configuration. +-- + + function premake.ow.getldflags(cfg) + local result = { } + + if (cfg.flags.Symbols) then + table.insert(result, "op symf") + end + + return result + end + + +-- +-- Returns a list of linker flags for library search directories and +-- library names. +-- + + function premake.ow.getlinkflags(cfg) + local result = { } + return result + end + + + +-- +-- Decorate defines for the command line. +-- + + function premake.ow.getdefines(defines) + local result = { } + for _,def in ipairs(defines) do + table.insert(result, '-D' .. def) + end + return result + end + + + +-- +-- Decorate include file search paths for the command line. +-- + + function premake.ow.getincludedirs(includedirs) + local result = { } + for _,dir in ipairs(includedirs) do + table.insert(result, '-I "' .. dir .. '"') + end + return result + end + |