trying to improve the stuff
This commit is contained in:
@@ -60,7 +60,11 @@ DECLARE_BUILD_STAGE(fpc)
|
|||||||
compileProject.files = g_CompiledFiles;
|
compileProject.files = g_CompiledFiles;
|
||||||
compileProject.includeDirectories = g_IncludeDirectories;
|
compileProject.includeDirectories = g_IncludeDirectories;
|
||||||
ldProject = ccompiler->Compile(&compileProject);
|
ldProject = ccompiler->Compile(&compileProject);
|
||||||
ldProject.libraryObjects = GET_PROJECT_LIBRARY("tier0", "tier0");
|
ldProject.libraryObjects = {
|
||||||
|
GET_PROJECT_LIBRARY("tier0", "tier0")
|
||||||
|
GET_PROJECT_LIBRARY("tier1", "tier1")
|
||||||
|
GET_PROJECT_LIBRARY("tier2", "tier2")
|
||||||
|
};
|
||||||
|
|
||||||
if (linker->IsLibraryExists("clang"))
|
if (linker->IsLibraryExists("clang"))
|
||||||
ldProject.libraries.AppendTail("clang");
|
ldProject.libraries.AppendTail("clang");
|
||||||
|
|||||||
0
fpc/library/builder.cpp
Normal file
0
fpc/library/builder.cpp
Normal file
@@ -135,11 +135,11 @@ bool CPOSIXFileSystem2::ShouldRecompile(const char *szSource, const char *szOutp
|
|||||||
|
|
||||||
CUtlVector<CBuildStage*> g_buildStages;
|
CUtlVector<CBuildStage*> g_buildStages;
|
||||||
|
|
||||||
CBuildStage::CBuildStage( CUtlString sz, int(*pMainFn)() )
|
CBuildStage::CBuildStage( const char *psz, int(*pMainFn)() )
|
||||||
{
|
{
|
||||||
m_sz = sz;
|
m_psz = psz;
|
||||||
m_pMainFn = pMainFn;
|
m_pMainFn = pMainFn;
|
||||||
if (sz == 0 || pMainFn == 0)
|
if (psz == 0 || pMainFn == 0)
|
||||||
Plat_FatalErrorFunc("Name and function pointer must be set\n");
|
Plat_FatalErrorFunc("Name and function pointer must be set\n");
|
||||||
|
|
||||||
g_buildStages.AppendTail(this);
|
g_buildStages.AppendTail(this);
|
||||||
|
|||||||
20
fpc/main.cpp
20
fpc/main.cpp
@@ -16,11 +16,16 @@
|
|||||||
|
|
||||||
CUtlString owndir;
|
CUtlString owndir;
|
||||||
extern char *g_szBuildDir;
|
extern char *g_szBuildDir;
|
||||||
int build()
|
|
||||||
|
void build_tier0()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
int build()
|
||||||
|
{
|
||||||
|
CreateInterfaceFn pBuildFactory;
|
||||||
|
BuildFileInfo_t *pBuildFileInfo;
|
||||||
CProject_t compileScriptProject = {};
|
CProject_t compileScriptProject = {};
|
||||||
compileScriptProject.m_szName = "build";
|
compileScriptProject.m_szName = "build";
|
||||||
compileScriptProject.files = {"build.cpp"};
|
compileScriptProject.files = {"build.cpp"};
|
||||||
@@ -36,12 +41,19 @@ int build()
|
|||||||
|
|
||||||
|
|
||||||
void *scriptDLL = Plat_LoadLibrary(script);
|
void *scriptDLL = Plat_LoadLibrary(script);
|
||||||
|
pBuildFactory = Sys_GetFactory(scriptDLL);
|
||||||
|
|
||||||
|
|
||||||
|
pBuildFactory = NULL;
|
||||||
|
pBuildFileInfo = (BuildFileInfo_t*)pBuildFactory(BUILD_FILE_INFO_INTERFACE_NAME, NULL);
|
||||||
|
if (!pBuildFactory)
|
||||||
|
Plat_FatalErrorFunc("Failed to find build file info interface\n");
|
||||||
|
|
||||||
auto PreinitFn = (void(*)())Plat_GetProc(scriptDLL, "Preinit");
|
auto PreinitFn = (void(*)())Plat_GetProc(scriptDLL, "Preinit");
|
||||||
if (PreinitFn)
|
if (PreinitFn)
|
||||||
PreinitFn();
|
PreinitFn();
|
||||||
|
|
||||||
for (auto &build: BuildStages())
|
for (auto &build: pBuildFileInfo->m_stages)
|
||||||
{
|
{
|
||||||
build->m_pMainFn();
|
build->m_pMainFn();
|
||||||
};
|
};
|
||||||
@@ -61,7 +73,7 @@ void IEngine_Signal(int sig)
|
|||||||
case SIGILL:
|
case SIGILL:
|
||||||
case SIGABRT:
|
case SIGABRT:
|
||||||
Plat_Backtrace();
|
Plat_Backtrace();
|
||||||
Plat_FatalErrorFunc("Fault");
|
Plat_FatalErrorFunc("Fault\n");
|
||||||
break;
|
break;
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
Plat_Exit(0);
|
Plat_Exit(0);
|
||||||
|
|||||||
31
fpc/public/builder.h
Normal file
31
fpc/public/builder.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef BUILDER_H
|
||||||
|
#define BUILDER_H
|
||||||
|
|
||||||
|
#include "tier1/interface.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
|
||||||
|
struct BuildOutput_t
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BuildOutputs_t
|
||||||
|
{
|
||||||
|
const char *m_szBuildStageName;
|
||||||
|
CUtlVector<BuildOutput_t> m_buildOutputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BuildFile_t
|
||||||
|
{
|
||||||
|
void *m_pLibrary;
|
||||||
|
CUtlVector<BuildOutputs_t> m_compiledProjects;
|
||||||
|
};
|
||||||
|
|
||||||
|
abstract_class IProjectBuilder
|
||||||
|
{
|
||||||
|
virtual BuildFile_t *BuildProject( const char *szPath ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
IProjectBuilder *ProjectBuilder();
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "tier2/fileformats/ini.h"
|
#include "tier2/fileformats/ini.h"
|
||||||
|
#include "tier1/interface.h"
|
||||||
|
|
||||||
#define FPC_TEMPORAL_DIRNAME ".fpc"
|
#define FPC_TEMPORAL_DIRNAME ".fpc"
|
||||||
|
|
||||||
@@ -81,11 +82,17 @@ extern IFileSystem2 *filesystem2;
|
|||||||
class CBuildStage
|
class CBuildStage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBuildStage( CUtlString sz, int(*pMainFn)() );
|
CBuildStage( const char *psz, int(*pMainFn)() );
|
||||||
CUtlString m_sz;
|
const char *m_psz;
|
||||||
int(*m_pMainFn)();
|
int(*m_pMainFn)();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CBuildDependentFile
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Declares new build stage.
|
// Declares new build stage.
|
||||||
// example:
|
// example:
|
||||||
@@ -107,9 +114,16 @@ int __build_stage_##sz()
|
|||||||
|
|
||||||
#define GET_PROJECT_LIBRARY(sz, szLib) \
|
#define GET_PROJECT_LIBRARY(sz, szLib) \
|
||||||
|
|
||||||
// Returns all available build stages
|
struct BuildFileInfo_t
|
||||||
// Used internally
|
{
|
||||||
CUtlVector<CBuildStage*>& BuildStages();
|
CUtlVector<const char*> m_dependantFile;
|
||||||
|
CUtlVector<CBuildStage*> m_stages;
|
||||||
|
};
|
||||||
|
|
||||||
|
BuildFileInfo_t *GetBuildFileInfo();
|
||||||
|
|
||||||
|
#define BUILD_FILE_INFO_INTERFACE_NAME "BuildFileInfo001"
|
||||||
|
|
||||||
|
|
||||||
extern IINIFile *g_pConfig;
|
extern IINIFile *g_pConfig;
|
||||||
|
|
||||||
|
|||||||
11
fpc/public/interfaces.cpp
Normal file
11
fpc/public/interfaces.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "tier1/interface.h"
|
||||||
|
#include "helper.h"
|
||||||
|
|
||||||
|
static BuildFileInfo_t buildfileinfo = {};
|
||||||
|
BuildFileInfo_t *GetBuildFileInfo()
|
||||||
|
{
|
||||||
|
return &buildfileinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXPOSE_INTERFACE_GLOBALVAR(BuildFileInfo_t, BuildFileInfo_t, BUILD_FILE_INFO_INTERFACE_NAME, buildfileinfo);
|
||||||
@@ -6,8 +6,6 @@
|
|||||||
typedef void *( *CreateInterfaceFn )( const char *szName, int *pReturnCode );
|
typedef void *( *CreateInterfaceFn )( const char *szName, int *pReturnCode );
|
||||||
typedef void *( *InstantiateInterfaceFn )( void );
|
typedef void *( *InstantiateInterfaceFn )( void );
|
||||||
|
|
||||||
CreateInterfaceFn Plat_GetInterfaceFactory( void *lib );
|
|
||||||
|
|
||||||
class CInterfaceRegistry
|
class CInterfaceRegistry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -24,7 +22,16 @@ public:
|
|||||||
static void *__Create##className##_interface() { return ( interfaceName* )( new className ); }; \
|
static void *__Create##className##_interface() { return ( interfaceName* )( new className ); }; \
|
||||||
static CInterfaceRegistry __Create##className##_registry( __Create##className##_interface, versionName );
|
static CInterfaceRegistry __Create##className##_registry( __Create##className##_interface, versionName );
|
||||||
|
|
||||||
|
#define EXPOSE_INTERFACE_FN( functionName, interfaceName, versionName ) \
|
||||||
|
static CInterfaceRegistry __Create##interfaceName##_registry( functionName, versionName );
|
||||||
|
|
||||||
|
#define EXPOSE_INTERFACE_GLOBALVAR( className, interfaceName, versionName, globalVarName ) \
|
||||||
|
static void *__Create##interfaceName##_interface() { return ( interfaceName* )( &globalVarName ); }; \
|
||||||
|
static CInterfaceRegistry __Create##interfaceName##_registry( __Create##className##_interface, versionName );
|
||||||
|
|
||||||
|
|
||||||
void *CreateInterface( const char *szName, int *pReturnCode );
|
void *CreateInterface( const char *szName, int *pReturnCode );
|
||||||
|
|
||||||
|
CreateInterfaceFn Sys_GetFactory( void *pLibrary );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void *CreateInterface( const char *szName, int *pReturnCode )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateInterfaceFn Plat_GetInterfaceFactory( void *lib )
|
CreateInterfaceFn Sys_GetFactory( void *lib )
|
||||||
{
|
{
|
||||||
return (CreateInterfaceFn)Plat_GetProc(lib, "CreateInterface");
|
return (CreateInterfaceFn)Plat_GetProc(lib, "CreateInterface");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user