|
@@ -7,7 +7,6 @@
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
#include <map>
|
|
#include <map>
|
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
|
-#include <string.h>
|
|
|
|
|
#include <utility>
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "cmAlgorithms.h"
|
|
#include "cmAlgorithms.h"
|
|
@@ -54,7 +53,8 @@ public:
|
|
|
typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
|
|
typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
|
|
|
ObjectInfoMap ObjectInfo;
|
|
ObjectInfoMap ObjectInfo;
|
|
|
|
|
|
|
|
- cmFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src)
|
|
|
|
|
|
|
+ cmFortranSourceInfo& CreateObjectInfo(const std::string& obj,
|
|
|
|
|
+ const std::string& src)
|
|
|
{
|
|
{
|
|
|
std::map<std::string, cmFortranSourceInfo>::iterator i =
|
|
std::map<std::string, cmFortranSourceInfo>::iterator i =
|
|
|
this->ObjectInfo.find(obj);
|
|
this->ObjectInfo.find(obj);
|
|
@@ -121,8 +121,7 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
|
|
|
bool okay = true;
|
|
bool okay = true;
|
|
|
for (std::string const& src : sources) {
|
|
for (std::string const& src : sources) {
|
|
|
// Get the information object for this source.
|
|
// Get the information object for this source.
|
|
|
- cmFortranSourceInfo& info =
|
|
|
|
|
- this->Internal->CreateObjectInfo(obj.c_str(), src.c_str());
|
|
|
|
|
|
|
+ cmFortranSourceInfo& info = this->Internal->CreateObjectInfo(obj, src);
|
|
|
|
|
|
|
|
// Create the parser object. The constructor takes info by reference,
|
|
// Create the parser object. The constructor takes info by reference,
|
|
|
// so we may look into the resulting objects later.
|
|
// so we may look into the resulting objects later.
|
|
@@ -153,7 +152,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
|
|
|
this->LocateModules();
|
|
this->LocateModules();
|
|
|
|
|
|
|
|
// Get the directory in which stamp files will be stored.
|
|
// Get the directory in which stamp files will be stored.
|
|
|
- const char* stamp_dir = this->TargetDirectory.c_str();
|
|
|
|
|
|
|
+ const std::string& stamp_dir = this->TargetDirectory;
|
|
|
|
|
|
|
|
// Get the directory in which module files will be created.
|
|
// Get the directory in which module files will be created.
|
|
|
cmMakefile* mf = this->LocalGenerator->GetMakefile();
|
|
cmMakefile* mf = this->LocalGenerator->GetMakefile();
|
|
@@ -167,9 +166,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
|
|
|
typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
|
|
typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
|
|
|
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
|
|
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
|
|
|
for (auto const& i : objInfo) {
|
|
for (auto const& i : objInfo) {
|
|
|
- if (!this->WriteDependenciesReal(i.first.c_str(), i.second, mod_dir,
|
|
|
|
|
- stamp_dir, makeDepends,
|
|
|
|
|
- internalDepends)) {
|
|
|
|
|
|
|
+ if (!this->WriteDependenciesReal(i.first, i.second, mod_dir, stamp_dir,
|
|
|
|
|
+ makeDepends, internalDepends)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -256,22 +254,22 @@ void cmDependsFortran::LocateModules()
|
|
|
std::string fname = targetDir + "/fortran.internal";
|
|
std::string fname = targetDir + "/fortran.internal";
|
|
|
cmsys::ifstream fin(fname.c_str());
|
|
cmsys::ifstream fin(fname.c_str());
|
|
|
if (fin) {
|
|
if (fin) {
|
|
|
- this->MatchRemoteModules(fin, targetDir.c_str());
|
|
|
|
|
|
|
+ this->MatchRemoteModules(fin, targetDir);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void cmDependsFortran::MatchLocalModules()
|
|
void cmDependsFortran::MatchLocalModules()
|
|
|
{
|
|
{
|
|
|
- const char* stampDir = this->TargetDirectory.c_str();
|
|
|
|
|
|
|
+ std::string const& stampDir = this->TargetDirectory;
|
|
|
std::set<std::string> const& provides = this->Internal->TargetProvides;
|
|
std::set<std::string> const& provides = this->Internal->TargetProvides;
|
|
|
for (std::string const& i : provides) {
|
|
for (std::string const& i : provides) {
|
|
|
- this->ConsiderModule(i.c_str(), stampDir);
|
|
|
|
|
|
|
+ this->ConsiderModule(i, stampDir);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void cmDependsFortran::MatchRemoteModules(std::istream& fin,
|
|
void cmDependsFortran::MatchRemoteModules(std::istream& fin,
|
|
|
- const char* stampDir)
|
|
|
|
|
|
|
+ const std::string& stampDir)
|
|
|
{
|
|
{
|
|
|
std::string line;
|
|
std::string line;
|
|
|
bool doing_provides = false;
|
|
bool doing_provides = false;
|
|
@@ -300,7 +298,8 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
|
|
|
|
|
|
|
+void cmDependsFortran::ConsiderModule(const std::string& name,
|
|
|
|
|
+ const std::string& stampDir)
|
|
|
{
|
|
{
|
|
|
// Locate each required module.
|
|
// Locate each required module.
|
|
|
typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
|
|
typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
|
|
@@ -317,17 +316,17 @@ void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-bool cmDependsFortran::WriteDependenciesReal(const char* obj,
|
|
|
|
|
|
|
+bool cmDependsFortran::WriteDependenciesReal(std::string const& obj,
|
|
|
cmFortranSourceInfo const& info,
|
|
cmFortranSourceInfo const& info,
|
|
|
std::string const& mod_dir,
|
|
std::string const& mod_dir,
|
|
|
- const char* stamp_dir,
|
|
|
|
|
|
|
+ std::string const& stamp_dir,
|
|
|
std::ostream& makeDepends,
|
|
std::ostream& makeDepends,
|
|
|
std::ostream& internalDepends)
|
|
std::ostream& internalDepends)
|
|
|
{
|
|
{
|
|
|
typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
|
|
typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
|
|
|
|
|
|
|
|
// Get the source file for this object.
|
|
// Get the source file for this object.
|
|
|
- const char* src = info.Source.c_str();
|
|
|
|
|
|
|
+ std::string const& src = info.Source;
|
|
|
|
|
|
|
|
// Write the include dependencies to the output stream.
|
|
// Write the include dependencies to the output stream.
|
|
|
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
|
|
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
|
|
@@ -502,8 +501,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
|
|
|
cmFortranModuleAppendUpperLower(cmSystemTools::GetFilenameName(mod),
|
|
cmFortranModuleAppendUpperLower(cmSystemTools::GetFilenameName(mod),
|
|
|
mod_upper, mod_lower);
|
|
mod_upper, mod_lower);
|
|
|
if (cmSystemTools::FileExists(mod_upper, true)) {
|
|
if (cmSystemTools::FileExists(mod_upper, true)) {
|
|
|
- if (cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
|
|
|
|
|
- compilerId.c_str())) {
|
|
|
|
|
|
|
+ if (cmDependsFortran::ModulesDiffer(mod_upper, stamp, compilerId)) {
|
|
|
if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
|
|
if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
|
|
|
std::cerr << "Error copying Fortran module from \"" << mod_upper
|
|
std::cerr << "Error copying Fortran module from \"" << mod_upper
|
|
|
<< "\" to \"" << stamp << "\".\n";
|
|
<< "\" to \"" << stamp << "\".\n";
|
|
@@ -513,8 +511,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
if (cmSystemTools::FileExists(mod_lower, true)) {
|
|
if (cmSystemTools::FileExists(mod_lower, true)) {
|
|
|
- if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
|
|
|
|
|
- compilerId.c_str())) {
|
|
|
|
|
|
|
+ if (cmDependsFortran::ModulesDiffer(mod_lower, stamp, compilerId)) {
|
|
|
if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
|
|
if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
|
|
|
std::cerr << "Error copying Fortran module from \"" << mod_lower
|
|
std::cerr << "Error copying Fortran module from \"" << mod_lower
|
|
|
<< "\" to \"" << stamp << "\".\n";
|
|
<< "\" to \"" << stamp << "\".\n";
|
|
@@ -581,9 +578,9 @@ static bool cmFortranStreamsDiffer(std::istream& ifs1, std::istream& ifs2)
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-bool cmDependsFortran::ModulesDiffer(const char* modFile,
|
|
|
|
|
- const char* stampFile,
|
|
|
|
|
- const char* compilerId)
|
|
|
|
|
|
|
+bool cmDependsFortran::ModulesDiffer(const std::string& modFile,
|
|
|
|
|
+ const std::string& stampFile,
|
|
|
|
|
+ const std::string& compilerId)
|
|
|
{
|
|
{
|
|
|
/*
|
|
/*
|
|
|
gnu >= 4.9:
|
|
gnu >= 4.9:
|
|
@@ -617,16 +614,17 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
|
|
|
* source is compiled twice
|
|
* source is compiled twice
|
|
|
* -SunPro
|
|
* -SunPro
|
|
|
*/
|
|
*/
|
|
|
- if (strcmp(compilerId, "SunPro") == 0) {
|
|
|
|
|
|
|
+ if (compilerId == "SunPro") {
|
|
|
return cmSystemTools::FilesDiffer(modFile, stampFile);
|
|
return cmSystemTools::FilesDiffer(modFile, stampFile);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
|
- cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary);
|
|
|
|
|
- cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary);
|
|
|
|
|
|
|
+ cmsys::ifstream finModFile(modFile.c_str(), std::ios::in | std::ios::binary);
|
|
|
|
|
+ cmsys::ifstream finStampFile(stampFile.c_str(),
|
|
|
|
|
+ std::ios::in | std::ios::binary);
|
|
|
#else
|
|
#else
|
|
|
- cmsys::ifstream finModFile(modFile);
|
|
|
|
|
- cmsys::ifstream finStampFile(stampFile);
|
|
|
|
|
|
|
+ cmsys::ifstream finModFile(modFile.c_str());
|
|
|
|
|
+ cmsys::ifstream finStampFile(stampFile.c_str());
|
|
|
#endif
|
|
#endif
|
|
|
if (!finModFile || !finStampFile) {
|
|
if (!finModFile || !finStampFile) {
|
|
|
// At least one of the files does not exist. The modules differ.
|
|
// At least one of the files does not exist. The modules differ.
|
|
@@ -641,7 +639,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
|
|
|
* Eat the stream content until all recompile only related changes
|
|
* Eat the stream content until all recompile only related changes
|
|
|
* are left behind.
|
|
* are left behind.
|
|
|
*/
|
|
*/
|
|
|
- if (strcmp(compilerId, "GNU") == 0) {
|
|
|
|
|
|
|
+ if (compilerId == "GNU") {
|
|
|
// GNU Fortran 4.9 and later compress .mod files with gzip
|
|
// GNU Fortran 4.9 and later compress .mod files with gzip
|
|
|
// but also do not include a date so we can fall through to
|
|
// but also do not include a date so we can fall through to
|
|
|
// compare them without skipping any prefix.
|
|
// compare them without skipping any prefix.
|
|
@@ -664,7 +662,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- } else if (strcmp(compilerId, "Intel") == 0) {
|
|
|
|
|
|
|
+ } else if (compilerId == "Intel") {
|
|
|
const char seq[2] = { '\n', '\0' };
|
|
const char seq[2] = { '\n', '\0' };
|
|
|
const int seqlen = 2;
|
|
const int seqlen = 2;
|
|
|
|
|
|