driver cross-compilation
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
[MSVC_C_COMPILER_INTERFACE_NAME]
|
|
||||||
exe = /opt/msvc/bin/x64/cl
|
|
||||||
|
|
||||||
[MSVC_LINKER_INTERFACE_NAME]
|
|
||||||
exe = /opt/msvc/bin/x64/link
|
|
||||||
@@ -22,14 +22,21 @@ CUtlVector<CUtlString> g_CompiledFiles = {
|
|||||||
"main.cpp",
|
"main.cpp",
|
||||||
"library/runner.cpp",
|
"library/runner.cpp",
|
||||||
"library/helper.cpp",
|
"library/helper.cpp",
|
||||||
"library/c.cpp",
|
|
||||||
"library/ld.cpp",
|
|
||||||
"library/target.cpp",
|
"library/target.cpp",
|
||||||
|
|
||||||
|
"library/winerunner.cpp",
|
||||||
|
|
||||||
|
"library/c.cpp",
|
||||||
|
"library/ld.cpp",
|
||||||
|
|
||||||
"library/android/apktool.cpp",
|
"library/android/apktool.cpp",
|
||||||
|
|
||||||
"library/clang/c.cpp",
|
"library/clang/c.cpp",
|
||||||
"library/clang/ld.cpp",
|
"library/clang/ld.cpp",
|
||||||
|
|
||||||
|
"library/windows/c.cpp",
|
||||||
|
"library/windows/ld.cpp",
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CUtlVector<CUtlString> g_IncludeDirectories = {
|
CUtlVector<CUtlString> g_IncludeDirectories = {
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ skipcompile:
|
|||||||
|
|
||||||
g_clangFiles.AppendTail(cfile);
|
g_clangFiles.AppendTail(cfile);
|
||||||
}
|
}
|
||||||
|
runner->Wait();
|
||||||
return proj;
|
return proj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ CUtlString CClangLinker::Link( LinkProject_t *pProject )
|
|||||||
if (pProject->m_target.kernel == TARGET_KERNEL_LINUX)
|
if (pProject->m_target.kernel == TARGET_KERNEL_LINUX)
|
||||||
szFileName = CUtlString("lib%s.so", pProject->m_szName.GetString());
|
szFileName = CUtlString("lib%s.so", pProject->m_szName.GetString());
|
||||||
break;
|
break;
|
||||||
|
case ELINK_KERNEL_DRIVER:
|
||||||
|
Plat_FatalErrorFunc("TODO: not supported\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CUtlString szTarget = pProject->m_target.GetTriplet();
|
CUtlString szTarget = pProject->m_target.GetTriplet();
|
||||||
|
|||||||
@@ -48,6 +48,34 @@ public:
|
|||||||
virtual bool ShouldRecompile( const char *szSource, const char *szOutput ) override;
|
virtual bool ShouldRecompile( const char *szSource, const char *szOutput ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char *GetWindowsPath( const char *szPath )
|
||||||
|
{
|
||||||
|
char *szNewPath = (char*)V_malloc(V_strlen(szPath)+1);
|
||||||
|
int i = 0;
|
||||||
|
V_strcpy(szNewPath, szPath);
|
||||||
|
while(szNewPath[i])
|
||||||
|
{
|
||||||
|
if (szNewPath[i] == '/')
|
||||||
|
szNewPath[i] = '\\';
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return szNewPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *GetPOSIXPath( const char *szPath )
|
||||||
|
{
|
||||||
|
char *szNewPath = (char*)V_malloc(V_strlen(szPath)+1);
|
||||||
|
int i = 0;
|
||||||
|
V_strcpy(szNewPath, szPath);
|
||||||
|
while(szNewPath[i])
|
||||||
|
{
|
||||||
|
if (szNewPath[i] == '\\')
|
||||||
|
szNewPath[i] = '/';
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return szNewPath;
|
||||||
|
}
|
||||||
|
|
||||||
EXPOSE_INTERFACE(CPOSIXFileSystem2, IFileSystem2, FILE_SYSTEM_2_INTERFACE_NAME);
|
EXPOSE_INTERFACE(CPOSIXFileSystem2, IFileSystem2, FILE_SYSTEM_2_INTERFACE_NAME);
|
||||||
IFileSystem2 *filesystem2;
|
IFileSystem2 *filesystem2;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include "sys/wait.h"
|
#include "sys/wait.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
|
#include "winerunner.h"
|
||||||
|
|
||||||
CUtlVector<pid_t> g_processes;
|
CUtlVector<pid_t> g_processes;
|
||||||
|
|
||||||
class CPOSIXRunner: public IRunner
|
class CPOSIXRunner: public IRunner
|
||||||
@@ -20,6 +22,7 @@ public:
|
|||||||
|
|
||||||
EXPOSE_INTERFACE(CPOSIXRunner, IRunner, RUNNER_INTERFACE_NAME);
|
EXPOSE_INTERFACE(CPOSIXRunner, IRunner, RUNNER_INTERFACE_NAME);
|
||||||
IRunner *runner;
|
IRunner *runner;
|
||||||
|
IWineRunner *winerunner;
|
||||||
|
|
||||||
int CPOSIXRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
|
int CPOSIXRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
#include "tier0/mem.h"
|
||||||
|
#include "winerunner.h"
|
||||||
|
#include "c.h"
|
||||||
|
#include "helper.h"
|
||||||
|
#include "obj.h"
|
||||||
|
#include "target.h"
|
||||||
|
#include "tier0/lib.h"
|
||||||
|
#include "tier0/mem.h"
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
#include "tier1/commandline.h"
|
||||||
|
#include "tier1/interface.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
#include "libgen.h"
|
||||||
|
#include "ctype.h"
|
||||||
|
|
||||||
|
struct ClangFile_t
|
||||||
|
{
|
||||||
|
CUtlString m_szName;
|
||||||
|
CUtlVector<CUtlString> m_szArguments;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CMSVCCompiler : public ICCompiler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual LinkProject_t Compile( CProject_t *pProject ) override;
|
||||||
|
virtual void GenerateLinterData( void ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
EXPOSE_INTERFACE(CMSVCCompiler, ICCompiler, MSVC_C_COMPILER_INTERFACE_NAME);
|
||||||
|
/*
|
||||||
|
CUtlVector<ClangFile_t> g_msvcFiles;
|
||||||
|
*/
|
||||||
|
LinkProject_t CMSVCCompiler::Compile( CProject_t *pProject )
|
||||||
|
{
|
||||||
|
if (pProject->m_szName == 0)
|
||||||
|
{
|
||||||
|
Plat_FatalErrorFunc("m_szName must be present\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pProject->m_target.kernel != TARGET_KERNEL_WINDOWS_MSVC)
|
||||||
|
{
|
||||||
|
Plat_FatalErrorFunc("target must be TARGET_KERNEL_WINDOWS_MSVC\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
LinkProject_t proj = {};
|
||||||
|
proj.m_szName = pProject->m_szName;
|
||||||
|
proj.m_target = pProject->m_target;
|
||||||
|
proj.m_androidmanifest = pProject->m_androidmanifest;
|
||||||
|
unsigned int hash = pProject->GenerateProjectHash();
|
||||||
|
|
||||||
|
if (!g_pConfig)
|
||||||
|
Plat_FatalErrorFunc(".fpccfg was not found\n");
|
||||||
|
IINISection *pSection = g_pConfig->GetSection("MSVC_C_COMPILER_INTERFACE_NAME");
|
||||||
|
if (!pSection)
|
||||||
|
Plat_FatalErrorFunc("MSVC_C_COMPILER_INTERFACE_NAME was not found in .fpccfg\n");
|
||||||
|
CUtlString szExePath = pSection->GetStringValue("exe");
|
||||||
|
if (!pSection)
|
||||||
|
Plat_FatalErrorFunc("exe was not found in MSVC_C_COMPILER_INTERFACE_NAME\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Get output directories
|
||||||
|
for (auto &file: pProject->files)
|
||||||
|
{
|
||||||
|
CUtlString szTarget = pProject->m_target.GetTriplet();
|
||||||
|
CUtlString szOutputFile = CUtlString("%s/%s/cc/%u_%s/%s/%s.obj",FPC_TEMPORAL_DIRNAME, szTarget.GetString(), hash, pProject->m_szName.GetString(), filesystem2->BuildDirectory(), file.GetString());
|
||||||
|
CUtlString szOutputDir = szOutputFile;
|
||||||
|
szOutputDir = dirname(szOutputDir);
|
||||||
|
filesystem2->MakeDirectory(szOutputDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run CC
|
||||||
|
for (auto &file: pProject->files)
|
||||||
|
{
|
||||||
|
V_printf(" CC %s\n", file.GetString());
|
||||||
|
|
||||||
|
CUtlVector<CUtlString> args;
|
||||||
|
CUtlString szTarget = pProject->m_target.GetTriplet();
|
||||||
|
CUtlString szCompiledTarget = szTarget;
|
||||||
|
bool bAreDependenciesUpdated = false;
|
||||||
|
if (pProject->m_target.kernel == TARGET_KERNEL_ANDROID)
|
||||||
|
{
|
||||||
|
szCompiledTarget = CUtlString("%s%u", szTarget.GetString(), pProject->m_androidmanifest.m_nTargetVersion);
|
||||||
|
}
|
||||||
|
CUtlString szOutputFile = CUtlString("%s/%s/cc/%u_%s/%s/%s.obj",FPC_TEMPORAL_DIRNAME, szTarget.GetString(), hash, pProject->m_szName.GetString(), filesystem2->BuildDirectory(), file.GetString());
|
||||||
|
|
||||||
|
args = {
|
||||||
|
"/nologo",
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
if (!strcmp(Plat_GetExtension(file),"cpp"))
|
||||||
|
args.AppendTail("-std=c++17");
|
||||||
|
else if (!strcmp(Plat_GetExtension(file),"mm"))
|
||||||
|
;
|
||||||
|
else
|
||||||
|
args.AppendTail("-std=c99");
|
||||||
|
|
||||||
|
if (pProject->bFPIC)
|
||||||
|
args.AppendTail("-fPIC");
|
||||||
|
if (pProject->bFPIE)
|
||||||
|
args.AppendTail("-fPIE");
|
||||||
|
*/
|
||||||
|
for (auto ¯o: pProject->macros)
|
||||||
|
{
|
||||||
|
args.AppendTail(CUtlString("/D%s=%s", (char*)macro.szName, (char*)macro.szValue));
|
||||||
|
}
|
||||||
|
for (auto &include: pProject->includeDirectories)
|
||||||
|
{
|
||||||
|
const char *szWindowsPath = GetWindowsPath(include.GetString());
|
||||||
|
args.AppendTail(CUtlString("/I%s", szWindowsPath));
|
||||||
|
V_free((void*)szWindowsPath);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
for (auto &include: pProject->includeFiles)
|
||||||
|
{
|
||||||
|
args.AppendTail("-include");
|
||||||
|
args.AppendTail(include);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
if (!filesystem2->ShouldRecompile(file, szOutputFile) && !bAreDependenciesUpdated)
|
||||||
|
goto skipcompile;
|
||||||
|
|
||||||
|
args.AppendTail("/c");
|
||||||
|
args.AppendTail(CUtlString("/Fo%s", szOutputFile.GetString()));
|
||||||
|
args.AppendTail(file);
|
||||||
|
|
||||||
|
winerunner->Run(szExePath, args);
|
||||||
|
skipcompile:
|
||||||
|
proj.objects.AppendTail((Object_t){szOutputFile});
|
||||||
|
|
||||||
|
ClangFile_t cfile = {};
|
||||||
|
cfile.m_szName = file;
|
||||||
|
cfile.m_szArguments = args;
|
||||||
|
if (pProject->m_target.kernel == TARGET_KERNEL_ANDROID)
|
||||||
|
{
|
||||||
|
if (!pProject->m_target.szSysroot)
|
||||||
|
Plat_FatalErrorFunc("sysroot must be specified for android\n");
|
||||||
|
cfile.m_szArguments.AppendHead(CUtlString("%s/bin/clang", pProject->m_target.szSysroot));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cfile.m_szArguments.AppendHead("clang");
|
||||||
|
|
||||||
|
/*
|
||||||
|
g_clangFiles.AppendTail(cfile);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
winerunner->Wait();
|
||||||
|
return proj;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMSVCCompiler::GenerateLinterData()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
FILE* f = V_fopen("compile_commands.json", "wb");
|
||||||
|
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");
|
||||||
|
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", filesystem2->BuildDirectory());
|
||||||
|
V_fprintf(f, "\t},\n");
|
||||||
|
};
|
||||||
|
V_fseek(f, -2, SEEK_CUR);
|
||||||
|
V_fprintf(f, "\n]\n");
|
||||||
|
V_fclose(f);
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "tier1/interface.h"
|
#include "tier1/interface.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier2/fileformats/ini.h"
|
#include "tier2/fileformats/ini.h"
|
||||||
|
#include "winerunner.h"
|
||||||
|
|
||||||
class CMSVCLinker : public ILinker
|
class CMSVCLinker : public ILinker
|
||||||
{
|
{
|
||||||
@@ -41,6 +42,9 @@ CUtlString CMSVCLinker::Link( LinkProject_t *pProject )
|
|||||||
case ELINK_DYNAMIC_LIBRARY:
|
case ELINK_DYNAMIC_LIBRARY:
|
||||||
szFileName = CUtlString("%s.dll", pProject->m_szName.GetString());
|
szFileName = CUtlString("%s.dll", pProject->m_szName.GetString());
|
||||||
break;
|
break;
|
||||||
|
case ELINK_KERNEL_DRIVER:
|
||||||
|
szFileName = CUtlString("%s.sys", pProject->m_szName.GetString());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CUtlString szTarget = pProject->m_target.GetTriplet();
|
CUtlString szTarget = pProject->m_target.GetTriplet();
|
||||||
@@ -50,13 +54,13 @@ CUtlString CMSVCLinker::Link( LinkProject_t *pProject )
|
|||||||
filesystem2->MakeDirectory(szOutputDir);
|
filesystem2->MakeDirectory(szOutputDir);
|
||||||
|
|
||||||
if (!g_pConfig)
|
if (!g_pConfig)
|
||||||
Plat_FatalErrorFunc(".fpccfg was not found");
|
Plat_FatalErrorFunc(".fpccfg was not found\n");
|
||||||
IINISection *pSection = g_pConfig->GetSection("MSVC_LINKER_INTERFACE_NAME");
|
IINISection *pSection = g_pConfig->GetSection("MSVC_LINKER_INTERFACE_NAME");
|
||||||
if (!pSection)
|
if (!pSection)
|
||||||
Plat_FatalErrorFunc("MSVC_LINKER_INTERFACE_NAME was not found in .fpccfg");
|
Plat_FatalErrorFunc("MSVC_LINKER_INTERFACE_NAME was not found in .fpccfg\n");
|
||||||
CUtlString szExePath = pSection->GetStringValue("exe");
|
CUtlString szExePath = pSection->GetStringValue("exe");
|
||||||
if (!pSection)
|
if (!pSection)
|
||||||
Plat_FatalErrorFunc("exe was not found in MSVC_LINKER_INTERFACE_NAME");
|
Plat_FatalErrorFunc("exe was not found in MSVC_LINKER_INTERFACE_NAME\n");
|
||||||
|
|
||||||
if (pProject->linkType == ELINK_STATIC_LIBRARY)
|
if (pProject->linkType == ELINK_STATIC_LIBRARY)
|
||||||
{
|
{
|
||||||
@@ -106,16 +110,26 @@ CUtlString CMSVCLinker::Link( LinkProject_t *pProject )
|
|||||||
{
|
{
|
||||||
szCompiledTarget = CUtlString("%s%u", szTarget.GetString(), pProject->m_androidmanifest.m_nTargetVersion);
|
szCompiledTarget = CUtlString("%s%u", szTarget.GetString(), pProject->m_androidmanifest.m_nTargetVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
"-o",
|
"/nologo"
|
||||||
szOutputFile,
|
|
||||||
"-target",
|
|
||||||
szCompiledTarget,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *szWindowsPath = GetWindowsPath(szOutputFile);
|
||||||
|
args.AppendTail(CUtlString("/out:%s", szWindowsPath));
|
||||||
|
V_free((void*)szWindowsPath);
|
||||||
|
|
||||||
if (pProject->linkType == ELINK_KERNEL_DRIVER)
|
if (pProject->linkType == ELINK_KERNEL_DRIVER)
|
||||||
{
|
{
|
||||||
args.AppendTail("/driver");
|
args.AppendTail("/driver");
|
||||||
args.AppendTail(CUtlString("/entry:\"%s\"", pProject->szEntry));
|
args.AppendTail(CUtlString("/entry:%s", pProject->szEntry));
|
||||||
|
}
|
||||||
|
switch (pProject->m_eWindowsSubsystem)
|
||||||
|
{
|
||||||
|
case WINDOWS_SUBSYSTEM_NATIVE:
|
||||||
|
args.AppendTail("/subsystem:native");
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable stdlib
|
// Disable stdlib
|
||||||
@@ -134,9 +148,19 @@ CUtlString CMSVCLinker::Link( LinkProject_t *pProject )
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
runner->Run(szExePath, args);
|
winerunner->Run(szExePath, args);
|
||||||
runner->Wait();
|
winerunner->Wait();
|
||||||
}
|
}
|
||||||
compiled:
|
compiled:
|
||||||
return szOutputFile;
|
return szOutputFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool CMSVCLinker::IsLibraryExists( CUtlString szName )
|
||||||
|
{
|
||||||
|
szName = CUtlString("%s.dll", szName.GetString());
|
||||||
|
void *pLib = Plat_LoadLibrary(szName.GetString());
|
||||||
|
if (!pLib)
|
||||||
|
return false;
|
||||||
|
Plat_UnloadLibrary(pLib);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
44
fpc/library/winerunner.cpp
Normal file
44
fpc/library/winerunner.cpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#include "runner.h"
|
||||||
|
#include "winerunner.h"
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
#include "tier1/interface.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
#include "unistd.h"
|
||||||
|
#include "sys/wait.h"
|
||||||
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
|
class CWineRunner: public IWineRunner
|
||||||
|
{
|
||||||
|
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(CWineRunner, IWineRunner, WINE_RUNNER_INTERFACE_NAME);
|
||||||
|
|
||||||
|
int CWineRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
|
||||||
|
{
|
||||||
|
return runner->Run(szName, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CWineRunner::Run(CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlString>& args)
|
||||||
|
{
|
||||||
|
CUtlVector<CUtlString> args2 = args;
|
||||||
|
args2.AppendHead(szName);
|
||||||
|
return runner->Run("wine", szDirectory, args2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CWineRunner::Run(CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlString>& args, CUtlVector<CUtlString>& environment)
|
||||||
|
{
|
||||||
|
CUtlVector<CUtlString> args2 = args;
|
||||||
|
args2.AppendHead(szName);
|
||||||
|
return runner->Run("wine", szDirectory, args2, environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CWineRunner::Wait( void )
|
||||||
|
{
|
||||||
|
return runner->Wait();
|
||||||
|
};
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "public/ld.h"
|
#include "public/ld.h"
|
||||||
#include "public/target.h"
|
#include "public/target.h"
|
||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
|
#include "winerunner.h"
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
#include "libgen.h"
|
#include "libgen.h"
|
||||||
@@ -106,6 +107,7 @@ findbuild:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
runner = (IRunner*)CreateInterface(RUNNER_INTERFACE_NAME, NULL);
|
runner = (IRunner*)CreateInterface(RUNNER_INTERFACE_NAME, NULL);
|
||||||
|
winerunner = (IWineRunner*)CreateInterface(WINE_RUNNER_INTERFACE_NAME, NULL);
|
||||||
filesystem2 = (IFileSystem2*)CreateInterface(FILE_SYSTEM_2_INTERFACE_NAME, NULL);
|
filesystem2 = (IFileSystem2*)CreateInterface(FILE_SYSTEM_2_INTERFACE_NAME, NULL);
|
||||||
ccompiler = (ICCompiler*)CreateInterface(CLANG_C_COMPILER_INTERFACE_NAME, NULL);
|
ccompiler = (ICCompiler*)CreateInterface(CLANG_C_COMPILER_INTERFACE_NAME, NULL);
|
||||||
linker = (ILinker*)CreateInterface(CLANG_LINKER_INTERFACE_NAME, NULL);
|
linker = (ILinker*)CreateInterface(CLANG_LINKER_INTERFACE_NAME, NULL);
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern IFileSystem2 *filesystem2;
|
extern IFileSystem2 *filesystem2;
|
||||||
|
char *GetWindowsPath( const char *szPath );
|
||||||
|
char *GetPOSIXPath( const char *szPath );
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public:
|
|||||||
virtual int Wait( void ) = 0;
|
virtual int Wait( void ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern IRunner *runner;
|
extern IRunner *runner;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
28
fpc/public/winerunner.h
Normal file
28
fpc/public/winerunner.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
//================= Copyright kotofyt, All rights reserved ==================//
|
||||||
|
// Purpose: Run Windows applications using Wine. On native system this will use
|
||||||
|
// CWindowsRunner.
|
||||||
|
//===========================================================================//
|
||||||
|
|
||||||
|
#ifndef WINE_RUNNER_H
|
||||||
|
#define WINE_RUNNER_H
|
||||||
|
|
||||||
|
#include "runner.h"
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
|
||||||
|
#define WINE_RUNNER_INTERFACE_NAME "WineRunner001"
|
||||||
|
|
||||||
|
abstract_class IWineRunner: public IRunner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual int Run( CUtlString szName, CUtlVector<CUtlString>& args ) = 0;
|
||||||
|
virtual int Run( CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlString>& args ) = 0;
|
||||||
|
virtual int Run( CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlString>& args, CUtlVector<CUtlString>& environment ) = 0;
|
||||||
|
virtual int Wait( void ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern IWineRunner *winerunner;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -98,7 +98,7 @@ IINIFile *CINIManager::ReadFile( const char *psz )
|
|||||||
if (!pFile)
|
if (!pFile)
|
||||||
return NULL;
|
return NULL;
|
||||||
data = CUtlBuffer<char>(pFile->Size()+1);
|
data = CUtlBuffer<char>(pFile->Size()+1);
|
||||||
pFile->Read(data.GetMemory(), pFile->Size());
|
uint32_t nSize = pFile->Read(data.GetMemory(), pFile->Size());
|
||||||
pFile->Close();
|
pFile->Close();
|
||||||
|
|
||||||
return ReadString(data.GetMemory());
|
return ReadString(data.GetMemory());
|
||||||
@@ -259,8 +259,6 @@ IINIFile *CINIManager::ReadString( const char *psz )
|
|||||||
pCurrentSectionData->m_eSectionType = SECTIONTYPE_STRING;
|
pCurrentSectionData->m_eSectionType = SECTIONTYPE_STRING;
|
||||||
pCurrentSectionData->m_szKey = tokens[i];
|
pCurrentSectionData->m_szKey = tokens[i];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
if (i>=tokens.GetSize())
|
if (i>=tokens.GetSize())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ public:
|
|||||||
pHandle = new CLIBCFileHandle;
|
pHandle = new CLIBCFileHandle;
|
||||||
pHandle->m_pFileSystem = this;
|
pHandle->m_pFileSystem = this;
|
||||||
pHandle->m_pFile = pFile;
|
pHandle->m_pFile = pFile;
|
||||||
pHandle->Seek(SEEKMODE_RELATIVE_START, 0);
|
|
||||||
pHandle->m_nSize = pHandle->Tell();
|
|
||||||
pHandle->Seek(SEEKMODE_RELATIVE_END, 0);
|
pHandle->Seek(SEEKMODE_RELATIVE_END, 0);
|
||||||
|
pHandle->m_nSize = pHandle->Tell();
|
||||||
|
pHandle->Seek(SEEKMODE_RELATIVE_START, 0);
|
||||||
return pHandle;
|
return pHandle;
|
||||||
}
|
}
|
||||||
virtual size_t Write( IFileHandle *pFile, const void *pData, size_t nDataSize ) override
|
virtual size_t Write( IFileHandle *pFile, const void *pData, size_t nDataSize ) override
|
||||||
|
|||||||
Reference in New Issue
Block a user