Initial community commit

This commit is contained in:
Jef 2024-09-24 14:54:57 +02:00
parent 537bcbc862
commit fc06254474
16440 changed files with 4239995 additions and 2 deletions

View file

@ -0,0 +1,117 @@
--
-- tests/config/test_linkinfo.lua
-- Test the config object's link target accessor.
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("config_linkinfo")
local config = p.config
--
-- Setup and teardown
--
local wks, prj
function suite.setup()
p.action.set("test")
wks, prj = test.createWorkspace()
kind "StaticLib"
system "Windows"
end
local function prepare()
local cfg = test.getconfig(prj, "Debug")
return config.getlinkinfo(cfg)
end
--
-- Directory should use targetdir() value if present.
--
function suite.directoryIsTargetDir_onTargetDir()
targetdir "../bin"
i = prepare()
test.isequal("../bin", path.getrelative(os.getcwd(), i.directory))
end
--
-- Shared library should use implibdir() if present.
--
function suite.directoryIsImpLibDir_onImpLibAndTargetDir()
kind "SharedLib"
targetdir "../bin"
implibdir "../lib"
i = prepare()
test.isequal("../lib", path.getrelative(os.getcwd(), i.directory))
end
--
-- Base name should use the project name by default.
--
function suite.basenameIsProjectName_onNoTargetName()
i = prepare()
test.isequal("MyProject", i.basename)
end
--
-- Base name should use targetname() if present.
--
function suite.basenameIsTargetName_onTargetName()
targetname "MyTarget"
i = prepare()
test.isequal("MyTarget", i.basename)
end
--
-- Shared library should use implibname() if present.
--
function suite.basenameIsImplibName_onTargetName()
kind "SharedLib"
targetname "MyTarget"
implibname "MyTargetImports"
i = prepare()
test.isequal("MyTargetImports", i.basename)
end
--
-- Test library name formatting.
--
function suite.nameFormatting_onWindows()
system "Windows"
i = prepare()
test.isequal("MyProject.lib", i.name)
end
function suite.nameFormatting_onLinux()
system "Linux"
i = prepare()
test.isequal("libMyProject.a", i.name)
end
--
-- The import library extension should not change if the a
-- custom target extension is set.
--
function suite.impLibExtensionUnmodified_OnCustomTargetExt()
system "windows"
kind "SharedLib"
targetextension ".mil"
i = prepare()
test.isequal("MyProject.lib", i.name)
end

View file

@ -0,0 +1,224 @@
--
-- tests/config/test_links.lua
-- Test the list of linked objects retrieval function.
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("config_links")
local config = p.config
--
-- Setup and teardown
--
local wks, prj
function suite.setup()
p.action.set("test")
_TARGET_OS = "windows"
wks, prj = test.createWorkspace()
end
local function prepare(kind, part, linkage)
cfg = test.getconfig(prj, "Debug")
return config.getlinks(cfg, kind, part, linkage)
end
--
-- If no links are present, should return an empty table.
--
function suite.emptyResult_onNoLinks()
local r = prepare("all", "object")
test.isequal(0, #r)
end
--
-- System libraries which include path information are made project relative.
--
function suite.pathMadeRelative_onSystemLibWithPath()
location "build"
links { "../libs/z" }
local r = prepare("all", "fullpath")
test.isequal({ "../../libs/z" }, r)
end
--
-- Handle the case where the library extension has been explicitly
-- included in the link statement.
--
function suite.skipsExtension_onExplicitExtension()
system "windows"
links { "user32.lib" }
local r = prepare("all", "fullpath")
test.isequal({ "user32.lib" }, r)
end
--
-- Check handling of shell variables in library paths.
--
function suite.variableMaintained_onLeadingVariable()
system "windows"
location "build"
links { "$(LOCAL_DEV_PATH)/sdk/lib/DEVMAPI" }
local r = prepare("all", "fullpath")
test.isequal({ "$(LOCAL_DEV_PATH)/sdk/lib/DEVMAPI" }, r)
end
function suite.variableMaintained_onQuotedVariable()
system "windows"
location "build"
links { '"$(LOCAL_DEV_PATH)/sdk/lib/DEVMAPI.lib"' }
local r = prepare("all", "fullpath")
test.isequal({ '"$(LOCAL_DEV_PATH)/sdk/lib/DEVMAPI.lib"' }, r)
end
--
-- If fetching directories, the libdirs should be included in the result.
--
function suite.includesLibDirs_onDirectories()
libdirs { "../libs" }
local r = prepare("all", "directory")
test.isequal({ "../libs" }, r)
end
--
-- Managed C++ projects should ignore links to managed assemblies, which
-- are designated with an explicit ".dll" extension.
--
function suite.skipsAssemblies_onManagedCpp()
system "windows"
clr "On"
links { "user32", "System.dll" }
local r = prepare("all", "fullpath")
test.isequal({ "user32" }, r)
end
--
-- When explicitly requesting managed links, any unmanaged items in the
-- list should be ignored.
--
function suite.skipsUnmanagedLibs_onManagedLinkage()
system "windows"
clr "On"
links { "user32", "System.dll" }
local r = prepare("all", "fullpath", "managed")
test.isequal({ "System.dll" }, r)
end
--
-- Managed projects can link to other managed projects, and unmanaged
-- projects can link to unmanaged projects.
--
function suite.canLink_CppAndCpp()
links { "MyProject2" }
project "MyProject2"
kind "StaticLib"
language "C++"
local r = prepare("all", "fullpath")
test.isequal({ "bin/Debug/MyProject2.lib" }, r)
end
function suite.canLink_CsAndCs()
language "C#"
links { "MyProject2" }
project "MyProject2"
kind "SharedLib"
language "C#"
local r = prepare("all", "fullpath")
test.isequal({ "bin/Debug/MyProject2.dll" }, r)
end
function suite.canLink_ManagedCppAndManagedCpp()
clr "On"
links { "MyProject2" }
project "MyProject2"
kind "StaticLib"
language "C++"
clr "On"
local r = prepare("all", "fullpath")
test.isequal({ "bin/Debug/MyProject2.lib" }, r)
end
function suite.canLink_ManagedCppAndCs()
clr "On"
links { "MyProject2" }
project "MyProject2"
kind "SharedLib"
language "C#"
local r = prepare("all", "fullpath")
test.isequal({ "bin/Debug/MyProject2.dll" }, r)
end
--
-- Managed and unmanaged projects can not link to each other.
--
function suite.ignoreLink_CppAndCs()
links { "MyProject2" }
project "MyProject2"
kind "SharedLib"
language "C#"
local r = prepare("all", "fullpath")
test.isequal({}, r)
end
--
-- Mixed and unmanaged projects can link to each other.
--
function suite.canLink_MixedAndNativeCpp()
clr "On"
links { "MyProject2" }
project "MyProject2"
kind "SharedLib"
language "C++"
local r = prepare("all", "fullpath")
test.isequal({ "bin/Debug/MyProject2.lib" }, r)
end
function suite.canLink_NativeAndMixedCpp()
links { "MyProject2" }
project "MyProject2"
kind "SharedLib"
language "C++"
clr "On"
local r = prepare("all", "fullpath")
test.isequal({ "bin/Debug/MyProject2.lib" }, r)
end

View file

@ -0,0 +1,296 @@
--
-- tests/config/test_targetinfo.lua
-- Test the config object's build target accessor.
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("config_targetinfo")
local config = p.config
--
-- Setup and teardown
--
local wks, prj
function suite.setup()
p.action.set("test")
wks, prj = test.createWorkspace()
system "macosx"
end
local function prepare()
local cfg = test.getconfig(prj, "Debug")
return config.gettargetinfo(cfg)
end
--
-- Directory uses targetdir() value if present.
--
function suite.directoryIsTargetDir_onTargetDir()
targetdir "../bin"
i = prepare()
test.isequal("../bin", path.getrelative(os.getcwd(), i.directory))
end
--
-- Base name should use the project name by default.
--
function suite.basenameIsProjectName_onNoTargetName()
i = prepare()
test.isequal("MyProject", i.basename)
end
--
-- Base name should use targetname() if present.
--
function suite.basenameIsTargetName_onTargetName()
targetname "MyTarget"
i = prepare()
test.isequal("MyTarget", i.basename)
end
--
-- Base name should use suffix if present.
--
function suite.basenameUsesSuffix_onTargetSuffix()
targetsuffix "-d"
i = prepare()
test.isequal("MyProject-d", i.basename)
end
--
-- Name should not have an extension for Posix executables.
--
function suite.nameHasNoExtension_onMacOSXConsoleApp()
system "MacOSX"
i = prepare()
test.isequal("MyProject", i.name)
end
function suite.nameHasNoExtension_onLinuxConsoleApp()
system "Linux"
i = prepare()
test.isequal("MyProject", i.name)
end
function suite.nameHasNoExtension_onBSDConsoleApp()
system "BSD"
i = prepare()
test.isequal("MyProject", i.name)
end
--
-- Name should use ".exe" for Windows executables.
--
function suite.nameUsesExe_onWindowsConsoleApp()
kind "ConsoleApp"
system "Windows"
i = prepare()
test.isequal("MyProject.exe", i.name)
end
function suite.nameUsesExe_onWindowsWindowedApp()
kind "WindowedApp"
system "Windows"
i = prepare()
test.isequal("MyProject.exe", i.name)
end
--
-- Name should use ".dll" for Windows shared libraries.
--
function suite.nameUsesDll_onWindowsSharedLib()
kind "SharedLib"
system "Windows"
i = prepare()
test.isequal("MyProject.dll", i.name)
end
--
-- Name should use ".lib" for Windows static libraries.
--
function suite.nameUsesLib_onWindowsStaticLib()
kind "StaticLib"
system "Windows"
i = prepare()
test.isequal("MyProject.lib", i.name)
end
--
-- Name should use "lib and ".dylib" for Mac shared libraries.
--
function suite.nameUsesLib_onMacSharedLib()
kind "SharedLib"
system "MacOSX"
i = prepare()
test.isequal("libMyProject.dylib", i.name)
end
--
-- Name should use "lib and ".a" for Mac static libraries.
--
function suite.nameUsesLib_onMacStaticLib()
kind "StaticLib"
system "MacOSX"
i = prepare()
test.isequal("libMyProject.a", i.name)
end
--
-- Name should use "lib" and ".so" for Linux shared libraries.
--
function suite.nameUsesLib_onLinuxSharedLib()
kind "SharedLib"
system "Linux"
i = prepare()
test.isequal("libMyProject.so", i.name)
end
--
-- Name should use "lib" and ".a" for Linux shared libraries.
--
function suite.nameUsesLib_onLinuxStaticLib()
kind "StaticLib"
system "Linux"
i = prepare()
test.isequal("libMyProject.a", i.name)
end
--
-- Name should use a prefix if set.
--
function suite.nameUsesPrefix_onTargetPrefix()
targetprefix "sys"
i = prepare()
test.isequal("sysMyProject", i.name)
end
--
-- Bundle name should be set and use ".app" for Mac windowed applications.
--
function suite.bundlenameUsesApp_onMacWindowedApp()
kind "WindowedApp"
system "MacOSX"
i = prepare()
test.isequal("MyProject.app", i.bundlename)
end
--
-- Bundle path should be set for Mac windowed applications.
--
function suite.bundlepathSet_onMacWindowedApp()
kind "WindowedApp"
system "MacOSX"
i = prepare()
test.isequal("bin/Debug/MyProject.app/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
end
--
-- Bundle path should be set for macOS/iOS cocoa bundle.
--
function suite.bundlepathSet_onMacSharedLibOSXBundle()
kind "SharedLib"
sharedlibtype "OSXBundle"
system "macosx"
i = prepare()
test.isequal("bin/Debug/MyProject.bundle/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
end
--
-- Bundle path should be set for macOS/iOS cocoa unit test bundle.
--
function suite.bundlepathSet_onMacSharedLibXCTest()
kind "SharedLib"
sharedlibtype "XCTest"
system "macosx"
i = prepare()
test.isequal("bin/Debug/MyProject.xctest/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
end
--
-- Bundle path should be set for macOS/iOS framework.
--
function suite.bundlepathSet_onMacSharedLibOSXFramework()
kind "SharedLib"
sharedlibtype "OSXFramework"
system "macosx"
i = prepare()
test.isequal("bin/Debug/MyProject.framework/Versions/A", path.getrelative(os.getcwd(), i.bundlepath))
end
--
-- Target extension is used if set.
--
function suite.extensionSet_onTargetExtension()
targetextension ".self"
i = prepare()
test.isequal("MyProject.self", i.name)
end
--
-- .NET executables should always default to ".exe" extensions.
--
function suite.appUsesExe_onDotNet()
_TARGET_OS = "macosx"
language "C#"
i = prepare()
test.isequal("MyProject.exe", i.name)
end
--
-- .NET libraries should always default to ".dll" extensions.
--
function suite.appUsesExe_onDotNetSharedLib()
_TARGET_OS = "macosx"
language "C#"
kind "SharedLib"
i = prepare()
test.isequal("MyProject.dll", i.name)
end