Ninja: Add support for OS X app bundles.
This patch fixes test Qt4Deploy on Darwin. Thanks to Jamie Kirkpatrick <jkp@kirkconsulting.co.uk>
This commit is contained in:
parent
cdfa14a4f5
commit
21f156c03b
|
@ -33,6 +33,8 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
|
||||||
, TargetNameReal()
|
, TargetNameReal()
|
||||||
, TargetNameImport()
|
, TargetNameImport()
|
||||||
, TargetNamePDB()
|
, TargetNamePDB()
|
||||||
|
, TargetLinkLanguage(0)
|
||||||
|
, MacContentDirectory()
|
||||||
{
|
{
|
||||||
this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
|
this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
|
||||||
if (target->GetType() == cmTarget::EXECUTABLE)
|
if (target->GetType() == cmTarget::EXECUTABLE)
|
||||||
|
@ -55,6 +57,15 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
|
||||||
// ensure the directory exists (OutDir test)
|
// ensure the directory exists (OutDir test)
|
||||||
EnsureDirectoryExists(target->GetDirectory(this->GetConfigName()));
|
EnsureDirectoryExists(target->GetDirectory(this->GetConfigName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Factor with the cmMakefileExecutableTargetGenerator constructor.
|
||||||
|
if(target->IsAppBundleOnApple())
|
||||||
|
{
|
||||||
|
this->MacContentDirectory = target->GetDirectory(this->GetConfigName());
|
||||||
|
this->MacContentDirectory += "/";
|
||||||
|
this->MacContentDirectory += this->TargetNameOut;
|
||||||
|
this->MacContentDirectory += ".app/Contents/";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
|
cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
|
||||||
|
@ -341,6 +352,29 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
||||||
{
|
{
|
||||||
cmTarget::TargetType targetType = this->GetTarget()->GetType();
|
cmTarget::TargetType targetType = this->GetTarget()->GetType();
|
||||||
|
|
||||||
|
std::string targetOutput = ConvertToNinjaPath(
|
||||||
|
this->GetTarget()->GetFullPath(this->GetConfigName()).c_str());
|
||||||
|
std::string targetOutputReal = ConvertToNinjaPath(
|
||||||
|
this->GetTarget()->GetFullPath(this->GetConfigName(),
|
||||||
|
/*implib=*/false,
|
||||||
|
/*realpath=*/true).c_str());
|
||||||
|
std::string targetOutputImplib = ConvertToNinjaPath(
|
||||||
|
this->GetTarget()->GetFullPath(this->GetConfigName(),
|
||||||
|
/*implib=*/true).c_str());
|
||||||
|
|
||||||
|
if (this->GetTarget()->IsAppBundleOnApple())
|
||||||
|
{
|
||||||
|
// Create the app bundle
|
||||||
|
std::string outpath;
|
||||||
|
this->CreateAppBundle(this->TargetNameOut, outpath);
|
||||||
|
|
||||||
|
// Calculate the output path
|
||||||
|
targetOutput = outpath + this->TargetNameOut;
|
||||||
|
targetOutput = this->ConvertToNinjaPath(targetOutput.c_str());
|
||||||
|
targetOutputReal = outpath + this->TargetNameReal;
|
||||||
|
targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// Write comments.
|
// Write comments.
|
||||||
cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
|
cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
|
||||||
this->GetBuildFileStream()
|
this->GetBuildFileStream()
|
||||||
|
@ -353,16 +387,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
||||||
cmNinjaDeps emptyDeps;
|
cmNinjaDeps emptyDeps;
|
||||||
cmNinjaVars vars;
|
cmNinjaVars vars;
|
||||||
|
|
||||||
std::string targetOutput = ConvertToNinjaPath(
|
|
||||||
this->GetTarget()->GetFullPath(this->GetConfigName()).c_str());
|
|
||||||
std::string targetOutputReal = ConvertToNinjaPath(
|
|
||||||
this->GetTarget()->GetFullPath(this->GetConfigName(),
|
|
||||||
/*implib=*/false,
|
|
||||||
/*realpath=*/true).c_str());
|
|
||||||
std::string targetOutputImplib = ConvertToNinjaPath(
|
|
||||||
this->GetTarget()->GetFullPath(this->GetConfigName(),
|
|
||||||
/*implib=*/true).c_str());
|
|
||||||
|
|
||||||
// Compute the comment.
|
// Compute the comment.
|
||||||
cmOStringStream comment;
|
cmOStringStream comment;
|
||||||
comment << "Link the " << this->GetVisibleTypeName() << " "
|
comment << "Link the " << this->GetVisibleTypeName() << " "
|
||||||
|
@ -576,3 +600,24 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
|
||||||
this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
|
this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
|
||||||
this->GetTarget());
|
this->GetTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Factor with cmMakefileExecutableTargetGenerator::CreateAppBundle().
|
||||||
|
void
|
||||||
|
cmNinjaNormalTargetGenerator::CreateAppBundle(const std::string& targetName,
|
||||||
|
std::string& outpath)
|
||||||
|
{
|
||||||
|
// Compute bundle directory names.
|
||||||
|
outpath = this->MacContentDirectory;
|
||||||
|
outpath += "MacOS";
|
||||||
|
cmSystemTools::MakeDirectory(outpath.c_str());
|
||||||
|
this->GetMakefile()->AddCMakeOutputFile(outpath.c_str());
|
||||||
|
outpath += "/";
|
||||||
|
|
||||||
|
// Configure the Info.plist file. Note that it needs the executable name
|
||||||
|
// to be set.
|
||||||
|
std::string plist = this->MacContentDirectory + "Info.plist";
|
||||||
|
this->GetLocalGenerator()->GenerateAppleInfoPList(this->GetTarget(),
|
||||||
|
targetName.c_str(),
|
||||||
|
plist.c_str());
|
||||||
|
this->GetMakefile()->AddCMakeOutputFile(plist.c_str());
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ private:
|
||||||
void WriteLinkStatement();
|
void WriteLinkStatement();
|
||||||
void WriteObjectLibStatement();
|
void WriteObjectLibStatement();
|
||||||
std::vector<std::string> ComputeLinkCmd();
|
std::vector<std::string> ComputeLinkCmd();
|
||||||
|
void CreateAppBundle(const std::string& targetName, std::string& outpath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Target name info.
|
// Target name info.
|
||||||
|
@ -43,6 +44,7 @@ private:
|
||||||
std::string TargetNameImport;
|
std::string TargetNameImport;
|
||||||
std::string TargetNamePDB;
|
std::string TargetNamePDB;
|
||||||
const char *TargetLinkLanguage;
|
const char *TargetLinkLanguage;
|
||||||
|
std::string MacContentDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ! cmNinjaNormalTargetGenerator_h
|
#endif // ! cmNinjaNormalTargetGenerator_h
|
||||||
|
|
Loading…
Reference in New Issue