1
/*******************************************************************************
2
* Copyright (c) 2006, 2007 QNX Software Systems and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* QNX Software Systems - Initial implementation
10
* Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
11
*******************************************************************************/
12
package org.eclipse.cdt.make.core;
16
import org.eclipse.core.resources.IContainer;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
22
public class MakeBuilderUtil {
24
public static IPath getBuildDirectory(IProject project, IPath subPath, String builderID) {
25
IPath rootPath = getBuildDirectory(project, builderID);
26
return rootPath.append(subPath);
29
public static IPath getBuildDirectory(IProject project, String builderID) {
30
IMakeBuilderInfo info;
32
info = MakeCorePlugin.createBuildInfo(project, builderID);
33
} catch (CoreException e) {
34
return project.getLocation();
36
return getBuildDirectory(project, info);
39
public static IPath getBuildDirectory(IProject project, IMakeBuilderInfo info) {
40
IPath buildDirectory = info.getBuildLocation();
41
if (!buildDirectory.isEmpty()) {
42
IResource res = project.getParent().findMember(buildDirectory);
43
if (res instanceof IContainer && res.exists()) {
44
buildDirectory = res.getLocation();
47
buildDirectory = project.getLocation();
49
return buildDirectory;
53
* Return the URI of the build directory for a prject and IMakeBuilderInfo
56
* @return URI of the build directory, or the Project's URI if one couldn't be found
59
public static URI getBuildDirectoryURI(IProject project, IMakeBuilderInfo info) {
60
IPath buildDirectory = info.getBuildLocation();
61
if (!buildDirectory.isEmpty()) {
62
IResource res = project.getParent().findMember(buildDirectory);
63
if (res instanceof IContainer && res.exists()) {
64
return res.getLocationURI();
67
return project.getLocationURI();