Explorar o código

Changed SublimeClang include path generation to expand to absolute paths.

Fixed an issue where compiler definitions for SublimeClang were not
written to the project file.
Morné Chamberlain %!s(int64=13) %!d(string=hai) anos
pai
achega
75b060ff20
Modificáronse 1 ficheiros con 14 adicións e 3 borrados
  1. 14 3
      Source/cmExtraSublimeTextGenerator.cxx

+ 14 - 3
Source/cmExtraSublimeTextGenerator.cxx

@@ -227,6 +227,13 @@ void cmExtraSublimeTextGenerator
   fout << "],\n";
   fout << "],\n";
   fout << "\t\t\t\"file_include_patterns\": [" <<
   fout << "\t\t\t\"file_include_patterns\": [" <<
           fileIncludePatternsStream.str() << "]\n";
           fileIncludePatternsStream.str() << "]\n";
+  fout << "\t\t},\n\t";
+  // In order for SublimeClang's path resolution to work, the directory that
+  // contains the sublime-project file must be included here. We just ensure
+  // that no files or subfolders are included
+  fout << "\t{\n\t\t\t\"path\": \"./\",\n";
+  fout << "\t\t\t\"folder_exclude_patterns\": [\"*\"],\n";
+  fout << "\t\t\t\"file_exclude_patterns\": [\"*\"]\n";
   fout << "\t\t}\n\t";
   fout << "\t\t}\n\t";
   // End of the folders section
   // End of the folders section
   fout << "]";
   fout << "]";
@@ -340,9 +347,13 @@ void cmExtraSublimeTextGenerator
     const std::string &relative = cmSystemTools::RelativePath(
     const std::string &relative = cmSystemTools::RelativePath(
                        lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
                        lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
                        includeDir.c_str());
                        includeDir.c_str());
-    fout << "\t\"-I" << relative << "\"";
+    // It appears that a relative path to the sublime-project file doesn't
+    // always work. So we use ${folder:${project_path:<project_filename>}}
+    // that SublimeClang will expand to the correct path
+    fout << "\t\"-I${folder:${project_path:" << mf->GetProjectName() <<
+            ".sublime-project}}/" << relative << "\"";
     stringSetIter++;
     stringSetIter++;
-    if (stringSetIter != includeDirs.end())
+    if ((stringSetIter != includeDirs.end()) || (!defines.empty()))
       {
       {
       fout << ",";
       fout << ",";
       }
       }
@@ -387,7 +398,7 @@ void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout,
                                     ->GetGeneratorTarget(target);
                                     ->GetGeneratorTarget(target);
       std::string cdefs = gtgt->GetCompileDefinitions();
       std::string cdefs = gtgt->GetCompileDefinitions();
 
 
-      if(cdefs.empty())
+      if(!cdefs.empty())
         {
         {
         // Expand the list.
         // Expand the list.
         std::vector<std::string> defs;
         std::vector<std::string> defs;