2016-11-09 19:29:33 +00:00
|
|
|
---
|
|
|
|
-- codelite/tests/test_codelite_config.lua
|
|
|
|
-- Automated test suite for CodeLite project generation.
|
|
|
|
-- Copyright (c) 2015 Manu Evans and the Premake project
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
local suite = test.declare("codelite_cproj_config")
|
2017-04-25 05:44:13 +00:00
|
|
|
local p = premake
|
|
|
|
local codelite = p.modules.codelite
|
2016-11-09 19:29:33 +00:00
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
-- Setup/Teardown
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local wks, prj, cfg
|
|
|
|
|
|
|
|
function suite.setup()
|
2017-04-25 05:44:13 +00:00
|
|
|
p.action.set("codelite")
|
2019-01-21 19:21:43 +00:00
|
|
|
p.escaper(codelite.esc)
|
2017-04-25 05:44:13 +00:00
|
|
|
p.indent(" ")
|
2017-06-23 14:38:52 +00:00
|
|
|
wks = test.createWorkspace()
|
2016-11-09 19:29:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare()
|
2017-06-23 14:38:52 +00:00
|
|
|
prj = test.getproject(wks,1)
|
2016-11-09 19:29:33 +00:00
|
|
|
cfg = test.getconfig(prj, "Debug")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_Compiler()
|
|
|
|
prepare()
|
|
|
|
codelite.project.compiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
|
|
|
</Compiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_Flags()
|
|
|
|
optimize "Debug"
|
|
|
|
exceptionhandling "Off"
|
|
|
|
rtti "Off"
|
|
|
|
pic "On"
|
|
|
|
symbols "On"
|
2017-05-04 00:01:33 +00:00
|
|
|
language "C++"
|
|
|
|
cppdialect "C++11"
|
2017-01-31 20:10:40 +00:00
|
|
|
flags { "NoBufferSecurityCheck" }
|
2019-05-01 17:07:02 +00:00
|
|
|
forceincludes { "forced_include1.h", "forced_include2.h" }
|
2016-11-09 19:29:33 +00:00
|
|
|
buildoptions { "-opt1", "-opt2" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.compiler(cfg)
|
|
|
|
test.capture [[
|
2019-05-01 17:07:02 +00:00
|
|
|
<Compiler Options="-O0;-fPIC;-g;-std=c++11;-fno-exceptions;-fno-stack-protector;-fno-rtti;-include forced_include1.h;-include forced_include2.h;-opt1;-opt2" C_Options="-O0;-fPIC;-g;-include forced_include1.h;-include forced_include2.h;-opt1;-opt2" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
2016-11-09 19:29:33 +00:00
|
|
|
</Compiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_Includes()
|
|
|
|
includedirs { "dir/", "dir2" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.compiler(cfg)
|
|
|
|
test.capture [[
|
2020-08-30 09:25:06 +00:00
|
|
|
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
2016-11-09 19:29:33 +00:00
|
|
|
<IncludePath Value="dir"/>
|
|
|
|
<IncludePath Value="dir2"/>
|
|
|
|
</Compiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
2020-08-30 09:25:06 +00:00
|
|
|
function suite.OnProjectCfg_SysIncludes()
|
|
|
|
sysincludedirs { "sysdir", "sysdir2/"}
|
|
|
|
prepare()
|
|
|
|
codelite.project.compiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Compiler Options="-isystem sysdir;-isystem sysdir2" C_Options="-isystem sysdir;-isystem sysdir2" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
|
|
|
</Compiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-11-09 19:29:33 +00:00
|
|
|
function suite.OnProjectCfg_Defines()
|
2019-05-01 16:37:22 +00:00
|
|
|
defines { "TEST", "DEF", "VAL=1", "ESCAPE=\"WITH SPACE\"" }
|
2016-11-09 19:29:33 +00:00
|
|
|
prepare()
|
|
|
|
codelite.project.compiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
|
|
|
<Preprocessor Value="TEST"/>
|
|
|
|
<Preprocessor Value="DEF"/>
|
2019-05-01 16:37:22 +00:00
|
|
|
<Preprocessor Value="VAL=1"/>
|
2020-08-30 07:38:26 +00:00
|
|
|
<Preprocessor Value="ESCAPE="WITH\ SPACE""/>
|
2016-11-09 19:29:33 +00:00
|
|
|
</Compiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
2021-05-29 18:19:18 +00:00
|
|
|
function suite.OnProjectCfg_Pch()
|
|
|
|
pchheader "pch.h"
|
|
|
|
prepare()
|
|
|
|
codelite.project.compiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="pch.h" PCHInCommandLine="yes" UseDifferentPCHFlags="no" PCHFlags="">
|
|
|
|
</Compiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
2016-11-09 19:29:33 +00:00
|
|
|
function suite.OnProjectCfg_Linker()
|
|
|
|
prepare()
|
|
|
|
codelite.project.linker(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Linker Required="yes" Options="">
|
|
|
|
</Linker>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_LibPath()
|
|
|
|
libdirs { "test/", "test2" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.linker(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Linker Required="yes" Options="">
|
2018-03-26 13:44:40 +00:00
|
|
|
<LibraryPath Value="test"/>
|
|
|
|
<LibraryPath Value="test2"/>
|
2016-11-09 19:29:33 +00:00
|
|
|
</Linker>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_Libs()
|
2016-11-16 20:40:49 +00:00
|
|
|
links { "a", "b" }
|
2016-11-09 19:29:33 +00:00
|
|
|
prepare()
|
|
|
|
codelite.project.linker(cfg)
|
|
|
|
test.capture [[
|
2016-11-16 20:40:49 +00:00
|
|
|
<Linker Required="yes" Options="-la;-lb">
|
2016-11-09 19:29:33 +00:00
|
|
|
</Linker>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
-- TODO: test sibling lib project links
|
|
|
|
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_ResCompiler()
|
|
|
|
prepare()
|
|
|
|
codelite.project.resourceCompiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<ResourceCompiler Options="" Required="no"/>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_ResInclude()
|
|
|
|
files { "x.rc" }
|
2020-08-30 09:25:06 +00:00
|
|
|
resincludedirs { "dir/" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.resourceCompiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<ResourceCompiler Options="" Required="yes">
|
|
|
|
<IncludePath Value="dir"/>
|
|
|
|
</ResourceCompiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_ResRegularInclude()
|
|
|
|
files { "x.rc" }
|
|
|
|
includedirs { "regulardir/" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.resourceCompiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<ResourceCompiler Options="" Required="yes">
|
|
|
|
<IncludePath Value="regulardir"/>
|
|
|
|
</ResourceCompiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_ResSysInclude()
|
|
|
|
files { "x.rc" }
|
2020-08-29 14:39:23 +00:00
|
|
|
sysincludedirs { "sysdir/" }
|
2016-11-09 19:29:33 +00:00
|
|
|
prepare()
|
|
|
|
codelite.project.resourceCompiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<ResourceCompiler Options="" Required="yes">
|
2020-08-29 14:39:23 +00:00
|
|
|
<IncludePath Value="sysdir"/>
|
2016-11-09 19:29:33 +00:00
|
|
|
</ResourceCompiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_General()
|
|
|
|
system "Windows"
|
|
|
|
prepare()
|
|
|
|
codelite.project.general(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<General OutputFile="bin/Debug/MyProject.exe" IntermediateDirectory="obj/Debug" Command="bin/Debug/MyProject.exe" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_Environment()
|
2018-05-23 19:43:53 +00:00
|
|
|
debugenvs { "ENV_ONE=1", "ENV_TWO=2" }
|
2016-11-09 19:29:33 +00:00
|
|
|
prepare()
|
|
|
|
codelite.project.environment(cfg)
|
|
|
|
test.capture(
|
|
|
|
' <Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">\n' ..
|
2018-05-23 19:43:53 +00:00
|
|
|
' <![CDATA[ENV_ONE=1\n' ..
|
|
|
|
'ENV_TWO=2]]>\n' ..
|
2016-11-09 19:29:33 +00:00
|
|
|
' </Environment>'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2019-05-01 16:37:22 +00:00
|
|
|
function suite.OnProjectCfg_EnvironmentEscaping()
|
|
|
|
debugenvs { "\"ENV\"=<&>" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.environment(cfg)
|
|
|
|
test.capture(
|
|
|
|
' <Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">\n' ..
|
|
|
|
' <![CDATA["ENV"=<&>]]>\n' ..
|
|
|
|
' </Environment>'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2016-11-09 19:29:33 +00:00
|
|
|
function suite.OnProjectCfg_Debugger()
|
|
|
|
prepare()
|
|
|
|
codelite.project.debugger(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
|
|
|
<DebuggerSearchPaths/>
|
|
|
|
<PostConnectCommands/>
|
|
|
|
<StartupCommands/>
|
|
|
|
</Debugger>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_DebuggerOpts()
|
|
|
|
debugremotehost "localhost"
|
|
|
|
debugport(2345)
|
|
|
|
debugextendedprotocol(true)
|
|
|
|
debugsearchpaths { "search/", "path" }
|
|
|
|
debugconnectcommands { "connectcmd1", "cmd2" }
|
|
|
|
debugstartupcommands { "startcmd1", "cmd2" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.debugger(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="2345" DebuggerPath="" IsExtended="yes">
|
|
|
|
<DebuggerSearchPaths>search
|
|
|
|
path</DebuggerSearchPaths>
|
|
|
|
<PostConnectCommands>connectcmd1
|
|
|
|
cmd2</PostConnectCommands>
|
|
|
|
<StartupCommands>startcmd1
|
|
|
|
cmd2</StartupCommands>
|
|
|
|
</Debugger>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
2019-05-01 16:37:22 +00:00
|
|
|
function suite.OnProjectCfg_DebuggerOptsEscaping()
|
|
|
|
debugremotehost "localhost"
|
|
|
|
debugport(2345)
|
|
|
|
debugextendedprotocol(true)
|
|
|
|
debugsearchpaths { "\"search\" && <path>" }
|
|
|
|
debugconnectcommands { "\"connect\" && <cmd>" }
|
|
|
|
debugstartupcommands { "\"start\" && <cmd>" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.debugger(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="2345" DebuggerPath="" IsExtended="yes">
|
|
|
|
<DebuggerSearchPaths>"search" && <path></DebuggerSearchPaths>
|
|
|
|
<PostConnectCommands>"connect" && <cmd></PostConnectCommands>
|
|
|
|
<StartupCommands>"start" && <cmd></StartupCommands>
|
|
|
|
</Debugger>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_PreBuild()
|
2016-11-09 19:29:33 +00:00
|
|
|
prebuildcommands { "cmd0", "cmd1" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.preBuild(prj)
|
|
|
|
test.capture [[
|
|
|
|
<PreBuild>
|
|
|
|
<Command Enabled="yes">cmd0</Command>
|
|
|
|
<Command Enabled="yes">cmd1</Command>
|
|
|
|
</PreBuild>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
2019-05-01 16:37:22 +00:00
|
|
|
function suite.OnProjectCfg_PreBuild_Escaped()
|
2019-01-21 19:21:43 +00:00
|
|
|
prebuildcommands {
|
|
|
|
"touch \"./build/copyright\" && echo OK",
|
|
|
|
"cat \"./lib/copyright\" >> \"./build/copyright\""
|
|
|
|
}
|
|
|
|
prepare()
|
|
|
|
codelite.project.preBuild(prj)
|
|
|
|
test.capture [[
|
|
|
|
<PreBuild>
|
|
|
|
<Command Enabled="yes">touch "./build/copyright" && echo OK</Command>
|
|
|
|
<Command Enabled="yes">cat "./lib/copyright" >> "./build/copyright"</Command>
|
|
|
|
</PreBuild>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
2019-05-01 16:37:22 +00:00
|
|
|
function suite.OnProjectCfg_PostBuild()
|
2016-11-09 19:29:33 +00:00
|
|
|
postbuildcommands { "cmd0", "cmd1" }
|
|
|
|
prepare()
|
|
|
|
codelite.project.postBuild(prj)
|
|
|
|
test.capture [[
|
|
|
|
<PostBuild>
|
|
|
|
<Command Enabled="yes">cmd0</Command>
|
|
|
|
<Command Enabled="yes">cmd1</Command>
|
|
|
|
</PostBuild>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
2019-05-01 16:37:22 +00:00
|
|
|
function suite.OnProjectCfg_PostBuild_Escaped()
|
2019-01-21 19:21:43 +00:00
|
|
|
postbuildcommands {
|
|
|
|
"touch \"./build/copyright\" && echo OK",
|
|
|
|
"cat \"./lib/copyright\" >> \"./build/copyright\""
|
|
|
|
}
|
|
|
|
prepare()
|
|
|
|
codelite.project.postBuild(prj)
|
|
|
|
test.capture [[
|
|
|
|
<PostBuild>
|
|
|
|
<Command Enabled="yes">touch "./build/copyright" && echo OK</Command>
|
|
|
|
<Command Enabled="yes">cat "./lib/copyright" >> "./build/copyright"</Command>
|
|
|
|
</PostBuild>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
2016-11-09 19:29:33 +00:00
|
|
|
-- TODO: test custom build
|
|
|
|
|
|
|
|
|
2019-05-01 16:37:22 +00:00
|
|
|
function suite.OnProjectCfg_AdditionalRules()
|
2016-11-09 19:29:33 +00:00
|
|
|
prepare()
|
|
|
|
codelite.project.additionalRules(prj)
|
|
|
|
test.capture [[
|
|
|
|
<AdditionalRules>
|
|
|
|
<CustomPostBuild/>
|
|
|
|
<CustomPreBuild/>
|
|
|
|
</AdditionalRules>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
2019-05-01 16:37:22 +00:00
|
|
|
function suite.OnProjectCfg_Completion()
|
2017-05-04 00:01:33 +00:00
|
|
|
language "C++"
|
|
|
|
cppdialect "C++11"
|
2016-11-09 19:29:33 +00:00
|
|
|
prepare()
|
|
|
|
codelite.project.completion(prj)
|
|
|
|
test.capture [[
|
|
|
|
<Completion EnableCpp11="yes" EnableCpp14="no">
|
|
|
|
<ClangCmpFlagsC/>
|
|
|
|
<ClangCmpFlags/>
|
|
|
|
<ClangPP/>
|
|
|
|
<SearchPaths/>
|
|
|
|
</Completion>
|
|
|
|
]]
|
|
|
|
end
|
2018-04-10 20:03:12 +00:00
|
|
|
|
|
|
|
function suite.OnProjectCfg_UnsignedCharOn()
|
|
|
|
unsignedchar "On"
|
|
|
|
prepare()
|
|
|
|
codelite.project.compiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Compiler Options="-funsigned-char" C_Options="-funsigned-char" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
|
|
|
</Compiler>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function suite.OnProjectCfg_UnsignedCharOff()
|
|
|
|
unsignedchar "Off"
|
|
|
|
prepare()
|
|
|
|
codelite.project.compiler(cfg)
|
|
|
|
test.capture [[
|
|
|
|
<Compiler Options="-fno-unsigned-char" C_Options="-fno-unsigned-char" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
|
|
|
</Compiler>
|
|
|
|
]]
|
|
|
|
end
|