Initial community commit

This commit is contained in:
Jef
2024-09-24 14:54:57 +02:00
parent 537bcbc862
commit 20d28e80a5
16810 changed files with 4640254 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
--
-- tests/actions/make/test_make_escaping.lua
-- Validate the escaping of literal values in Makefiles.
-- Copyright (c) 2010 Jason Perkins and the Premake project
--
T.make_escaping = { }
local suite = T.make_escaping
function suite.Escapes_Spaces()
test.isequal("Program\\ Files", _MAKE.esc("Program Files"))
end
function suite.Escapes_Backslashes()
test.isequal("Program\\\\Files", _MAKE.esc("Program\\Files"))
end
function suite.Escapes_Parens()
test.isequal("Debug\\(x86\\)", _MAKE.esc("Debug(x86)"))
end
function suite.DoesNotEscape_ShellReplacements()
test.isequal("-L$(NVSDKCUDA_ROOT)/C/lib", _MAKE.esc("-L$(NVSDKCUDA_ROOT)/C/lib"))
end
function suite.CanEscape_ShellReplacementCapturesShortest()
test.isequal("a\\(x\\)b$(ROOT)c\\(y\\)d", _MAKE.esc("a(x)b$(ROOT)c(y)d"))
end

View File

@@ -0,0 +1,126 @@
--
-- tests/actions/make/test_make_linking.lua
-- Validate library references in makefiles.
-- Copyright (c) 2010-2013 Jason Perkins and the Premake project
--
T.gcc_linking = {}
local suite = T.gcc_linking
local cpp = premake.make.cpp
--
-- Setup
--
local sln, prj
function suite.setup()
_OS = "linux"
sln, prj = test.createsolution()
end
local function prepare()
premake.bake.buildconfigs()
cfg = premake.getconfig(prj, "Debug")
cpp.linker(cfg, premake.gcc)
end
--
-- Check linking to a shared library sibling project. In order to support
-- custom target prefixes and extensions, use the full, relative path
-- to the library.
--
function suite.onSharedLibrarySibling()
links { "MyProject2" }
test.createproject(sln)
kind "SharedLib"
targetdir "libs"
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -Llibs -s
LDDEPS += libs/libMyProject2.so
LIBS += $(LDDEPS)
]]
end
--
-- Check linking to a static library sibling project. As with shared
-- libraries, it should list out the full relative path.
--
function suite.onStaticLibrarySibling()
links { "MyProject2" }
test.createproject(sln)
kind "StaticLib"
targetdir "libs"
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -Llibs -s
LDDEPS += libs/libMyProject2.a
LIBS += $(LDDEPS)
]]
end
--
-- If an executable is listed in the links, no linking should happen (a
-- build dependency would have been created at the solution level)
--
function suite.onConsoleAppSibling()
links { "MyProject2" }
test.createproject(sln)
kind "ConsoleApp"
targetdir "libs"
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LDDEPS +=
LIBS += $(LDDEPS)
]]
end
--
-- Make sure that project locations are taken into account when building
-- the path to the library.
--
function suite.onProjectLocations()
location "MyProject"
links { "MyProject2" }
test.createproject(sln)
kind "SharedLib"
location "MyProject2"
targetdir "MyProject2"
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -L../MyProject2 -s
LDDEPS += ../MyProject2/libMyProject2.so
LIBS += $(LDDEPS)
]]
end
--
-- When referencing an external library via a path, the directory
-- should be added to the library search paths, and the library
-- itself included via an -l flag.
--
function suite.onExternalLibraryWithPath()
location "MyProject"
links { "libs/SomeLib" }
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -L../libs -s
LDDEPS +=
LIBS += $(LDDEPS) -lSomeLib
]]
end

View File

@@ -0,0 +1,120 @@
--
-- tests/actions/make/test_make_pch.lua
-- Validate the setup for precompiled headers in makefiles.
-- Copyright (c) 2010 Jason Perkins and the Premake project
--
T.make_pch = { }
local suite = T.make_pch
local _ = premake.make.cpp
--
-- Setup and teardown
--
local sln, prj, cfg
function suite.setup()
sln, prj = test.createsolution()
end
local function prepare()
premake.bake.buildconfigs()
prj = premake.getconfig(prj)
cfg = premake.getconfig(prj, "Debug")
end
--
-- Configuration block tests
--
function suite.NoConfig_OnNoHeaderSet()
prepare()
_.pchconfig(cfg)
test.capture [[]]
end
function suite.NoConfig_OnHeaderAndNoPCHFlag()
pchheader "include/myproject.h"
flags { NoPCH }
prepare()
_.pchconfig(cfg)
test.capture [[]]
end
function suite.ConfigBlock_OnPchEnabled()
pchheader "include/myproject.h"
prepare()
_.pchconfig(cfg)
test.capture [[
PCH = include/myproject.h
GCH = $(OBJDIR)/$(notdir $(PCH)).gch
]]
end
--
-- Build rule tests
--
function suite.BuildRules_OnCpp()
pchheader "include/myproject.h"
prepare()
_.pchrules(prj)
test.capture [[
ifneq (,$(PCH))
$(GCH): $(PCH)
@echo $(notdir $<)
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
]]
end
function suite.BuildRules_OnC()
language "C"
pchheader "include/myproject.h"
prepare()
_.pchrules(prj)
test.capture [[
ifneq (,$(PCH))
$(GCH): $(PCH)
@echo $(notdir $<)
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
]]
end
--
-- Ensure that PCH is included on all files that use it.
--
function suite.includesPCH_onUse()
pchheader "include/myproject.h"
files { "main.cpp" }
prepare()
_.fileRules(prj)
test.capture [[
$(OBJDIR)/main.o: main.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF $(@:%.o=%.d) -c "$<"
]]
end
--
-- If the header is located on one of the include file
-- search directories, it should get found automatically.
--
function suite.findsPCH_onIncludeDirs()
location "MyProject"
pchheader "premake.h"
includedirs { "../src/host" }
prepare()
_.pchconfig(cfg)
test.capture [[
PCH = ../../src/host/premake.h
]]
end

View File

@@ -0,0 +1,51 @@
--
-- tests/actions/make/test_makesettings.lua
-- Tests makesettings lists in generated makefiles.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
T.make_settings = { }
local suite = T.make_settings
local make = premake.make
local sln, prj, cfg
function suite.setup()
_ACTION = "gmake"
sln = solution("MySolution")
configurations { "Debug", "Release" }
makesettings { "SOLUTION_LEVEL_SETTINGS" }
project("MyProject")
makesettings { "PROJECT_LEVEL_SETTINGS" }
configuration { "Debug" }
makesettings { "DEBUG_LEVEL_SETTINGS" }
configuration { "Release" }
makesettings { "RELEASE_LEVEL_SETTINGS" }
premake.bake.buildconfigs()
prj = premake.solution.getproject(sln, 1)
cfg = premake.getconfig(prj, "Debug")
end
function suite.writesProjectSettings()
make.settings(prj, premake.gcc)
test.capture [[
SOLUTION_LEVEL_SETTINGS
PROJECT_LEVEL_SETTINGS
]]
end
function suite.writesConfigSettings()
make.settings(cfg, premake.gcc)
test.capture [[
DEBUG_LEVEL_SETTINGS
]]
end

View File

@@ -0,0 +1,62 @@
--
-- tests/actions/make/test_wiidev.lua
-- Tests for Wii homebrew support in makefiles.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
T.make_wiidev = { }
local suite = T.make_wiidev
local make = premake.make
local cpp = premake.make.cpp
local sln, prj, cfg
function suite.setup()
_ACTION = "gmake"
sln = solution("MySolution")
configurations { "Debug", "Release" }
platforms { "WiiDev" }
prj = project("MyProject")
premake.bake.buildconfigs()
cfg = premake.getconfig(prj, "Debug", "WiiDev")
end
--
-- Make sure that the Wii-specific flags are passed to the tools.
--
function suite.writesCorrectFlags()
cpp.flags(cfg, premake.gcc)
test.capture [[
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP -I$(LIBOGC_INC) $(MACHDEP) -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
]]
end
function suite.writesCorrectLinkFlags()
cpp.linker(cfg, premake.gcc)
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s -L$(LIBOGC_LIB) $(MACHDEP)
]]
end
--
-- Make sure the dev kit include is written to each Wii build configuration.
--
function suite.writesIncludeBlock()
make.settings(cfg, premake.gcc)
test.capture [[
ifeq ($(strip $(DEVKITPPC)),)
$(error "DEVKITPPC environment variable is not set")'
endif
include $(DEVKITPPC)/wii_rules'
]]
end