Commit 1b20edf5 authored by balaskoa's avatar balaskoa
Browse files

refactoring handling of makefile generating flags


Signed-off-by: default avatarbalaskoa <jeno.balasko@ericsson.com>
parent c900fa7d
......@@ -402,14 +402,7 @@ public final class Activator extends AbstractUIPlugin {
GlobalParser.getProjectSourceParser(project).analyzeAll(false);
// It is of no importance when this analysis will run, or end for that matter.
boolean generateMakefile;
try {
generateMakefile = "true".equals(project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.GENERATE_MAKEFILE_PROPERTY)));
} catch (CoreException e) {
generateMakefile = false;
}
if (generateMakefile) {
if (ProjectBuildPropertyData.useAutomaticMakefilegeneration(project)) {
TITANBuilder.markProjectForRebuild(project);
SymbolicLinkHandler.createSymlinks(project);
TITANBuilder.regenerateMakefile(project);
......
......@@ -234,20 +234,17 @@ public final class SymbolicLinkHandler {
* @return true if the refresh succeeded, false otherwise.
*/
public static boolean createSymlinks(final IResource resource) {
if (!TITANBuilder.isBuilderEnabled(resource.getProject())) {
IProject rProject = resource.getProject();
if (!TITANBuilder.isBuilderEnabled(rProject)) {
return true;
}
try {
if ("true".equals(resource.getProject().getPersistentProperty(
new QualifiedName(ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.SYMLINKLESS_BUILD_PROPERTY)))) {
return true;
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace("While checking build property", e);
if (!ProjectBuildPropertyData.useSymbolicLinks(rProject)) {
return true;
}
IPath workingDir = ProjectBasedBuilder.getProjectBasedBuilder(resource.getProject()).getWorkingDirectoryPath(true);
IPath workingDir = ProjectBasedBuilder.getProjectBasedBuilder(rProject).getWorkingDirectoryPath(true);
if (workingDir == null || !workingDir.toFile().exists()) {
return true;
......@@ -257,26 +254,20 @@ public final class SymbolicLinkHandler {
return true;
}
TITANBuilderResourceVisitor visitor = ProjectBasedBuilder.getProjectBasedBuilder(resource.getProject()).getResourceVisitor();
TITANBuilderResourceVisitor visitor = ProjectBasedBuilder.getProjectBasedBuilder(rProject).getResourceVisitor();
if (visitor.getFiles().isEmpty()) {
return true;
}
TITANJob buildJob = new TITANJob(SYMBOLIC_LINK_CREATION_PROCESS, visitor.getFiles(), workingDir.toFile(), resource.getProject());
TITANJob buildJob = new TITANJob(SYMBOLIC_LINK_CREATION_PROCESS, visitor.getFiles(), workingDir.toFile(), rProject);
buildJob.setPriority(Job.DECORATE);
buildJob.setUser(true);
buildJob.setRule(resource.getProject());
try {
final String automaticMakefileManagement = resource.getProject().getPersistentProperty(
new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.GENERATE_MAKEFILE_PROPERTY));
SymbolicLinkHandler.addSymlinkCreationCommand(visitor.getFiles(), workingDir.toOSString(), buildJob,
new HashMap<String, IFile>(), null, "true".equals(automaticMakefileManagement));
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace("while creating symlinks for project`" + resource.getProject() + "'", e);
}
buildJob.setRule(rProject);
SymbolicLinkHandler.addSymlinkCreationCommand(visitor.getFiles(), workingDir.toOSString(), buildJob,
new HashMap<String, IFile>(), null, ProjectBuildPropertyData.useAutomaticMakefilegeneration(rProject) );
buildJob.schedule();
......
......@@ -2215,16 +2215,12 @@ public final class InternalMakefileGenerator {
useRuntime2 = ResourceUtils.getBooleanPersistentProperty(project, ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.FUNCTIONTESTRUNTIME_PROPERTY);
library = MakefileCreationData.DefaultTarget.LIBRARY.toString().equals(
project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
MakefileCreationData.DEFAULT_TARGET_PROPERTY)));
usingSymbolicLinks =
!ResourceUtils.getBooleanPersistentProperty(
project, ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.GENERATE_INTERNAL_MAKEFILE_PROPERTY)
|| !ResourceUtils.getBooleanPersistentProperty(
project, ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.SYMLINKLESS_BUILD_PROPERTY);
usingSymbolicLinks = ProjectBuildPropertyData.useSymbolicLinks(project);
allProjectsUseSymbolicLinks = usingSymbolicLinks;
String temp = ResourceUtils.getPersistentProperty(project, ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.TARGET_EXECUTABLE_PROPERTY);
......
......@@ -72,11 +72,9 @@ public final class MakefileGeneratorVisitor implements IResourceVisitor {
this.makefileGenerator.addBaseDirectory(path.toOSString());
}
this.makefileGenerator.setAllProjectsUseSymbolicLinks(this.makefileGenerator.isAllProjectsUseSymbolicLinks()
&& (!ResourceUtils.getBooleanPersistentProperty(
project, ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.GENERATE_INTERNAL_MAKEFILE_PROPERTY)
|| !ResourceUtils.getBooleanPersistentProperty(
project, ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.SYMLINKLESS_BUILD_PROPERTY)));
this.makefileGenerator.setAllProjectsUseSymbolicLinks(
this.makefileGenerator.isAllProjectsUseSymbolicLinks()
&& ProjectBuildPropertyData.useSymbolicLinks(project) );
}
@Override
......
......@@ -205,22 +205,19 @@ public final class TITANDecorator extends LabelProvider implements ILabelDecorat
case IResource.ROOT:
break;
case IResource.PROJECT:
try {
final IProject resource = (IProject) element;
if (ExcludedResourceFilter.isActive() || WorkingDirectoryFilter.isActive()) {
result.append("[filtered]");
}
{
final IProject resource = (IProject) element;
if (ExcludedResourceFilter.isActive() || WorkingDirectoryFilter.isActive()) {
result.append("[filtered]");
}
if (TRUE_STRING.equals(resource.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.GENERATE_MAKEFILE_PROPERTY)))) {
result.append(OPENING_PARENTHESIS);
result.append(propertiesAsParameters(resource, false));
result.append(CLOSING_PARENTHESIS);
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
if (ProjectBuildPropertyData.useAutomaticMakefilegeneration(resource)) {
result.append(OPENING_PARENTHESIS);
result.append(propertiesAsParameters(resource, false));
result.append(CLOSING_PARENTHESIS);
}
break;
}
case IResource.FOLDER:
try {
final IFolder resource = (IFolder) element;
......
......@@ -325,4 +325,92 @@ public final class ProjectBuildPropertyData {
}
}
//************ Getting the state of makefile generating switches on project level*****
/**
* Gets if automatic makefile generation is switched on in the given project.
* @param project
* @return
*/
public static boolean useAutomaticMakefilegeneration(final IProject project) {
if( project == null) {
return false;
}
String automaticMakefileGeneration = FALSE_STRING;
try{
automaticMakefileGeneration = project.getPersistentProperty(
new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.GENERATE_MAKEFILE_PROPERTY));
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
return false; //?
}
return TRUE_STRING.equals(automaticMakefileGeneration);
}
/**
* Gets if internal makefile generation is switched on in the given project.
*
* @param project
* @return true if internal makefile generation is switched on
*/
public static boolean useInternalMakefilegeneration(final IProject project) {
if( project == null) {
return false;
}
String useInternalMakefileGeneration = FALSE_STRING;
try{
useInternalMakefileGeneration = project.getPersistentProperty(
new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.GENERATE_INTERNAL_MAKEFILE_PROPERTY));
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
return false; //?
}
return TRUE_STRING.equals(useInternalMakefileGeneration);
}
/**
* Gets if symbolic link switch is switched on in the given project.
* <p>
* Do not use this function to decide if symbolic linking shall be performed
* because this condition is necessary but not sufficient.
* Use the function useSymbolicLinks() instead of this function
* </p>
* @param project
* @return true if symlinkless build switch is set
*/
public static boolean isSymlinklessBuildSwitchedOn(final IProject project) {
if( project == null) {
return false;
}
String symlinklessBuild = FALSE_STRING;
try{
symlinklessBuild = project.getPersistentProperty(
new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.SYMLINKLESS_BUILD_PROPERTY));
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
return false; //?
}
return TRUE_STRING.equals(symlinklessBuild);
}
/**
* Gets if symbolic links shall be generated or not in the given project.
*
* @param project - the project reference
* @return false if the project reference is null, or
* automatic makefile handling and
* internal makefilegen generation and
* symlinkless build are switched on, otherwise
* true
*/
public static boolean useSymbolicLinks(final IProject project) {
return !( useAutomaticMakefilegeneration(project)
&& useInternalMakefilegeneration(project)
&& isSymlinklessBuildSwitchedOn(project) );
}
}
......@@ -464,12 +464,7 @@ public final class ProjectBuildPropertyPage extends PropertyPage {
result = false;
continue;
}
if ("true".equals(referencedProject.getPersistentProperty(new QualifiedName(
ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.GENERATE_INTERNAL_MAKEFILE_PROPERTY)))
&& "true".equals(referencedProject.getPersistentProperty(new QualifiedName(
ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.SYMLINKLESS_BUILD_PROPERTY)))) {
if ( ! ProjectBuildPropertyData.useSymbolicLinks(referencedProject) ) {
setErrorMessage("Will not be able to generate a makefile to project `" + projectResource.getName()
+ "' with the external makefile generator as project `" + referencedProject.getName()
+ "' is set to build without generating symbolic links");
......
......@@ -269,6 +269,8 @@ public class HelloWorldSample extends SampleProject {
protected void configure(final IProject project) {
final String trueString = "true";
try {
project.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.GENERATE_MAKEFILE_PROPERTY), trueString);
project.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
ProjectBuildPropertyData.GENERATE_INTERNAL_MAKEFILE_PROPERTY), trueString);
project.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment