Community
Participate
Working Groups
If you create a sample project with a single directory linked to an existing directory containing source files, it will not build. The makefile does not realize that the directory is linked, so therefore the GnuMakefileGenerator attempts to locate the resources using relative paths. The fix is actually very simple. In the addRule(...) method of the GnuMakefileGenerator.java file, you just need to see if the resource's actual location is contained within the project's actual location. Here is a snippet from my code: String buildFlags = null; String resourceName = getFileName(resource); String inputExtension = resource.getFileExtension(); IPath resourceLocation = resource.getLocation(); String cmd = info.getToolForSource(inputExtension); String outputExtension = info.getOutputExtension (inputExtension); String outflag = null; String outputPrefix = null; String projectLocation = project.getLocation().toString(); String resourcePath = null; String buildRule = null; /** * We need to check if the current resource is LINKED, because * the default CDT doesn't handle this properly. If it IS linked, * then we must get the actual location of the resource, rather * than the relative path. */ if(!resourceLocation.toString().startsWith(projectLocation)) { // it IS linked, so use the actual location resourcePath = resourceLocation.toString(); buildRule = relativePath + resourceName + DOT + outputExtension + COLON + WHITESPACE + resourcePath; } else { // use the relative path resourcePath = relativePath; buildRule = relativePath + resourceName + DOT + outputExtension + COLON + WHITESPACE + ROOT + SEPARATOR + relativePath + resourceName + DOT + inputExtension; } Thanks!
Will test the fix and if it works I will add it to the default makefile generator
Created attachment 13924 [details] proposed patch This patch is largely the same as the one posted by the submitter, however, the submitter's patch did not take into account the relative path of the object file in the project. Currently there is a restriction (for unknown reasons) that linked files can only be in the project root directory, but I am hoping that this restriction will disappear, and hence it would be good to allow for this case.
Applied the patch to 2.0.1 and head. The switch to absolute paths is probably the only way to go until we have a strategy in place to define and use path variables. There are two usability probalems that will not be addressed with thispatch. Despite the fact that the resource "looks" like it is part of the worksapce, the user will have to set the proper includes path in the build settings or the compielr will failt o find it. Second, error markers are not cleared if the linked resource belongs to another, open project in the workspace.
Created attachment 14445 [details] NPE in generated makefile builder These log entries are added when I build a project containing a linked directory to a mixed source/object directory.
Found out that the NPEs would also happen if the object files were in a non-linked directory as well, so now we can mark this fix for linked dir as verified. I verified in CDT 2.0.1 build 200408271356.
Marking it verified as per Tany's comment