File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -553,20 +553,23 @@ namespace {
553553 }
554554 }
555555
556+ // see https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-conditions
557+ // properties are .NET String objects and you can call any of its members on them
556558 bool conditionIsTrue (const ProjectConfiguration &p) const {
557559 if (condition.empty ())
558560 return true ;
559561 std::string c = ' (' + condition + " );" ;
560562 replaceAll (c, " $(Configuration)" , p.configuration );
561563 replaceAll (c, " $(Platform)" , p.platformStr );
562564
563- // TODO: evaluate without using the Tokenizer
565+ // TODO: improve evaluation
564566 const Settings s;
565- Tokenizer tokenizer (s, nullptr );
567+ TokenList tokenlist (&s );
566568 std::istringstream istr (c);
567- tokenizer. tokenize (istr," vcxproj.c " );
568- for (const Token *tok = tokenizer. tokens (); tok; tok = tok->next ()) {
569+ tokenlist. createTokens (istr, Standards::Language::C); // TODO: check result
570+ for (const Token *tok = tokenlist. front (); tok; tok = tok->next ()) {
569571 if (tok->str () == " (" && tok->astOperand1 () && tok->astOperand2 ()) {
572+ // TODO: this is wrong - it is Contains() not Equals()
570573 if (tok->astOperand1 ()->expressionString () == " Configuration.Contains" )
571574 return (' \' ' + p.configuration + ' \' ' ) == tok->astOperand2 ()->str ();
572575 }
Original file line number Diff line number Diff line change @@ -389,6 +389,27 @@ class TestImportProject : public TestFixture {
389389 }
390390
391391 // TODO: test fsParseCommand()
392+
393+ // TODO: test vcxproj conditions
394+ /*
395+ <?xml version="1.0" encoding="utf-8"?>
396+ <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
397+ <ItemGroup Label="ProjectConfigurations">
398+ <ProjectConfiguration Include="Debug|x64">
399+ <Configuration>Debug</Configuration>
400+ <Platform>x64</Platform>
401+ </ProjectConfiguration>
402+ </ItemGroup>
403+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
404+ <ClCompile>
405+ <PreprocessorDefinitions>CPPCHECKLIB_IMPORT</PreprocessorDefinitions>
406+ </ClCompile>
407+ </ItemDefinitionGroup>
408+ <ItemGroup>
409+ <ClCompile Include="main.c" />
410+ </ItemGroup>
411+ </Project>
412+ */
392413};
393414
394415REGISTER_TEST (TestImportProject)
You can’t perform that action at this time.
0 commit comments