diff options
author | Jason Perkins <starkos@industriousone.com> | 2011-02-10 20:24:51 +0300 |
---|---|---|
committer | Jason Perkins <starkos@industriousone.com> | 2011-02-10 20:24:51 +0300 |
commit | 553185ac9c70b984af9049f32ea520f5f7458bd8 (patch) | |
tree | f64537fd006d8d4b61f1fbc9f855b6c3de7246e5 | |
parent | 914deb2e13ad0d08ad924f462a6c11c4ae28ed29 (diff) |
Added support for Haiku OS (Yuriy O'Donnell)
-rw-r--r-- | .hgignore | 1 | ||||
-rw-r--r-- | CHANGES.txt | 1 | ||||
-rw-r--r-- | premake4.lua | 2 | ||||
-rw-r--r-- | src/base/cmdline.lua | 3 | ||||
-rw-r--r-- | src/base/os.lua | 409 | ||||
-rw-r--r-- | src/host/premake.h | 137 | ||||
-rw-r--r-- | src/tools/gcc.lua | 26 | ||||
-rw-r--r-- | tests/base/test_os.lua | 247 | ||||
-rw-r--r-- | tests/premake4.lua | 4 | ||||
-rw-r--r-- | tests/tools/test_gcc.lua (renamed from tests/test_gcc.lua) | 42 |
10 files changed, 461 insertions, 411 deletions
@@ -6,6 +6,7 @@ build bin obj release +ipch src/host/scripts.c Makefile diff --git a/CHANGES.txt b/CHANGES.txt index 4925816..53a1214 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,7 @@ 4.4 (in progress) ------- +* Added support for Haiku OS (Yuriy O'Donnell) * Patch 2963313: Enable setting .NET framework version (Justen Hyde) * Switched PS3 builds from GCC to SNC * Ignore NoRTTI flag for Managed C++ projects (Nick Darnell) diff --git a/premake4.lua b/premake4.lua index 503930b..1646731 100644 --- a/premake4.lua +++ b/premake4.lua @@ -60,7 +60,7 @@ buildoptions { "-mmacosx-version-min=10.1" } linkoptions { "-lstdc++-static", "-mmacosx-version-min=10.1" } - configuration { "not windows", "not solaris" } + configuration { "linux", "bsd", "macosx" } linkoptions { "-rdynamic" } configuration { "solaris" } diff --git a/src/base/cmdline.lua b/src/base/cmdline.lua index 4b1433b..592edff 100644 --- a/src/base/cmdline.lua +++ b/src/base/cmdline.lua @@ -1,7 +1,7 @@ -- -- cmdline.lua -- Functions to define and handle command line actions and options. --- Copyright (c) 2002-2009 Jason Perkins and the Premake project +-- Copyright (c) 2002-2011 Jason Perkins and the Premake project -- @@ -52,6 +52,7 @@ description = "Generate files for a different operating system", allowed = { { "bsd", "OpenBSD, NetBSD, or FreeBSD" }, + { "haiku", "Haiku" }, { "linux", "Linux" }, { "macosx", "Apple Mac OS X" }, { "solaris", "Solaris" }, diff --git a/src/base/os.lua b/src/base/os.lua index a9a040e..59dc041 100644 --- a/src/base/os.lua +++ b/src/base/os.lua @@ -1,203 +1,206 @@ --- --- os.lua --- Additions to the OS namespace. --- Copyright (c) 2002-2010 Jason Perkins and the Premake project --- - - --- --- Same as os.execute(), but accepts string formatting arguments. --- - - function os.executef(cmd, ...) - cmd = string.format(cmd, unpack(arg)) - return os.execute(cmd) - end - - --- --- Scan the well-known system locations for a particular library. --- - - function os.findlib(libname) - local path, formats - - -- assemble a search path, depending on the platform - if os.is("windows") then - formats = { "%s.dll", "%s" } - path = os.getenv("PATH") - else - if os.is("macosx") then - formats = { "lib%s.dylib", "%s.dylib" } - path = os.getenv("DYLD_LIBRARY_PATH") - else - formats = { "lib%s.so", "%s.so" } - path = os.getenv("LD_LIBRARY_PATH") or "" - - io.input("/etc/ld.so.conf") - if io.input() then - for line in io.lines() do - path = path .. ":" .. line - end - io.input():close() - end - end - - table.insert(formats, "%s") - path = (path or "") .. ":/lib:/usr/lib:/usr/local/lib" - end - - for _, fmt in ipairs(formats) do - local name = string.format(fmt, libname) - local result = os.pathsearch(name, path) - if result then return result end - end - end - - - --- --- Retrieve the current operating system ID string. --- - - function os.get() - return _OPTIONS.os or _OS - end - - - --- --- Check the current operating system; may be set with the /os command line flag. --- - - function os.is(id) - return (os.get():lower() == id:lower()) - end - - - --- --- The os.matchdirs() and os.matchfiles() functions --- - - local function domatch(result, mask, wantfiles) - -- need to remove extraneous path info from the mask to ensure a match - -- against the paths returned by the OS. Haven't come up with a good - -- way to do it yet, so will handle cases as they come up - if mask:startswith("./") then - mask = mask:sub(3) - end - - -- strip off any leading directory information to find out - -- where the search should take place - local basedir = mask - local starpos = mask:find("%*") - if starpos then - basedir = basedir:sub(1, starpos - 1) - end - basedir = path.getdirectory(basedir) - if (basedir == ".") then basedir = "" end - - -- recurse into subdirectories? - local recurse = mask:find("**", nil, true) - - -- convert mask to a Lua pattern - mask = path.wildcards(mask) - - local function matchwalker(basedir) - local wildcard = path.join(basedir, "*") - - -- retrieve files from OS and test against mask - local m = os.matchstart(wildcard) - while (os.matchnext(m)) do - local isfile = os.matchisfile(m) - if ((wantfiles and isfile) or (not wantfiles and not isfile)) then - local fname = path.join(basedir, os.matchname(m)) - if fname:match(mask) == fname then - table.insert(result, fname) - end - end - end - os.matchdone(m) - - -- check subdirectories - if recurse then - m = os.matchstart(wildcard) - while (os.matchnext(m)) do - if not os.matchisfile(m) then - local dirname = os.matchname(m) - matchwalker(path.join(basedir, dirname)) - end - end - os.matchdone(m) - end - end - - matchwalker(basedir) - end - - function os.matchdirs(...) - local result = { } - for _, mask in ipairs(arg) do - domatch(result, mask, false) - end - return result - end - - function os.matchfiles(...) - local result = { } - for _, mask in ipairs(arg) do - domatch(result, mask, true) - end - return result - end - - - --- --- An overload of the os.mkdir() function, which will create any missing --- subdirectories along the path. --- - - local builtin_mkdir = os.mkdir - function os.mkdir(p) - local dir = iif(p:startswith("/"), "/", "") - for part in p:gmatch("[^/]+") do - dir = dir .. part - - if (part ~= "" and not path.isabsolute(part) and not os.isdir(dir)) then - local ok, err = builtin_mkdir(dir) - if (not ok) then - return nil, err - end - end - - dir = dir .. "/" - end - - return true - end - - --- --- Remove a directory, along with any contained files or subdirectories. --- - - local builtin_rmdir = os.rmdir - function os.rmdir(p) - -- recursively remove subdirectories - local dirs = os.matchdirs(p .. "/*") - for _, dname in ipairs(dirs) do - os.rmdir(dname) - end - - -- remove any files - local files = os.matchfiles(p .. "/*") - for _, fname in ipairs(files) do - os.remove(fname) - end - - -- remove this directory - builtin_rmdir(p) - end - +--
+-- os.lua
+-- Additions to the OS namespace.
+-- Copyright (c) 2002-2011 Jason Perkins and the Premake project
+--
+
+
+--
+-- Same as os.execute(), but accepts string formatting arguments.
+--
+
+ function os.executef(cmd, ...)
+ cmd = string.format(cmd, unpack(arg))
+ return os.execute(cmd)
+ end
+
+
+--
+-- Scan the well-known system locations for a particular library.
+--
+
+ function os.findlib(libname)
+ local path, formats
+
+ -- assemble a search path, depending on the platform
+ if os.is("windows") then
+ formats = { "%s.dll", "%s" }
+ path = os.getenv("PATH")
+ elseif os.is("haiku") then
+ formats = { "lib%s.so", "%s.so" }
+ path = os.getenv("LIBRARY_PATH")
+ else
+ if os.is("macosx") then
+ formats = { "lib%s.dylib", "%s.dylib" }
+ path = os.getenv("DYLD_LIBRARY_PATH")
+ else
+ formats = { "lib%s.so", "%s.so" }
+ path = os.getenv("LD_LIBRARY_PATH") or ""
+
+ io.input("/etc/ld.so.conf")
+ if io.input() then
+ for line in io.lines() do
+ path = path .. ":" .. line
+ end
+ io.input():close()
+ end
+ end
+
+ table.insert(formats, "%s")
+ path = (path or "") .. ":/lib:/usr/lib:/usr/local/lib"
+ end
+
+ for _, fmt in ipairs(formats) do
+ local name = string.format(fmt, libname)
+ local result = os.pathsearch(name, path)
+ if result then return result end
+ end
+ end
+
+
+
+--
+-- Retrieve the current operating system ID string.
+--
+
+ function os.get()
+ return _OPTIONS.os or _OS
+ end
+
+
+
+--
+-- Check the current operating system; may be set with the /os command line flag.
+--
+
+ function os.is(id)
+ return (os.get():lower() == id:lower())
+ end
+
+
+
+--
+-- The os.matchdirs() and os.matchfiles() functions
+--
+
+ local function domatch(result, mask, wantfiles)
+ -- need to remove extraneous path info from the mask to ensure a match
+ -- against the paths returned by the OS. Haven't come up with a good
+ -- way to do it yet, so will handle cases as they come up
+ if mask:startswith("./") then
+ mask = mask:sub(3)
+ end
+
+ -- strip off any leading directory information to find out
+ -- where the search should take place
+ local basedir = mask
+ local starpos = mask:find("%*")
+ if starpos then
+ basedir = basedir:sub(1, starpos - 1)
+ end
+ basedir = path.getdirectory(basedir)
+ if (basedir == ".") then basedir = "" end
+
+ -- recurse into subdirectories?
+ local recurse = mask:find("**", nil, true)
+
+ -- convert mask to a Lua pattern
+ mask = path.wildcards(mask)
+
+ local function matchwalker(basedir)
+ local wildcard = path.join(basedir, "*")
+
+ -- retrieve files from OS and test against mask
+ local m = os.matchstart(wildcard)
+ while (os.matchnext(m)) do
+ local isfile = os.matchisfile(m)
+ if ((wantfiles and isfile) or (not wantfiles and not isfile)) then
+ local fname = path.join(basedir, os.matchname(m))
+ if fname:match(mask) == fname then
+ table.insert(result, fname)
+ end
+ end
+ end
+ os.matchdone(m)
+
+ -- check subdirectories
+ if recurse then
+ m = os.matchstart(wildcard)
+ while (os.matchnext(m)) do
+ if not os.matchisfile(m) then
+ local dirname = os.matchname(m)
+ matchwalker(path.join(basedir, dirname))
+ end
+ end
+ os.matchdone(m)
+ end
+ end
+
+ matchwalker(basedir)
+ end
+
+ function os.matchdirs(...)
+ local result = { }
+ for _, mask in ipairs(arg) do
+ domatch(result, mask, false)
+ end
+ return result
+ end
+
+ function os.matchfiles(...)
+ local result = { }
+ for _, mask in ipairs(arg) do
+ domatch(result, mask, true)
+ end
+ return result
+ end
+
+
+
+--
+-- An overload of the os.mkdir() function, which will create any missing
+-- subdirectories along the path.
+--
+
+ local builtin_mkdir = os.mkdir
+ function os.mkdir(p)
+ local dir = iif(p:startswith("/"), "/", "")
+ for part in p:gmatch("[^/]+") do
+ dir = dir .. part
+
+ if (part ~= "" and not path.isabsolute(part) and not os.isdir(dir)) then
+ local ok, err = builtin_mkdir(dir)
+ if (not ok) then
+ return nil, err
+ end
+ end
+
+ dir = dir .. "/"
+ end
+
+ return true
+ end
+
+
+--
+-- Remove a directory, along with any contained files or subdirectories.
+--
+
+ local builtin_rmdir = os.rmdir
+ function os.rmdir(p)
+ -- recursively remove subdirectories
+ local dirs = os.matchdirs(p .. "/*")
+ for _, dname in ipairs(dirs) do
+ os.rmdir(dname)
+ end
+
+ -- remove any files
+ local files = os.matchfiles(p .. "/*")
+ for _, fname in ipairs(files) do
+ os.remove(fname)
+ end
+
+ -- remove this directory
+ builtin_rmdir(p)
+ end
+
diff --git a/src/host/premake.h b/src/host/premake.h index 4358b18..0c83571 100644 --- a/src/host/premake.h +++ b/src/host/premake.h @@ -1,67 +1,70 @@ -/** - * \file premake.h - * \brief Program-wide constants and definitions. - * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project - */ - -#define lua_c -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - - -/* Identify the current platform I'm not sure how to reliably detect - * Windows but since it is the most common I use it as the default */ -#if defined(__linux__) -#define PLATFORM_LINUX (1) -#define PLATFORM_STRING "linux" -#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) -#define PLATFORM_BSD (1) -#define PLATFORM_STRING "bsd" -#elif defined(__APPLE__) && defined(__MACH__) -#define PLATFORM_MACOSX (1) -#define PLATFORM_STRING "macosx" -#elif defined(__sun__) && defined(__svr4__) -#define PLATFORM_SOLARIS (1) -#define PLATFORM_STRING "solaris" -#else -#define PLATFORM_WINDOWS (1) -#define PLATFORM_STRING "windows" -#endif - - -/* Pull in platform-specific headers required by built-in functions */ -#if PLATFORM_WINDOWS -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#else -#include <unistd.h> -#endif - - -/* A success return code */ -#define OKAY (0) - - -/* Bootstrapping helper functions */ -int do_isfile(const char* filename); - - -/* Built-in functions */ -int path_isabsolute(lua_State* L); -int os_chdir(lua_State* L); -int os_copyfile(lua_State* L); -int os_getcwd(lua_State* L); -int os_isdir(lua_State* L); -int os_isfile(lua_State* L); -int os_matchdone(lua_State* L); -int os_matchisfile(lua_State* L); -int os_matchname(lua_State* L); -int os_matchnext(lua_State* L); -int os_matchstart(lua_State* L); -int os_mkdir(lua_State* L); -int os_pathsearch(lua_State* L); -int os_rmdir(lua_State* L); -int os_uuid(lua_State* L); -int string_endswith(lua_State* L); - +/**
+ * \file premake.h
+ * \brief Program-wide constants and definitions.
+ * \author Copyright (c) 2002-2011 Jason Perkins and the Premake project
+ */
+
+#define lua_c
+#include "lua.h"
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+/* Identify the current platform I'm not sure how to reliably detect
+ * Windows but since it is the most common I use it as the default */
+#if defined(__linux__)
+#define PLATFORM_LINUX (1)
+#define PLATFORM_STRING "linux"
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#define PLATFORM_BSD (1)
+#define PLATFORM_STRING "bsd"
+#elif defined(__APPLE__) && defined(__MACH__)
+#define PLATFORM_MACOSX (1)
+#define PLATFORM_STRING "macosx"
+#elif defined(__sun__) && defined(__svr4__)
+#define PLATFORM_SOLARIS (1)
+#define PLATFORM_STRING "solaris"
+#elif defined(__HAIKU__)
+#define PLATFORM_HAIKU (1)
+#define PLATFORM_STRING "haiku"
+#else
+#define PLATFORM_WINDOWS (1)
+#define PLATFORM_STRING "windows"
+#endif
+
+
+/* Pull in platform-specific headers required by built-in functions */
+#if PLATFORM_WINDOWS
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
+
+/* A success return code */
+#define OKAY (0)
+
+
+/* Bootstrapping helper functions */
+int do_isfile(const char* filename);
+
+
+/* Built-in functions */
+int path_isabsolute(lua_State* L);
+int os_chdir(lua_State* L);
+int os_copyfile(lua_State* L);
+int os_getcwd(lua_State* L);
+int os_isdir(lua_State* L);
+int os_isfile(lua_State* L);
+int os_matchdone(lua_State* L);
+int os_matchisfile(lua_State* L);
+int os_matchname(lua_State* L);
+int os_matchnext(lua_State* L);
+int os_matchstart(lua_State* L);
+int os_mkdir(lua_State* L);
+int os_pathsearch(lua_State* L);
+int os_rmdir(lua_State* L);
+int os_uuid(lua_State* L);
+int string_endswith(lua_State* L);
+
diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 1f5fc74..7adb9a0 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -1,7 +1,7 @@ -- -- gcc.lua -- Provides GCC-specific configuration strings. --- Copyright (c) 2002-2008 Jason Perkins and the Premake project +-- Copyright (c) 2002-2011 Jason Perkins and the Premake project -- @@ -50,15 +50,15 @@ premake.gcc.platforms = { Native = { - cppflags = "-MMD -MP", + cppflags = "-MMD", }, x32 = { - cppflags = "-MMD -MP", + cppflags = "-MMD", flags = "-m32", ldflags = "-L/usr/lib32", }, x64 = { - cppflags = "-MMD -MP", + cppflags = "-MMD", flags = "-m64", ldflags = "-L/usr/lib64", }, @@ -78,7 +78,7 @@ cc = "ppu-lv2-g++", cxx = "ppu-lv2-g++", ar = "ppu-lv2-ar", - cppflags = "-MMD -MP", + cppflags = "-MMD", } } @@ -90,11 +90,20 @@ -- function premake.gcc.getcppflags(cfg) - local result = { } - table.insert(result, platforms[cfg.platform].cppflags) - return result + local flags = { } + table.insert(flags, platforms[cfg.platform].cppflags) + + -- We want the -MP flag for dependency generation (creates phony rules + -- for headers, prevents make errors if file is later deleted), but + -- Haiku doesn't support it (yet) + if flags[1]:startswith("-MMD") and cfg.system ~= "haiku" then + table.insert(flags, "-MP") + end + + return flags end + function premake.gcc.getcflags(cfg) local result = table.translate(cfg.flags, cflags) table.insert(result, platforms[cfg.platform].flags) @@ -104,6 +113,7 @@ return result end + function premake.gcc.getcxxflags(cfg) local result = table.translate(cfg.flags, cxxflags) return result diff --git a/tests/base/test_os.lua b/tests/base/test_os.lua index 9bcd230..fb720c9 100644 --- a/tests/base/test_os.lua +++ b/tests/base/test_os.lua @@ -1,121 +1,126 @@ --- --- tests/base/test_os.lua --- Automated test suite for the new OS functions. --- Copyright (c) 2008-2010 Jason Perkins and the Premake project --- - - - T.os = { } - local suite = T.os - - --- --- os.findlib() tests --- - - function suite.findlib_FindSystemLib() - local libname = iif(os.is("windows"), "user32", "m") - test.istrue(os.findlib(libname)) - end - - function suite.findlib_FailsOnBadLibName() - test.isfalse(os.findlib("NoSuchLibraryAsThisOneHere")) - end - - --- --- os.isfile() tests --- - - function suite.isfile_ReturnsTrue_OnExistingFile() - test.istrue(os.isfile("premake4.lua")) - end - - function suite.isfile_ReturnsFalse_OnNonexistantFile() - test.isfalse(os.isfile("no_such_file.lua")) - end - - - --- --- os.matchfiles() tests --- - - function suite.matchfiles_OnNonRecursive() - local result = os.matchfiles("*.lua") - test.istrue(table.contains(result, "testfx.lua")) - test.isfalse(table.contains(result, "folder/ok.lua")) - end - - function suite.matchfiles_Recursive() - local result = os.matchfiles("**.lua") - test.istrue(table.contains(result, "folder/ok.lua")) - end - - function suite.matchfiles_SkipsDotDirs_OnRecursive() - local result = os.matchfiles("**.lua") - test.isfalse(table.contains(result, ".svn/text-base/testfx.lua.svn-base")) - end - - function suite.matchfiles_OnSubfolderMatch() - local result = os.matchfiles("**/xcode/*") - test.istrue(table.contains(result, "actions/xcode/test_xcode_project.lua")) - test.isfalse(table.contains(result, "premake4.lua")) - end - - function suite.matchfiles_OnDotSlashPrefix() - local result = os.matchfiles("./**.lua") - test.istrue(table.contains(result, "folder/ok.lua")) - end - - function suite.matchfiles_OnImplicitEndOfString() - local result = os.matchfiles("folder/*.lua") - test.istrue(table.contains(result, "folder/ok.lua")) - test.isfalse(table.contains(result, "folder/ok.lua.2")) - end - - function suite.matchfiles_OnLeadingDotSlashWithPath() - local result = os.matchfiles("./folder/*.lua") - test.istrue(table.contains(result, "folder/ok.lua")) - end - - - --- --- os.pathsearch() tests --- - - function suite.pathsearch_ReturnsNil_OnNotFound() - test.istrue( os.pathsearch("nosuchfile", "aaa;bbb;ccc") == nil ) - end - - function suite.pathsearch_ReturnsPath_OnFound() - test.isequal(os.getcwd(), os.pathsearch("premake4.lua", os.getcwd())) - end - - function suite.pathsearch_FindsFile_OnComplexPath() - test.isequal(os.getcwd(), os.pathsearch("premake4.lua", "aaa;"..os.getcwd()..";bbb")) - end - - function suite.pathsearch_NilPathsAllowed() - test.isequal(os.getcwd(), os.pathsearch("premake4.lua", nil, os.getcwd(), nil)) - end - - --- --- os.uuid() tests --- - - function suite.guid_ReturnsValidUUID() - local g = os.uuid() - test.istrue(#g == 36) - for i=1,36 do - local ch = g:sub(i,i) - test.istrue(ch:find("[ABCDEF0123456789-]")) - end - test.isequal("-", g:sub(9,9)) - test.isequal("-", g:sub(14,14)) - test.isequal("-", g:sub(19,19)) - test.isequal("-", g:sub(24,24)) - end - +--
+-- tests/base/test_os.lua
+-- Automated test suite for the new OS functions.
+-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
+--
+
+
+ T.os = { }
+ local suite = T.os
+
+
+--
+-- os.findlib() tests
+--
+
+ function suite.findlib_FindSystemLib()
+ if os.is("windows") then
+ test.istrue(os.findlib("user32"))
+ elseif os.is("haiku") then
+ test.istrue(os.findlib("root"))
+ else
+ test.istrue(os.findlib("m"))
+ end
+ end
+
+ function suite.findlib_FailsOnBadLibName()
+ test.isfalse(os.findlib("NoSuchLibraryAsThisOneHere"))
+ end
+
+
+--
+-- os.isfile() tests
+--
+
+ function suite.isfile_ReturnsTrue_OnExistingFile()
+ test.istrue(os.isfile("premake4.lua"))
+ end
+
+ function suite.isfile_ReturnsFalse_OnNonexistantFile()
+ test.isfalse(os.isfile("no_such_file.lua"))
+ end
+
+
+
+--
+-- os.matchfiles() tests
+--
+
+ function suite.matchfiles_OnNonRecursive()
+ local result = os.matchfiles("*.lua")
+ test.istrue(table.contains(result, "testfx.lua"))
+ test.isfalse(table.contains(result, "folder/ok.lua"))
+ end
+
+ function suite.matchfiles_Recursive()
+ local result = os.matchfiles("**.lua")
+ test.istrue(table.contains(result, "folder/ok.lua"))
+ end
+
+ function suite.matchfiles_SkipsDotDirs_OnRecursive()
+ local result = os.matchfiles("**.lua")
+ test.isfalse(table.contains(result, ".svn/text-base/testfx.lua.svn-base"))
+ end
+
+ function suite.matchfiles_OnSubfolderMatch()
+ local result = os.matchfiles("**/xcode/*")
+ test.istrue(table.contains(result, "actions/xcode/test_xcode_project.lua"))
+ test.isfalse(table.contains(result, "premake4.lua"))
+ end
+
+ function suite.matchfiles_OnDotSlashPrefix()
+ local result = os.matchfiles("./**.lua")
+ test.istrue(table.contains(result, "folder/ok.lua"))
+ end
+
+ function suite.matchfiles_OnImplicitEndOfString()
+ local result = os.matchfiles("folder/*.lua")
+ test.istrue(table.contains(result, "folder/ok.lua"))
+ test.isfalse(table.contains(result, "folder/ok.lua.2"))
+ end
+
+ function suite.matchfiles_OnLeadingDotSlashWithPath()
+ local result = os.matchfiles("./folder/*.lua")
+ test.istrue(table.contains(result, "folder/ok.lua"))
+ end
+
+
+
+--
+-- os.pathsearch() tests
+--
+
+ function suite.pathsearch_ReturnsNil_OnNotFound()
+ test.istrue( os.pathsearch("nosuchfile", "aaa;bbb;ccc") == nil )
+ end
+
+ function suite.pathsearch_ReturnsPath_OnFound()
+ test.isequal(os.getcwd(), os.pathsearch("premake4.lua", os.getcwd()))
+ end
+
+ function suite.pathsearch_FindsFile_OnComplexPath()
+ test.isequal(os.getcwd(), os.pathsearch("premake4.lua", "aaa;"..os.getcwd()..";bbb"))
+ end
+
+ function suite.pathsearch_NilPathsAllowed()
+ test.isequal(os.getcwd(), os.pathsearch("premake4.lua", nil, os.getcwd(), nil))
+ end
+
+
+--
+-- os.uuid() tests
+--
+
+ function suite.guid_ReturnsValidUUID()
+ local g = os.uuid()
+ test.istrue(#g == 36)
+ for i=1,36 do
+ local ch = g:sub(i,i)
+ test.istrue(ch:find("[ABCDEF0123456789-]"))
+ end
+ test.isequal("-", g:sub(9,9))
+ test.isequal("-", g:sub(14,14))
+ test.isequal("-", g:sub(19,19))
+ test.isequal("-", g:sub(24,24))
+ end
+
diff --git a/tests/premake4.lua b/tests/premake4.lua index 51d9691..48dd459 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -1,7 +1,7 @@ -- -- tests/premake4.lua -- Automated test suite for Premake 4.x --- Copyright (c) 2008-2010 Jason Perkins and the Premake project +-- Copyright (c) 2008-2011 Jason Perkins and the Premake project -- dofile("testfx.lua") @@ -44,7 +44,6 @@ dofile("test_platforms.lua") dofile("test_targets.lua") dofile("test_keywords.lua") - dofile("test_gcc.lua") dofile("test_gmake_cpp.lua") dofile("test_gmake_cs.lua") dofile("base/test_api.lua") @@ -55,6 +54,7 @@ dofile("base/test_path.lua") dofile("base/test_table.lua") dofile("base/test_tree.lua") + dofile("tools/test_gcc.lua") -- Clean tests dofile("actions/test_clean.lua") diff --git a/tests/test_gcc.lua b/tests/tools/test_gcc.lua index 9334ef3..c7fed84 100644 --- a/tests/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -1,7 +1,7 @@ -- -- tests/test_gcc.lua -- Automated test suite for the GCC toolset interface. --- Copyright (c) 2009 Jason Perkins and the Premake project +-- Copyright (c) 2009-2011 Jason Perkins and the Premake project -- T.gcc = { } @@ -23,19 +23,33 @@ end - function suite.cflags_SharedLib_Windows() - cfg.kind = "SharedLib" +-- +-- CPPFLAGS tests +-- + + function suite.cppflags_OnWindows() cfg.system = "windows" - local r = premake.gcc.getcflags(cfg) - test.isequal('', table.concat(r,"|")) + local r = premake.gcc.getcppflags(cfg) + test.isequal("-MMD -MP", table.concat(r, " ")) end + function suite.cppflags_OnHaiku() + cfg.system = "haiku" + local r = premake.gcc.getcppflags(cfg) + test.isequal("-MMD", table.concat(r, " ")) + end - function suite.ldflags_SharedLib_Windows() + + +-- +-- CFLAGS tests +-- + + function suite.cflags_SharedLib_Windows() cfg.kind = "SharedLib" cfg.system = "windows" - local r = premake.gcc.getldflags(cfg) - test.isequal('-s|-shared|-Wl,--out-implib="libMyProject.a"', table.concat(r,"|")) + local r = premake.gcc.getcflags(cfg) + test.isequal('', table.concat(r,"|")) end @@ -53,6 +67,18 @@ end +-- +-- LDFLAGS tests +-- + + function suite.ldflags_SharedLib_Windows() + cfg.kind = "SharedLib" + cfg.system = "windows" + local r = premake.gcc.getldflags(cfg) + test.isequal('-s|-shared|-Wl,--out-implib="libMyProject.a"', table.concat(r,"|")) + end + + function suite.linkflags_OnFrameworks() cfg.links = { "Cocoa.framework" } local r = premake.gcc.getlinkflags(cfg) |