diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath b/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath index 14d41daf60e..f72c49cfe53 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath @@ -1,24 +1,8 @@ - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml index e31ef0b4db0..2c5b3e31cc4 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml @@ -25,6 +25,9 @@ id="buildTest" name="Tools for Build Test" point="org.eclipse.cdt.managedbuilder.core.ManagedBuildInfo"> + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/copyandDeploy/copyandDeploy.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/copyandDeploy/copyandDeploy.zip new file mode 100644 index 00000000000..2a2d6585b20 Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/copyandDeploy/copyandDeploy.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/makefile b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/makefile new file mode 100644 index 00000000000..3f2c7ba6d61 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/makefile @@ -0,0 +1,43 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +ROOT := .. + +-include $(ROOT)/makefile.init + +RM := rm -rf + +# All of the sources participating in the build are defined here +-include sources.mk +-include $(SUBDIRS:%=%/subdir.mk) +-include objects.mk +ifneq ($(strip $(DEPS)),) +-include $(DEPS) +endif + +-include $(ROOT)/makefile.defs + +# Add inputs and outputs from these tool invocations to the build variables + +# All Target +all: lib.a + +# Tool invocations +lib.a: $(OBJS) $(USER_OBJS) + @echo 'Building target: $@' + @echo 'Invoking: MBS30.archiver.gnu' + @echo ar -r lib.a $(OBJS) $(USER_OBJS) $(LIBS) + @ar -r lib.a $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Finished building target: $@' + @echo ' ' + +# Other Targets +clean: + -$(RM) $(OBJS)$(ARCHIVES)$(DEPS) lib.a + -@echo ' ' + +.PHONY: all clean dependents +.SECONDARY: + +-include $(ROOT)/makefile.targets diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/objects.mk b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/objects.mk new file mode 100644 index 00000000000..eae6a31b65d --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/objects.mk @@ -0,0 +1,7 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +LIBS := + +USER_OBJS := \ No newline at end of file diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/sources.mk b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/sources.mk new file mode 100644 index 00000000000..0a4b7d18d1d --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/sources.mk @@ -0,0 +1,14 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +C_SRCS := +O_SRCS := +OBJS := +ARCHIVES := +DEPS := + +# Every subdirectory with source files must be described here +SUBDIRS := \ +. \ + diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/subdir.mk b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/subdir.mk new file mode 100644 index 00000000000..ed487cec9c7 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/subdir.mk @@ -0,0 +1,34 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +$(ROOT)/f1.c \ +$(ROOT)/f2.c + +OBJS += \ +${addprefix ./, \ +f1.o \ +f2.o \ +} + +DEPS += \ +${addprefix ./, \ +f1.d \ +f2.d \ +} + + +# Each subdirectory must supply rules for building sources it contributes +%.o: $(ROOT)/%.c + @echo 'Building file: $<' + @echo 'Invoking: MBS30.compiler.gnu.c' + @echo gcc -O0 -g3 -Wall -c -fmessage-length=0 -o$@ $< + @gcc -O0 -g3 -Wall -c -fmessage-length=0 -o$@ $< && \ + echo -n $(@:%.o=%.d) $(dir $@) > $(@:%.o=%.d) && \ + gcc -MM -MG -P -w -O0 -g3 -Wall -c -fmessage-length=0 $< >> $(@:%.o=%.d) + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/f1.c b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/f1.c new file mode 100644 index 00000000000..5e77893b8a6 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/f1.c @@ -0,0 +1,8 @@ +#include +#include "test_ar.h" + +void f1_ar() +{ + printf ( "Hello from f1_ar.\n" ) ; + return ; +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/f2.c b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/f2.c new file mode 100644 index 00000000000..56e2c730d4d --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/f2.c @@ -0,0 +1,8 @@ +#include +#include "test_ar.h" + +void f2_ar() +{ + printf ( "Hello from f2_ar.\n" ) ; + return ; +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/test_ar.h b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/test_ar.h new file mode 100644 index 00000000000..55e38f0d5ac --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/test_ar.h @@ -0,0 +1,2 @@ +void f1_ar() ; +void f2_ar() ; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/f1.c b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/f1.c new file mode 100644 index 00000000000..5e77893b8a6 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/f1.c @@ -0,0 +1,8 @@ +#include +#include "test_ar.h" + +void f1_ar() +{ + printf ( "Hello from f1_ar.\n" ) ; + return ; +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/f2.c b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/f2.c new file mode 100644 index 00000000000..56e2c730d4d --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/f2.c @@ -0,0 +1,8 @@ +#include +#include "test_ar.h" + +void f2_ar() +{ + printf ( "Hello from f2_ar.\n" ) ; + return ; +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/linkedLib.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/linkedLib.zip new file mode 100644 index 00000000000..6008541b4aa Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/linkedLib.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/test_ar.h b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/test_ar.h new file mode 100644 index 00000000000..55e38f0d5ac --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedLib/test_ar.h @@ -0,0 +1,2 @@ +void f1_ar() ; +void f2_ar() ; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/multiResConfig/multiResConfig.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/multiResConfig/multiResConfig.zip new file mode 100644 index 00000000000..4b45304748a Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/multiResConfig/multiResConfig.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/singleFileExe/singleFileExe.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/singleFileExe/singleFileExe.zip new file mode 100644 index 00000000000..92c6cc6d57d Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/singleFileExe/singleFileExe.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/twoFileSO/twoFileSO.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/twoFileSO/twoFileSO.zip new file mode 100644 index 00000000000..9f868767eab Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/twoFileSO/twoFileSO.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java index cf40dbf8c39..4eda3b2743d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java @@ -32,7 +32,6 @@ import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.resources.IWorkspaceRoot; @@ -244,10 +243,7 @@ public class ManagedBuildTestHelper { static public StringBuffer readContentsStripLineEnds(IProject project, IPath path) { StringBuffer buff = new StringBuffer(); - IFile file = project.getFile(path); - IWorkspaceRoot root = project.getWorkspace().getRoot(); - IPath fullPath = root.getLocation(); - fullPath = fullPath.append(file.getFullPath()); + IPath fullPath = project.getLocation().append(path); try { FileReader input = null; try { @@ -255,7 +251,7 @@ public class ManagedBuildTestHelper { } catch (Exception e) { Assert.fail("File " + fullPath.toString() + " could not be read."); } - //InputStream input = file.getContents(true); + //InputStream input = file.getContents(true); // A different way to read the file... int c; do { c = input.read(); @@ -266,7 +262,7 @@ public class ManagedBuildTestHelper { } while (c != -1); input.close(); } catch (Exception e) { - Assert.fail("File " + file.toString() + " could not be read."); + Assert.fail("File " + fullPath.toString() + " could not be read."); } return buff; } @@ -362,13 +358,15 @@ public class ManagedBuildTestHelper { } static private void deleteDirectory(File dir) { + boolean b; File[] toDelete = dir.listFiles(); for (int i=0; i 0) { + if (i == 0) { + String configName = info.getDefaultConfiguration().getName(); + IPath buildDir = Path.fromOSString(configName); + ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files); + } + } + } + } + + for(int i = 0; i < projects.length; i++) + ManagedBuildTestHelper.removeProject(projects[i].getName()); + } + + private void createPathVariable(IPath tmpDir) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + workspace = ResourcesPlugin.getWorkspace(); + IPathVariableManager pathMan = workspace.getPathVariableManager(); + String name = MBS_TEMP_DIR; + try { + if (pathMan.validateName(name).isOK() && pathMan.validateValue(tmpDir).isOK()) { + pathMan.setValue(name, tmpDir); + assertTrue(pathMan.isDefined(name)); + } else { + fail("could not create the path variable " + name); + } + } catch (Exception e) {fail("could not create the path variable " + name);} + } + + private void createFileLink(IProject project, IPath tmpDir, String linkName, String fileName) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + String name = MBS_TEMP_DIR; + if (!pathVariableCreated) { + createPathVariable(tmpDir); + pathVariableCreated = true; + } + + try { + // Now we can create a linked resource relative to the defined path variable: + IFile linkF1 = project.getFile(linkName); + IPath location = new Path("MBSTemp/" + fileName); + if (workspace.validateLinkLocation(linkF1, location).isOK()) { + linkF1.createLink(location, IResource.NONE, null); + } else { + fail("could not create the link to " + name); + } + } catch (Exception e) {fail("could not create the link to " + name);} + } + + /* (non-Javadoc) + * tests 3.0 style tool integration for a single file executable + */ + public void test30SingleFileExe(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk")}; + IProject[] projects = createProjects("singleFileExe", null, null, true); + buildProjects(projects, makefiles); + } + + /* (non-Javadoc) + * tests 3.0 style tool integration for a two file SO + */ + public void test30TwoFileSO(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk")}; + IProject[] projects = createProjects("twoFileSO", null, null, true); + buildProjects(projects, makefiles); + } + + /* (non-Javadoc) + * tests 3.0 style tool integration for multiple source files & a resource configuration + */ + public void test30MultiResConfig(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk"), + Path.fromOSString("source1/subdir.mk"), + Path.fromOSString("source2/subdir.mk"), + Path.fromOSString("source2/source21/subdir.mk")}; + IProject[] projects = createProjects("multiResConfig", null, null, true); + buildProjects(projects, makefiles); + } + + /* (non-Javadoc) + * tests 3.0 style tool integration for linked files + */ + public void test30LinkedLib(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + //Path.fromOSString("subdir.mk") // Can't compare this yet since it contains absolute paths! + Path.fromOSString("sources.mk")}; + IPath[] linkedFiles = { + Path.fromOSString("f1.c"), + Path.fromOSString("f2.c"), + Path.fromOSString("test_ar.h")}; + File srcDirFile = CTestPlugin.getFileInPlugin(new Path("resources/test30Projects/linkedLib/")); + IPath srcDir = Path.fromOSString(srcDirFile.toString()); + IPath tmpSubDir = Path.fromOSString("CDTMBSTest"); + IPath tmpDir = ManagedBuildTestHelper.copyFilesToTempDir(srcDir, tmpSubDir, linkedFiles); + try { + IProject[] projects = createProjects("linkedLib", null, "cdt.managedbuild.target.gnu30.lib", true); + // There should be only one project. Add our linked files to it. + IProject project = projects[0]; + createFileLink(project, tmpDir, "f1.c", "f1.c"); + createFileLink(project, tmpDir, "f2link.c", "f2.c"); + createFileLink(project, tmpDir, "test_ar.h", "test_ar.h"); + // Build the project + buildProjects(projects, makefiles); + } finally {ManagedBuildTestHelper.deleteTempDir(tmpSubDir, linkedFiles);} + } + + /* (non-Javadoc) + * tests 3.0 style tool integration for a linked folder + */ + public void test30LinkedFolder(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("subdir.mk"), + Path.fromOSString("sources.mk")}; + IPath[] linkedFiles = { + Path.fromOSString("f1.c"), + Path.fromOSString("f2.c"), + Path.fromOSString("test_ar.h"), + Path.fromOSString("Benchmarks/makefile"), + Path.fromOSString("Benchmarks/objects.mk"), + Path.fromOSString("Benchmarks/subdir.mk"), + Path.fromOSString("Benchmarks/sources.mk")}; + File srcDirFile = CTestPlugin.getFileInPlugin(new Path("resources/test30Projects/linkedFolder/")); + IPath srcDir = Path.fromOSString(srcDirFile.toString()); + IPath tmpSubDir = Path.fromOSString("CDTMBSTest"); + IPath tmpDir = ManagedBuildTestHelper.copyFilesToTempDir(srcDir, tmpSubDir, linkedFiles); + if (!pathVariableCreated) { + createPathVariable(tmpDir); + pathVariableCreated = true; + } + try { + IPath location = Path.fromOSString(MBS_TEMP_DIR); + IProject[] projects = createProjects("linkedFolder", location, "cdt.managedbuild.target.gnu30.lib", false); + // Build the project + buildProjects(projects, makefiles); + } finally {ManagedBuildTestHelper.deleteTempDir(tmpSubDir, linkedFiles);} + } + + /* (non-Javadoc) + * tests 3.0 style tool integration with pre and post process steps added to typical compile & link + */ + public void test30CopyandDeploy(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk"), + Path.fromOSString("Functions/subdir.mk")}; + IProject[] projects = createProjects("copyandDeploy", null, null, true); + buildProjects(projects, makefiles); + } +}