summaryrefslogtreecommitdiffstats
path: root/org.rtems.cdt/src/org/rtems/cdt/Activator.java
blob: f9e8f3595e9b001ad742f41cfeb52b0811b9b261 (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
/*
 * Copyright (c) 2008 Embedded Brains GmbH and others.
 *
 *   Embedded Brains GmbH
 *   Obere Lagerstr. 30
 *   D-82178 Puchheim
 *   Germany
 *   rtems@embedded-brains.de
 *
 * All rights reserved.  This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License Version 1.0 ("EPL")
 * which accompanies this distribution and is available at
 *
 *   http://www.eclipse.org/legal/epl-v10.html
 *
 * For purposes of the EPL, "Program" will mean the Content.
 *
 * Contributors:
 *
 *   Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation.
 */

package org.rtems.cdt;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class Activator extends AbstractUIPlugin {
	private static Activator mPlugin;

	public void start(BundleContext context) throws Exception {
		super.start(context);
		mPlugin = this;
		createBSPInfoMakefile();
	}

	public void stop(BundleContext context) throws Exception {
		mPlugin = null;
		super.stop(context);
	}

	public static Activator getDefault() {
		return mPlugin;
	}

	public IPath getMakefileLocation() {
		return getStateLocation();
	}

	private void createBSPInfoMakefile() {
		IPath makefile = getMakefileLocation().append("Makefile");
		BufferedWriter out = null;
		try {
			out = new BufferedWriter(new FileWriter(makefile.toFile()));
			out.write(
				"include $(" + Constants.BSP_PATH_MAKE_VARIABLE + ")/Makefile.inc\n"
					+ "include $(RTEMS_CUSTOM)\n"
					+ "include $(PROJECT_ROOT)/make/leaf.cfg\n"
					+ "all:\n"
					+ "\t@echo " + Constants.TOOL_ARCHIVER_KEY + "\n"
					+ "\t@for i in $(AR) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n"
					+ "\t@echo " + Constants.TOOL_ASSEMBLER_KEY + "\n"
					+ "\t@for i in $(AS) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n"
					+ "\t@echo " + Constants.TOOL_COMPILER_C_KEY + "\n"
					+ "\t@for i in $(COMPILE.c) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n"
					+ "\t@echo " + Constants.TOOL_COMPILER_CPP_KEY + "\n"
					+ "\t@for i in $(COMPILE.cc) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n"
					+ "\t@echo " + Constants.TOOL_LINKER_C_KEY + "\n"
					+ "\t@for i in $(LINK.c) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n"
					+ "\t@echo " + Constants.TOOL_LINKER_CPP_KEY + "\n"
					+ "\t@for i in $(LINK.cc) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n"
			);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (out != null) {
					out.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}