Build system almost done
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -2,8 +2,12 @@ TIER0_FILES := $(wildcard ../tier0/*.cpp)
|
||||
TIER1_FILES := $(wildcard ../tier1/*.cpp)
|
||||
FPC_FILES := main.cpp library/runner.cpp library/helper.cpp library/c.cpp library/ld.cpp
|
||||
CC = clang
|
||||
OUTPUT_DIR = ../build/tools/fpc
|
||||
OUTPUT_DIR = fpc
|
||||
|
||||
full: $(TIER0_FILES) $(TIER1_FILES) $(FPC_FILES)
|
||||
install:
|
||||
|
||||
../build/tools:
|
||||
mkdir -p ../build/tools
|
||||
|
||||
minimal: $(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)
|
||||
|
||||
@@ -1,8 +1,46 @@
|
||||
#include "helper.h"
|
||||
#include "public/c.h"
|
||||
#include "public/ld.h"
|
||||
#include "public/c.h"
|
||||
#include "public/helper.h"
|
||||
#include "tier0/platform.h"
|
||||
#include "signal.h"
|
||||
|
||||
CUtlVector<CUtlString> g_CompiledFiles = {
|
||||
"main.cpp",
|
||||
"library/runner.cpp",
|
||||
"library/helper.cpp",
|
||||
"library/c.cpp",
|
||||
"library/ld.cpp",
|
||||
"../tier0/lib.cpp",
|
||||
"../tier0/mem.cpp",
|
||||
"../tier0/platform.cpp",
|
||||
"../tier1/utlbuffer.cpp",
|
||||
"../tier1/utlstring.cpp",
|
||||
"../tier1/utlvector.cpp",
|
||||
"../tier1/utlmap.cpp",
|
||||
"../tier1/commandline.cpp",
|
||||
};
|
||||
|
||||
CUtlVector<CUtlString> g_IncludeDirectories = {
|
||||
"public",
|
||||
"../public",
|
||||
};
|
||||
|
||||
|
||||
int build_fpc()
|
||||
{
|
||||
V_printf("cool\n");
|
||||
CCProject compileProject = {};
|
||||
CLDProject ldProject = {};
|
||||
|
||||
compileProject.m_szName = "fpc";
|
||||
compileProject.files = g_CompiledFiles;
|
||||
compileProject.includeDirectories = g_IncludeDirectories;
|
||||
ldProject = compileProject.Compile();
|
||||
|
||||
ldProject.Link();
|
||||
|
||||
IFileSystem2::MakeDirectory("../build/tools");
|
||||
|
||||
return 0;
|
||||
};
|
||||
DECLARE_BUILD_STAGE(fpc, build_fpc);
|
||||
|
||||
@@ -19,12 +19,13 @@ CLDProject CCProject::Compile()
|
||||
unsigned int hash = GenerateProjectHash();
|
||||
for (auto &file: files)
|
||||
{
|
||||
CUtlString szOutputFile = CUtlString("%s/cc/%u/%s.o",FPC_TEMPORAL_DIRNAME, hash, 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 = szOutputFile;
|
||||
szOutputDir = dirname(szOutputDir);
|
||||
IFileSystem2::MakeDirectory(szOutputDir);
|
||||
|
||||
CUtlVector<CUtlString> args = {
|
||||
"-g",
|
||||
"-c",
|
||||
"-o",
|
||||
szOutputFile,
|
||||
@@ -52,10 +53,10 @@ CLDProject CCProject::Compile()
|
||||
IRunner::Run("clang", args);
|
||||
proj.objects.AppendTail((CObject){szOutputFile});
|
||||
|
||||
ClangFile_t file = {};
|
||||
file.m_szName = m_szName;
|
||||
file.m_szArguments = args;
|
||||
g_clangFiles.AppendTail(file);
|
||||
ClangFile_t cfile = {};
|
||||
cfile.m_szName = m_szName;
|
||||
cfile.m_szArguments = args;
|
||||
g_clangFiles.AppendTail(cfile);
|
||||
}
|
||||
return proj;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "unistd.h"
|
||||
#include "libgen.h"
|
||||
|
||||
unsigned int g_hashState = 102851263;
|
||||
unsigned int CProject::GenerateProjectHash( void )
|
||||
@@ -19,11 +21,19 @@ unsigned int CProject::GenerateProjectHash( void )
|
||||
return hash;
|
||||
};
|
||||
|
||||
static char path[1024];
|
||||
static ssize_t pathSize = readlink("/proc/self/exe", path, sizeof(path) - 1);
|
||||
static char* pathDir = dirname(path);
|
||||
char *IFileSystem2::OwnDirectory()
|
||||
{
|
||||
return pathDir;
|
||||
};
|
||||
|
||||
void IFileSystem2::MakeDirectory( const char *psz )
|
||||
{
|
||||
CUtlVector<CUtlString> args = {
|
||||
"-p",
|
||||
psz,
|
||||
CUtlString(psz),
|
||||
};
|
||||
IRunner::Run("mkdir", args);
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ CUtlString CLDProject::Link( void )
|
||||
szFileName = CUtlString("lib%s.so", m_szName.GetString());
|
||||
break;
|
||||
}
|
||||
CUtlString szOutputFile = CUtlString("%s/ld/%u/%s",FPC_TEMPORAL_DIRNAME, hash, szFileName.GetString());
|
||||
CUtlString szOutputFile = CUtlString("%s/ld/%u_%s/%s",FPC_TEMPORAL_DIRNAME, hash, m_szName.GetString(), szFileName.GetString());
|
||||
CUtlString szOutputDir = szOutputFile;
|
||||
szOutputDir = dirname(szOutputDir);
|
||||
IFileSystem2::MakeDirectory(szOutputDir);
|
||||
@@ -29,6 +29,7 @@ CUtlString CLDProject::Link( void )
|
||||
IRunner::Run("ar", args);
|
||||
} else {
|
||||
CUtlVector<CUtlString> args = {
|
||||
"-rdynamic",
|
||||
"-o",
|
||||
szOutputFile,
|
||||
};
|
||||
|
||||
30
fpc/main.cpp
30
fpc/main.cpp
@@ -4,6 +4,7 @@
|
||||
#include "tier1/commandline.h"
|
||||
#include "c.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "signal.h"
|
||||
|
||||
int build()
|
||||
{
|
||||
@@ -24,10 +25,37 @@ int build()
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
void IEngine_Signal(int sig)
|
||||
{
|
||||
switch (sig)
|
||||
{
|
||||
case SIGSEGV:
|
||||
case SIGILL:
|
||||
case SIGABRT:
|
||||
Plat_Backtrace();
|
||||
Plat_FatalErrorFunc("Fault");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
_exit(0);
|
||||
};
|
||||
|
||||
int main(int c, char **v)
|
||||
{
|
||||
#ifdef __linux
|
||||
signal(SIGHUP, IEngine_Signal);
|
||||
signal(SIGINT, IEngine_Signal);
|
||||
signal(SIGQUIT, IEngine_Signal);
|
||||
signal(SIGILL, IEngine_Signal);
|
||||
signal(SIGTRAP, IEngine_Signal);
|
||||
signal(SIGIOT, IEngine_Signal);
|
||||
signal(SIGBUS, IEngine_Signal);
|
||||
signal(SIGFPE, IEngine_Signal);
|
||||
signal(SIGSEGV, IEngine_Signal);
|
||||
signal(SIGTERM, IEngine_Signal);
|
||||
V_printf("cool\n");
|
||||
#endif
|
||||
ICommandLine::CreateCommandLine(c, v);
|
||||
if (ICommandLine::CheckParam("build"))
|
||||
return build();
|
||||
|
||||
@@ -15,13 +15,12 @@ public:
|
||||
interface IFileSystem2
|
||||
{
|
||||
public:
|
||||
static char *OwnDirectory();
|
||||
static void MakeDirectory( const char *psz );
|
||||
static void CopyFile( const char *szDestination, const char *szOrigin );
|
||||
static void CopyDirectory( const char *szDestination, const char *szOrigin );
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CBuildStage
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user