generate `*.vcxproj` file lists with `dmake` (#4652)

This commit is contained in:
Oliver Stöneberg 2023-01-21 11:55:36 +01:00 committed by GitHub
parent 38abeccd24
commit 41849b1a78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 271 additions and 88 deletions

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug-PCRE|Win32">
@ -403,24 +403,23 @@
<ItemGroup>
<ResourceCompile Include="version.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\lib\config.h" />
<ItemGroup Label="HeaderFiles">
<ClInclude Include="cmdlineparser.h" />
<ClInclude Include="cppcheckexecutor.h" />
<ClCompile Include="cppcheckexecutorseh.h" />
<ClCompile Include="cppcheckexecutorsig.h" />
<ClInclude Include="cppcheckexecutorseh.h" />
<ClInclude Include="cppcheckexecutorsig.h" />
<ClInclude Include="executor.h" />
<ClInclude Include="filelister.h" />
<ClInclude Include="processexecutor.h" />
<ClInclude Include="threadexecutor.h" />
<ClInclude Include="stacktrace.h" />
<ClInclude Include="threadexecutor.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib\cppcheck.vcxproj">
<Project>{c183db5b-ad6c-423d-80ca-1f9549555a1a}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ItemGroup Label="SourceFiles">
<ClCompile Include="cmdlineparser.cpp" />
<ClCompile Include="cppcheckexecutor.cpp" />
<ClCompile Include="cppcheckexecutorseh.cpp" />
@ -429,8 +428,8 @@
<ClCompile Include="filelister.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="processexecutor.cpp" />
<ClCompile Include="threadexecutor.cpp" />
<ClCompile Include="stacktrace.cpp" />
<ClCompile Include="threadexecutor.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
@ -13,7 +13,7 @@
<UniqueIdentifier>{6d3be647-edb6-43e6-a7eb-3031a2c7b655}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ItemGroup Label="HeaderFiles">
<ClInclude Include="..\lib\config.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -45,7 +45,7 @@
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ItemGroup Label="SourceFiles">
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>

View File

@ -15,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testrunner", "test\testrunn
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cppcheck", "lib\cppcheck.vcxproj", "{C183DB5B-AD6C-423D-80CA-1F9549555A1A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dmake", "tools\dmake.vcxproj", "{19EC86CD-0004-4917-B852-E6BD110B6E6F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -75,8 +77,23 @@ Global
{C183DB5B-AD6C-423D-80CA-1F9549555A1A}.Release-PCRE|Win32.Build.0 = Release-PCRE|Win32
{C183DB5B-AD6C-423D-80CA-1F9549555A1A}.Release-PCRE|x64.ActiveCfg = Release-PCRE|x64
{C183DB5B-AD6C-423D-80CA-1F9549555A1A}.Release-PCRE|x64.Build.0 = Release-PCRE|x64
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Debug|Win32.ActiveCfg = Debug|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Debug|Win32.Build.0 = Debug|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Debug|x64.ActiveCfg = Debug|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Debug-PCRE|Win32.ActiveCfg = Debug|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Debug-PCRE|Win32.Build.0 = Debug|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Debug-PCRE|x64.ActiveCfg = Debug|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Release|Win32.ActiveCfg = Release|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Release|Win32.Build.0 = Release|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Release|x64.ActiveCfg = Release|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Release-PCRE|Win32.ActiveCfg = Release|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Release-PCRE|Win32.Build.0 = Release|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Release-PCRE|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8CB50DEA-06DB-48E8-9C7B-F917494480A1}
EndGlobalSection
EndGlobal

View File

@ -178,7 +178,7 @@ bool isTemporary(bool cpp, const Token* tok, const Library* library, bool unknow
const Token* previousBeforeAstLeftmostLeaf(const Token* tok);
Token* previousBeforeAstLeftmostLeaf(Token* tok);
const Token * nextAfterAstRightmostLeaf(const Token * tok);
CPPCHECKLIB const Token * nextAfterAstRightmostLeaf(const Token * tok);
Token* nextAfterAstRightmostLeaf(Token* tok);
Token* astParentSkipParens(Token* tok);
@ -240,7 +240,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
int depth = 20);
const Token* followReferences(const Token* tok, ErrorPath* errors = nullptr);
bool isSameExpression(bool cpp, bool macro, const Token *tok1, const Token *tok2, const Library& library, bool pure, bool followVar, ErrorPath* errors=nullptr);
CPPCHECKLIB bool isSameExpression(bool cpp, bool macro, const Token *tok1, const Token *tok2, const Library& library, bool pure, bool followVar, ErrorPath* errors=nullptr);
bool isEqualKnownValue(const Token * const tok1, const Token * const tok2);
@ -251,7 +251,7 @@ const Token* isInLoopCondition(const Token* tok);
/**
* Is token used a boolean, that is to say cast to a bool, or used as a condition in a if/while/for
*/
bool isUsedAsBool(const Token * const tok);
CPPCHECKLIB bool isUsedAsBool(const Token * const tok);
/**
* Are two conditions opposite
@ -277,10 +277,10 @@ bool isUniqueExpression(const Token* tok);
bool isEscapeFunction(const Token* ftok, const Library* library);
/** Is scope a return scope (scope will unconditionally return) */
bool isReturnScope(const Token* const endToken,
const Library* library = nullptr,
const Token** unknownFunc = nullptr,
bool functionScope = false);
CPPCHECKLIB bool isReturnScope(const Token* const endToken,
const Library* library = nullptr,
const Token** unknownFunc = nullptr,
bool functionScope = false);
/** Is tok within a scope of the given type, nested within var's scope? */
bool isWithinScope(const Token* tok,
@ -312,10 +312,10 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, nonneg int
* @param settings program settings
* @param inconclusive pointer to output variable which indicates that the answer of the question is inconclusive
*/
bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Settings *settings, bool *inconclusive);
CPPCHECKLIB bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Settings *settings, bool *inconclusive);
/** Is variable changed in block of code? */
bool isVariableChanged(const Token *start, const Token *end, const nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20);
CPPCHECKLIB bool isVariableChanged(const Token *start, const Token *end, const nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20);
bool isVariableChanged(const Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20);
bool isVariableChanged(const Token *tok, int indirect, const Settings *settings, bool cpp, int depth = 20);
@ -380,14 +380,14 @@ int getArgumentPos(const Variable* var, const Function* f);
*/
bool isIteratorPair(std::vector<const Token*> args);
const Token *findLambdaStartToken(const Token *last);
CPPCHECKLIB const Token *findLambdaStartToken(const Token *last);
/**
* find lambda function end token
* \param first The [ token
* \return nullptr or the }
*/
const Token *findLambdaEndToken(const Token *first);
CPPCHECKLIB const Token *findLambdaEndToken(const Token *first);
Token* findLambdaEndToken(Token* first);
bool isLikelyStream(bool cpp, const Token *stream);
@ -418,7 +418,7 @@ const Token* findAllocFuncCallToken(const Token *expr, const Library &library);
bool isScopeBracket(const Token* tok);
bool isNullOperand(const Token *expr);
CPPCHECKLIB bool isNullOperand(const Token *expr);
bool isGlobalData(const Token *expr, bool cpp);

View File

@ -33,7 +33,7 @@
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ItemGroup Label="SourceFiles">
<ClCompile Include="..\externals\simplecpp\simplecpp.cpp" />
<ClCompile Include="..\externals\tinyxml2\tinyxml2.cpp" />
<ClCompile Include="analyzerinfo.cpp" />
@ -56,9 +56,8 @@
<ClCompile Include="checkbufferoverrun.cpp" />
<ClCompile Include="checkclass.cpp" />
<ClCompile Include="checkcondition.cpp" />
<ClCompile Include="checkfunctions.cpp" />
<ClCompile Include="checkstring.cpp" />
<ClCompile Include="checkexceptionsafety.cpp" />
<ClCompile Include="checkfunctions.cpp" />
<ClCompile Include="checkinternal.cpp" />
<ClCompile Include="checkio.cpp" />
<ClCompile Include="checkleakautovar.cpp" />
@ -68,6 +67,7 @@
<ClCompile Include="checkpostfixoperator.cpp" />
<ClCompile Include="checksizeof.cpp" />
<ClCompile Include="checkstl.cpp" />
<ClCompile Include="checkstring.cpp" />
<ClCompile Include="checktype.cpp" />
<ClCompile Include="checkuninitvar.cpp" />
<ClCompile Include="checkunusedfunctions.cpp" />
@ -79,7 +79,9 @@
<ClCompile Include="ctu.cpp" />
<ClCompile Include="errorlogger.cpp" />
<ClCompile Include="errortypes.cpp" />
<ClCompile Include="forwardanalyzer.cpp" />
<ClCompile Include="fwdanalysis.cpp" />
<ClCompile Include="importproject.cpp" />
<ClCompile Include="infer.cpp" />
<ClCompile Include="library.cpp" />
<ClCompile Include="mathlib.cpp" />
@ -88,8 +90,8 @@
<ClCompile Include="pathmatch.cpp" />
<ClCompile Include="platform.cpp" />
<ClCompile Include="preprocessor.cpp" />
<ClCompile Include="importproject.cpp" />
<ClCompile Include="programmemory.cpp" />
<ClCompile Include="reverseanalyzer.cpp" />
<ClCompile Include="settings.cpp" />
<ClCompile Include="summaries.cpp" />
<ClCompile Include="suppressions.cpp" />
@ -101,10 +103,8 @@
<ClCompile Include="tokenlist.cpp" />
<ClCompile Include="utils.cpp" />
<ClCompile Include="valueflow.cpp" />
<ClCompile Include="forwardanalyzer.cpp" />
<ClCompile Include="reverseanalyzer.cpp" />
</ItemGroup>
<ItemGroup>
<ItemGroup Label="HeaderFiles">
<ClInclude Include="..\externals\simplecpp\simplecpp.h" />
<ClInclude Include="..\externals\tinyxml2\tinyxml2.h" />
<ClInclude Include="analyzer.h" />
@ -120,9 +120,8 @@
<ClInclude Include="checkbufferoverrun.h" />
<ClInclude Include="checkclass.h" />
<ClInclude Include="checkcondition.h" />
<ClInclude Include="checkfunctions.h" />
<ClInclude Include="checkstring.h" />
<ClInclude Include="checkexceptionsafety.h" />
<ClInclude Include="checkfunctions.h" />
<ClInclude Include="checkinternal.h" />
<ClInclude Include="checkio.h" />
<ClInclude Include="checkleakautovar.h" />
@ -132,6 +131,7 @@
<ClInclude Include="checkpostfixoperator.h" />
<ClInclude Include="checksizeof.h" />
<ClInclude Include="checkstl.h" />
<ClInclude Include="checkstring.h" />
<ClInclude Include="checktype.h" />
<ClInclude Include="checkuninitvar.h" />
<ClInclude Include="checkunusedfunctions.h" />
@ -144,8 +144,9 @@
<ClInclude Include="ctu.h" />
<ClInclude Include="errorlogger.h" />
<ClInclude Include="errortypes.h" />
<ClInclude Include="fwdanalysis.h" />
<ClInclude Include="forwardanalyzer.h" />
<ClInclude Include="fwdanalysis.h" />
<ClInclude Include="importproject.h" />
<ClInclude Include="infer.h" />
<ClInclude Include="library.h" />
<ClInclude Include="mathlib.h" />
@ -155,7 +156,6 @@
<ClInclude Include="platform.h" />
<ClInclude Include="precompiled.h" />
<ClInclude Include="preprocessor.h" />
<ClInclude Include="importproject.h" />
<ClInclude Include="programmemory.h" />
<ClInclude Include="reverseanalyzer.h" />
<ClInclude Include="settings.h" />

View File

@ -10,7 +10,7 @@
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ItemGroup Label="SourceFiles">
<ClCompile Include="tokenize.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -192,7 +192,7 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ItemGroup Label="HeaderFiles">
<ClInclude Include="checkbufferoverrun.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -3,8 +3,10 @@
include($$PWD/pcrerules.pri)
include($$PWD/../externals/externals.pri)
INCLUDEPATH += $$PWD
HEADERS += $${PWD}/analyzerinfo.h \
HEADERS += $${PWD}/analyzer.h \
$${PWD}/analyzerinfo.h \
$${PWD}/astutils.h \
$${PWD}/calculate.h \
$${PWD}/check.h \
$${PWD}/check64bit.h \
$${PWD}/checkassert.h \
@ -33,6 +35,7 @@ HEADERS += $${PWD}/analyzerinfo.h \
$${PWD}/checkvaarg.h \
$${PWD}/clangimport.h \
$${PWD}/color.h \
$${PWD}/config.h \
$${PWD}/cppcheck.h \
$${PWD}/ctu.h \
$${PWD}/errorlogger.h \
@ -47,10 +50,13 @@ HEADERS += $${PWD}/analyzerinfo.h \
$${PWD}/pathanalysis.h \
$${PWD}/pathmatch.h \
$${PWD}/platform.h \
$${PWD}/precompiled.h \
$${PWD}/preprocessor.h \
$${PWD}/programmemory.h \
$${PWD}/reverseanalyzer.h \
$${PWD}/settings.h \
$${PWD}/smallvector.h \
$${PWD}/standards.h \
$${PWD}/summaries.h \
$${PWD}/suppressions.h \
$${PWD}/symboldatabase.h \
@ -59,8 +65,11 @@ HEADERS += $${PWD}/analyzerinfo.h \
$${PWD}/token.h \
$${PWD}/tokenize.h \
$${PWD}/tokenlist.h \
$${PWD}/tokenrange.h \
$${PWD}/utils.h \
$${PWD}/valueflow.h
$${PWD}/valueflow.h \
$${PWD}/valueptr.h \
$${PWD}/version.h
SOURCES += $${PWD}/analyzerinfo.cpp \
$${PWD}/astutils.cpp \

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -23,15 +23,16 @@
<Project>{c183db5b-ad6c-423d-80ca-1f9549555a1a}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ItemGroup Label="SourceFiles">
<ClCompile Include="..\cli\cmdlineparser.cpp" />
<ClCompile Include="..\cli\cppcheckexecutor.cpp" />
<ClCompile Include="..\cli\cppcheckexecutorseh.cpp" />
<ClCompile Include="..\cli\filelister.cpp" />
<ClCompile Include="..\cli\cppcheckexecutorsig.cpp" />
<ClCompile Include="..\cli\executor.cpp" />
<ClCompile Include="..\cli\filelister.cpp" />
<ClCompile Include="..\cli\processexecutor.cpp" />
<ClCompile Include="..\cli\stacktrace.cpp" />
<ClCompile Include="..\cli\threadexecutor.cpp" />
<ClCompile Include="..\lib\astutils.cpp" />
<ClCompile Include="options.cpp" />
<ClCompile Include="test64bit.cpp" />
<ClCompile Include="testanalyzerinformation.cpp" />
@ -51,6 +52,7 @@
<ClCompile Include="testerrorlogger.cpp" />
<ClCompile Include="testexceptionsafety.cpp" />
<ClCompile Include="testfilelister.cpp" />
<ClCompile Include="testfunctions.cpp" />
<ClCompile Include="testgarbage.cpp" />
<ClCompile Include="testimportproject.cpp" />
<ClCompile Include="testincompletestatement.cpp" />
@ -61,7 +63,6 @@
<ClCompile Include="testmathlib.cpp" />
<ClCompile Include="testmemleak.cpp" />
<ClCompile Include="testnullpointer.cpp" />
<ClCompile Include="testfunctions.cpp" />
<ClCompile Include="testoptions.cpp" />
<ClCompile Include="testother.cpp" />
<ClCompile Include="testpath.cpp" />
@ -80,10 +81,10 @@
<ClCompile Include="teststl.cpp" />
<ClCompile Include="teststring.cpp" />
<ClCompile Include="testsuite.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="testsummaries.cpp" />
<ClCompile Include="testsuppressions.cpp" />
@ -104,11 +105,16 @@
<ClCompile Include="testvalueflow.cpp" />
<ClCompile Include="testvarid.cpp" />
</ItemGroup>
<ItemGroup>
<ItemGroup Label="HeaderFiles">
<ClInclude Include="..\cli\cmdlineparser.h" />
<ClInclude Include="..\cli\cppcheckexecutor.h" />
<ClInclude Include="..\cli\cppcheckexecutorseh.h" />
<ClInclude Include="..\cli\cppcheckexecutorsig.h" />
<ClInclude Include="..\cli\executor.h" />
<ClInclude Include="..\cli\filelister.h" />
<ClInclude Include="..\cli\processexecutor.h" />
<ClInclude Include="..\cli\stacktrace.h" />
<ClInclude Include="..\cli\threadexecutor.h" />
<ClInclude Include="..\lib\config.h" />
<ClInclude Include="options.h" />
<ClInclude Include="precompiled.h" />
<ClInclude Include="redirect.h" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
@ -18,7 +18,7 @@
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ItemGroup Label="SourceFiles">
<ClCompile Include="options.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -211,9 +211,6 @@
<ClCompile Include="testastutils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\lib\astutils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="testsimplifyusing.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -230,7 +227,7 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ItemGroup Label="HeaderFiles">
<ClInclude Include="options.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -252,9 +249,6 @@
<ClInclude Include="..\cli\cmdlineparser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\lib\config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="precompiled.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -21,6 +21,7 @@
#include <algorithm>
#include <array>
#include <fstream> // IWYU pragma: keep
#include <functional>
#include <iostream>
#include <string>
#include <vector>
@ -157,6 +158,105 @@ static void makeConditionalVariable(std::ostream &os, const std::string &variabl
<< "\n";
}
static int write_vcxproj(const std::string &proj_name, const std::function<void(std::string&)> &source_f, const std::function<void(std::string&)> &header_f)
{
std::string outstr;
{
// treat as binary to prevent inplicit line ending conversions
std::ifstream in(proj_name, std::ios::binary);
if (!in.is_open()) {
std::cerr << "Could not open " << proj_name << std::endl;
return EXIT_FAILURE;
}
std::string line;
bool in_itemgroup = false;
while (std::getline(in, line)) {
if (in_itemgroup) {
if (line.find("</ItemGroup>") == std::string::npos)
continue;
in_itemgroup = false;
}
// strip all remaining line endings
const std::string::size_type pos = line.find_last_not_of("\r\n");
if (pos != std::string::npos)
line.resize(pos+1, '\0');
outstr += line;
outstr += "\r\n";
if (line.find("<ItemGroup Label=\"SourceFiles\">") != std::string::npos) {
in_itemgroup = true;
source_f(outstr);
}
if (line.find("<ItemGroup Label=\"HeaderFiles\">") != std::string::npos) {
in_itemgroup = true;
header_f(outstr);
}
}
}
// strip trailing \r\n
{
const std::string::size_type pos = outstr.find_last_not_of("\r\n");
if (pos != std::string::npos)
outstr.resize(pos+1, '\0');
}
// treat as binary to prevent inplicit line ending conversions
std::ofstream out(proj_name, std::ios::binary|std::ios::trunc);
out << outstr;
return EXIT_SUCCESS;
}
enum ClType { Compile, Include, Precompile, PrecompileNoPCRE };
static std::string make_vcxproj_cl_entry(const std::string& file, ClType type)
{
std::string outstr;
if (type == Precompile || type == PrecompileNoPCRE) {
outstr += R"( <ClCompile Include=")";
outstr += file;
outstr += R"(">)";
outstr += "\r\n";
outstr += R"( <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>)";
outstr += "\r\n";
outstr += R"( <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>)";
outstr += "\r\n";
if (type == Precompile) {
outstr += R"( <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release-PCRE|Win32'">Create</PrecompiledHeader>)";
outstr += "\r\n";
outstr += R"( <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-PCRE|Win32'">Create</PrecompiledHeader>)";
outstr += "\r\n";
}
outstr += R"( <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>)";
outstr += "\r\n";
outstr += R"( <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>)";
outstr += "\r\n";
if (type == Precompile) {
outstr += R"( <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release-PCRE|x64'">Create</PrecompiledHeader>)";
outstr += "\r\n";
outstr += R"( <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-PCRE|x64'">Create</PrecompiledHeader>)";
outstr += "\r\n";
}
outstr += " </ClCompile>\r\n";
return outstr;
}
outstr += " <";
outstr += (type == Compile) ? "ClCompile" : "ClInclude";
outstr += R"( Include=")";
outstr += file;
outstr += R"(" />)";
outstr += "\r\n";
return outstr;
}
int main(int argc, char **argv)
{
const bool release(argc >= 2 && std::string(argv[1]) == "--release");
@ -202,6 +302,93 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
// TODO: add files without source via parsing
std::vector<std::string> libfiles_h;
for (const std::string &libfile : libfiles) {
std::string fname(libfile.substr(4));
fname.erase(fname.find(".cpp"));
libfiles_h.emplace_back(fname + ".h");
}
libfiles_h.emplace_back("analyzer.h");
libfiles_h.emplace_back("calculate.h");
libfiles_h.emplace_back("config.h");
libfiles_h.emplace_back("precompiled.h");
libfiles_h.emplace_back("smallvector.h");
libfiles_h.emplace_back("standards.h");
libfiles_h.emplace_back("tokenrange.h");
libfiles_h.emplace_back("valueptr.h");
libfiles_h.emplace_back("version.h");
std::sort(libfiles_h.begin(), libfiles_h.end());
std::vector<std::string> clifiles_h;
for (const std::string &clifile : clifiles) {
std::string fname(clifile.substr(4));
if (fname == "main.cpp")
continue;
fname.erase(fname.find(".cpp"));
clifiles_h.emplace_back(fname + ".h");
}
std::vector<std::string> testfiles_h;
testfiles_h.emplace_back("options.h");
testfiles_h.emplace_back("precompiled.h");
testfiles_h.emplace_back("redirect.h");
testfiles_h.emplace_back("testsuite.h");
testfiles_h.emplace_back("testutils.h");
std::sort(testfiles_h.begin(), testfiles_h.end());
// TODO: write filter files
// Visual Studio projects
write_vcxproj("cli/cli.vcxproj", [&](std::string &outstr){
for (const std::string &clifile: clifiles) {
outstr += make_vcxproj_cl_entry(clifile.substr(4), Compile);
}
}, [&](std::string &outstr){
for (const std::string &clifile_h: clifiles_h) {
outstr += make_vcxproj_cl_entry(clifile_h, Include);
}
});
write_vcxproj("lib/cppcheck.vcxproj", [&](std::string &outstr){
outstr += make_vcxproj_cl_entry(R"(..\externals\simplecpp\simplecpp.cpp)", Compile);
outstr += make_vcxproj_cl_entry(R"(..\externals\tinyxml2\tinyxml2.cpp)", Compile);
for (const std::string &libfile: libfiles) {
const std::string l = libfile.substr(4);
outstr += make_vcxproj_cl_entry(l, l == "check.cpp" ? Precompile : Compile);
}
}, [&](std::string &outstr){
outstr += make_vcxproj_cl_entry(R"(..\externals\simplecpp\simplecpp.h)", Include);
outstr += make_vcxproj_cl_entry(R"(..\externals\tinyxml2\tinyxml2.h)", Include);
for (const std::string &libfile_h: libfiles_h) {
outstr += make_vcxproj_cl_entry(libfile_h, Include);
}
});
write_vcxproj("test/testrunner.vcxproj", [&](std::string &outstr){
for (const std::string &clifile: clifiles) {
if (clifile == "cli/main.cpp")
continue;
const std::string c = R"(..\cli\)" + clifile.substr(4);
outstr += make_vcxproj_cl_entry(c, Compile);
}
for (const std::string &testfile: testfiles) {
const std::string t = testfile.substr(5);
outstr += make_vcxproj_cl_entry(t, t == "testsuite.cpp" ? PrecompileNoPCRE : Compile);
}
}, [&](std::string &outstr){
for (const std::string &clifile_h: clifiles_h) {
const std::string c = R"(..\cli\)" + clifile_h;
outstr += make_vcxproj_cl_entry(c, Include);
}
for (const std::string &testfile_h: testfiles_h) {
outstr += make_vcxproj_cl_entry(testfile_h, Include);
}
});
// QMAKE - lib/lib.pri
{
std::ofstream fout1("lib/lib.pri");
@ -211,13 +398,9 @@ int main(int argc, char **argv)
fout1 << "include($$PWD/../externals/externals.pri)\n";
fout1 << "INCLUDEPATH += $$PWD\n";
fout1 << "HEADERS += ";
for (const std::string &libfile : libfiles) {
std::string fname(libfile.substr(4));
if (fname.find(".cpp") == std::string::npos)
continue; // shouldn't happen
fname.erase(fname.find(".cpp"));
fout1 << "$${PWD}/" << fname << ".h";
if (libfile != libfiles.back())
for (const std::string &libfile_h : libfiles_h) {
fout1 << "$${PWD}/" << libfile_h;
if (libfile_h != libfiles_h.back())
fout1 << " \\\n" << std::string(11, ' ');
}
fout1 << "\n\nSOURCES += ";

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dmake", "dmake.vcxproj", "{19EC86CD-0004-4917-B852-E6BD110B6E6F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Debug|Win32.ActiveCfg = Debug|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Debug|Win32.Build.0 = Debug|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Release|Win32.ActiveCfg = Release|Win32
{19EC86CD-0004-4917-B852-E6BD110B6E6F}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3C0A1D1C-BDE8-453D-9FB3-EC4DEB9BC733}
EndGlobalSection
EndGlobal