Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 023bf85e98b0c240867cc667c75b7bb4ab444472 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
/*******************************************************************************
 * Copyright (c) 2006, 2016 Intel Corporation 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:
 * Intel Corporation - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.buildmodel;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildIOType;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildResource;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildStep;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.macros.IFileContextData;
import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;

public class BuildStep implements IBuildStep {
	private List<BuildIOType> fInputTypes = new ArrayList<BuildIOType>();
	private List<BuildIOType> fOutputTypes = new ArrayList<BuildIOType>();
	private ITool fTool;
	private BuildGroup fBuildGroup;
	private boolean fNeedsRebuild;
	private boolean fIsRemoved;
	private BuildDescription fBuildDescription;
	private IInputType fInputType;
	private ITool fLibTool;
	private boolean fAssignToCalculated;

	protected BuildStep(BuildDescription des, ITool tool, IInputType inputType){
		fTool = tool;
		fInputType = inputType;
		fBuildDescription = des;

		if(DbgUtil.DEBUG)
			DbgUtil.trace("step " + DbgUtil.stepName(this) + " created");	//$NON-NLS-1$	//$NON-NLS-2$

		des.stepCreated(this);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getInputIOTypes()
	 */
	@Override
	public IBuildIOType[] getInputIOTypes() {
		return fInputTypes.toArray(new BuildIOType[fInputTypes.size()]);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getOutputIOTypes()
	 */
	@Override
	public IBuildIOType[] getOutputIOTypes() {
		return fOutputTypes.toArray(new BuildIOType[fOutputTypes.size()]);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#needsRebuild()
	 */
	@Override
	public boolean needsRebuild() {
		if(fNeedsRebuild
				|| (fTool != null && fTool.needsRebuild())
				|| (fLibTool != null && fLibTool.needsRebuild()))
			return true;

		if(fBuildGroup != null && fBuildGroup.needsRebuild())
			return true;

		return false;
	}

	public void setRebuildState(boolean rebuild){
		fNeedsRebuild = rebuild;
	}

	public BuildResource[] removeIOType(BuildIOType type) {

		BuildResource rcs[] = type.remove();

		if(type.isInput())
			fInputTypes.remove(type);
		else
			fOutputTypes.remove(type);

		return rcs;
	}

	BuildResource[][] remove(){
		BuildResource[][] rcs = clear();

		if(DbgUtil.DEBUG)
			DbgUtil.trace("step  " + DbgUtil.stepName(this) + " removed");	//$NON-NLS-1$	//$NON-NLS-2$

		fBuildDescription.stepRemoved(this);
		fBuildDescription = null;

		return rcs;
	}

	BuildResource[][] clear(){
		BuildResource[][] rcs = new BuildResource[2][];

		rcs[0] = (BuildResource[])getInputResources();
		rcs[1] = (BuildResource[])getOutputResources();

		BuildIOType types[] = (BuildIOType[])getInputIOTypes();
		for(int i = 0; i < types.length; i++){
			removeIOType(types[i]);
		}

		types = (BuildIOType[])getOutputIOTypes();
		for(int i = 0; i < types.length; i++){
			removeIOType(types[i]);
		}

		return rcs;
	}

	public void removeResource(BuildIOType type, BuildResource rc, boolean rmTypeIfEmpty){
		type.removeResource(rc);
		if(rmTypeIfEmpty && type.getResources().length == 0){
			removeIOType(type);
		}
	}

	public BuildIOType createIOType(boolean input, boolean primary, /*String ext,*/ IBuildObject ioType) {
		if(input){
			if(fBuildDescription.getInputStep() == this)
				throw new IllegalArgumentException("input step can not have inputs");	//$NON-NLS-1$
		} else {
			if(fBuildDescription.getOutputStep() == this)
				throw new IllegalArgumentException("input step can not have outputs");	//$NON-NLS-1$
		}

		BuildIOType arg = new BuildIOType(this, input, primary, /*ext,*/ ioType);
		if(input)
			fInputTypes.add(arg);
		else
			fOutputTypes.add(arg);

		return arg;
	}

	public void setTool(ITool tool){
		fTool = tool;
	}

	public ITool getTool(){
		return fTool;
	}

	public BuildIOType[] getPrimaryTypes(boolean input){
		List<BuildIOType> types = input ? fInputTypes : fOutputTypes;

		List<BuildIOType> list = new ArrayList<BuildIOType>();
		for (BuildIOType arg : types) {
			if(arg.isPrimary())
				list.add(arg);
		}
		return list.toArray(new BuildIOType[list.size()]);
	}

	public BuildIOType getIOTypeForType(IBuildObject ioType, boolean input){
		List<BuildIOType> list = input ? fInputTypes : fOutputTypes;

		if(ioType != null){
			for (BuildIOType arg : list) {
				if(arg.getIoType() == ioType)
					return arg;
			}
		} else {
			if(list.size() > 0)
				return list.get(0);
		}
		return null;
	}

	protected void setGroup(BuildGroup group){
		fBuildGroup = group;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getInputResources()
	 */
	@Override
	public IBuildResource[] getInputResources() {
		return getResources(true);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getOutputResources()
	 */
	@Override
	public IBuildResource[] getOutputResources() {
		return getResources(false);
	}

	public IBuildResource[] getResources(boolean input){
		List<BuildIOType> list = input ? fInputTypes : fOutputTypes;
		Set<IBuildResource> set = new HashSet<IBuildResource>();

		for (BuildIOType arg : list) {
			IBuildResource rcs[] = arg.getResources();
			for(int j = 0; j < rcs.length; j++){
				set.add(rcs[j]);
			}
		}
		return set.toArray(new BuildResource[set.size()]);
	}


	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getCommands(org.eclipse.core.runtime.IPath, java.util.Map, java.util.Map, boolean)
	 */
	@Override
	public IBuildCommand[] getCommands(IPath cwd, Map inputArgValues, Map outputArgValues, boolean resolveAll) {
		if(cwd == null)
			cwd = calcCWD();


		if(fTool == null){
			String step = null;
			String appendToLastStep = null;
			if(this == fBuildDescription.getInputStep()){
				step = fBuildDescription.getConfiguration().getPrebuildStep();
			} else if(this == fBuildDescription.getOutputStep()){
				step = fBuildDescription.getConfiguration().getPostbuildStep();
			} else if(this == fBuildDescription.getCleanStep()){
				step = fBuildDescription.getConfiguration().getCleanCommand();

				IBuildResource[] generated = fBuildDescription.getResources(true);

				if(generated.length != 0){
					StringBuffer buf = new StringBuffer();
					for(int i = 0; i < generated.length; i++){
						buf.append(' ');

						IPath rel = BuildDescriptionManager.getRelPath(cwd, generated[i].getLocation());
						buf.append(rel.toString());
					}
					appendToLastStep = buf.toString();
				}
			}

			if(step != null && (step = step.trim()).length() > 0){
				step = resolveMacros(step, resolveAll);
				if(step != null && (step = step.trim()).length() > 0){
					String commands[] = step.split(";"); 	//$NON-NLS-1$

					if(appendToLastStep != null && commands.length != 0){
						commands[commands.length - 1] = commands[commands.length - 1] + appendToLastStep;
					}

					List<IBuildCommand> list = new ArrayList<IBuildCommand>();
					for(int i = 0; i < commands.length; i++){
						IBuildCommand cmds[] = createCommandsFromString(commands[i], cwd, getEnvironment());
						for(int j = 0; j < cmds.length; j++){
							list.add(cmds[j]);
						}
					}
					return list.toArray(new BuildCommand[list.size()]);
				}
			}
			return new IBuildCommand[0];
		}


		performAsignToOption(cwd);

		BuildResource inRc = getRcForMacros(true);
		BuildResource outRc = getRcForMacros(false);
		IPath inRcPath = inRc != null ? BuildDescriptionManager.getRelPath(cwd, inRc.getLocation()) : null;
		IPath outRcPath = outRc != null ? BuildDescriptionManager.getRelPath(cwd, outRc.getLocation()) : null;

		IManagedCommandLineGenerator gen = fTool.getCommandLineGenerator();
		FileContextData data = new FileContextData(inRcPath, outRcPath, null, fTool);
		String outPrefix = fTool.getOutputPrefix();
		outPrefix = resolveMacros(outPrefix, data, true);
		outRcPath = rmNamePrefix(outRcPath, outPrefix);

		IManagedCommandLineInfo info = gen.generateCommandLineInfo(fTool,
				fTool.getToolCommand(),
				getCommandFlags(inRcPath, outRcPath, resolveAll),
				fTool.getOutputFlag(),
				outPrefix,
				listToString(resourcesToStrings(cwd, getPrimaryResources(false), outPrefix), " "), 	//$NON-NLS-1$
				getInputResources(cwd, getPrimaryResources(true)),
				fTool.getCommandLinePattern());

		return createCommandsFromString(resolveMacros(info.getCommandLine(), data, true), cwd, getEnvironment());
	}

	private IPath rmNamePrefix(IPath path, String prefix){
		if(prefix != null && prefix.length() != 0){
			String name = path.lastSegment();
			if(name.startsWith(prefix)){
				name = name.substring(prefix.length());
				path = path.removeLastSegments(1).append(name);
			}
		}
		return path;
	}

	private String[] getInputResources(IPath cwd, BuildResource[] rcs) {
		String[] resources = resourcesToStrings(cwd, rcs, null);

		// also need to get libraries
		String[] libs = null;
		IOption[] opts = fTool.getOptions();
		for (int i = 0; i < opts.length; ++i) {
			try {
				IOption opt = opts[i];
				if (opt.getValueType() == IOption.LIBRARIES) {
					String[] l = opts[i].getLibraries();
					if (l != null) {
						libs = new String[l.length];
						for (int j = 0; j < l.length; ++j) {
							libs[j] = opt.getCommand() + l[j];
						}
					}
				}
			} catch (BuildException e) {
			}
		}

		if (libs != null) {
			String[] irs = new String[resources.length + libs.length];
			System.arraycopy(resources, 0, irs, 0, resources.length);
			System.arraycopy(libs, 0, irs, resources.length, libs.length);
			return irs;
		} else {
			return resources;
		}
	}

	private IPath calcCWD(){
		IPath cwd = fBuildDescription.getDefaultBuildDirLocation();

		if(!cwd.isAbsolute())
			cwd = fBuildDescription.getConfiguration().getOwner().getProject().getLocation().append(cwd);

		return cwd;
	}

	protected Map<String, String> getEnvironment(){
		return fBuildDescription.getEnvironment();
	}

	protected IBuildCommand[] createCommandsFromString(String cmd, IPath cwd, Map<String, String> env){
		char arr[] = cmd.toCharArray();
		char expect = 0;
		char prev = 0;
//		int start = 0;
		List<String> list = new ArrayList<String>();
		StringBuffer buf = new StringBuffer();
		for(int i = 0; i < arr.length; i++){
			char ch = arr[i];
			switch(ch){
			case '\'':
			case '"':
				if(expect == ch){
//					String s = cmd.substring(start, i);
//					list.add(s);
					expect = 0;
//					start = i + 1;
				} else if (expect == 0){
//					String s = cmd.substring(start, i);
//					list.add(s);
					expect = ch;
//					start = i + 1;
				} else {
					buf.append(ch);
				}
				break;
			case ' ':
				if(expect == 0){
					if(prev != ' '){
						list.add(buf.toString());
						buf.delete(0, buf.length());
					}
//					start = i + 1;
				} else {
					buf.append(ch);
				}
				break;
			default:
				buf.append(ch);
				break;

			}
			prev = ch;
		}

		if(buf.length() > 0)
			list.add(buf.toString());

		IPath c = new Path(list.remove(0));
		String[] args = list.toArray(new String[list.size()]);

		return new IBuildCommand[]{new BuildCommand(c, args, env, cwd, this)};
	}

	private BuildResource[] getPrimaryResources(boolean input){
		BuildIOType[] types = getPrimaryTypes(input);
		if(types.length == 0)
			types = input ? (BuildIOType[])getInputIOTypes() : (BuildIOType[])getOutputIOTypes();
		List<BuildResource> list = new ArrayList<BuildResource>();

		for(int i = 0; i < types.length; i++){
			BuildResource [] rcs = (BuildResource[])types[i].getResources();

			for(int j = 0; j < rcs.length; j++){
				list.add(rcs[j]);
			}
		}

		return list.toArray(new BuildResource[list.size()]);
	}

	private String[] resourcesToStrings(IPath cwd, BuildResource rcs[], String prefixToRm){
		List<String> list = new ArrayList<String>(rcs.length);

		for(int i = 0; i < rcs.length; i++){
			IPath path = BuildDescriptionManager.getRelPath(cwd, rcs[i].getLocation());
			path = rmNamePrefix(path, prefixToRm);
			list.add(path.toOSString());
		}
		return list.toArray(new String[list.size()]);
	}

	private String resolveMacros(String str, IFileContextData fileData, boolean resolveAll){
		String result = str;
		try {
			if(resolveAll){
				IConfiguration cfg = getBuildDescription().getConfiguration();
				IBuilder builder = cfg.getBuilder();
				SupplierBasedCdtVariableSubstitutor sub = createSubstitutor(cfg, builder, fileData);
				result = CdtVariableResolver.resolveToString(str, sub);
			} else {
				result = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(str, "", " ", IBuildMacroProvider.CONTEXT_FILE, fileData);	//$NON-NLS-1$	//$NON-NLS-2$
			}
		} catch (CdtVariableException e) {
		}

		return result;
	}

	private String resolveMacros(String str, boolean resolveAll){
		String result = str;
		try {
			IConfiguration cfg = getBuildDescription().getConfiguration();
			if(resolveAll){
				result = ManagedBuildManager.getBuildMacroProvider().resolveValue(str, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg);	//$NON-NLS-1$	//$NON-NLS-2$
			} else {
				result = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(str, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg);	//$NON-NLS-1$	//$NON-NLS-2$
			}
		} catch (CdtVariableException e) {
		}

		return result;
	}

	private SupplierBasedCdtVariableSubstitutor createSubstitutor(IConfiguration cfg, IBuilder builder, IFileContextData fileData){
		BuildMacroProvider prov = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
		IMacroContextInfo info = prov.getMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE, fileData);
		FileMacroExplicitSubstitutor sub = new FileMacroExplicitSubstitutor(
				info,
				cfg,
				builder,
				"", " ");	//$NON-NLS-1$	//$NON-NLS-2$

		return sub;
	}

	private String[] getCommandFlags(IPath inRcPath, IPath outRcPath, boolean resolveAll){
		try {
			if(resolveAll) {
				IConfiguration cfg = getBuildDescription().getConfiguration();
				IBuilder builder = cfg.getBuilder();
					return ((Tool)fTool).getToolCommandFlags(inRcPath, outRcPath,
							createSubstitutor(cfg, builder,
									new FileContextData(inRcPath, outRcPath, null, fTool)),
							BuildMacroProvider.getDefault());
			}
			return fTool.getToolCommandFlags(inRcPath, outRcPath);
		} catch (BuildException e) {
		}
		return new String[0];
	}

	private String listToString(String[] list, String delimiter){
		if(list == null || list.length == 0)
			return ""; // $NON-NLS-1$

		StringBuffer buf = new StringBuffer(list[0]);

		for(int i = 1; i < list.length; i++){
			buf.append(delimiter).append(list[i]);
		}

		return buf.toString();
	}

	private BuildResource getRcForMacros(boolean input){
		IBuildIOType types[] = getPrimaryTypes(input);
		if(types.length != 0){
			for(int i = 0; i < types.length; i++){
				IBuildResource rcs[] = types[i].getResources();
				if(rcs.length != 0)
					return (BuildResource)rcs[0];
			}
		}

		types = input ? getInputIOTypes() : getOutputIOTypes();
		if(types.length != 0){
			for(int i = 0; i < types.length; i++){
				IBuildResource rcs[] = types[i].getResources();
				if(rcs.length != 0)
					return (BuildResource)rcs[0];
			}
		}

		return null;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#isRemoved()
	 */
	@Override
	public boolean isRemoved(){
		return fIsRemoved;
	}

	public void setRemoved() {
		fIsRemoved = true;
		fNeedsRebuild = false;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getBuildDescription()
	 */
	@Override
	public IBuildDescription getBuildDescription(){
		return fBuildDescription;
	}

	boolean isMultiAction(){
		BuildIOType args[] = getPrimaryTypes(true);
		BuildIOType arg = args.length > 0 ? args[0] : null;

		if(arg != null){
			if(arg.getIoType() != null)
				return ((IInputType)arg.getIoType()).getMultipleOfType();
			return fTool != null && fTool == ((Configuration)fBuildDescription.getConfiguration()).calculateTargetTool();
		}
		return false;
	}

	public IInputType getInputType(){
		return fInputType;
	}

	public void setLibTool(ITool libTool){
		fLibTool = libTool;
	}

	public ITool getLibTool(){
		return fLibTool;
	}

	protected void performAsignToOption(IPath cwd){
		if(fTool == null && !fAssignToCalculated)
			return;

		fAssignToCalculated = true;

		IConfiguration cfg = fBuildDescription.getConfiguration();

		for (BuildIOType bType : fInputTypes) {
			IInputType type = (IInputType)bType.getIoType();

			if(type == null)
				continue;

			IOption option = fTool.getOptionBySuperClassId(type.getOptionId());
			IOption assignToOption = fTool.getOptionBySuperClassId(type.getAssignToOptionId());
			if (assignToOption != null && option == null) {
				try {
					BuildResource bRcs[] = (BuildResource[])bType.getResources();
					int optType = assignToOption.getValueType();
					if (optType == IOption.STRING) {
						String optVal = "";	   //$NON-NLS-1$
						for (int j=0; j<bRcs.length; j++) {
							if (j != 0) {
								optVal += " ";	   //$NON-NLS-1$
							}
							optVal += BuildDescriptionManager.getRelPath(cwd, bRcs[j].getLocation()).toOSString();
						}
						ManagedBuildManager.setOption(cfg, fTool, assignToOption, optVal);
					} else if (
							optType == IOption.STRING_LIST ||
							optType == IOption.LIBRARIES ||
							optType == IOption.OBJECTS ||
							optType == IOption.INCLUDE_PATH ||
							optType == IOption.PREPROCESSOR_SYMBOLS ||
							optType == IOption.INCLUDE_FILES ||
							optType == IOption.LIBRARY_PATHS ||
							optType == IOption.LIBRARY_FILES ||
							optType == IOption.MACRO_FILES ||
							optType == IOption.UNDEF_INCLUDE_PATH ||
							optType == IOption.UNDEF_PREPROCESSOR_SYMBOLS ||
							optType == IOption.UNDEF_INCLUDE_FILES ||
							optType == IOption.UNDEF_LIBRARY_PATHS ||
							optType == IOption.UNDEF_LIBRARY_FILES ||
							optType == IOption.UNDEF_MACRO_FILES){
						//  Mote that when using the enumerated inputs, the path(s) must be translated from project relative
						//  to top build directory relative
						String[] paths = new String[bRcs.length];
						for (int j=0; j<bRcs.length; j++) {
							paths[j] = BuildDescriptionManager.getRelPath(cwd, bRcs[j].getLocation()).toOSString();
						}
						ManagedBuildManager.setOption(cfg, fTool, assignToOption, paths);
					} else if (optType == IOption.BOOLEAN) {
						if (bRcs.length > 0) {
							ManagedBuildManager.setOption(cfg, fTool, assignToOption, true);
						} else {
							ManagedBuildManager.setOption(cfg, fTool, assignToOption, false);
						}
					} else if (optType == IOption.ENUMERATED || optType == IOption.TREE) {
						if (bRcs.length > 0) {
							ManagedBuildManager.setOption(cfg, fTool, assignToOption, BuildDescriptionManager.getRelPath(cwd, bRcs[0].getLocation()).toOSString());
						}
					}
				} catch( BuildException ex ) {
				}
			}
		}
	}
}

Back to the top