Skip to content

Commit

Permalink
VSProject - Add support for CompileFileCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-polymorph committed Sep 17, 2023
1 parent 7c2426a commit 1a360cf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Code/Tools/FBuild/FBuildCore/Graph/NodeGraph.h
Expand Up @@ -64,7 +64,7 @@ class NodeGraphHeader
}
inline ~NodeGraphHeader() = default;

enum : uint8_t { NODE_GRAPH_CURRENT_VERSION = 171 };
enum : uint8_t { NODE_GRAPH_CURRENT_VERSION = 172 };

bool IsValid() const;
bool IsCompatibleVersion() const { return m_Version == NODE_GRAPH_CURRENT_VERSION; }
Expand Down
1 change: 1 addition & 0 deletions Code/Tools/FBuild/FBuildCore/Graph/VCXProjectNode.cpp
Expand Up @@ -36,6 +36,7 @@ REFLECT_STRUCT_BEGIN_BASE( VSProjectConfigBase )
REFLECT( m_ProjectBuildCommand, "ProjectBuildCommand", MetaInheritFromOwner() + MetaOptional() )
REFLECT( m_ProjectRebuildCommand, "ProjectRebuildCommand", MetaInheritFromOwner() + MetaOptional() )
REFLECT( m_ProjectCleanCommand, "ProjectCleanCommand", MetaInheritFromOwner() + MetaOptional() )
REFLECT( m_CompileFileCommand, "CompileFileCommand", MetaInheritFromOwner() + MetaOptional() )
REFLECT( m_Output, "Output", MetaInheritFromOwner() + MetaOptional() )
REFLECT( m_PreprocessorDefinitions, "PreprocessorDefinitions", MetaInheritFromOwner() + MetaOptional() )
REFLECT( m_IncludeSearchPath, "IncludeSearchPath", MetaInheritFromOwner() + MetaOptional() )
Expand Down
1 change: 1 addition & 0 deletions Code/Tools/FBuild/FBuildCore/Graph/VCXProjectNode.h
Expand Up @@ -26,6 +26,7 @@ class VSProjectConfigBase : public Struct
AString m_ProjectBuildCommand;
AString m_ProjectRebuildCommand;
AString m_ProjectCleanCommand;
AString m_CompileFileCommand;
AString m_Output;
AString m_PreprocessorDefinitions;
AString m_IncludeSearchPath;
Expand Down
14 changes: 11 additions & 3 deletions Code/Tools/FBuild/FBuildCore/Helpers/VSProjectGenerator.cpp
Expand Up @@ -142,13 +142,13 @@ const AString & VSProjectGenerator::GenerateVCXProj( const AString & projectFile
}
if ( fileTypeToUse )
{
WriteF( " <CustomBuild Include=\"%s\">\n", fileName.Get() );
WriteF( " <ClCompile Include=\"%s\">\n", fileName.Get() );
WriteF( " <FileType>%s</FileType>\n", fileTypeToUse );
Write( " </CustomBuild>\n" );
Write( " </ClCompile>\n" );
}
else
{
WriteF( " <CustomBuild Include=\"%s\" />\n", fileName.Get() );
WriteF( " <ClCompile Include=\"%s\" />\n", fileName.Get() );
}
}
Write(" </ItemGroup>\n" );
Expand Down Expand Up @@ -420,6 +420,14 @@ const AString & VSProjectGenerator::GenerateVCXProj( const AString & projectFile
WritePGItem( "DeploymentFiles", config.m_DeploymentFiles );
Write( " </Deploy>\n" );
}
if ( !config.m_CompileFileCommand.IsEmpty() )
{
AString compileFileCommand( config.m_CompileFileCommand );
compileFileCommand.Replace( "%1", "$(SelectedFiles)" );
Write( " <NMakeCompile>\n" );
WritePGItem( "NMakeCompileFileCommandLine", compileFileCommand );
Write( " </NMakeCompile>\n" );
}
Write( " </ItemDefinitionGroup>\n" );
}
}
Expand Down
12 changes: 6 additions & 6 deletions Code/Tools/FBuild/FBuildTest/Tests/TestProjectGeneration.cpp
Expand Up @@ -1000,9 +1000,9 @@ void TestProjectGeneration::VCXProj_ProjectRelativePaths() const
// Check vcxproj
{
AStackString<> proj( pg.GenerateVCXProj( projectFileName, configs, Array< VSProjectFileType >(), Array< VSProjectImport >() ) );
TEST_ASSERT( proj.Replace( "<CustomBuild Include=\"..\\ProjectSourceFiles\\File.cpp\" />", "" ) == 1 );
TEST_ASSERT( proj.Replace( "<CustomBuild Include=\"..\\ProjectSourceFiles\\SubDir\\File.cpp\" />", "" ) == 1 );
TEST_ASSERT( proj.FindI( "<CustomBuild " ) == nullptr );
TEST_ASSERT( proj.Replace( "<ClCompile Include=\"..\\ProjectSourceFiles\\File.cpp\" />", "" ) == 1 );
TEST_ASSERT( proj.Replace( "<ClCompile Include=\"..\\ProjectSourceFiles\\SubDir\\File.cpp\" />", "" ) == 1 );
TEST_ASSERT( proj.FindI( "<ClCompile " ) == nullptr );
}

// Check vcxproj.filters
Expand Down Expand Up @@ -1071,9 +1071,9 @@ void TestProjectGeneration::VCXProj_ProjectRelativePaths2() const
// Check vcxproj
{
AStackString<> proj( pg.GenerateVCXProj( projectFileName, configs, Array< VSProjectFileType >(), Array< VSProjectImport >() ) );
TEST_ASSERT( proj.Replace( "<CustomBuild Include=\"GeneratedCpp.cpp\" />", "" ) == 1 );
TEST_ASSERT( proj.Replace( "<CustomBuild Include=\"SubDir\\GeneratedCpp.cpp\" />", "" ) == 1 );
TEST_ASSERT( proj.FindI( "<CustomBuild " ) == nullptr );
TEST_ASSERT( proj.Replace( "<ClCompile Include=\"GeneratedCpp.cpp\" />", "" ) == 1 );
TEST_ASSERT( proj.Replace( "<ClCompile Include=\"SubDir\\GeneratedCpp.cpp\" />", "" ) == 1 );
TEST_ASSERT( proj.FindI( "<ClCompile " ) == nullptr );
}

// Check vcxproj.filters
Expand Down

0 comments on commit 1a360cf

Please sign in to comment.