Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8b4ceeddfcf8a9d0a6385380e24fb0a595556333 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*******************************************************************************
 * Copyright (c) 2000, 2016 QNX Software Systems and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     QNX Software Systems - Initial API and implementation
 *     Red Hat Inc. - modified to be If class
 *******************************************************************************/
package org.eclipse.cdt.internal.autotools.ui.editors.automake;

import java.io.File;

import org.eclipse.cdt.make.core.makefile.ICommand;

public class If extends Conditional implements IAutomakeConditional, ICommand {
    private static final String EMPTY = ""; //$NON-NLS-1$
    private Rule rules[] = null;
    
	public If(Directive parent, Rule[] rules, String var) {
		super(parent, var, EMPTY, EMPTY);
		if (rules != null) {
			this.rules = new Rule[rules.length];
			System.arraycopy(rules, 0, this.rules, 0, rules.length);
		}
	}

	@Override
	public Rule[] getRules() {
		if (rules != null)
			return rules.clone();
		return null;
	}
	
	@Override
	public void setRules(Rule[] rules) {
		if (rules != null)
			this.rules = rules.clone();
		else
			this.rules = rules;
	}
	
	@Override
	public boolean isIf() {
		return true;
	}

	@Override
	public boolean isAutomake() {
		return true;
	}
	
	@Override
	public void setAutomake(boolean value) {
		// ignore value
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder(GNUMakefileConstants.CONDITIONAL_IF);
		sb.append(' ').append(getVariable());
		return sb.toString();
	}

	public String getVariable() {
		return getConditional();
	}
	
	// ICommand methods so Automake if can be a child of an IRule
	@Override
	public Process execute(String shell, String[] envp, File dir) {
		return null;
	}
	
	@Override
	public boolean shouldBeSilent() {
		return false;
	}
	
	@Override
	public boolean shouldIgnoreError() {
		return false;
	}
	
	@Override
	public boolean shouldExecute() {
		return false;
	}
}

Back to the top