diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:23:09 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:24:09 +0200 |
commit | c7da892cb23d50d4d85746c9a0b6b14bf570989d (patch) | |
tree | e7136073f386d6156f51766c498c52c30c8df85f /plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/builder/BitbakeCommanderNature.java | |
download | eclipse-poky-kepler-c7da892cb23d50d4d85746c9a0b6b14bf570989d.tar.gz |
initial commit for Enea Linux 4.0daisy
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/builder/BitbakeCommanderNature.java')
-rw-r--r-- | plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/builder/BitbakeCommanderNature.java | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/builder/BitbakeCommanderNature.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/builder/BitbakeCommanderNature.java new file mode 100644 index 0000000..25f7894 --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/builder/BitbakeCommanderNature.java | |||
@@ -0,0 +1,119 @@ | |||
1 | /***************************************************************************** | ||
2 | * Copyright (c) 2013 Ken Gilmer, Intel Corporation | ||
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 | ||
7 | * | ||
8 | * Contributors: | ||
9 | * Ken Gilmer - initial API and implementation | ||
10 | * Jessica Zhang - extend to support HOB build | ||
11 | * Ioana Grigoropol (Intel) - adapt class for remote support | ||
12 | *******************************************************************************/ | ||
13 | package org.yocto.bc.ui.builder; | ||
14 | |||
15 | import java.util.ArrayList; | ||
16 | |||
17 | import org.eclipse.core.resources.ICommand; | ||
18 | import org.eclipse.core.resources.IProject; | ||
19 | import org.eclipse.core.resources.IProjectDescription; | ||
20 | import org.eclipse.core.resources.IProjectNature; | ||
21 | import org.eclipse.core.runtime.CoreException; | ||
22 | import org.eclipse.debug.core.DebugPlugin; | ||
23 | import org.eclipse.debug.core.ILaunchConfigurationType; | ||
24 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; | ||
25 | import org.eclipse.debug.core.ILaunchManager; | ||
26 | |||
27 | |||
28 | public class BitbakeCommanderNature implements IProjectNature { | ||
29 | |||
30 | /** | ||
31 | * ID of this project nature | ||
32 | */ | ||
33 | public static final String NATURE_ID = "org.yocto.bc.ui.builder.BitbakeCommanderNature"; | ||
34 | public static final String BUILD_DIR_KEY = "org.yocto.bc.ui.builder.BitbakeCommander.BuildDir"; | ||
35 | private IProject project; | ||
36 | |||
37 | public static void launchHob(IProject project, String buildDir) { | ||
38 | try { | ||
39 | ILaunchManager lManager = DebugPlugin.getDefault().getLaunchManager(); | ||
40 | ILaunchConfigurationType configType = | ||
41 | lManager.getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); | ||
42 | ILaunchConfigurationWorkingCopy w_copy = configType.newInstance(null, "hob"); | ||
43 | ArrayList<String> listValue = new ArrayList<String>(); | ||
44 | listValue.add(new String("org.eclipse.ui.externaltools.launchGroup")); | ||
45 | w_copy.setAttribute("org.eclipse.debug.ui.favoriteGroups", listValue); | ||
46 | w_copy.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", "/usr/bin/xterm"); | ||
47 | |||
48 | String init_script = project.getLocationURI().getPath() + "/oe-init-build-env "; | ||
49 | String argument = "-e \"source " + init_script + buildDir + ";hob";// + ";bash\""; | ||
50 | |||
51 | w_copy.setAttribute("org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS", argument); | ||
52 | w_copy.launch(ILaunchManager.RUN_MODE, null); | ||
53 | |||
54 | } catch (CoreException e) { | ||
55 | System.out.println(e.getMessage()); | ||
56 | } | ||
57 | } | ||
58 | /* | ||
59 | * (non-Javadoc) | ||
60 | * | ||
61 | * @see org.eclipse.core.resources.IProjectNature#configure() | ||
62 | */ | ||
63 | public void configure() throws CoreException { | ||
64 | IProjectDescription desc = project.getDescription(); | ||
65 | ICommand[] commands = desc.getBuildSpec(); | ||
66 | |||
67 | for (int i = 0; i < commands.length; ++i) { | ||
68 | if (commands[i].getBuilderName().equals(BitbakeBuilder.BUILDER_ID)) { | ||
69 | return; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | ICommand[] newCommands = new ICommand[commands.length + 1]; | ||
74 | System.arraycopy(commands, 0, newCommands, 0, commands.length); | ||
75 | ICommand command = desc.newCommand(); | ||
76 | command.setBuilderName(BitbakeBuilder.BUILDER_ID); | ||
77 | newCommands[newCommands.length - 1] = command; | ||
78 | desc.setBuildSpec(newCommands); | ||
79 | project.setDescription(desc, null); | ||
80 | } | ||
81 | |||
82 | /* | ||
83 | * (non-Javadoc) | ||
84 | * | ||
85 | * @see org.eclipse.core.resources.IProjectNature#deconfigure() | ||
86 | */ | ||
87 | public void deconfigure() throws CoreException { | ||
88 | IProjectDescription description = getProject().getDescription(); | ||
89 | ICommand[] commands = description.getBuildSpec(); | ||
90 | for (int i = 0; i < commands.length; ++i) { | ||
91 | if (commands[i].getBuilderName().equals(BitbakeBuilder.BUILDER_ID)) { | ||
92 | ICommand[] newCommands = new ICommand[commands.length - 1]; | ||
93 | System.arraycopy(commands, 0, newCommands, 0, i); | ||
94 | System.arraycopy(commands, i + 1, newCommands, i, | ||
95 | commands.length - i - 1); | ||
96 | description.setBuildSpec(newCommands); | ||
97 | return; | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | |||
102 | /* | ||
103 | * (non-Javadoc) | ||
104 | * | ||
105 | * @see org.eclipse.core.resources.IProjectNature#getProject() | ||
106 | */ | ||
107 | public IProject getProject() { | ||
108 | return project; | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * (non-Javadoc) | ||
113 | * | ||
114 | * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject) | ||
115 | */ | ||
116 | public void setProject(IProject project) { | ||
117 | this.project = project; | ||
118 | } | ||
119 | } | ||