21
21
from workspace_tools .utils import mkdir
22
22
from workspace_tools .export import uvision4 , codesourcery , codered , gccarm , ds5_5 , iar , emblocks , coide , kds , zip , simplicityv3 , atmelstudio
23
23
from workspace_tools .export .exporters import zip_working_directory_and_clean_up , OldLibrariesException
24
- from workspace_tools .targets import TARGET_NAMES , EXPORT_MAP
24
+ from workspace_tools .targets import TARGET_NAMES , EXPORT_MAP , TARGET_MAP
25
+
26
+ from project_generator_definitions .definitions import ProGenDef
25
27
26
28
EXPORTERS = {
27
29
'uvision' : uvision4 .Uvision4 ,
@@ -60,7 +62,7 @@ def export(project_path, project_name, ide, target, destination='/tmp/',
60
62
if tempdir is None :
61
63
tempdir = tempfile .mkdtemp ()
62
64
63
- report = {'success' : False }
65
+ report = {'success' : False , 'errormsg' : '' }
64
66
if ide is None or ide == "zip" :
65
67
# Simple ZIP exporter
66
68
try :
@@ -73,20 +75,36 @@ def export(project_path, project_name, ide, target, destination='/tmp/',
73
75
report ['errormsg' ] = ERROR_MESSAGE_NOT_EXPORT_LIBS
74
76
else :
75
77
if ide not in EXPORTERS :
76
- report ['errormsg' ] = "Unsupported toolchain"
78
+ report ['errormsg' ] = ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN % ( target , ide )
77
79
else :
78
80
Exporter = EXPORTERS [ide ]
79
81
target = EXPORT_MAP .get (target , target )
80
- if target not in Exporter .TARGETS :
81
- report ['errormsg' ] = ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN % (target , ide )
82
+ # use progen targets or mbed exporters targets, check progen attribute
83
+ use_progen = False
84
+ supported = True
85
+ try :
86
+ if Exporter .PROGEN_ACTIVE :
87
+ use_progen = True
88
+ except AttributeError :
89
+ pass
90
+ if use_progen :
91
+ if not ProGenDef (ide ).is_supported (TARGET_MAP [target ].progen_target ):
92
+ supported = False
82
93
else :
94
+ if target not in Exporter .TARGETS :
95
+ supported = False
96
+
97
+ if supported :
98
+ # target checked, export
83
99
try :
84
100
exporter = Exporter (target , tempdir , project_name , build_url_resolver , extra_symbols = extra_symbols )
85
101
exporter .scan_and_copy_resources (project_path , tempdir )
86
102
exporter .generate ()
87
103
report ['success' ] = True
88
104
except OldLibrariesException , e :
89
105
report ['errormsg' ] = ERROR_MESSAGE_NOT_EXPORT_LIBS
106
+ else :
107
+ report ['errormsg' ] = ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN % (target , ide )
90
108
91
109
zip_path = None
92
110
if report ['success' ]:
0 commit comments