Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7670e1008300fb746a55200427f724223e91e8f9 (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
/*******************************************************************************
 * Copyright (c) 2015 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
 *******************************************************************************/
package org.eclipse.cdt.arduino.core.internal.build;

import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoTool;
import org.eclipse.cdt.core.build.CToolChain;
import org.eclipse.cdt.core.build.IToolChainFactory;
import org.eclipse.cdt.core.build.gcc.GCCToolChain;
import org.osgi.service.prefs.Preferences;

public class ArduinoGCCToolChain extends GCCToolChain {

	private static final String PACKAGE = "arduinoPackage"; //$NON-NLS-1$
	private static final String TOOL = "arduinoTool"; //$NON-NLS-1$

	private final ArduinoTool tool;

	public ArduinoGCCToolChain(String id, Preferences settings) {
		super(id, settings);
		ArduinoPackage pkg = ArduinoManager.instance.getPackage(settings.get(PACKAGE, "")); //$NON-NLS-1$
		if (pkg != null) {
			this.tool = pkg.getLatestTool(settings.get(TOOL, "")); //$NON-NLS-1$
		} else {
			// TODO where did it go?
			this.tool = null;
		}
	}

	public ArduinoGCCToolChain(ArduinoTool tool) {
		super(tool.getName());
		this.tool = tool;
	}

	public static class ArduinoFactory implements IToolChainFactory {
		@Override
		public CToolChain createToolChain(String id, Preferences settings) {
			return new ArduinoGCCToolChain(id, settings);
		}
	}

	@Override
	public String getFamily() {
		return "Arduino GCC"; //$NON-NLS-1$
	}

	public ArduinoTool getTool() {
		return tool;
	}

	@Override
	public void save(Preferences settings) {
		super.save(settings);
		settings.put(TOOL, tool.getName());
		settings.put(PACKAGE, tool.getPackage().getName());
	}

}

Back to the top