Skip to content

Commit

Permalink
IEP-822 Eclipse 2022-12 support (#722)
Browse files Browse the repository at this point in the history
* Eclipse 2022-12 support

* add CCorePlugin.PLUGIN_ID + ".ELF"
  • Loading branch information
sigmaaa authored Apr 4, 2023
1 parent f06f7fd commit fb441d0
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
package com.espressif.idf.core.build;

import java.nio.file.Path;
import java.util.List;

import org.eclipse.cdt.build.gcc.core.GCCToolChain;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.build.IToolChainProvider;


/**
* @author Kondal Kolipaka <[email protected]>
*
Expand All @@ -25,7 +25,13 @@ public AbstractESPToolchain(IToolChainProvider provider, Path pathToToolChain, S
setProperty(ATTR_ARCH, ARCH);
}

@Override
// API after changes in CDT 10.5.0
public List<String> getBinaryParserIds()
{
return List.<String>of(CCorePlugin.PLUGIN_ID + ".ELF"); //$NON-NLS-1$
}

// API before CDT 10.5.0
public String getBinaryParserId()
{
return CCorePlugin.PLUGIN_ID + ".ELF"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.espressif.idf.core.build;

import java.nio.file.Path;
import java.util.List;

import org.eclipse.cdt.build.gcc.core.ClangToolChain;
import org.eclipse.cdt.core.CCorePlugin;
Expand All @@ -21,7 +22,13 @@ public ESP32ClangToolChain(IToolChainProvider provider, Path pathToToolChain)
setProperty("ATTR_ID", ESP32ClangCmakeToolChainProvider.TOOLCHAIN_NAME); //$NON-NLS-1$
}

@Override
// API after Changes in CDT 10.5.0
public List<String> getBinaryParserIds()
{
return List.<String>of(CCorePlugin.PLUGIN_ID + ".ELF"); //$NON-NLS-1$
}

// API before CDT 10.5.0
public String getBinaryParserId()
{
return CCorePlugin.PLUGIN_ID + ".ELF"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
*******************************************************************************/
package com.espressif.idf.core.build;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Reader;
import java.net.URI;
import java.nio.file.FileVisitResult;
Expand Down Expand Up @@ -46,6 +51,7 @@
import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.IConsoleParser2;
import org.eclipse.cdt.core.build.CBuildConfiguration;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.envvar.EnvironmentVariable;
Expand Down Expand Up @@ -419,6 +425,145 @@ private void runCmakeBuildCommand(IConsole console, IProgressMonitor monitor, IP
}
}

/**
* //API after changes in CDT 10.5.0
*/
protected int watchProcess(Process process, IConsole console) throws CoreException
{
Thread t1 = new ReaderThread(process.getInputStream(), console.getOutputStream());
t1.start();
Thread t2 = new ReaderThread(process.getErrorStream(), console.getErrorStream());
t2.start();
try
{
int rc = process.waitFor();
// Allow reader threads the chance to process all output to console
while (t1.isAlive())
{
Thread.sleep(100);
}
while (t2.isAlive())
{
Thread.sleep(100);
}
return rc;
}
catch (InterruptedException e)
{
CCorePlugin.log(e);
return -1;
}
}

/**
* @since 6.4
*/
protected int watchProcess(Process process, IConsoleParser[] consoleParsers) throws CoreException
{
Thread t1 = new ReaderThread(this, process.getInputStream(), consoleParsers);
t1.start();
Thread t2 = new ReaderThread(this, process.getErrorStream(), consoleParsers);
t2.start();
try
{
int rc = process.waitFor();
// Allow reader threads the chance to process all output to console
while (t1.isAlive())
{
Thread.sleep(100);
}
while (t2.isAlive())
{
Thread.sleep(100);
}
return rc;
}
catch (InterruptedException e)
{
CCorePlugin.log(e);
return -1;
}
}

private static class ReaderThread extends Thread
{
CBuildConfiguration config;
private final BufferedReader in;
private final IConsoleParser[] consoleParsers;
private final PrintStream out;

public ReaderThread(CBuildConfiguration config, InputStream in, IConsoleParser[] consoleParsers)
{
this.config = config;
this.in = new BufferedReader(new InputStreamReader(in));
this.out = null;
this.consoleParsers = consoleParsers;
}

public ReaderThread(InputStream in, OutputStream out)
{
this.in = new BufferedReader(new InputStreamReader(in));
this.out = new PrintStream(out);
this.consoleParsers = null;
this.config = null;
}

@Override
public void run()
{
List<Job> jobList = new ArrayList<>();
try
{
for (String line = in.readLine(); line != null; line = in.readLine())
{
if (consoleParsers != null)
{
for (IConsoleParser consoleParser : consoleParsers)
{
// Synchronize to avoid interleaving of lines
synchronized (consoleParser)
{
// if we have an IConsoleParser2, use the processLine method that
// takes a job list (Container Build support)
if (consoleParser instanceof IConsoleParser2)
{
((IConsoleParser2) consoleParser).processLine(line, jobList);
}
else
{
consoleParser.processLine(line);
}
}
}
}
if (out != null)
{
out.println(line);
}
}
for (Job j : jobList)
{
try
{
j.join();
}
catch (InterruptedException e)
{
// ignore
}
}
if (config != null)
{
config.shutdown();
}
}
catch (IOException e)
{
CCorePlugin.log(e);
}
}
}

private void runCmakeCommand(IConsole console, IProgressMonitor monitor, IProject project, String generator,
ConsoleOutputStream infoStream, Path buildDir) throws CoreException, IOException, CmakeBuildException
{
Expand Down

0 comments on commit fb441d0

Please sign in to comment.