From 4ce1f1ca16b0013298c51a5311528ae21cdfd645 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Wed, 8 Nov 2017 12:49:00 -0500 Subject: Add Makefile Projects to collection of core build project types. Reuses the old makeNature. Reuses the StandardBuildConfiguration. Generates a pretty simple project for now. Also handles the case where you don't want to generate anything, just create an empty or on an existing source tree. Change-Id: I2f3cddc85d55792a2c537e37d4bc236a3073d930 --- .../eclipse/cdt/build/gcc/core/GCCToolChain.java | 38 +- .../cdt/cmake/core/CMakeProjectGenerator.java | 9 +- .../icons/cdt_logo_48.png | Bin 0 -> 3654 bytes build/org.eclipse.cdt.core.autotools.ui/plugin.xml | 1 + .../org.eclipse.cdt.make.core/META-INF/MANIFEST.MF | 6 +- build/org.eclipse.cdt.make.core/plugin.xml | 8 + .../org/eclipse/cdt/make/core/MakeCorePlugin.java | 11 + .../cdt/make/core/MakefileProjectGenerator.java | 89 ++++ .../core/MakefileBuildConfigurationProvider.java | 66 +++ .../templates/simple/Makefile | 12 + .../templates/simple/main.cpp | 4 + .../templates/simple/manifest.xml | 7 + build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF | 4 +- .../org.eclipse.cdt.make.ui/icons/cdt_logo_48.png | Bin 0 -> 3654 bytes build/org.eclipse.cdt.make.ui/plugin.xml | 22 + .../ui/wizards/NewMakefileProjectWizard.java | 78 +++ .../cdt/core/build/CBuildConfiguration.java | 61 ++- .../cdt/core/build/StandardBuildConfiguration.java | 8 +- .../eclipse/cdt/internal/core/build/Messages.java | 1 + .../cdt/internal/core/build/ToolChainManager.java | 24 +- .../cdt/internal/core/build/messages.properties | 1 + .../debug.product | 576 +++++++++++---------- 22 files changed, 672 insertions(+), 354 deletions(-) create mode 100644 build/org.eclipse.cdt.core.autotools.ui/icons/cdt_logo_48.png create mode 100644 build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileProjectGenerator.java create mode 100644 build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakefileBuildConfigurationProvider.java create mode 100644 build/org.eclipse.cdt.make.core/templates/simple/Makefile create mode 100644 build/org.eclipse.cdt.make.core/templates/simple/main.cpp create mode 100644 build/org.eclipse.cdt.make.core/templates/simple/manifest.xml create mode 100644 build/org.eclipse.cdt.make.ui/icons/cdt_logo_48.png create mode 100644 build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/NewMakefileProjectWizard.java diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java index 1b61d1a7b14..c922c4e32c2 100644 --- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java @@ -288,11 +288,11 @@ public class GCCToolChain extends PlatformObject implements IToolChain { // Change source file to a tmp file (needs to be empty) Path tmpFile = null; for (int i = 1; i < commandLine.size(); ++i) { - if (!commandLine.get(i).startsWith("-")) { //$NON-NLS-1$ - // TODO optimize by dealing with multi arg options like -o + String arg = commandLine.get(i); + if (!arg.startsWith("-")) { //$NON-NLS-1$ Path filePath; try { - filePath = buildDirectory.resolve(commandLine.get(i)); + filePath = buildDirectory.resolve(commandLine.get(i)).normalize(); } catch (InvalidPathException e) { continue; } @@ -312,6 +312,10 @@ public class GCCToolChain extends PlatformObject implements IToolChain { tmpFile = Files.createTempFile(parentPath, ".sc", extension); //$NON-NLS-1$ commandLine.set(i, tmpFile.toString()); } + } else if (arg.equals("-o")) { //$NON-NLS-1$ + // skip over the next arg + // TODO handle other args like this + i++; } } if (tmpFile == null) { @@ -486,7 +490,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain { if (cCommand.contains("gcc")) { //$NON-NLS-1$ cppCommand = cCommand.replace("gcc", "g++"); //$NON-NLS-1$ //$NON-NLS-2$ // Also recognize c++ as an alias for g++ - commands = new String[] { cCommand, cppCommand, cCommand.replace("gcc", "c++") }; //$NON-NLS-1$ //$NON-NLS-2$ + commands = new String[] { cCommand, cppCommand, cCommand.replace("gcc", "c++"), "cc", "c++" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } else if (cCommand.contains("clang")) { //$NON-NLS-1$ cppCommand = cCommand.replace("clang", "clang++"); //$NON-NLS-1$ //$NON-NLS-2$ commands = new String[] { cCommand, cppCommand }; @@ -529,21 +533,21 @@ public class GCCToolChain extends PlatformObject implements IToolChain { // ran into an option, we're done. break; } - Path srcPath = Paths.get(arg); - URI uri; - if (srcPath.isAbsolute()) { - uri = srcPath.toUri(); - } else { - try { - uri = buildDirectoryURI.resolve(arg); - } catch (IllegalArgumentException e) { - // Bad URI - continue; + try { + Path srcPath = Paths.get(arg); + URI uri; + if (srcPath.isAbsolute()) { + uri = srcPath.toUri(); + } else { + uri = Paths.get(buildDirectoryURI).resolve(srcPath).toUri().normalize(); } - } - for (IFile resource : root.findFilesForLocationURI(uri)) { - resources.add(resource); + for (IFile resource : root.findFilesForLocationURI(uri)) { + resources.add(resource); + } + } catch (IllegalArgumentException e) { + // Bad URI + continue; } } diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java index de95869895d..45de6077e6a 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java @@ -58,7 +58,9 @@ public class CMakeProjectGenerator extends FMProjectGenerator { List entries = new ArrayList<>(); IProject project = getProject(); - // Create the source folders + // Create the source and output folders + IFolder buildFolder = getProject().getFolder("build"); //$NON-NLS-1$ + TemplateManifest manifest = getManifest(); if (manifest != null) { List srcRoots = getManifest().getSrcRoots(); @@ -69,14 +71,15 @@ public class CMakeProjectGenerator extends FMProjectGenerator { sourceFolder.create(true, true, monitor); } - entries.add(CoreModel.newSourceEntry(sourceFolder.getFullPath())); + entries.add(CoreModel.newSourceEntry(sourceFolder.getFullPath(), + new IPath[] { buildFolder.getFullPath() })); } } else { entries.add(CoreModel.newSourceEntry(getProject().getFullPath())); } } - entries.add(CoreModel.newOutputEntry(getProject().getFolder("build").getFullPath(), //$NON-NLS-1$ + entries.add(CoreModel.newOutputEntry(buildFolder.getFullPath(), // $NON-NLS-1$ new IPath[] { new Path("**/CMakeFiles/**") })); //$NON-NLS-1$ CoreModel.getDefault().create(project).setRawPathEntries(entries.toArray(new IPathEntry[entries.size()]), monitor); diff --git a/build/org.eclipse.cdt.core.autotools.ui/icons/cdt_logo_48.png b/build/org.eclipse.cdt.core.autotools.ui/icons/cdt_logo_48.png new file mode 100644 index 00000000000..4f2aecee517 Binary files /dev/null and b/build/org.eclipse.cdt.core.autotools.ui/icons/cdt_logo_48.png differ diff --git a/build/org.eclipse.cdt.core.autotools.ui/plugin.xml b/build/org.eclipse.cdt.core.autotools.ui/plugin.xml index e4abf4678a7..0437944c565 100644 --- a/build/org.eclipse.cdt.core.autotools.ui/plugin.xml +++ b/build/org.eclipse.cdt.core.autotools.ui/plugin.xml @@ -4,6 +4,7 @@