Skip to content

Commit

Permalink
fixed: passing double quoted string (in the middle of it) as an inclu…
Browse files Browse the repository at this point in the history
…de path, caused unwanted paths to be generated in compile_flags.txt file

    see discussion here: #1845 (comment)
  • Loading branch information
eranif committed Feb 12, 2022
1 parent 4b82fa4 commit 68eb6d3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
15 changes: 12 additions & 3 deletions CodeLite/compiler_command_line_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,18 @@ CompilerCommandLineParser::CompilerCommandLineParser(const wxString& cmdline, co
m_includesWithPrefix.Add(wxString() << "-I" << include_path);
++i;

} else if(opt.StartsWith("-I", &rest) || opt.StartsWith("/I", &rest)) {
m_includes.Add(rest);
m_includesWithPrefix.Add(opt);
} else if(opt.StartsWith("-I", &rest)) {
rest.Replace("\"", wxEmptyString);
wxFileName path(rest, wxEmptyString);
m_includes.Add(path.GetPath());
m_includesWithPrefix.Add("-I" + path.GetPath());

} else if(opt.StartsWith("/I", &rest)) {
rest.Replace("\"", wxEmptyString);
wxFileName path(rest, wxEmptyString);
m_includes.Add(path.GetPath());
m_includesWithPrefix.Add("/I" + path.GetPath());

}

else if(opt.StartsWith("-D", &rest) || opt.StartsWith("/D", &rest)) {
Expand Down
11 changes: 7 additions & 4 deletions Plugin/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,8 +1363,10 @@ void Project::SetExcludeConfigsForFile(const wxString& filename, const wxStringS
SaveXmlFile();
}

static void ProcessIncludes(const wxArrayString& paths, const wxString& wd, wxStringSet_t& res,
std::vector<wxString>& pathsVec)
namespace
{
void ProcessIncludes(const wxArrayString& paths, const wxString& wd, wxStringSet_t& res,
std::vector<wxString>& pathsVec)
{
// Convert the include paths to full path, prepend -I and add them
for(const wxString& path : paths) {
Expand All @@ -1382,7 +1384,7 @@ static void ProcessIncludes(const wxArrayString& paths, const wxString& wd, wxSt
}
}

static void ProcessMacros(const wxArrayString& macros, wxStringSet_t& res)
void ProcessMacros(const wxArrayString& macros, wxStringSet_t& res)
{
for(const wxString& macro : macros) {
wxString tmpMacro = macro;
Expand All @@ -1399,7 +1401,7 @@ static void ProcessMacros(const wxArrayString& macros, wxStringSet_t& res)
}
}

static wxString GetExtraFlags(CompilerPtr compiler)
wxString GetExtraFlags(CompilerPtr compiler)
{
wxString extra_flags;
if(compiler->HasMetadata()) {
Expand All @@ -1408,6 +1410,7 @@ static wxString GetExtraFlags(CompilerPtr compiler)
}
return extra_flags;
}
} // namespace

wxString Project::GetCompileLineForCXXFile(const wxStringMap_t& compilersGlobalPaths, BuildConfigPtr buildConf,
const wxString& filenamePlaceholder, size_t flags)
Expand Down
17 changes: 10 additions & 7 deletions codelite_make/codelite_make.project
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
<File Name="cl_make_generator_app.h"/>
<File Name="cl_make_generator_app.cpp"/>
</VirtualDirectory>
<Dependencies Name="Debug_Linux"/>
<Dependencies Name="Release"/>
<Dependencies Name="Win_x64_Release"/>
<Dependencies Name="Win_x86_Release"/>
<Dependencies Name="Debug">
<Project Name="libCodeLite"/>
<Project Name="plugin_sdk"/>
</Dependencies>
<Settings Type="Executable">
<GlobalSettings>
<Compiler Options="" C_Options="" Assembler="">
Expand All @@ -57,7 +65,7 @@
<Library Value="libwxsqlite3ud.dll"/>
</Linker>
<ResourceCompiler Options="$(shell wx-config --rcflags)" Required="no"/>
<General OutputFile="codelite-make" IntermediateDirectory="" Command="$(WorkspacePath)/build-$(WorkspaceConfiguration)/bin/$(OutputFile)" CommandArguments="--workspace=C:\src\codelite\CodeLiteIDE.workspace --json --verbose --config=Win_x64_Release" UseSeparateDebugArgs="yes" DebugArguments="--config=Release --workspace=C:\Users\Eran\Documents\HelloWorld\HelloWorld.workspace --compile-flags --verbose --settings=C:\Users\Eran\AppData\Roaming\codelite-dbg\config\build_settings.xml" WorkingDirectory="C:/src/codelite/Runtime" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<General OutputFile="codelite-make" IntermediateDirectory="" Command="$(WorkspacePath)/build-$(WorkspaceConfiguration)/bin/$(OutputFile)" CommandArguments="--workspace=C:\src\codelite\CodeLiteIDE.workspace --verbose --config=Win_x64_Release" UseSeparateDebugArgs="yes" DebugArguments="--workspace=C:\Users\eran\Documents\TestCTagsd\TestCTagsd.workspace --compile-flags --config=Debug --settings=C:\Users\Eran\AppData\Roaming\CodeLite-Debug\config\build_settings.xml" WorkingDirectory="C:/src/codelite/Runtime" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<BuildSystem Name="CodeLite Makefile Generator"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[PATH=$(WorkspacePath)\..\lib\gcc_lib;$PATH]]>
Expand Down Expand Up @@ -199,7 +207,7 @@
<Library Value="libwxsqlite3u.dll"/>
</Linker>
<ResourceCompiler Options="$(shell wx-config --rcflags)" Required="no"/>
<General OutputFile="codelite-make" IntermediateDirectory="" Command="$(WorkspacePath)/build-$(WorkspaceConfiguration)/bin/$(OutputFile)" CommandArguments="" UseSeparateDebugArgs="yes" DebugArguments="--workspace=/home/eran/Documents/HelloWorld/HelloWorld.workspace --config=Debug --json --versbose" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<General OutputFile="codelite-make" IntermediateDirectory="" Command="$(WorkspacePath)/build-$(WorkspaceConfiguration)/bin/$(OutputFile)" CommandArguments="" UseSeparateDebugArgs="yes" DebugArguments="--workspace=C:\\Users\\eran\\Documents\\TestCTagsd\\TestCTagsd.workspace --compile-flags --config=Debug --settings=C:\\Users\\Eran\\AppData\\Roaming\\CodeLite-Debug\\config\\build_settings.xml" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<BuildSystem Name="CodeLite Makefile Generator"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[]]>
Expand Down Expand Up @@ -285,9 +293,4 @@
</Completion>
</Configuration>
</Settings>
<Dependencies Name="Debug"/>
<Dependencies Name="Debug_Linux"/>
<Dependencies Name="Release"/>
<Dependencies Name="Win_x64_Release"/>
<Dependencies Name="Win_x86_Release"/>
</CodeLite_Project>

0 comments on commit 68eb6d3

Please sign in to comment.