improvements to the fpc

This commit is contained in:
2025-11-27 20:09:11 +02:00
parent 34e54fdc0d
commit f031ed3f70
5 changed files with 298 additions and 75 deletions

View File

@@ -23,14 +23,108 @@ struct ClangFile_t
class CMSVCCompiler : public ICCompiler
{
public:
virtual LinkProject_t Compile( CProject_t *pProject ) override;
virtual void GenerateLinterData( void ) override;
virtual void GenerateLinterData() override;
protected:
virtual CUtlVector<CUtlString> BuildCommandLine( CProject_t *pProject, const char *szFileName, const char *szOutputFileName ) override;
// Returns executable which should the OS run
virtual const char *GetCompilerExecutable( CProject_t *pProject ) override;
// returns object file format, eg .obj or .o
virtual const char *GetOutputObjectFormat() override;
virtual void IncludeDirectory( CUtlVector<CUtlString> &cmd, const char *szName ) override;
virtual void IncludeFile( CUtlVector<CUtlString> &cmd, const char *szName ) override;
virtual void Macro( CUtlVector<CUtlString> &cmd, const char *szName ) override;
virtual void Macro( CUtlVector<CUtlString> &cmd, const char *szName, const char *szValue ) override;
virtual void SetTarget( CUtlVector<CUtlString> &cmd, CProject_t *pProject ) override;
virtual void CompileFile( CUtlVector<CUtlString> &cmd, const char *szName ) override;
virtual void SetOutputFile( CUtlVector<CUtlString> &cmd, const char *szName ) override;
virtual void EnableDebugSymbols( CUtlVector<CUtlString> &cmd ) override;
virtual void EnablePIE( CUtlVector<CUtlString> &cmd ) override;
virtual void EnablePIC( CUtlVector<CUtlString> &cmd ) override;
};
const char *CMSVCCompiler::GetOutputObjectFormat()
{
return ".o";
}
CUtlVector<CUtlString> CMSVCCompiler::BuildCommandLine( CProject_t *pProject, const char *szFileName, const char *szOutputFileName )
{
CUtlVector<CUtlString> cmd;
cmd = ICCompiler::BuildCommandLine(pProject, szFileName, szOutputFileName);
cmd.AppendHead("/c");
return cmd;
}
const char *CMSVCCompiler::GetCompilerExecutable( CProject_t *pProject )
{
if (!g_pConfig)
Plat_FatalErrorFunc(".fpccfg was not found\n");
static IINISection *pSection = g_pConfig->GetSection("MSVC_C_COMPILER_INTERFACE_NAME");
if (!pSection)
Plat_FatalErrorFunc("MSVC_C_COMPILER_INTERFACE_NAME was not found in .fpccfg\n");
static CUtlString szExePath = pSection->GetStringValue("exe");
return szExePath;
}
void CMSVCCompiler::IncludeDirectory( CUtlVector<CUtlString> &cmd, const char *szName )
{
cmd.AppendTail(CUtlString("/I%s",szName));
}
void CMSVCCompiler::IncludeFile( CUtlVector<CUtlString> &cmd, const char *szName )
{
}
void CMSVCCompiler::Macro( CUtlVector<CUtlString> &cmd, const char *szName )
{
}
void CMSVCCompiler::Macro( CUtlVector<CUtlString> &cmd, const char *szName, const char *szValue )
{
cmd.AppendTail(CUtlString("/D%s=%s", (char*)szName, (char*)szValue));
}
void CMSVCCompiler::EnableDebugSymbols( CUtlVector<CUtlString> &cmd )
{
}
void CMSVCCompiler::SetTarget( CUtlVector<CUtlString> &cmd, CProject_t *pProject )
{
}
void CMSVCCompiler::CompileFile( CUtlVector<CUtlString> &cmd, const char *szName )
{
cmd.AppendTail(szName);
}
void CMSVCCompiler::SetOutputFile( CUtlVector<CUtlString> &cmd, const char *szName )
{
cmd.AppendTail("/Fo");
cmd.AppendTail(szName);
}
void CMSVCCompiler::EnablePIE( CUtlVector<CUtlString> &cmd )
{
}
void CMSVCCompiler::EnablePIC( CUtlVector<CUtlString> &cmd )
{
}
EXPOSE_INTERFACE(CMSVCCompiler, ICCompiler, MSVC_C_COMPILER_INTERFACE_NAME);
/*
CUtlVector<ClangFile_t> g_msvcFiles;
*/
/*
LinkProject_t CMSVCCompiler::Compile( CProject_t *pProject )
{
if (pProject->m_szName == 0)
@@ -55,7 +149,6 @@ LinkProject_t CMSVCCompiler::Compile( CProject_t *pProject )
if (!pSection)
Plat_FatalErrorFunc("MSVC_C_COMPILER_INTERFACE_NAME was not found in .fpccfg\n");
CUtlString szExePath = pSection->GetStringValue("exe");
bool bUseClangCL = pSection->GetStringValue("exe");
@@ -87,7 +180,6 @@ LinkProject_t CMSVCCompiler::Compile( CProject_t *pProject )
args = {
"/nologo",
};
/*
if (!strcmp(Plat_GetExtension(file),"cpp"))
args.AppendTail("-std=c++17");
else if (!strcmp(Plat_GetExtension(file),"mm"))
@@ -99,7 +191,6 @@ LinkProject_t CMSVCCompiler::Compile( CProject_t *pProject )
args.AppendTail("-fPIC");
if (pProject->bFPIE)
args.AppendTail("-fPIE");
*/
for (auto &macro: pProject->macros)
{
args.AppendTail(CUtlString("/D%s=%s", (char*)macro.szName, (char*)macro.szValue));
@@ -110,13 +201,11 @@ LinkProject_t CMSVCCompiler::Compile( CProject_t *pProject )
args.AppendTail(CUtlString("/I%s", szWindowsPath));
V_free((void*)szWindowsPath);
}
/*
for (auto &include: pProject->includeFiles)
{
args.AppendTail("-include");
args.AppendTail(include);
}
*/
if (!filesystem2->ShouldRecompile(file, szOutputFile) && !bAreDependenciesUpdated)
@@ -142,13 +231,13 @@ skipcompile:
else
cfile.m_szArguments.AppendHead("clang");
/*
g_clangFiles.AppendTail(cfile);
*/
}
winerunner->Wait();
return proj;
}
*/
void CMSVCCompiler::GenerateLinterData()
{