|
#include "stdafx.h"
#include "DSUtils.h"
#include "Config.h"
#include "MkUtils.h"
MkUtils::MkUtils(AApplication spApp): m_spApp(spApp)
{
}
_bstr_t MkUtils::GetProjectMakefile(const _bstr_t &sProject)
{
LOG(Logger::cDebug, "MkUtils::GetProjectMakefile(%S){", static_cast<WCHAR*>(sProject));
TEST_BOOL(m_spApp);
_bstr_t ret = DSUtils(m_spApp).GetProjectDir(sProject) + "\\Makefile";
LOG(Logger::cDebug, "MkUtils::GetProjectMakefile()}, ret = '%S'", static_cast<WCHAR*>(ret));
return ret;
}
bool MkUtils::IsProjectMakeable(const _bstr_t &sProject)
{
LOG(Logger::cDebug, "MkUtils::IsProjectMakeable(%S){", static_cast<WCHAR*>(sProject));
_bstr_t sMakefile = GetProjectMakefile(sProject);
FILE *fp = _wfopen(sMakefile, L"r");
bool ret = NULL != fp;
if(NULL != fp)
fclose(fp);
LOG(Logger::cDebug, "MkUtils::IsProjectMakeable()}, ret = %d", ret);
return ret;
}
bool MkUtils::IsProjectTestable(const _bstr_t &sProject)
{
LOG(Logger::cDebug, "MkUtils::IsProjectTestable(%S){", static_cast<WCHAR*>(sProject));
_bstr_t sTestMakefile = DSUtils(m_spApp).GetProjectDir(sProject);
sTestMakefile += "\\UnitTest\\Makefile";
FILE *fp = _wfopen(sTestMakefile, L"r");
bool ret = NULL != fp;
if(NULL != fp)
fclose(fp);
LOG(Logger::cDebug, "MkUtils::IsProjectTestable(){, ret = %d", ret);
return ret;
}
bool MkUtils::IsProjectUTest(const _bstr_t &sProject)
{
LOG(Logger::cDebug, "MkUtils::IsProjectUTest(%S){", static_cast<WCHAR*>(sProject));
const WCHAR szSuffix[] = L"_UTest";
WCHAR *p = wcsstr(static_cast<WCHAR*>(sProject), szSuffix);
bool ret = NULL != p && L'\0' == *(p + wcslen(szSuffix));
LOG(Logger::cDebug, "MkUtils::IsProjectUTest()}, ret = %d", ret);
return ret;
}
_bstr_t MkUtils::CreateMakeCommand(SupportedCommands::CmdId Id)
{
LOG(Logger::cDebug, "MkUtils::CreateMakeCommand(%d){", Id);
TEST_BOOL(m_spApp);
_bstr_t sMake("make");
if(SupportedCommands::GetInstance().GetCmdInfo(Id).bMake)
{
static Config cfg;
cfg.Load();
if(cfg.GetCmdMakeOpts(Id).bMasterToDswName)
sMake += _bstr_t(" MASTER_PROJECT=") + DSUtils(m_spApp).GetDswName();
if(DSUtils(m_spApp).IsDebug())
sMake += " DEBUG=1";
sMake += _bstr_t(" ") + cfg.GetGeneralMakeOpts();
sMake += _bstr_t(" ") + cfg.GetCmdMakeOpts(Id).sMakeOpts;
}
else
{
sMake = "echo Unknown command ";
char buf[20];
sMake += itoa(Id, buf, 10);
}
LOG(Logger::cDebug, "MkUtils::CreateMakeCommand()}, ret = '%S'", static_cast<WCHAR*>(sMake));
return sMake;
}
_bstr_t MkUtils::AddPathToCmd(const _bstr_t &sMakeCommand, const _bstr_t &sPath)
{
LOG(Logger::cDebug, "MkUtils::AddPathToCmd(%S){", static_cast<WCHAR*>(sMakeCommand));
WCHAR *p = wcschr(static_cast<WCHAR*>(sMakeCommand), L' ');
TEST_BOOL(NULL != p);
_bstr_t ret = _bstr_t(::SysAllocStringLen(sMakeCommand, p-static_cast<WCHAR*>(sMakeCommand)), false);
ret += " -C \"";
ret += sPath;
ret += "\" ";
ret += p;
LOG(Logger::cDebug, "MkUtils::AddPathToCmd()}, ret = %S", static_cast<WCHAR*>(ret));
return ret;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.