added compile_commands.json
This commit is contained in:
10
fpc/Makefile
10
fpc/Makefile
@@ -4,10 +4,16 @@ FPC_FILES := main.cpp library/runner.cpp library/helper.cpp library/c.cpp librar
|
|||||||
CC = clang
|
CC = clang
|
||||||
OUTPUT_DIR = fpc
|
OUTPUT_DIR = fpc
|
||||||
|
|
||||||
install:
|
recompile:
|
||||||
|
./fpc build
|
||||||
|
mv fpc_temp fpc
|
||||||
|
cp fpc ../build/tools/fpc
|
||||||
|
|
||||||
../build/tools:
|
../build/tools:
|
||||||
mkdir -p ../build/tools
|
mkdir -p ../build/tools
|
||||||
|
|
||||||
minimal: $(TIER0_FILES) $(TIER1_FILES) $(FPC_FILES) ../build/tools
|
install: $(TIER0_FILES) $(TIER1_FILES) $(FPC_FILES) ../build/tools
|
||||||
$(CC) -g -rdynamic $(TIER0_FILES) $(TIER1_FILES) $(FPC_FILES) -I../public -Ipublic -lc -lstdc++ -o $(OUTPUT_DIR)
|
$(CC) -g -rdynamic $(TIER0_FILES) $(TIER1_FILES) $(FPC_FILES) -I../public -Ipublic -lc -lstdc++ -o $(OUTPUT_DIR)
|
||||||
|
./fpc build
|
||||||
|
mv fpc_temp fpc
|
||||||
|
cp fpc ../build/tools/fpc
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "public/c.h"
|
#include "c.h"
|
||||||
#include "public/ld.h"
|
#include "ld.h"
|
||||||
#include "public/c.h"
|
#include "helper.h"
|
||||||
#include "public/helper.h"
|
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
|
|
||||||
@@ -37,9 +36,10 @@ int build_fpc()
|
|||||||
compileProject.includeDirectories = g_IncludeDirectories;
|
compileProject.includeDirectories = g_IncludeDirectories;
|
||||||
ldProject = compileProject.Compile();
|
ldProject = compileProject.Compile();
|
||||||
|
|
||||||
ldProject.Link();
|
CUtlString outputProject = ldProject.Link();
|
||||||
|
|
||||||
IFileSystem2::MakeDirectory("../build/tools");
|
IFileSystem2::MakeDirectory("../build/tools");
|
||||||
|
IFileSystem2::CopyFile("fpc_temp", outputProject);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "libgen.h"
|
#include "libgen.h"
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
struct ClangFile_t
|
struct ClangFile_t
|
||||||
{
|
{
|
||||||
@@ -54,9 +55,33 @@ CLDProject CCProject::Compile()
|
|||||||
proj.objects.AppendTail((CObject){szOutputFile});
|
proj.objects.AppendTail((CObject){szOutputFile});
|
||||||
|
|
||||||
ClangFile_t cfile = {};
|
ClangFile_t cfile = {};
|
||||||
cfile.m_szName = m_szName;
|
cfile.m_szName = file;
|
||||||
cfile.m_szArguments = args;
|
cfile.m_szArguments = args;
|
||||||
g_clangFiles.AppendTail(cfile);
|
g_clangFiles.AppendTail(cfile);
|
||||||
}
|
}
|
||||||
return proj;
|
return proj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCProject::GenerateCompileCommands()
|
||||||
|
{
|
||||||
|
FILE* f = V_fopen("compile_commands.json", "w");
|
||||||
|
V_fprintf(f, "[\n");
|
||||||
|
uint32_t i = 0;
|
||||||
|
for (auto &file: g_clangFiles)
|
||||||
|
{
|
||||||
|
V_fprintf(f, "\t{\n");
|
||||||
|
V_fprintf(f, "\t\t\"arguments\": [\n");
|
||||||
|
V_fprintf(f, "\t\t\t\"clang\",\n");
|
||||||
|
for (auto &arg: file.m_szArguments)
|
||||||
|
V_fprintf(f, "\t\t\t\"%s\",\n",arg.GetString());
|
||||||
|
|
||||||
|
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},\n");
|
||||||
|
};
|
||||||
|
V_fseek(f, -2, SEEK_CUR);
|
||||||
|
V_fprintf(f, "\n]\n");
|
||||||
|
V_fclose(f);
|
||||||
|
};
|
||||||
|
|||||||
@@ -23,11 +23,25 @@ unsigned int CProject::GenerateProjectHash( void )
|
|||||||
|
|
||||||
static char path[1024];
|
static char path[1024];
|
||||||
static ssize_t pathSize = readlink("/proc/self/exe", path, sizeof(path) - 1);
|
static ssize_t pathSize = readlink("/proc/self/exe", path, sizeof(path) - 1);
|
||||||
static char* pathDir = dirname(path);
|
char *szPathDir = dirname(path);
|
||||||
|
char *szBuildDir = 0;
|
||||||
char *IFileSystem2::OwnDirectory()
|
char *IFileSystem2::OwnDirectory()
|
||||||
{
|
{
|
||||||
return pathDir;
|
return szPathDir;
|
||||||
};
|
};
|
||||||
|
char *IFileSystem2::BuildDirectory()
|
||||||
|
{
|
||||||
|
return szBuildDir;
|
||||||
|
};
|
||||||
|
|
||||||
|
void IFileSystem2::CopyFile( const char *szDestination, const char *szOrigin )
|
||||||
|
{
|
||||||
|
CUtlVector<CUtlString> args = {
|
||||||
|
CUtlString(szOrigin),
|
||||||
|
CUtlString(szDestination),
|
||||||
|
};
|
||||||
|
IRunner::Run("cp", args);
|
||||||
|
}
|
||||||
|
|
||||||
void IFileSystem2::MakeDirectory( const char *psz )
|
void IFileSystem2::MakeDirectory( const char *psz )
|
||||||
{
|
{
|
||||||
|
|||||||
31
fpc/main.cpp
31
fpc/main.cpp
@@ -1,3 +1,4 @@
|
|||||||
|
#include "public/c.h"
|
||||||
#include "public/helper.h"
|
#include "public/helper.h"
|
||||||
#include "public/ld.h"
|
#include "public/ld.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
@@ -5,13 +6,18 @@
|
|||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
|
#include "libgen.h"
|
||||||
|
|
||||||
|
CUtlString owndir;
|
||||||
int build()
|
int build()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
extern char *szBuildDir;
|
||||||
|
|
||||||
CCProject compileScriptProject = {};
|
CCProject compileScriptProject = {};
|
||||||
compileScriptProject.m_szName = "build";
|
compileScriptProject.m_szName = "build";
|
||||||
compileScriptProject.files = {"build.cpp"};
|
compileScriptProject.files = {"build.cpp"};
|
||||||
compileScriptProject.includeDirectories = {"public","../public"};
|
compileScriptProject.includeDirectories = {CUtlString("%s/public",IFileSystem2::OwnDirectory()),CUtlString("%s/public", IFileSystem2::BuildDirectory()), CUtlString("%s/../public",IFileSystem2::OwnDirectory()),CUtlString("%s/../public", IFileSystem2::BuildDirectory())};
|
||||||
compileScriptProject.bFPIC = true;
|
compileScriptProject.bFPIC = true;
|
||||||
CLDProject linkScriptProject = compileScriptProject.Compile();
|
CLDProject linkScriptProject = compileScriptProject.Compile();
|
||||||
linkScriptProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
linkScriptProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||||
@@ -22,6 +28,7 @@ int build()
|
|||||||
build->m_pMainFn();
|
build->m_pMainFn();
|
||||||
};
|
};
|
||||||
Plat_UnloadLibrary(scriptDLL);
|
Plat_UnloadLibrary(scriptDLL);
|
||||||
|
CCProject::GenerateCompileCommands();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
@@ -43,6 +50,27 @@ void IEngine_Signal(int sig)
|
|||||||
|
|
||||||
int main(int c, char **v)
|
int main(int c, char **v)
|
||||||
{
|
{
|
||||||
|
CUtlString buildcppDir = IFileSystem2::OwnDirectory();
|
||||||
|
owndir = buildcppDir;
|
||||||
|
char *szBuildcppDir = buildcppDir.GetString();
|
||||||
|
findbuild:
|
||||||
|
FILE* file = V_fopen("build.cpp", "rb");
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
dirname(szBuildcppDir);
|
||||||
|
if (buildcppDir=="/")
|
||||||
|
{
|
||||||
|
V_printf("build.cpp not found\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
chdir(szBuildcppDir);
|
||||||
|
goto findbuild;
|
||||||
|
} else {
|
||||||
|
V_fclose(file);
|
||||||
|
}
|
||||||
|
extern char *szBuildDir;
|
||||||
|
szBuildDir = szBuildcppDir;
|
||||||
|
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
signal(SIGHUP, IEngine_Signal);
|
signal(SIGHUP, IEngine_Signal);
|
||||||
signal(SIGINT, IEngine_Signal);
|
signal(SIGINT, IEngine_Signal);
|
||||||
@@ -54,7 +82,6 @@ int main(int c, char **v)
|
|||||||
signal(SIGFPE, IEngine_Signal);
|
signal(SIGFPE, IEngine_Signal);
|
||||||
signal(SIGSEGV, IEngine_Signal);
|
signal(SIGSEGV, IEngine_Signal);
|
||||||
signal(SIGTERM, IEngine_Signal);
|
signal(SIGTERM, IEngine_Signal);
|
||||||
V_printf("cool\n");
|
|
||||||
#endif
|
#endif
|
||||||
ICommandLine::CreateCommandLine(c, v);
|
ICommandLine::CreateCommandLine(c, v);
|
||||||
if (ICommandLine::CheckParam("build"))
|
if (ICommandLine::CheckParam("build"))
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
bool bFPIE;
|
bool bFPIE;
|
||||||
bool bFPIC;
|
bool bFPIC;
|
||||||
CLDProject Compile();
|
CLDProject Compile();
|
||||||
|
static void GenerateCompileCommands();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ interface IFileSystem2
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static char *OwnDirectory();
|
static char *OwnDirectory();
|
||||||
|
static char *BuildDirectory();
|
||||||
static void MakeDirectory( const char *psz );
|
static void MakeDirectory( const char *psz );
|
||||||
static void CopyFile( const char *szDestination, const char *szOrigin );
|
static void CopyFile( const char *szDestination, const char *szOrigin );
|
||||||
static void CopyDirectory( const char *szDestination, const char *szOrigin );
|
static void CopyDirectory( const char *szDestination, const char *szOrigin );
|
||||||
|
|||||||
9
tier0/__build.cpp
Normal file
9
tier0/__build.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include "helper.h"
|
||||||
|
#include "c.h"
|
||||||
|
#include "ld.h"
|
||||||
|
|
||||||
|
int tier0_build()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
DECLARE_BUILD_STAGE(tier0, tier0_build);
|
||||||
Reference in New Issue
Block a user