improved physics, added better caching

This commit is contained in:
2025-06-05 22:02:53 +03:00
parent 5d85ebd85f
commit 64c0f41884
36 changed files with 651 additions and 106 deletions

View File

@@ -19,6 +19,7 @@ CLDProject CCProject::Compile()
unsigned int hash = GenerateProjectHash();
for (auto &file: files)
{
V_printf(" CC %s\n", file.GetString());
CUtlString szOutputFile = CUtlString("%s/cc/%u_%s/%s/%s.o",FPC_TEMPORAL_DIRNAME, hash, m_szName.GetString(), IFileSystem2::OwnDirectory(), file.GetString());
CUtlString szOutputDir;
CUtlVector<CUtlString> args;
@@ -83,7 +84,7 @@ void CCProject::GenerateCompileCommands()
V_fseek(f, -2, SEEK_CUR);
V_fprintf(f, "\n\t\t],\n");
V_fprintf(f, "\t\t\"file\": \"%s\",\n", file.m_szName.GetString());
V_fprintf(f, "\t\t\"directory\": \"%s\"\n", IFileSystem2::OwnDirectory());
V_fprintf(f, "\t\t\"directory\": \"%s\"\n", IFileSystem2::BuildDirectory());
V_fprintf(f, "\t},\n");
};
V_fseek(f, -2, SEEK_CUR);

View File

@@ -43,6 +43,15 @@ void IFileSystem2::CopyFile( const char *szDestination, const char *szOrigin )
};
IRunner::Run("cp", args);
}
void IFileSystem2::CopyDirectory( const char *szDestination, const char *szOrigin )
{
CUtlVector<CUtlString> args = {
"-r",
CUtlString(szOrigin),
CUtlString(szDestination),
};
IRunner::Run("cp", args);
}
void IFileSystem2::MakeDirectory( const char *psz )
{

View File

@@ -1,4 +1,5 @@
#include "ld.h"
#include "helper.h"
#include "libgen.h"
CUtlString CLDProject::Link( void )
@@ -23,7 +24,20 @@ CUtlString CLDProject::Link( void )
IFileSystem2::MakeDirectory(szOutputDir);
if (linkType == ELINK_STATIC_LIBRARY)
{
CUtlVector<CUtlString> args = {
V_printf(" AR %s\n", m_szName.GetString());
bool shouldRecompile = false;
CUtlVector<CUtlString> args;
for (auto object: objects)
{
if (IFileSystem2::ShouldRecompile(object.m_szObjectFile,szOutputFile))
{
shouldRecompile = true;
break;
}
}
if (!shouldRecompile)
goto compiled;
args = {
"rcs",
szOutputFile
};
@@ -31,7 +45,20 @@ CUtlString CLDProject::Link( void )
args.AppendTail(object.m_szObjectFile);
IRunner::Run("ar", args);
} else {
CUtlVector<CUtlString> args = {
V_printf(" LINK %s\n", m_szName.GetString());
bool shouldRecompile = false;
CUtlVector<CUtlString> args;
for (auto object: objects)
{
if (IFileSystem2::ShouldRecompile(object.m_szObjectFile,szOutputFile))
{
shouldRecompile = true;
break;
}
}
if (!shouldRecompile)
goto compiled;
args = {
"-rdynamic",
"-o",
szOutputFile,
@@ -47,5 +74,6 @@ CUtlString CLDProject::Link( void )
}
IRunner::Run("clang++", args);
}
compiled:
return szOutputFile;
};

View File

@@ -16,7 +16,6 @@ int IRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
execargs.AppendTail(szName);
for (auto &arg: args)
{
V_printf("%s\n",arg.GetString());
execargs.AppendTail(arg);
}
execargs.AppendTail(0);

View File

@@ -7,6 +7,7 @@
#include "tier1/utlvector.h"
#include "signal.h"
#include "libgen.h"
#include <unistd.h>
CUtlString owndir;
int build()
@@ -50,7 +51,9 @@ void IEngine_Signal(int sig)
int main(int c, char **v)
{
CUtlString buildcppDir = IFileSystem2::OwnDirectory();
char path[1024];
CUtlString buildcppDir = getcwd(path, 1024);
owndir = buildcppDir;
char *szBuildcppDir = buildcppDir.GetString();
findbuild: