Skip to content

Commit cc154a4

Browse files
committed
[Exporters] Build method documentation. Removal of unused Exception classes.
1 parent d8fc362 commit cc154a4

File tree

6 files changed

+31
-17
lines changed

6 files changed

+31
-17
lines changed

tools/export/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from tools.export import codered, ds5_5, iar, makefile
1919
from tools.export import emblocks, coide, kds, simplicityv3, atmelstudio
2020
from tools.export import sw4stm32, e2studio, zip, cmsis, uvision, cdt
21-
from tools.export.exporters import OldLibrariesException, FailedBuildException
2221
from tools.targets import TARGET_NAMES
2322

2423
EXPORTERS = {

tools/export/cmsis/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class DeviceCMSIS():
3030
"""CMSIS Device class
3131
3232
Encapsulates target information retrieved by arm-pack-manager"""
33-
cache = Cache(True, False)
33+
34+
CACHE = Cache(True, False)
3435
def __init__(self, target):
3536
target_info = self.check_supported(target)
3637
if not target_info:
@@ -52,7 +53,7 @@ def check_supported(target):
5253
t = TARGET_MAP[target]
5354
try:
5455
cpu_name = t.device_name
55-
target_info = DeviceCMSIS.cache.index[cpu_name]
56+
target_info = DeviceCMSIS.CACHE.index[cpu_name]
5657
# Target does not have device name or pdsc file
5758
except:
5859
try:

tools/export/exporters.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@
1111
from tools.targets import TARGET_MAP
1212

1313

14-
class OldLibrariesException(Exception):
15-
"""Exception that indicates an export can not complete due to an out of date
16-
library version.
17-
"""
18-
pass
19-
20-
class FailedBuildException(Exception):
21-
"""Exception that indicates that a build failed"""
22-
pass
23-
2414
class TargetNotSupportedException(Exception):
2515
"""Indicates that an IDE does not support a particular MCU"""
2616
pass
@@ -146,9 +136,31 @@ def make_key(self, src):
146136
def group_project_files(self, sources):
147137
"""Group the source files by their encompassing directory
148138
Positional Arguments:
149-
sources - array of sourc locations
139+
sources - array of source locations
150140
151141
Returns a dictionary of {group name: list of source locations}
152142
"""
153143
data = sorted(sources, key=self.make_key)
154144
return {k: list(g) for k,g in groupby(data, self.make_key)}
145+
146+
@staticmethod
147+
def build(project_name, log_name='build_log.txt', cleanup=True):
148+
"""Invoke exporters build command within a subprocess.
149+
This method is assumed to be executed at the same level as exporter
150+
project files and project source code.
151+
See uvision/__init__.py, iar/__init__.py, and makefile/__init__.py for
152+
example implemenation.
153+
154+
Positional Arguments:
155+
project_name - the name of the project to build; often required by
156+
exporter's build command.
157+
158+
Keyword Args:
159+
log_name - name of the build log to create. Written and printed out,
160+
deleted if cleanup = True
161+
cleanup - a boolean dictating whether exported project files and
162+
build log are removed after build
163+
164+
Returns -1 on failure and 0 on success
165+
"""
166+
raise NotImplemented("Implement in derived Exporter class.")

tools/export/iar/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sys
88

99
from tools.targets import TARGET_MAP
10-
from tools.export.exporters import Exporter, FailedBuildException
10+
from tools.export.exporters import Exporter
1111
import json
1212
from tools.export.cmsis import DeviceCMSIS
1313
from multiprocessing import cpu_count

tools/export/makefile/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def generate(self):
108108
@staticmethod
109109
def build(project_name, log_name="build_log.txt", cleanup=True):
110110
""" Build Make project """
111-
# > Make -C [project directory] -j
111+
# > Make -j
112112
cmd = ["make", "-j"]
113113
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
114114
ret = p.communicate()

tools/export/uvision/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from tools.arm_pack_manager import Cache
1111
from tools.targets import TARGET_MAP
12-
from tools.export.exporters import Exporter, FailedBuildException
12+
from tools.export.exporters import Exporter
1313
from tools.export.cmsis import DeviceCMSIS
1414

1515
cache_d = False
@@ -207,6 +207,8 @@ def generate(self):
207207

208208
@staticmethod
209209
def build(project_name, log_name='build_log.txt', cleanup=True):
210+
""" Build Uvision project """
211+
# > UV4.exe -r -j0 -o [log_name] [project_name].uvprojx
210212
success = 0
211213
warn = 1
212214
cmd = ["UV4.exe", '-r', '-j0', '-o', log_name, project_name+".uvprojx"]

0 commit comments

Comments
 (0)