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,33 @@
require ("gmake")
return {
-- Makefile tests
"test_make_escaping.lua",
"test_make_tovar.lua",
-- Makefile workspaces
"workspace/test_config_maps.lua",
"workspace/test_default_config.lua",
"workspace/test_group_rule.lua",
"workspace/test_help_rule.lua",
"workspace/test_project_rule.lua",
-- Makefile C/C++ projects
"cpp/test_clang.lua",
"cpp/test_file_rules.lua",
"cpp/test_flags.lua",
"cpp/test_ldflags.lua",
"cpp/test_make_pch.lua",
"cpp/test_make_linking.lua",
"cpp/test_objects.lua",
"cpp/test_target_rules.lua",
"cpp/test_tools.lua",
"cpp/test_wiidev.lua",
-- Makefile C# projects
"cs/test_embed_files.lua",
"cs/test_flags.lua",
"cs/test_links.lua",
"cs/test_response.lua",
"cs/test_sources.lua",
}

View File

@@ -0,0 +1,63 @@
--
-- tests/actions/make/cpp/test_clang.lua
-- Test Clang support in Makefiles.
-- Copyright (c) 2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_clang")
local make = p.make
local cpp = p.make.cpp
local project = p.project
--
-- Setup
--
local wks, prj
function suite.setup()
wks = test.createWorkspace()
toolset "clang"
prj = p.workspace.getproject(wks, 1)
end
--
-- Make sure that the correct compilers are used.
--
function suite.usesCorrectCompilers()
make.cppConfigs(prj)
test.capture [[
ifeq ($(config),debug)
ifeq ($(origin CC), default)
CC = clang
endif
ifeq ($(origin CXX), default)
CXX = clang++
endif
ifeq ($(origin AR), default)
AR = ar
endif
]]
end
function suite.usesCorrectCompilersAndLinkTimeOptimization()
flags { "LinkTimeOptimization" }
make.cppConfigs(prj)
test.capture [[
ifeq ($(config),debug)
ifeq ($(origin CC), default)
CC = clang
endif
ifeq ($(origin CXX), default)
CXX = clang++
endif
ifeq ($(origin AR), default)
AR = llvm-ar
endif
]]
end

View File

@@ -0,0 +1,170 @@
--
-- tests/actions/make/cpp/test_file_rules.lua
-- Validate the makefile source building rules.
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_cpp_file_rules")
local make = p.make
local project = p.project
--
-- Setup
--
local wks, prj
function suite.setup()
p.escaper(make.esc)
wks = test.createWorkspace()
end
local function prepare()
prj = p.workspace.getproject(wks, 1)
make.cppFileRules(prj)
end
--
-- Two files with the same base name should have different object files.
--
function suite.uniqueObjNames_onBaseNameCollision()
files { "src/hello.cpp", "src/greetings/hello.cpp" }
prepare()
test.capture [[
$(OBJDIR)/hello.o: src/greetings/hello.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/hello1.o: src/hello.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
]]
end
--
-- C files in C++ projects should been compiled as c
--
function suite.cFilesGetsCompiledWithCCWhileInCppProject()
files { "src/hello.c", "src/test.cpp" }
prepare()
test.capture [[
$(OBJDIR)/hello.o: src/hello.c
@echo $(notdir $<)
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/test.o: src/test.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
]]
end
--
-- C files in C++ projects can be compiled as C++ with 'compileas'
--
function suite.cFilesGetsCompiledWithCXXWithCompileas()
files { "src/hello.c", "src/test.c" }
filter { "files:src/hello.c" }
compileas "C++"
prepare()
test.capture [[
$(OBJDIR)/hello.o: src/hello.c
@echo $(notdir $<)
ifeq ($(config),debug)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
endif
ifeq ($(config),release)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
endif
$(OBJDIR)/test.o: src/test.c
@echo $(notdir $<)
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
]]
end
--
-- C files in C++ projects can be compiled as C++ with 'compileas' on a configuration basis
--
function suite.cFilesGetsCompiledWithCXXWithCompileasDebugOnly()
files { "src/test.c", "src/hello.c" }
filter { "configurations:Debug", "files:src/hello.c" }
compileas "C++"
prepare()
test.capture [[
$(OBJDIR)/hello.o: src/hello.c
@echo $(notdir $<)
ifeq ($(config),debug)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
endif
ifeq ($(config),release)
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
endif
$(OBJDIR)/test.o: src/test.c
@echo $(notdir $<)
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
]]
end
--
-- If a custom build rule is supplied, it should be used.
--
function suite.customBuildRule()
files { "hello.x" }
filter "files:**.x"
buildmessage "Compiling %{file.name}"
buildcommands {
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"'
}
buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" }
prepare()
test.capture [[
ifeq ($(config),debug)
obj/Debug/hello.obj: hello.x
@echo "Compiling hello.x"
$(SILENT) cxc -c "hello.x" -o "obj/Debug/hello.xo"
$(SILENT) c2o -c "obj/Debug/hello.xo" -o "obj/Debug/hello.obj"
endif
ifeq ($(config),release)
obj/Release/hello.obj: hello.x
@echo "Compiling hello.x"
$(SILENT) cxc -c "hello.x" -o "obj/Release/hello.xo"
$(SILENT) c2o -c "obj/Release/hello.xo" -o "obj/Release/hello.obj"
endif
]]
end
function suite.customBuildRuleWithAdditionalInputs()
files { "hello.x" }
filter "files:**.x"
buildmessage "Compiling %{file.name}"
buildcommands {
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"'
}
buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" }
buildinputs { "%{file.path}.inc", "%{file.path}.inc2" }
prepare()
test.capture [[
ifeq ($(config),debug)
obj/Debug/hello.obj: hello.x hello.x.inc hello.x.inc2
@echo "Compiling hello.x"
$(SILENT) cxc -c "hello.x" -o "obj/Debug/hello.xo"
$(SILENT) c2o -c "obj/Debug/hello.xo" -o "obj/Debug/hello.obj"
endif
ifeq ($(config),release)
obj/Release/hello.obj: hello.x hello.x.inc hello.x.inc2
@echo "Compiling hello.x"
$(SILENT) cxc -c "hello.x" -o "obj/Release/hello.xo"
$(SILENT) c2o -c "obj/Release/hello.xo" -o "obj/Release/hello.obj"
endif
]]
end

View File

@@ -0,0 +1,144 @@
--
-- tests/actions/make/cpp/test_flags.lua
-- Tests compiler and linker flags for Makefiles.
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_flags")
local make = p.make
local project = p.project
--
-- Setup
--
local wks, prj
function suite.setup()
wks, prj = test.createWorkspace()
end
local function prepare(calls)
local cfg = test.getconfig(prj, "Debug")
local toolset = p.tools.gcc
p.callarray(make, calls, cfg, toolset)
end
--
-- Include directories should be relative and space separated.
--
function suite.includeDirs()
includedirs { "src/include", "../include" }
prepare { "includes" }
test.capture [[
INCLUDES += -Isrc/include -I../include
]]
end
--
-- symbols "on" should produce -g
--
function suite.symbols_on()
symbols "on"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
]]
end
--
-- symbols default to 'off'
--
function suite.symbols_default()
symbols "default"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS)
]]
end
--
-- All other symbols flags also produce -g
--
function suite.symbols_fastlink()
symbols "FastLink"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
]]
end
function suite.symbols_full()
symbols "full"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
]]
end
--
-- symbols "off" should not produce -g
--
function suite.symbols_off()
symbols "off"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS)
]]
end
--
-- symbols "on" with a proper debugformat should produce a corresponding -g
--
function suite.symbols_on_default()
symbols "on"
debugformat "Default"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
]]
end
function suite.symbols_on_dwarf()
symbols "on"
debugformat "Dwarf"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gdwarf
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gdwarf
]]
end
function suite.symbols_on_split_dwarf()
symbols "on"
debugformat "SplitDwarf"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf
]]
end
--
-- symbols "off" with a proper debugformat should not produce -g
--
function suite.symbols_off_dwarf()
symbols "off"
debugformat "Dwarf"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS)
]]
end

View File

@@ -0,0 +1,78 @@
--
-- tests/actions/make/cpp/test_ldflags.lua
-- Tests compiler and linker flags for Makefiles.
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_ldflags")
local make = p.make
--
-- Setup
--
local wks, prj
function suite.setup()
wks, prj = test.createWorkspace()
symbols "On"
end
local function prepare(calls)
local cfg = test.getconfig(prj, "Debug")
local toolset = p.tools.gcc
make.ldFlags(cfg, toolset)
end
--
-- Check the output from default project values.
--
function suite.checkDefaultValues()
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS)
]]
end
--
-- Check addition of library search directores.
--
function suite.checkLibDirs()
libdirs { "../libs", "libs" }
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -L../libs -Llibs
]]
end
function suite.checkLibDirs_X86_64()
architecture ("x86_64")
system (p.LINUX)
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64
]]
end
function suite.checkLibDirs_X86()
architecture ("x86")
system (p.LINUX)
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32
]]
end
function suite.checkLibDirs_X86_64_MacOSX()
architecture ("x86_64")
system (p.MACOSX)
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -m64
]]
end

View File

@@ -0,0 +1,270 @@
--
-- tests/actions/make/cpp/test_make_linking.lua
-- Validate the link step generation for makefiles.
-- Copyright (c) 2010-2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_linking")
local make = p.make
local project = p.project
--
-- Setup and teardown
--
local wks, prj
function suite.setup()
_TARGET_OS = "linux"
wks, prj = test.createWorkspace()
end
local function prepare(calls)
local cfg = test.getconfig(prj, "Debug")
local toolset = p.tools.gcc
p.callarray(make, calls, cfg, toolset)
end
--
-- Check link command for a shared C++ library.
--
function suite.links_onCppSharedLib()
kind "SharedLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -shared -Wl,-soname=libMyProject.so -s
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
]]
end
function suite.links_onMacOSXCppSharedLib()
_TARGET_OS = "macosx"
kind "SharedLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -dynamiclib -Wl,-install_name,@rpath/libMyProject.dylib -Wl,-x
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
]]
end
--
-- Check link command for a shared C library.
--
function suite.links_onCSharedLib()
language "C"
kind "SharedLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -shared -Wl,-soname=libMyProject.so -s
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
]]
end
--
-- Check link command for a static library.
--
function suite.links_onStaticLib()
kind "StaticLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LINKCMD = $(AR) -rcs "$@" $(OBJECTS)
]]
end
--
-- Check link command for the Utility kind.
--
-- Utility projects should only run custom commands, and perform no linking.
--
function suite.links_onUtility()
kind "Utility"
prepare { "linkCmd" }
test.capture [[
LINKCMD =
]]
end
--
-- Check link command for a Mac OS X universal static library.
--
function suite.links_onMacUniversalStaticLib()
architecture "universal"
kind "StaticLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LINKCMD = libtool -o "$@" $(OBJECTS)
]]
end
--
-- Check a linking to a sibling static library.
--
function suite.links_onSiblingStaticLib()
links "MyProject2"
test.createproject(wks)
kind "StaticLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += build/bin/Debug/libMyProject2.a
LDDEPS += build/bin/Debug/libMyProject2.a
]]
end
--
-- Check a linking to a sibling shared library.
--
function suite.links_onSiblingSharedLib()
links "MyProject2"
test.createproject(wks)
kind "SharedLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../../build/bin/Debug' -s
LIBS += build/bin/Debug/libMyProject2.so
LDDEPS += build/bin/Debug/libMyProject2.so
]]
end
--
-- Check a linking to a sibling shared library using -l and -L.
--
function suite.links_onSiblingSharedLibRelativeLinks()
links "MyProject2"
flags { "RelativeLinks" }
test.createproject(wks)
kind "SharedLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -Lbuild/bin/Debug -Wl,-rpath,'$$ORIGIN/../../build/bin/Debug' -s
LIBS += -lMyProject2
LDDEPS += build/bin/Debug/libMyProject2.so
]]
end
function suite.links_onMacOSXSiblingSharedLib()
_TARGET_OS = "macosx"
links "MyProject2"
flags { "RelativeLinks" }
test.createproject(wks)
kind "SharedLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -Lbuild/bin/Debug -Wl,-rpath,'@loader_path/../../build/bin/Debug' -Wl,-x
LIBS += -lMyProject2
LDDEPS += build/bin/Debug/libMyProject2.dylib
]]
end
--
-- Check a linking multiple siblings.
--
function suite.links_onMultipleSiblingStaticLib()
links "MyProject2"
links "MyProject3"
test.createproject(wks)
kind "StaticLib"
location "build"
test.createproject(wks)
kind "StaticLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a
LDDEPS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a
]]
end
--
-- Check a linking multiple siblings with link groups enabled.
--
function suite.links_onSiblingStaticLibWithLinkGroups()
links "MyProject2"
links "MyProject3"
linkgroups "On"
test.createproject(wks)
kind "StaticLib"
location "build"
test.createproject(wks)
kind "StaticLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += -Wl,--start-group build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a -Wl,--end-group
LDDEPS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a
]]
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 { "ldFlags", "libs" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -L../libs -s
LIBS += -lSomeLib
]]
end
--
-- When referencing an external library with a period in the
-- file name make sure it appears correctly in the LIBS
-- directive. Currently the period and everything after it
-- is stripped
--
function suite.onExternalLibraryWithPathAndVersion()
location "MyProject"
links { "libs/SomeLib-1.1" }
prepare { "libs", }
test.capture [[
LIBS += -lSomeLib-1.1
]]
end

View File

@@ -0,0 +1,142 @@
--
-- tests/actions/make/cpp/test_make_pch.lua
-- Validate the setup for precompiled headers in makefiles.
-- Copyright (c) 2010-2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_pch")
local make = p.make
local project = p.project
--
-- Setup and teardown
--
local wks, prj
function suite.setup()
os.chdir(_TESTS_DIR)
wks, prj = test.createWorkspace()
end
local function prepareVars()
local cfg = test.getconfig(prj, "Debug")
make.pch(cfg)
end
local function prepareRules()
local cfg = test.getconfig(prj, "Debug")
make.pchRules(cfg.project)
end
--
-- If no header has been set, nothing should be output.
--
function suite.noConfig_onNoHeaderSet()
prepareVars()
test.isemptycapture()
end
--
-- If a header is set, but the NoPCH flag is also set, then
-- nothing should be output.
--
function suite.noConfig_onHeaderAndNoPCHFlag()
pchheader "include/myproject.h"
flags "NoPCH"
prepareVars()
test.isemptycapture()
end
--
-- If a header is specified and the NoPCH flag is not set, then
-- the header can be used.
--
function suite.config_onPchEnabled()
pchheader "include/myproject.h"
prepareVars()
test.capture [[
PCH = include/myproject.h
GCH = $(OBJDIR)/$(notdir $(PCH)).gch
]]
end
--
-- The PCH can be specified relative the an includes search path.
--
function suite.pch_searchesIncludeDirs()
pchheader "premake.h"
includedirs { "../../../src/host" }
prepareVars()
test.capture [[
PCH = ../../../src/host/premake.h
]]
end
--
-- Verify the format of the PCH rules block for a C++ file.
--
function suite.buildRules_onCpp()
pchheader "include/myproject.h"
prepareRules()
test.capture [[
ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
else
$(OBJECTS): | $(OBJDIR)
endif
]]
end
--
-- Verify the format of the PCH rules block for a C file.
--
function suite.buildRules_onC()
language "C"
pchheader "include/myproject.h"
prepareRules()
test.capture [[
ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
else
$(OBJECTS): | $(OBJDIR)
endif
]]
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" }
prepareVars()
test.capture [[
PCH = ../../../../src/host/premake.h
]]
end

View File

@@ -0,0 +1,250 @@
--
-- tests/actions/make/cpp/test_objects.lua
-- Validate the list of objects for a makefile.
-- Copyright (c) 2009-2015 Jason Perkins and the Premake project
--
local suite = test.declare("make_cpp_objects")
local p = premake
--
-- Setup
--
local wks, prj
function suite.setup()
wks = test.createWorkspace()
end
local function prepare()
prj = test.getproject(wks, 1)
p.make.cppObjects(prj)
end
--
-- If a file is listed at the project level, it should get listed in
-- the project level objects list.
--
function suite.listFileInProjectObjects()
files { "src/hello.cpp" }
prepare()
test.capture [[
OBJECTS := \
$(OBJDIR)/hello.o \
]]
end
--
-- Only buildable files should be listed.
--
function suite.onlyListBuildableFiles()
files { "include/gl.h", "src/hello.cpp" }
prepare()
test.capture [[
OBJECTS := \
$(OBJDIR)/hello.o \
]]
end
--
-- A file should only be listed in the configurations to which it belongs.
--
function suite.configFilesAreConditioned()
filter "Debug"
files { "src/hello_debug.cpp" }
filter "Release"
files { "src/hello_release.cpp" }
prepare()
test.capture [[
OBJECTS := \
RESOURCES := \
CUSTOMFILES := \
ifeq ($(config),debug)
OBJECTS += \
$(OBJDIR)/hello_debug.o \
endif
ifeq ($(config),release)
OBJECTS += \
$(OBJDIR)/hello_release.o \
endif
]]
end
--
-- Two files with the same base name should have different object files.
--
function suite.uniqueObjNames_onBaseNameCollision()
files { "src/hello.cpp", "src/greetings/hello.cpp" }
prepare()
test.capture [[
OBJECTS := \
$(OBJDIR)/hello.o \
$(OBJDIR)/hello1.o \
]]
end
--
-- If a custom rule builds to an object file, include it in the
-- link automatically to match the behavior of Visual Studio
--
function suite.linkBuildOutputs_onNotSpecified()
files { "hello.x" }
filter "files:**.x"
buildmessage "Compiling %{file.name}"
buildcommands {
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"'
}
buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" }
prepare()
test.capture [[
OBJECTS := \
RESOURCES := \
CUSTOMFILES := \
ifeq ($(config),debug)
OBJECTS += \
obj/Debug/hello.obj \
endif
]]
end
--
-- Also include it in the link step if we explicitly specified so with
-- linkbuildoutputs.
--
function suite.linkBuildOutputs_onOn()
files { "hello.x" }
filter "files:**.x"
buildmessage "Compiling %{file.name}"
buildcommands {
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"'
}
buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" }
linkbuildoutputs "On"
prepare()
test.capture [[
OBJECTS := \
RESOURCES := \
CUSTOMFILES := \
ifeq ($(config),debug)
OBJECTS += \
obj/Debug/hello.obj \
endif
]]
end
--
-- If linkbuildoutputs says that we shouldn't include it in the link however,
-- don't do it.
--
function suite.linkBuildOutputs_onOff()
files { "hello.x" }
filter "files:**.x"
buildmessage "Compiling %{file.name}"
buildcommands {
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"'
}
buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" }
linkbuildoutputs "Off"
prepare()
test.capture [[
OBJECTS := \
RESOURCES := \
CUSTOMFILES := \
ifeq ($(config),debug)
CUSTOMFILES += \
obj/Debug/hello.obj \
endif
]]
end
--
-- If a file is excluded from a configuration, it should not be listed.
--
function suite.excludedFromBuild_onExcludedFile()
files { "hello.cpp" }
filter "Debug"
removefiles { "hello.cpp" }
prepare()
test.capture [[
OBJECTS := \
RESOURCES := \
CUSTOMFILES := \
ifeq ($(config),release)
OBJECTS += \
$(OBJDIR)/hello.o \
endif
]]
end
function suite.excludedFromBuild_onExcludeFlag()
files { "hello.cpp" }
filter { "Debug", "files:hello.cpp" }
flags { "ExcludeFromBuild" }
prepare()
test.capture [[
OBJECTS := \
RESOURCES := \
CUSTOMFILES := \
ifeq ($(config),release)
OBJECTS += \
$(OBJDIR)/hello.o \
endif
]]
end

View File

@@ -0,0 +1,57 @@
--
-- tests/actions/make/cpp/test_target_rules.lua
-- Validate the makefile target building rules.
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_cpp_target_rules")
local make = p.make
local project = p.project
--
-- Setup
--
local wks, prj
function suite.setup()
wks, prj = test.createWorkspace()
end
local function prepare()
local cfg = test.getconfig(prj, "Debug")
make.cppAllRules(cfg)
end
--
-- Check the default, normal format of the rules.
--
function suite.defaultRules()
prepare()
test.capture [[
all: prebuild prelink $(TARGET)
@:
]]
end
--
-- Check rules for an OS X Cocoa application.
--
function suite.osxWindowedAppRules()
system "MacOSX"
kind "WindowedApp"
prepare()
test.capture [[
all: prebuild prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist
@:
$(dir $(TARGETDIR))PkgInfo:
$(dir $(TARGETDIR))Info.plist:
]]
end

View File

@@ -0,0 +1,35 @@
--
-- tests/actions/make/cpp/test_tools.lua
-- Tests for tools support in makefiles.
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_tools")
local make = p.make
local cpp = p.make.cpp
local project = p.project
--
-- Setup
--
local cfg
function suite.setup()
local wks, prj = test.createWorkspace()
cfg = test.getconfig(prj, "Debug")
end
--
-- Make sure that the correct tools are used.
--
function suite.usesCorrectTools()
make.cppTools(cfg, p.tools.gcc)
test.capture [[
RESCOMP = windres
]]
end

View File

@@ -0,0 +1,58 @@
--
-- tests/actions/make/cpp/test_wiidev.lua
-- Tests for Wii homebrew support in makefiles.
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_wiidev")
local make = p.make
local project = p.project
--
-- Setup
--
local cfg
function suite.setup()
local wks, prj = test.createWorkspace()
system "wii"
symbols "On"
cfg = test.getconfig(prj, "Debug")
end
--
-- Make sure that the Wii-specific flags are passed to the tools.
--
function suite.writesCorrectCppFlags()
make.cppFlags(cfg, p.tools.gcc)
test.capture [[
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP -I$(LIBOGC_INC) $(MACHDEP) $(DEFINES) $(INCLUDES)
]]
end
function suite.writesCorrectLinkerFlags()
make.ldFlags(cfg, p.tools.gcc)
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -L$(LIBOGC_LIB) $(MACHDEP)
]]
end
--
-- Make sure the dev kit include is written to each Wii build configuration.
--
function suite.writesIncludeBlock()
make.settings(cfg, p.tools.gcc)
test.capture [[
ifeq ($(strip $(DEVKITPPC)),)
$(error "DEVKITPPC environment variable is not set")'
endif
include $(DEVKITPPC)/wii_rules'
]]
end

View File

@@ -0,0 +1,75 @@
--
-- tests/actions/make/cs/test_embed_files.lua
-- Tests embedded file listings for C# Makefiles.
-- Copyright (c) 2013-2014 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_cs_embed_files")
local make = p.make
local cs = p.make.cs
local project = p.project
--
-- Setup
--
local wks, prj, cfg
function suite.setup()
wks = test.createWorkspace()
end
local function prepare()
prj = p.workspace.getproject(wks, 1)
make.csEmbedFiles(prj, p.tools.dotnet)
end
--
-- Files that can be compiled should be listed here.
--
function suite.doesListResourceFiles()
files { "Hello.resx" }
prepare()
test.capture [[
EMBEDFILES += \
$(OBJDIR)/MyProject.Hello.resources \
]]
end
--
-- Files that should not be compiled should be excluded.
--
function suite.doesIgnoreNonResourceFiles()
files { "About.txt", "Hello.resx" }
prepare()
test.capture [[
EMBEDFILES += \
$(OBJDIR)/MyProject.Hello.resources \
]]
end
--
-- Files with a non-standard file extension but a build action of
-- "Embed" should be listed here.
--
function suite.doesIncludeCompileBuildAction()
files { "Hello.txt" }
filter "files:*.txt"
buildaction "Embed"
prepare()
test.capture [[
EMBEDFILES += \
Hello.txt \
]]
end

View File

@@ -0,0 +1,65 @@
--
-- tests/actions/make/cs/test_flags.lua
-- Tests compiler and linker flags for C# Makefiles.
-- Copyright (c) 2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_cs_flags")
local make = p.make
local cs = p.make.cs
local project = p.project
--
-- Setup
--
local wks, prj
function suite.setup()
wks, prj = test.createWorkspace()
end
local function prepare()
local cfg = test.getconfig(prj, "Debug")
make.csFlags(cfg, p.tools.dotnet)
end
--
-- Should return an empty assignment if nothing has been specified.
--
function suite.isEmptyAssignment_onNoSettings()
prepare()
test.capture [[
FLAGS = /noconfig
]]
end
--
-- If the Unsafe flag has been set, it should be specified.
--
function suite.onUnsafe()
clr "Unsafe"
prepare()
test.capture [[
FLAGS = /unsafe /noconfig
]]
end
--
-- If an application icon has been set, it should be specified.
--
function suite.onApplicationIcon()
icon "MyProject.ico"
prepare()
test.capture [[
FLAGS = /noconfig /win32icon:"MyProject.ico"
]]
end

View File

@@ -0,0 +1,60 @@
--
-- tests/actions/make/cs/test_links.lua
-- Tests linking for C# Makefiles.
-- Copyright (c) 2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_cs_links")
local make = p.make
local cs = p.make.cs
local project = p.project
--
-- Setup
--
local wks, prj
function suite.setup()
wks, prj = test.createWorkspace()
end
local function prepare()
local cfg = test.getconfig(prj, "Debug")
make.csLinkCmd(cfg, p.tools.dotnet)
end
--
-- Should return an empty assignment if nothing has been specified.
--
function suite.isEmptyAssignment_onNoSettings()
prepare()
test.capture [[
DEPENDS =
]]
end
--
-- Files that can be compiled should be listed here.
--
function suite.doesListLinkDependencyFiles()
links { "MyProject2", "MyProject3" }
test.createproject(wks)
kind "SharedLib"
language "C#"
test.createproject(wks)
kind "SharedLib"
language "C#"
prepare ()
test.capture [[
DEPENDS = bin/Debug/MyProject2.dll bin/Debug/MyProject3.dll
]]
end

View File

@@ -0,0 +1,90 @@
--
-- tests/actions/make/cs/test_response.lua
-- Validate the list of objects for a response file used by a makefile.
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_cs_response")
local make = p.make
--
-- Setup
--
local wks, prj
function suite.setup()
p.action.set("vs2010")
wks = test.createWorkspace()
end
local function prepare()
prj = test.getproject(wks, 1)
end
--
-- Create a project with a lot of files to force the generation of response files.
-- This makes sure they can be processed in Windows since else we reach the command
-- line length max limit.
--
function suite.listResponse()
prepare()
make.csResponseFile(prj)
test.capture [[
RESPONSE += $(OBJDIR)/MyProject.rsp
]]
end
function suite.listResponseTargets()
prepare()
make.csTargetRules(prj)
test.capture [[
$(TARGET): $(SOURCES) $(EMBEDFILES) $(DEPENDS) $(RESPONSE)
$(SILENT) $(CSC) /nologo /out:$@ $(FLAGS) $(REFERENCES) @$(RESPONSE) $(patsubst %,/resource:%,$(EMBEDFILES))
]]
end
function suite.listResponseRules()
files { "foo.cs", "bar.cs", "dir/foo.cs" }
prepare()
make.csResponseRules(prj)
end
function suite.listResponseRulesPosix()
_TARGET_OS = "linux"
suite.listResponseRules()
test.capture [[
$(RESPONSE): MyProject.make
@echo Generating response file
ifeq (posix,$(SHELLTYPE))
$(SILENT) rm -f $(RESPONSE)
else
$(SILENT) if exist $(RESPONSE) del $(OBJDIR)\MyProject.rsp
endif
@echo bar.cs >> $(RESPONSE)
@echo dir/foo.cs >> $(RESPONSE)
@echo foo.cs >> $(RESPONSE)
]]
end
function suite.listResponseRulesWindows()
_TARGET_OS = "windows"
suite.listResponseRules()
test.capture [[
$(RESPONSE): MyProject.make
@echo Generating response file
ifeq (posix,$(SHELLTYPE))
$(SILENT) rm -f $(RESPONSE)
else
$(SILENT) if exist $(RESPONSE) del $(OBJDIR)\MyProject.rsp
endif
@echo bar.cs >> $(RESPONSE)
@echo dir\foo.cs >> $(RESPONSE)
@echo foo.cs >> $(RESPONSE)
]]
end

View File

@@ -0,0 +1,90 @@
--
-- tests/actions/make/cs/test_sources.lua
-- Tests source file listings for C# Makefiles.
-- Copyright (c) 2013-2014 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_cs_sources")
local make = p.make
local cs = p.make.cs
local project = p.project
--
-- Setup
--
local wks, prj, cfg
function suite.setup()
wks = test.createWorkspace()
end
local function prepare()
prj = p.workspace.getproject(wks, 1)
make.csSources(prj, p.tools.dotnet)
end
--
-- Files that can be compiled should be listed here.
--
function suite.doesListSourceFiles()
files { "Hello.cs" }
prepare()
test.capture [[
SOURCES += \
Hello.cs \
]]
end
--
-- Path delimiter uses slash instead of backslash
--
function suite.doesUseProperPathDelimiter()
files { "Folder\\Hello.cs", "Folder/World.cs" }
prepare()
test.capture [[
SOURCES += \
Folder/Hello.cs \
Folder/World.cs \
]]
end
--
-- Files that should not be compiled should be excluded.
--
function suite.doesIgnoreNonSourceFiles()
files { "About.txt", "Hello.cs" }
prepare()
test.capture [[
SOURCES += \
Hello.cs \
]]
end
--
-- Files with a non-standard file extension but a build action of
-- "Compile" should be listed here.
--
function suite.doesIncludeCompileBuildAction()
files { "Hello.txt" }
filter "files:*.txt"
buildaction "Compile"
prepare()
test.capture [[
SOURCES += \
Hello.txt \
]]
end

View File

@@ -0,0 +1,31 @@
--
-- tests/actions/make/test_make_escaping.lua
-- Validate the escaping of literal values in Makefiles.
-- Copyright (c) 2010-2012 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_escaping")
local make = p.make
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,35 @@
--
-- tests/actions/make/test_make_tovar.lua
-- Test translation of strings to make variable names.
-- Copyright (c) 2012 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_tovar")
local make = p.make
--
-- Convert spaces to underscores.
--
function suite.removesSpaces()
test.isequal("My_Project", make.tovar("My Project"))
end
--
-- Convert dashes to underscores.
--
function suite.removesDashes()
test.isequal("My_Project", make.tovar("My-Project"))
end
--
-- Remove parenthesis.
--
function suite.removesParenthesis()
test.isequal("MyProject_x86", make.tovar("MyProject (x86)"))
end

View File

@@ -0,0 +1,78 @@
--
-- tests/actions/make/test_config_maps.lua
-- Validate handling of configuration maps in makefiles.
-- Copyright (c) 2012 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_config_maps")
local make = p.make
--
-- Setup/teardown
--
local wks, prj
function suite.setup()
wks = test.createWorkspace()
end
local function prepare()
make.configmap(wks)
end
--
-- If no map is present, the configurations should pass through
-- to the projects unchanged.
--
function suite.passesThroughConfigs_onNoMap()
prepare()
test.capture [[
ifeq ($(config),debug)
MyProject_config = debug
endif
ifeq ($(config),release)
MyProject_config = release
endif
]]
end
--
-- If a map is present, the configuration change should be applied.
--
function suite.passesThroughConfigs_onMap()
configmap { Debug = "Development" }
prepare()
test.capture [[
ifeq ($(config),debug)
MyProject_config = development
endif
ifeq ($(config),release)
MyProject_config = release
endif
]]
end
--
-- If a configuration is not included in a particular project,
-- no mapping should be created.
--
function suite.passesThroughConfigs_onNoMapRemovedConfiguration()
removeconfigurations { "Debug" }
prepare()
test.capture [[
ifeq ($(config),debug)
endif
ifeq ($(config),release)
MyProject_config = release
endif
]]
end

View File

@@ -0,0 +1,87 @@
--
-- tests/actions/make/test_default_config.lua
-- Validate generation of default configuration block for makefiles.
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
--
local suite = test.declare("make_default_config")
local p = premake
--
-- Setup/teardown
--
local wks, prj
function suite.setup()
wks = test.createWorkspace()
end
local function prepare()
prj = test.getproject(wks, 1)
p.make.defaultconfig(prj)
end
--
-- Verify the handling of the default setup: Debug and Release, no platforms.
--
function suite.defaultsToFirstBuildCfg_onNoPlatforms()
prepare()
test.capture [[
ifndef config
config=debug
endif
]]
end
--
-- Verify handling of build config/platform combination.
--
function suite.defaultsToFirstPairing_onPlatforms()
platforms { "Win32", "Win64" }
prepare()
test.capture [[
ifndef config
config=debug_win32
endif
]]
end
--
-- If the project excludes a workspace build cfg, it should be skipped
-- over as the default config as well.
--
function suite.usesFirstValidPairing_onExcludedConfig()
platforms { "Win32", "Win64" }
removeconfigurations { "Debug" }
prepare()
test.capture [[
ifndef config
config=release_win32
endif
]]
end
--
-- Verify handling of defaultplatform
--
function suite.defaultsToSpecifiedPlatform()
platforms { "Win32", "Win64" }
defaultplatform "Win64"
prepare()
test.capture [[
ifndef config
config=debug_win64
endif
]]
end

View File

@@ -0,0 +1,61 @@
--
-- tests/actions/make/workspace/test_group_rule.lua
-- Validate generation of group rules
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_group_rule")
local make = p.make
--
-- Setup/teardown
--
local wks
function suite.setup()
wks = test.createWorkspace()
group "MainGroup"
test.createproject(wks)
group "MainGroup/SubGroup1"
test.createproject(wks)
group "MainGroup/SubGroup2"
test.createproject(wks)
test.createproject(wks)
end
local function prepare()
wks = test.getWorkspace(wks)
end
--
-- Groups should be added to workspace's PHONY
--
function suite.groupRule_groupAsPhony()
prepare()
make.workspacePhonyRule(wks)
test.capture [[
.PHONY: all clean help $(PROJECTS) MainGroup MainGroup/SubGroup1 MainGroup/SubGroup2
]]
end
--
-- Transform workspace groups into target aggregate
--
function suite.groupRule_groupRules()
prepare()
make.groupRules(wks)
test.capture [[
MainGroup: MainGroup/SubGroup1 MainGroup/SubGroup2 MyProject2
MainGroup/SubGroup1: MyProject3
MainGroup/SubGroup2: MyProject4 MyProject5
]]
end

View File

@@ -0,0 +1,41 @@
--
-- tests/actions/make/test_help_rule.lua
-- Validate generation of help rule and configurations list.
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_help_rule")
--
-- Setup/teardown
--
local wks
function suite.setup()
wks = test.createWorkspace()
end
local function prepare()
wks = test.getWorkspace(wks)
p.make.helprule(wks)
end
--
-- Start with the default Debug and Release setup.
--
function suite.looksOkay_onDefaultSetup()
prepare()
test.capture [[
help:
@echo "Usage: make [config=name] [target]"
@echo ""
@echo "CONFIGURATIONS:"
@echo " debug"
@echo " release"
]]
end

View File

@@ -0,0 +1,42 @@
--
-- tests/actions/make/workspace/test_project_rule.lua
-- Validate generation of project rules in workspace makefile.
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("make_project_rule")
--
-- Setup/teardown
--
local wks
function suite.setup()
wks = test.createWorkspace()
end
local function prepare()
p.oven.bake()
wks = test.getWorkspace(wks)
p.make.projectrules(wks)
end
--
-- Verify a simple project with no dependencies.
--
function suite.projectRule_onNoDependencies()
prepare()
test.capture [[
MyProject:
ifneq (,$(MyProject_config))
@echo "==== Building MyProject ($(MyProject_config)) ===="
@${MAKE} --no-print-directory -C . -f MyProject.make config=$(MyProject_config)
endif
]]
end