diff options
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 | 118 |
1 files changed, 118 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..fe2a997 --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/builder/BitbakeCommanderNature.java | |||
@@ -0,0 +1,118 @@ | |||
1 | /***************************************************************************** | ||
2 | * Copyright (c) 2009 Ken Gilmer | ||
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 | *******************************************************************************/ | ||
12 | package org.yocto.bc.ui.builder; | ||
13 | |||
14 | import java.util.ArrayList; | ||
15 | |||
16 | import org.eclipse.core.resources.ICommand; | ||
17 | import org.eclipse.core.resources.IProject; | ||
18 | import org.eclipse.core.resources.IProjectDescription; | ||
19 | import org.eclipse.core.resources.IProjectNature; | ||
20 | import org.eclipse.core.runtime.CoreException; | ||
21 | import org.eclipse.debug.core.DebugPlugin; | ||
22 | import org.eclipse.debug.core.ILaunchConfigurationType; | ||
23 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; | ||
24 | import org.eclipse.debug.core.ILaunchManager; | ||
25 | |||
26 | |||
27 | public class BitbakeCommanderNature implements IProjectNature { | ||
28 | |||
29 | /** | ||
30 | * ID of this project nature | ||
31 | */ | ||
32 | public static final String NATURE_ID = "org.yocto.bc.ui.builder.BitbakeCommanderNature"; | ||
33 | public static final String BUILD_DIR_KEY = "org.yocto.bc.ui.builder.BitbakeCommander.BuildDir"; | ||
34 | private IProject project; | ||
35 | |||
36 | public static void launchHob(IProject project, String buildDir) { | ||
37 | try { | ||
38 | ILaunchManager lManager = DebugPlugin.getDefault().getLaunchManager(); | ||
39 | ILaunchConfigurationType configType = | ||
40 | lManager.getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); | ||
41 | ILaunchConfigurationWorkingCopy w_copy = configType.newInstance(null, "hob"); | ||
42 | ArrayList<String> listValue = new ArrayList<String>(); | ||
43 | listValue.add(new String("org.eclipse.ui.externaltools.launchGroup")); | ||
44 | w_copy.setAttribute("org.eclipse.debug.ui.favoriteGroups", listValue); | ||
45 | w_copy.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", "/usr/bin/xterm"); | ||
46 | |||
47 | String init_script = project.getLocation().toString() + "/oe-init-build-env "; | ||
48 | String argument = "-e \"source " + init_script + buildDir + ";hob";// + ";bash\""; | ||
49 | |||
50 | w_copy.setAttribute("org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS", argument); | ||
51 | w_copy.launch(ILaunchManager.RUN_MODE, null); | ||
52 | |||
53 | } catch (CoreException e) { | ||
54 | System.out.println(e.getMessage()); | ||
55 | } | ||
56 | } | ||
57 | /* | ||
58 | * (non-Javadoc) | ||
59 | * | ||
60 | * @see org.eclipse.core.resources.IProjectNature#configure() | ||
61 | */ | ||
62 | public void configure() throws CoreException { | ||
63 | IProjectDescription desc = project.getDescription(); | ||
64 | ICommand[] commands = desc.getBuildSpec(); | ||
65 | |||
66 | for (int i = 0; i < commands.length; ++i) { | ||
67 | if (commands[i].getBuilderName().equals(BitbakeBuilder.BUILDER_ID)) { | ||
68 | return; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | ICommand[] newCommands = new ICommand[commands.length + 1]; | ||
73 | System.arraycopy(commands, 0, newCommands, 0, commands.length); | ||
74 | ICommand command = desc.newCommand(); | ||
75 | command.setBuilderName(BitbakeBuilder.BUILDER_ID); | ||
76 | newCommands[newCommands.length - 1] = command; | ||
77 | desc.setBuildSpec(newCommands); | ||
78 | project.setDescription(desc, null); | ||
79 | } | ||
80 | |||
81 | /* | ||
82 | * (non-Javadoc) | ||
83 | * | ||
84 | * @see org.eclipse.core.resources.IProjectNature#deconfigure() | ||
85 | */ | ||
86 | public void deconfigure() throws CoreException { | ||
87 | IProjectDescription description = getProject().getDescription(); | ||
88 | ICommand[] commands = description.getBuildSpec(); | ||
89 | for (int i = 0; i < commands.length; ++i) { | ||
90 | if (commands[i].getBuilderName().equals(BitbakeBuilder.BUILDER_ID)) { | ||
91 | ICommand[] newCommands = new ICommand[commands.length - 1]; | ||
92 | System.arraycopy(commands, 0, newCommands, 0, i); | ||
93 | System.arraycopy(commands, i + 1, newCommands, i, | ||
94 | commands.length - i - 1); | ||
95 | description.setBuildSpec(newCommands); | ||
96 | return; | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | |||
101 | /* | ||
102 | * (non-Javadoc) | ||
103 | * | ||
104 | * @see org.eclipse.core.resources.IProjectNature#getProject() | ||
105 | */ | ||
106 | public IProject getProject() { | ||
107 | return project; | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * (non-Javadoc) | ||
112 | * | ||
113 | * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject) | ||
114 | */ | ||
115 | public void setProject(IProject project) { | ||
116 | this.project = project; | ||
117 | } | ||
118 | } | ||