Skip to content

Commit 2ccaed9

Browse files
author
Evgueni Driouk
committed
Adding missing files for 2.8.0
1 parent 41a193a commit 2ccaed9

17 files changed

Lines changed: 1403 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 ARM Ltd. and others
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+
* ARM Ltd and ARM Germany GmbH - Initial API and implementation
10+
*******************************************************************************/
11+
12+
package com.arm.cmsis.pack.data;
13+
14+
import java.util.Set;
15+
16+
/**
17+
* Helper interface to get all device names fount in an item (pack, board,
18+
* device)
19+
*/
20+
public interface IAllDeviceNames {
21+
22+
/**
23+
* Get names of all devices declared in the item
24+
*
25+
* @return a set of device names, includes family, sub-family, device and
26+
* variant levels.
27+
*/
28+
Set<String> getAllDeviceNames();
29+
30+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 ARM Ltd. and others
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+
* ARM Ltd and ARM Germany GmbH - Initial API and implementation
10+
*******************************************************************************/
11+
12+
package com.arm.cmsis.pack.info;
13+
14+
import com.arm.cmsis.pack.common.CmsisConstants;
15+
import com.arm.cmsis.pack.data.ICpBoard;
16+
import com.arm.cmsis.pack.data.ICpItem;
17+
import com.arm.cmsis.pack.data.ICpPack;
18+
19+
/**
20+
* Default implementation of ICpDeviceInfo interface
21+
*/
22+
public class CpBoardInfo extends CpItemInfo implements ICpBoardInfo {
23+
24+
protected ICpBoard fBoard = null;
25+
26+
/**
27+
* Constructs CpBoardInfo from supplied ICpBoard
28+
*
29+
* @param parent parent ICpItem
30+
* @param board ICpBoard to construct from
31+
*/
32+
public CpBoardInfo(ICpItem parent, ICpBoard board) {
33+
super(parent, CmsisConstants.BOARD_TAG);
34+
setBoard(board);
35+
}
36+
37+
/**
38+
* Default constructor
39+
*
40+
* @param parent parent ICpItem
41+
*/
42+
public CpBoardInfo(ICpItem parent) {
43+
super(parent, CmsisConstants.BOARD_TAG);
44+
}
45+
46+
/**
47+
* Constructs CpDeviceInfo from parent and tag
48+
*
49+
* @param parent parent ICpItem
50+
* @param tag
51+
*/
52+
public CpBoardInfo(ICpItem parent, String tag) {
53+
super(parent, tag);
54+
}
55+
56+
@Override
57+
public ICpBoard getBoard() {
58+
return fBoard;
59+
}
60+
61+
@Override
62+
public ICpPack getPack() {
63+
if (fBoard != null) {
64+
return fBoard.getPack();
65+
}
66+
return super.getPack();
67+
}
68+
69+
@Override
70+
public String getPackId() {
71+
if (fBoard != null) {
72+
return fBoard.getPackId();
73+
}
74+
return super.getPackId();
75+
}
76+
77+
@Override
78+
public String getName() {
79+
return getAttribute(CmsisConstants.BNAME);
80+
}
81+
82+
@Override
83+
public String getDescription() {
84+
if (fBoard != null) {
85+
return fBoard.getDescription();
86+
}
87+
return CmsisConstants.EMPTY_STRING;
88+
}
89+
90+
@Override
91+
public String constructId() {
92+
return ICpBoard.constructBoardId(this);
93+
}
94+
95+
@Override
96+
public synchronized String getUrl() {
97+
if (fBoard != null) {
98+
return fBoard.getUrl();
99+
}
100+
return getAttribute(CmsisConstants.URL);
101+
}
102+
103+
@Override
104+
public void setBoard(ICpBoard board) {
105+
fBoard = board;
106+
updateInfo();
107+
}
108+
109+
@Override
110+
public void updateInfo() {
111+
if (fBoard != null) {
112+
setAttribute(CmsisConstants.BNAME, fBoard.getName());
113+
setAttribute(CmsisConstants.BVENDOR, fBoard.getVendor());
114+
setAttribute(CmsisConstants.BREVISION, fBoard.getRevision());
115+
String url = fBoard.getUrl();
116+
if (url != null && !url.isEmpty()) {
117+
attributes().setAttribute(CmsisConstants.URL, url);
118+
}
119+
}
120+
updatePackInfo(fBoard != null ? fBoard.getPack() : null);
121+
}
122+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 ARM Ltd. and others
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+
* ARM Ltd and ARM Germany GmbH - Initial API and implementation
10+
*******************************************************************************/
11+
12+
package com.arm.cmsis.pack.info;
13+
14+
import com.arm.cmsis.pack.common.CmsisConstants;
15+
import com.arm.cmsis.pack.data.CpItem;
16+
import com.arm.cmsis.pack.data.ICpItem;
17+
import com.arm.cmsis.pack.data.ICpPack;
18+
import com.arm.cmsis.pack.enums.EEvaluationResult;
19+
import com.arm.cmsis.pack.enums.IEvaluationResult;
20+
21+
/**
22+
* Default implementation of ICpDeviceInfo interface
23+
*/
24+
public abstract class CpItemInfo extends CpItem implements ICpItemInfo, IEvaluationResult {
25+
26+
protected ICpPackInfo fPackInfo = null;
27+
protected EEvaluationResult fResolveResult = EEvaluationResult.UNDEFINED;
28+
29+
/**
30+
*
31+
* @Override protected ICpItem createChildItem(String tag) { return
32+
* CpConfigurationInfo.createChildItem(this, tag); }
33+
*
34+
* /** Constructs CpDeviceInfo from parent and tag
35+
*
36+
* @param parent parent ICpItem
37+
* @param tag
38+
*/
39+
protected CpItemInfo(ICpItem parent, String tag) {
40+
super(parent, tag);
41+
}
42+
43+
@Override
44+
protected ICpItem createChildItem(String tag) {
45+
return CpConfigurationInfo.createChildItem(this, tag);
46+
}
47+
48+
@Override
49+
public ICpPack getPack() {
50+
if (getPackInfo() != null) {
51+
return getPackInfo().getPack();
52+
}
53+
return null;
54+
}
55+
56+
@Override
57+
public String getPackId() {
58+
if (getPackInfo() != null) {
59+
return getPackInfo().getPackId();
60+
}
61+
return CmsisConstants.EMPTY_STRING;
62+
}
63+
64+
@Override
65+
public ICpPackInfo getPackInfo() {
66+
if (fPackInfo == null) {
67+
fPackInfo = getFirstChildOfType(ICpPackInfo.class);
68+
}
69+
return fPackInfo;
70+
}
71+
72+
public void updatePackInfo(ICpPack pack) {
73+
if (pack != null) {
74+
if (fPackInfo != null && fPackInfo.getPack() == pack) {
75+
return;
76+
}
77+
fPackInfo = new CpPackInfo(this, pack);
78+
fPackInfo.attributes().setAttribute(CmsisConstants.INFO, pack.getDescription());
79+
replaceChild(fPackInfo);
80+
} else if (fPackInfo != null) {
81+
fPackInfo.setPack(null);
82+
}
83+
}
84+
85+
@Override
86+
public void addChild(ICpItem item) {
87+
if (item instanceof ICpPackInfo) {
88+
fPackInfo = (ICpPackInfo) item;
89+
}
90+
super.addChild(item);
91+
}
92+
93+
@Override
94+
public EEvaluationResult getEvaluationResult() {
95+
return fResolveResult;
96+
}
97+
98+
@Override
99+
public void setEvaluationResult(EEvaluationResult result) {
100+
fResolveResult = result;
101+
}
102+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 ARM Ltd. and others
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+
* ARM Ltd and ARM Germany GmbH - Initial API and implementation
10+
*******************************************************************************/
11+
12+
package com.arm.cmsis.pack.info;
13+
14+
import com.arm.cmsis.pack.data.ICpBoard;
15+
import com.arm.cmsis.pack.enums.IEvaluationResult;
16+
17+
/**
18+
* Interface representing board used in the configuration
19+
*/
20+
public interface ICpBoardInfo extends ICpItemInfo, IEvaluationResult {
21+
22+
/**
23+
* Returns actual board represented by this info
24+
*
25+
* @return actual board
26+
*/
27+
ICpBoard getBoard();
28+
29+
/**
30+
* Sets actual board to this info
31+
*
32+
* @param board actual board to set
33+
*/
34+
void setBoard(ICpBoard board);
35+
36+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2022 ARM Ltd. and others
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+
* ARM Ltd and ARM Germany GmbH - Initial API and implementation
10+
*******************************************************************************/
11+
package com.arm.cmsis.pack.project.template;
12+
13+
import java.util.HashSet;
14+
import java.util.Set;
15+
16+
import org.eclipse.cdt.core.templateengine.TemplateCore;
17+
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
18+
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
19+
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
20+
import org.eclipse.core.runtime.IProgressMonitor;
21+
import org.eclipse.core.runtime.IStatus;
22+
23+
import com.arm.cmsis.pack.CpPlugIn;
24+
import com.arm.cmsis.pack.ICpPackInstaller;
25+
import com.arm.cmsis.pack.ICpPackManager;
26+
import com.arm.cmsis.pack.info.ICpBoardInfo;
27+
import com.arm.cmsis.pack.info.ICpDeviceInfo;
28+
import com.arm.cmsis.pack.project.Messages;
29+
30+
/**
31+
* @author edriouk
32+
*
33+
*/
34+
public class InstallDeviceAndBoardPacks extends ProcessRunner {
35+
36+
@Override
37+
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor)
38+
throws ProcessFailureException {
39+
String projectName = args[0].getSimpleValue();
40+
41+
String msg = Messages.CreateRteProject_ErrorCreatingRteProject;
42+
ICpPackManager packManager = CpPlugIn.getPackManager();
43+
ICpPackInstaller packInstaller = packManager != null ? packManager.getPackInstaller() : null;
44+
if (packInstaller == null) {
45+
msg += Messages.CmsisHeadlessBuilder_CmsisPackManagerNotAvailable;
46+
msg += projectName;
47+
throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, msg));
48+
}
49+
String cmsisPackRoot = packManager.getCmsisPackRootDirectory();
50+
if (cmsisPackRoot == null || cmsisPackRoot.isEmpty()) {
51+
msg += Messages.CmsisHeadlessBuilder_NoCmsisPackRoot;
52+
throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, msg));
53+
}
54+
55+
// Get device and board infos to create obtain packs
56+
ICpDeviceInfo deviceInfo = RteProjectTemplate.getSelectedDeviceInfo();
57+
Set<String> requiredPacks = new HashSet<>();
58+
if (deviceInfo != null) {
59+
requiredPacks.add(deviceInfo.getPackId());
60+
}
61+
ICpBoardInfo boardInfo = RteProjectTemplate.getSelectedBoardInfo();
62+
if (boardInfo != null) {
63+
requiredPacks.add(boardInfo.getPackId());
64+
}
65+
packInstaller.installPacks(requiredPacks);
66+
}
67+
}

0 commit comments

Comments
 (0)