Ninja: add .def file support
This commit is contained in:
parent
f1bb08f55b
commit
dbe3dce546
|
@ -325,6 +325,8 @@ private:
|
||||||
|
|
||||||
typedef std::map<std::string, cmTarget*> TargetAliasMap;
|
typedef std::map<std::string, cmTarget*> TargetAliasMap;
|
||||||
TargetAliasMap TargetAliases;
|
TargetAliasMap TargetAliases;
|
||||||
|
|
||||||
|
static cmLocalGenerator* LocalGenerator;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ! cmGlobalNinjaGenerator_h
|
#endif // ! cmGlobalNinjaGenerator_h
|
||||||
|
|
|
@ -1503,7 +1503,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
||||||
linkFlags +=
|
linkFlags +=
|
||||||
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
||||||
linkFlags += this->Convert(sf->GetFullPath().c_str(),
|
linkFlags += this->Convert(sf->GetFullPath().c_str(),
|
||||||
START_OUTPUT, SHELL);
|
FULL, SHELL);
|
||||||
linkFlags += " ";
|
linkFlags += " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,6 +285,7 @@ cmNinjaNormalTargetGenerator
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unexpected target type");
|
assert(0 && "Unexpected target type");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *linkCmd =
|
const char *linkCmd =
|
||||||
this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
|
this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
|
||||||
cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
|
cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
|
||||||
|
|
|
@ -229,6 +229,13 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
|
||||||
const std::vector<std::string> &deps = cli->GetDepends();
|
const std::vector<std::string> &deps = cli->GetDepends();
|
||||||
cmNinjaDeps result(deps.size());
|
cmNinjaDeps result(deps.size());
|
||||||
std::transform(deps.begin(), deps.end(), result.begin(), MapToNinjaPath());
|
std::transform(deps.begin(), deps.end(), result.begin(), MapToNinjaPath());
|
||||||
|
|
||||||
|
// Add a dependency on the link definitions file, if any.
|
||||||
|
if(!this->ModuleDefinitionFile.empty())
|
||||||
|
{
|
||||||
|
result.push_back(this->ModuleDefinitionFile);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,6 +335,7 @@ cmNinjaTargetGenerator
|
||||||
}
|
}
|
||||||
vars.Flags = flags.c_str();
|
vars.Flags = flags.c_str();
|
||||||
|
|
||||||
|
|
||||||
// Rule for compiling object file.
|
// Rule for compiling object file.
|
||||||
std::string compileCmdVar = "CMAKE_";
|
std::string compileCmdVar = "CMAKE_";
|
||||||
compileCmdVar += language;
|
compileCmdVar += language;
|
||||||
|
@ -395,6 +403,8 @@ cmNinjaTargetGenerator
|
||||||
if (!language) {
|
if (!language) {
|
||||||
if (source->GetPropertyAsBool("EXTERNAL_OBJECT"))
|
if (source->GetPropertyAsBool("EXTERNAL_OBJECT"))
|
||||||
this->Objects.push_back(this->GetSourceFilePath(source));
|
this->Objects.push_back(this->GetSourceFilePath(source));
|
||||||
|
if(cmSystemTools::UpperCase(source->GetExtension()) == "DEF")
|
||||||
|
this->ModuleDefinitionFile = GetSourceFilePath(source);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,3 +475,29 @@ cmNinjaTargetGenerator
|
||||||
orderOnlyDeps,
|
orderOnlyDeps,
|
||||||
vars);
|
vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void
|
||||||
|
cmNinjaTargetGenerator
|
||||||
|
::AddModuleDefinitionFlag(std::string& flags)
|
||||||
|
{
|
||||||
|
if(this->ModuleDefinitionFile.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Create a per-language flag variable.
|
||||||
|
const char* defFileFlag =
|
||||||
|
this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
||||||
|
if(!defFileFlag)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append the flag and value. Use ConvertToLinkReference to help
|
||||||
|
// vs6's "cl -link" pass it to the linker.
|
||||||
|
std::string flag = defFileFlag;
|
||||||
|
flag += (this->LocalGenerator->ConvertToLinkReference(
|
||||||
|
this->ModuleDefinitionFile.c_str()));
|
||||||
|
this->LocalGenerator->AppendFlags(flags, flag.c_str());
|
||||||
|
}
|
||||||
|
|
|
@ -107,12 +107,18 @@ protected:
|
||||||
cmNinjaDeps GetObjects() const
|
cmNinjaDeps GetObjects() const
|
||||||
{ return this->Objects; }
|
{ return this->Objects; }
|
||||||
|
|
||||||
|
// Helper to add flag for windows .def file.
|
||||||
|
void AddModuleDefinitionFlag(std::string& flags);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cmTarget* Target;
|
cmTarget* Target;
|
||||||
cmMakefile* Makefile;
|
cmMakefile* Makefile;
|
||||||
cmLocalNinjaGenerator* LocalGenerator;
|
cmLocalNinjaGenerator* LocalGenerator;
|
||||||
/// List of object files for this target.
|
/// List of object files for this target.
|
||||||
cmNinjaDeps Objects;
|
cmNinjaDeps Objects;
|
||||||
|
|
||||||
|
// The windows module definition source file (.def), if any.
|
||||||
|
std::string ModuleDefinitionFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ! cmNinjaTargetGenerator_h
|
#endif // ! cmNinjaTargetGenerator_h
|
||||||
|
|
Loading…
Reference in New Issue