summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2019-02-20 09:57:07 (GMT)
committerBrad King <brad.king@kitware.com>2019-02-25 15:14:09 (GMT)
commit2c0a7bc770367e80ce1fc68ea6cb9c9543e854e4 (patch)
tree670ba9cd0a90566e8fbca03a49eb38faa6747d17 /Source
parent72f9bb29939f3765216e98e672197b3899d75f7d (diff)
downloadCMake-2c0a7bc770367e80ce1fc68ea6cb9c9543e854e4.zip
CMake-2c0a7bc770367e80ce1fc68ea6cb9c9543e854e4.tar.gz
CMake-2c0a7bc770367e80ce1fc68ea6cb9c9543e854e4.tar.bz2
ninja: pass language to cmake_ninja_depends
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx119
-rw-r--r--Source/cmNinjaTargetGenerator.cxx6
2 files changed, 85 insertions, 40 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 5a85963..74d3e8d 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1574,7 +1574,8 @@ Compilation of source files within a target is split into the following steps:
command = gfortran -cpp $DEFINES $INCLUDES $FLAGS -E $in -o $out &&
cmake -E cmake_ninja_depends \
--tdi=FortranDependInfo.json --pp=$out --dep=$DEP_FILE \
- --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE
+ --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE \
+ --lang=Fortran
build src.f90-pp.f90 | src.f90-pp.f90.ddi: Fortran_PREPROCESS src.f90
OBJ_FILE = src.f90.o
@@ -1633,6 +1634,19 @@ Compilation of source files within a target is split into the following steps:
(because the latter consumes the module).
*/
+struct cmSourceInfo
+{
+ // Set of provided and required modules.
+ std::set<std::string> Provides;
+ std::set<std::string> Requires;
+
+ // Set of files included in the translation unit.
+ std::set<std::string> Includes;
+};
+
+static std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
+ std::string const& arg_tdi, std::string const& arg_pp);
+
int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
std::vector<std::string>::const_iterator argEnd)
{
@@ -1641,6 +1655,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
std::string arg_dep;
std::string arg_obj;
std::string arg_ddi;
+ std::string arg_lang;
for (std::string const& arg : cmMakeRange(argBeg, argEnd)) {
if (cmHasLiteralPrefix(arg, "--tdi=")) {
arg_tdi = arg.substr(6);
@@ -1652,6 +1667,8 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
arg_obj = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--ddi=")) {
arg_ddi = arg.substr(6);
+ } else if (cmHasLiteralPrefix(arg, "--lang=")) {
+ arg_lang = arg.substr(7);
} else {
cmSystemTools::Error("-E cmake_ninja_depends unknown argument: " + arg);
return 1;
@@ -1677,7 +1694,61 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
cmSystemTools::Error("-E cmake_ninja_depends requires value for --ddi=");
return 1;
}
+ if (arg_lang.empty()) {
+ cmSystemTools::Error("-E cmake_ninja_depends requires value for --lang=");
+ return 1;
+ }
+
+ std::unique_ptr<cmSourceInfo> info;
+ if (arg_lang == "Fortran") {
+ info = cmcmd_cmake_ninja_depends_fortran(arg_tdi, arg_pp);
+ } else {
+ cmSystemTools::Error("-E cmake_ninja_depends does not understand the " +
+ arg_lang + " language");
+ return 1;
+ }
+ if (!info) {
+ // The error message is already expected to have been output.
+ return 1;
+ }
+
+ {
+ cmGeneratedFileStream depfile(arg_dep);
+ depfile << cmSystemTools::ConvertToUnixOutputPath(arg_pp) << ":";
+ for (std::string const& include : info->Includes) {
+ depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include);
+ }
+ depfile << "\n";
+ }
+
+ Json::Value ddi(Json::objectValue);
+ ddi["object"] = arg_obj;
+
+ Json::Value& ddi_provides = ddi["provides"] = Json::arrayValue;
+ for (std::string const& provide : info->Provides) {
+ ddi_provides.append(provide);
+ }
+ Json::Value& ddi_requires = ddi["requires"] = Json::arrayValue;
+ for (std::string const& r : info->Requires) {
+ // Require modules not provided in the same source.
+ if (!info->Provides.count(r)) {
+ ddi_requires.append(r);
+ }
+ }
+
+ cmGeneratedFileStream ddif(arg_ddi);
+ ddif << ddi;
+ if (!ddif) {
+ cmSystemTools::Error("-E cmake_ninja_depends failed to write " + arg_ddi);
+ return 1;
+ }
+ return 0;
+}
+
+std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
+ std::string const& arg_tdi, std::string const& arg_pp)
+{
cmFortranCompiler fc;
std::vector<std::string> includes;
{
@@ -1689,7 +1760,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
if (!reader.parse(tdif, tdio, false)) {
cmSystemTools::Error("-E cmake_ninja_depends failed to parse " +
arg_tdi + reader.getFormattedErrorMessages());
- return 1;
+ return nullptr;
}
}
@@ -1710,49 +1781,23 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
fc.SModExt = tdi_submodule_ext.asString();
}
- cmFortranSourceInfo info;
+ cmFortranSourceInfo finfo;
std::set<std::string> defines;
- cmFortranParser parser(fc, includes, defines, info);
+ cmFortranParser parser(fc, includes, defines, finfo);
if (!cmFortranParser_FilePush(&parser, arg_pp.c_str())) {
cmSystemTools::Error("-E cmake_ninja_depends failed to open " + arg_pp);
- return 1;
+ return nullptr;
}
if (cmFortran_yyparse(parser.Scanner) != 0) {
// Failed to parse the file.
- return 1;
- }
-
- {
- cmGeneratedFileStream depfile(arg_dep);
- depfile << cmSystemTools::ConvertToUnixOutputPath(arg_pp) << ":";
- for (std::string const& include : info.Includes) {
- depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include);
- }
- depfile << "\n";
+ return nullptr;
}
- Json::Value ddi(Json::objectValue);
- ddi["object"] = arg_obj;
-
- Json::Value& ddi_provides = ddi["provides"] = Json::arrayValue;
- for (std::string const& provide : info.Provides) {
- ddi_provides.append(provide);
- }
- Json::Value& ddi_requires = ddi["requires"] = Json::arrayValue;
- for (std::string const& r : info.Requires) {
- // Require modules not provided in the same source.
- if (!info.Provides.count(r)) {
- ddi_requires.append(r);
- }
- }
-
- cmGeneratedFileStream ddif(arg_ddi);
- ddif << ddi;
- if (!ddif) {
- cmSystemTools::Error("-E cmake_ninja_depends failed to write " + arg_ddi);
- return 1;
- }
- return 0;
+ auto info = cm::make_unique<cmSourceInfo>();
+ info->Provides = finfo.Provides;
+ info->Requires = finfo.Requires;
+ info->Includes = finfo.Includes;
+ return info;
}
struct cmDyndepObjectInfo
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 6a08d5c..28d4a07 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -558,7 +558,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
cmake +
" -E cmake_ninja_depends"
" --tdi=" +
- tdi +
+ tdi + " --lang=" + lang +
" --pp=$out"
" --dep=$DEP_FILE" +
(needDyndep ? " --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE" : ""));
@@ -1062,8 +1062,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
// In case compilation requires flags that are incompatible with
// preprocessing, include them here.
- std::string const postFlag =
- this->Makefile->GetSafeDefinition("CMAKE_Fortran_POSTPROCESS_FLAG");
+ std::string const postFlag = this->Makefile->GetSafeDefinition(
+ "CMAKE_" + language + "_POSTPROCESS_FLAG");
this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag);
// Move preprocessor definitions to the preprocessor build statement.
_rewrite Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful.
summaryrefslogtreecommitdiffstats
path: root/generic
Commit message (Expand)AuthorAgeFilesLines
...
* * generic/tclResult.c (Tcl_AppendResultVA):stanton1999-05-072-5/+6
* * tests/string.test:stanton1999-05-061-3/+3
* lintstanton1999-05-062-10/+10
* * doc/string.n:stanton1999-05-062-109/+386
* * doc/Utf.3:stanton1999-05-064-4/+115
* ran dos2unix on this file--Irix couldn't build Tcl because it detected strangehershey1999-05-061-1062/+1062
* lint and better documentation of the character vs. byte oriented commandsstanton1999-05-051-2/+2
* fixed memory leaksurles1999-05-051-1048/+1062
* * doc/string.n:stanton1999-05-041-7/+20
* * tests/cmdIL.test:stanton1999-05-042-71/+331
* * generic/tclParse.c (Tcl_ParseCommand): Changed to avoidstanton1999-05-041-4/+10
* * tests/binary.test:stanton1999-05-031-1/+3
* * Changed version to 8.1.1.stanton1999-04-301-3/+3
* * Merged changes from 8.1.0 branchstanton1999-04-305-23/+40
* Tcl_UtfToUpper and Tcl_UtfToTitle now works on badly formed Utf strings.hershey1999-04-301-6/+23
* fixed part of bug 1791: Tcl_UtfToUpper and Tcl_UtfToLower now work onhershey1999-04-291-8/+88
* * mac/tclMacResource.c:stanton1999-04-283-14/+14
* * generic/tclLiteral.c (TclHideLiteral): Fixed so hidden literalsstanton1999-04-281-6/+10
* merged 8.1.0 changes into mainlinestanton1999-04-241-251/+248
* * generic/tclPort.h: Added include of tcl.h since it definesstanton1999-04-231-1/+3
* * generic/tclEvent.c: lintstanton1999-04-231-2/+2
* * generic/tclInt.h:stanton1999-04-226-56/+269
* Resynced with mainline.rjohnson1999-04-2114-19/+19
* merged the parse changes between TclPro1.2 and Tcl8.1. Fixed bug in Windows ...surles1999-04-213-7/+45
* added first draft of documentation for Tcl_Access and Tcl_Stat.hershey1999-04-171-3/+3
* changes make Tcl_Access and Tcl_Stat public.hershey1999-04-1710-24/+100
* fixed bug 1811: Add TclSetPreInitScript to the stubs files.surles1999-04-163-11/+14
* merged tcl 8.1 branch back into the main trunkstanton1999-04-16