Added support for Haiku OS (Yuriy O'Donnell)
This commit is contained in:
parent
b3dfe26ec6
commit
a69bcbfb58
@ -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)
|
||||
|
@ -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" }
|
||||
|
@ -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" },
|
||||
|
409
src/base/os.lua
409
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
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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,6 +23,28 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- CPPFLAGS tests
|
||||
--
|
||||
|
||||
function suite.cppflags_OnWindows()
|
||||
cfg.system = "windows"
|
||||
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
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- CFLAGS tests
|
||||
--
|
||||
|
||||
function suite.cflags_SharedLib_Windows()
|
||||
cfg.kind = "SharedLib"
|
||||
cfg.system = "windows"
|
||||
@ -31,14 +53,6 @@
|
||||
end
|
||||
|
||||
|
||||
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.cflags_OnFpFast()
|
||||
cfg.flags = { "FloatFast" }
|
||||
local r = premake.gcc.getcflags(cfg)
|
||||
@ -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)
|
Loading…
Reference in New Issue
Block a user