blob: 073ee8bdc2cd8313605ac74a2b4215c9e54e5a8f (
plain)
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
|
/*****************************************************************************
* Copyright (c) 2009 Ken Gilmer
* 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:
* Ken Gilmer - initial API and implementation
*******************************************************************************/
package org.openembedded.bc.ui.actions;
import org.eclipse.core.resources.IFile;
public class BitbakeBuildRecipeAction extends AbstractBitbakeCommandAction {
@Override
public String [] getCommands() {
return new String[] {"bitbake " + getRecipeFromIFile(recipe)};
}
@Override
public String getJobTitle() {
return "Building " + recipe.getName();
}
/**
* @param path Path to recipe file
* @return The recipe name that bitbake will understand, based on a full path to a recipe file.
*/
private static String getRecipeFromIFile(IFile path) {
String bbRecipeExtension = ".bb";
if (!path.getName().endsWith(bbRecipeExtension))
throw new RuntimeException("File is not a bitbake recipe: " + path.getName());
//Extract the filename without the extension.
String name = path.getName().substring(0, path.getName().length() - bbRecipeExtension.length());
String [] nvp = name.split("_");
if (nvp.length == 0)
throw new RuntimeException("Unable to parse recipe name from filename: " + name);
//No version information embedded in the filename
if (nvp.length == 1)
return nvp[0];
//Use bitbake's convention for specifying the version with a "-"
if (nvp.length == 2)
return nvp[0] + "-" + nvp[1];
//Unknown format, just return the name
return nvp[0];
}
}
|