reworked linking
This commit is contained in:
@@ -34,13 +34,74 @@ CUtlString ILinker::GetOutputObjectName( LinkProject_t *pProject, unsigned int h
|
||||
szFileNameFormat.GetString());
|
||||
}
|
||||
|
||||
CUtlString ILinker::Link( LinkProject_t *pProject )
|
||||
{
|
||||
if (pProject->m_szName == 0)
|
||||
{
|
||||
Plat_FatalErrorFunc("m_szName must be present\n");
|
||||
}
|
||||
LinkProject_t stLinkProject = *pProject;
|
||||
if (pProject->m_target.kernel == TARGET_KERNEL_ANDROID)
|
||||
stLinkProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||
|
||||
unsigned int hash = pProject->GenerateProjectHash();
|
||||
CUtlString szOutputFile = GetOutputObjectName(&stLinkProject, hash, NULL);
|
||||
filesystem2->MakeDirectory(szOutputFile.GetDirectory());
|
||||
|
||||
if (stLinkProject.linkType == ELINK_STATIC_LIBRARY)
|
||||
{
|
||||
CUtlVector<CUtlString> args;
|
||||
bool shouldRecompile = false;
|
||||
for (auto object: pProject->objects)
|
||||
{
|
||||
if (filesystem2->ShouldRecompile(object.m_szObjectFile,szOutputFile))
|
||||
{
|
||||
shouldRecompile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!shouldRecompile)
|
||||
goto compiled;
|
||||
|
||||
V_printf(" AR %s\n", pProject->m_szName.GetString());
|
||||
args = {
|
||||
"rcs",
|
||||
szOutputFile
|
||||
};
|
||||
for (auto object: pProject->objects)
|
||||
args.AppendTail(object.m_szObjectFile);
|
||||
runner->Run("ar", args);
|
||||
runner->Wait();
|
||||
} else {
|
||||
bool shouldRecompile = false;
|
||||
for (auto object: pProject->objects)
|
||||
{
|
||||
if (filesystem2->ShouldRecompile(object.m_szObjectFile,szOutputFile))
|
||||
{
|
||||
shouldRecompile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!shouldRecompile)
|
||||
goto compiled;
|
||||
|
||||
V_printf(" LINK %s\n", pProject->m_szName.GetString());
|
||||
CUtlVector<CUtlString> args;
|
||||
args = BuildLinkCommandLine(pProject, szOutputFile);
|
||||
runner->Run(GetCompilerExecutable(pProject), args);
|
||||
runner->Wait();
|
||||
}
|
||||
compiled:
|
||||
return szOutputFile;
|
||||
}
|
||||
|
||||
CUtlVector<CUtlString> ILinker::BuildLinkCommandLine( LinkProject_t *pProject, const char *szOutputFileName )
|
||||
{
|
||||
CUtlVector<CUtlString> cmd;
|
||||
SetTarget(cmd, pProject);
|
||||
SetOutputFile(cmd);
|
||||
SetOutputFile(cmd, szOutputFileName);
|
||||
SetSysroot(cmd, pProject, NULL);
|
||||
SetDefaultLibraryPaths(cmd, pProject);
|
||||
UseFullFile(cmd);
|
||||
for (auto &o: pProject->objects)
|
||||
{
|
||||
@@ -60,6 +121,7 @@ CUtlVector<CUtlString> ILinker::BuildLinkCommandLine( LinkProject_t *pProject, c
|
||||
{
|
||||
LinkLibraryPath(cmd, o);
|
||||
};
|
||||
return cmd;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user