fpc
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# We want to build just enough to use other stuff
|
# We want to build just enough to use other stuff
|
||||||
TIER_FILES := ../tier0/lib.cpp ../tier0/mem.cpp ../tier0/platform.cpp ../tier1/utlbuffer.cpp ../tier1/interface.cpp ../tier1/utlstring.cpp ../tier1/utlvector.cpp ../tier1/utlmap.cpp ../tier1/commandline.cpp
|
TIER_FILES := ../tier0/lib.cpp ../tier0/mem.cpp ../tier0/platform.cpp ../tier1/utlbuffer.cpp ../tier1/interface.cpp ../tier1/utlstring.cpp ../tier1/utlvector.cpp ../tier1/utlmap.cpp ../tier1/commandline.cpp ../tier2/filesystem.cpp ../tier2/filesystem_libc.cpp ../tier2/fileformats/ini.cpp
|
||||||
|
|
||||||
FPC_FILES := main.cpp library/runner.cpp library/helper.cpp library/c.cpp library/ld.cpp library/clang/c.cpp library/clang/ld.cpp library/target.cpp
|
FPC_FILES := main.cpp library/runner.cpp library/helper.cpp library/c.cpp library/ld.cpp library/clang/c.cpp library/clang/ld.cpp library/target.cpp
|
||||||
CC = clang
|
CC = clang
|
||||||
OUTPUT_DIR = fpc
|
OUTPUT_DIR = fpc
|
||||||
|
|||||||
@@ -49,8 +49,14 @@ CUtlString CMSVCLinker::Link( LinkProject_t *pProject )
|
|||||||
szOutputDir = dirname(szOutputDir);
|
szOutputDir = dirname(szOutputDir);
|
||||||
filesystem2->MakeDirectory(szOutputDir);
|
filesystem2->MakeDirectory(szOutputDir);
|
||||||
|
|
||||||
|
if (!g_pConfig)
|
||||||
|
Plat_FatalErrorFunc(".fpccfg was not found");
|
||||||
IINISection *pSection = g_pConfig->GetSection("MSVC_LINKER_INTERFACE_NAME");
|
IINISection *pSection = g_pConfig->GetSection("MSVC_LINKER_INTERFACE_NAME");
|
||||||
|
if (!pSection)
|
||||||
|
Plat_FatalErrorFunc("MSVC_LINKER_INTERFACE_NAME was not found in .fpccfg");
|
||||||
CUtlString szExePath = pSection->GetStringValue("exe");
|
CUtlString szExePath = pSection->GetStringValue("exe");
|
||||||
|
if (!pSection)
|
||||||
|
Plat_FatalErrorFunc("exe was not found in MSVC_LINKER_INTERFACE_NAME");
|
||||||
|
|
||||||
if (pProject->linkType == ELINK_STATIC_LIBRARY)
|
if (pProject->linkType == ELINK_STATIC_LIBRARY)
|
||||||
{
|
{
|
||||||
@@ -106,11 +112,15 @@ CUtlString CMSVCLinker::Link( LinkProject_t *pProject )
|
|||||||
"-target",
|
"-target",
|
||||||
szCompiledTarget,
|
szCompiledTarget,
|
||||||
};
|
};
|
||||||
|
if (pProject->linkType == ELINK_KERNEL_DRIVER)
|
||||||
|
{
|
||||||
|
args.AppendTail("/driver");
|
||||||
|
args.AppendTail(CUtlString("/entry:\"%s\"", pProject->szEntry));
|
||||||
|
}
|
||||||
|
|
||||||
// Disable stdlib
|
// Disable stdlib
|
||||||
if (pProject->bNoStdLib)
|
if (pProject->bNoStdLib)
|
||||||
{
|
{
|
||||||
args.AppendTail("-nostdlib");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto object: pProject->objects)
|
for (auto object: pProject->objects)
|
||||||
@@ -118,21 +128,12 @@ CUtlString CMSVCLinker::Link( LinkProject_t *pProject )
|
|||||||
|
|
||||||
for (auto lib: pProject->libraries)
|
for (auto lib: pProject->libraries)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
args.AppendTail("-l");
|
args.AppendTail("-l");
|
||||||
args.AppendTail(lib);
|
args.AppendTail(lib);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apple frameworks
|
|
||||||
for (auto &directory: pProject->frameworkDirectories)
|
|
||||||
{
|
|
||||||
args.AppendTail("-F");
|
|
||||||
args.AppendTail(directory);
|
|
||||||
}
|
|
||||||
for (auto &framework: pProject->frameworks)
|
|
||||||
{
|
|
||||||
args.AppendTail("-framework");
|
|
||||||
args.AppendTail(framework);
|
|
||||||
}
|
|
||||||
runner->Run(szExePath, args);
|
runner->Run(szExePath, args);
|
||||||
runner->Wait();
|
runner->Wait();
|
||||||
}
|
}
|
||||||
|
|||||||
101
fpc/library/windows/runner.cpp
Normal file
101
fpc/library/windows/runner.cpp
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
#include "runner.h"
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
#include "tier1/interface.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
#include "tier1/commandline.h"
|
||||||
|
#include "windows.h"
|
||||||
|
|
||||||
|
CUtlVector<pid_t> g_processes;
|
||||||
|
|
||||||
|
class CWindowsRunner: public IRunner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual int Run( CUtlString szName, CUtlVector<CUtlString>& args ) override;
|
||||||
|
virtual int Run( CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlString>& args ) override;
|
||||||
|
virtual int Run( CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlString>& args, CUtlVector<CUtlString>& environment ) override;
|
||||||
|
virtual int Wait( void ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
EXPOSE_INTERFACE(CWindowsRunner, IRunner, POSIX_RUNNER_INTERFACE_NAME);
|
||||||
|
IRunner *runner;
|
||||||
|
|
||||||
|
int CWindowsRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
|
||||||
|
{
|
||||||
|
pid_t pid = fork();
|
||||||
|
if (pid < 0)
|
||||||
|
Plat_FatalErrorFunc("Failed to fork");
|
||||||
|
/* child */
|
||||||
|
if (pid == 0)
|
||||||
|
{
|
||||||
|
CUtlVector<const char*> execargs;
|
||||||
|
execargs.AppendTail(szName);
|
||||||
|
if (CommandLine()->CheckParam("-fpcdebug"))
|
||||||
|
V_printf("%s",szName.GetString());
|
||||||
|
for (auto &arg: args)
|
||||||
|
{
|
||||||
|
execargs.AppendTail(arg);
|
||||||
|
if (CommandLine()->CheckParam("-fpcdebug"))
|
||||||
|
V_printf(" %s",arg.GetString());
|
||||||
|
}
|
||||||
|
if (CommandLine()->CheckParam("-fpcdebug"))
|
||||||
|
V_printf("\n");
|
||||||
|
execargs.AppendTail(0);
|
||||||
|
if ( execvp(szName, (char *const*)execargs.GetData()) == -1 )
|
||||||
|
{
|
||||||
|
V_printf("Failed to launch %s\n",szName.GetString());
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_processes.AppendTail(pid);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CWindowsRunner::Run(CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlString>& args)
|
||||||
|
{
|
||||||
|
pid_t pid = fork();
|
||||||
|
if (pid < 0)
|
||||||
|
Plat_FatalErrorFunc("Failed to fork");
|
||||||
|
/* child */
|
||||||
|
if (pid == 0)
|
||||||
|
{
|
||||||
|
CUtlVector<const char*> execargs;
|
||||||
|
execargs.AppendTail(szName);
|
||||||
|
if (CommandLine()->CheckParam("-fpcdebug"))
|
||||||
|
V_printf("%s",szName.GetString());
|
||||||
|
for (auto &arg: args)
|
||||||
|
{
|
||||||
|
execargs.AppendTail(arg);
|
||||||
|
if (CommandLine()->CheckParam("-fpcdebug"))
|
||||||
|
V_printf(" %s",arg.GetString());
|
||||||
|
}
|
||||||
|
if (CommandLine()->CheckParam("-fpcdebug"))
|
||||||
|
V_printf("\n");
|
||||||
|
execargs.AppendTail(0);
|
||||||
|
chdir(szDirectory.GetString());
|
||||||
|
if ( execvp(szName, (char *const*)execargs.GetData()) == -1 )
|
||||||
|
{
|
||||||
|
V_printf("Failed to launch %s\n",szName.GetString());
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_processes.AppendTail(pid);
|
||||||
|
/* parent */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CWindowsRunner::Run(CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlString>& args, CUtlVector<CUtlString>& environment)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CWindowsRunner::Wait( void )
|
||||||
|
{
|
||||||
|
for (auto &process: g_processes)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
pid_t wpid = waitpid(process, &status, 0);
|
||||||
|
}
|
||||||
|
g_processes = {};
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
@@ -17,6 +17,14 @@ enum ELinkType
|
|||||||
ELINK_EXECUTABLE,
|
ELINK_EXECUTABLE,
|
||||||
ELINK_DYNAMIC_LIBRARY,
|
ELINK_DYNAMIC_LIBRARY,
|
||||||
ELINK_STATIC_LIBRARY,
|
ELINK_STATIC_LIBRARY,
|
||||||
|
|
||||||
|
// drivers
|
||||||
|
ELINK_KERNEL_DRIVER
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EWindowsSubsystem
|
||||||
|
{
|
||||||
|
WINDOWS_SUBSYSTEM_NATIVE,
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -58,6 +66,8 @@ public:
|
|||||||
// Apple framework directories
|
// Apple framework directories
|
||||||
CUtlVector<CUtlString> frameworkDirectories = {};
|
CUtlVector<CUtlString> frameworkDirectories = {};
|
||||||
|
|
||||||
|
const char *szEntry = "";
|
||||||
|
|
||||||
// Disables C standart library
|
// Disables C standart library
|
||||||
bool bNoStdLib;
|
bool bNoStdLib;
|
||||||
|
|
||||||
@@ -66,6 +76,9 @@ public:
|
|||||||
|
|
||||||
// Android manifest
|
// Android manifest
|
||||||
AndroidManifest_t m_androidmanifest;
|
AndroidManifest_t m_androidmanifest;
|
||||||
|
|
||||||
|
// Windows subsystem
|
||||||
|
EWindowsSubsystem m_eWindowsSubsystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Basic interface name
|
// Basic interface name
|
||||||
|
|||||||
Reference in New Issue
Block a user