Skip to content

Commit 2196d50

Browse files
sarahmarshytheotherjimmy
authored andcommitted
Create projectfiles directory when exporting
Compatible with new c/asm/cpp flag separation.
1 parent e5de39e commit 2196d50

File tree

5 files changed

+16
-39
lines changed

5 files changed

+16
-39
lines changed

tools/export/exporters.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,9 @@ def __init__(self, target, export_dir, project_name, toolchain,
7171
jinja_loader = FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
7272
self.jinja_environment = Environment(loader=jinja_loader)
7373
self.resources = resources
74-
self.symbols = self.toolchain.get_symbols()
7574
self.generated_files = []
7675
self.builder_files_dict = {}
7776

78-
# Add extra symbols and config file symbols to the Exporter's list of
79-
# symbols.
80-
config_macros = self.toolchain.config.get_config_data_macros()
81-
if config_macros:
82-
self.symbols.extend(config_macros)
83-
if extra_symbols:
84-
self.symbols.extend(extra_symbols)
85-
8677
def get_toolchain(self):
8778
"""A helper getter function that we should probably eliminate"""
8879
return self.TOOLCHAIN
@@ -98,8 +89,6 @@ def flags(self):
9889
common_flags - common options
9990
"""
10091
config_header = self.toolchain.get_config_header()
101-
config_header = relpath(config_header,
102-
self.resources.file_basepath[config_header])
10392
flags = {key + "_flags": value for key, value
10493
in self.toolchain.flags.iteritems()}
10594
asm_defines = ["-D" + symbol for symbol in self.toolchain.get_symbols(True)]
@@ -108,6 +97,8 @@ def flags(self):
10897
flags['c_flags'] += c_defines
10998
flags['cxx_flags'] += c_defines
11099
if config_header:
100+
config_header = relpath(config_header,
101+
self.resources.file_basepath[config_header])
111102
flags['c_flags'] += self.toolchain.get_config_option(config_header)
112103
flags['cxx_flags'] += self.toolchain.get_config_option(
113104
config_header)
@@ -162,7 +153,7 @@ def grouped(sources):
162153
project_data['source_files_lib'] = grouped(self.resources.libraries)
163154
project_data['output_dir']['path'] = self.export_dir
164155
project_data['linker_file'] = self.resources.linker_script
165-
project_data['macros'] = self.symbols
156+
project_data['macros'] = []
166157
project_data['build_dir'] = 'build'
167158
project_data['template'] = None
168159
project_data['name'] = self.project_name

tools/export/uvision4.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ def generate(self):
7979
# asm flags only, common are not valid within uvision project, they are armcc specific
8080
project_data['misc']['asm_flags'] = [asm_flag_string]
8181
# cxx flags included, as uvision have them all in one tab
82-
project_data['misc']['c_flags'] = list(set(self.flags['common_flags'] + self.flags['c_flags'] + self.flags['cxx_flags']))
82+
project_data['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']
83+
+ self.progen_flags['common_flags']
84+
+ self.progen_flags['c_flags']
85+
+ self.progen_flags['cxx_flags']))
8386
# not compatible with c99 flag set in the template
8487
project_data['misc']['c_flags'].remove("--c99")
8588
# cpp is not required as it's implicit for cpp files
@@ -88,16 +91,5 @@ def generate(self):
8891
project_data['misc']['c_flags'].remove("--no_vla")
8992
project_data['misc']['ld_flags'] = self.flags['ld_flags']
9093

91-
i = 0
92-
for macro in self.symbols:
93-
# armasm does not like floating numbers in macros, timestamp to int
94-
if macro.startswith('MBED_BUILD_TIMESTAMP'):
95-
timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
96-
project_data['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
97-
# armasm does not even accept MACRO=string
98-
if macro.startswith('MBED_USERNAME'):
99-
project_data['macros'].pop(i)
100-
i += 1
101-
project_data['macros'].append('__ASSERT_MSG')
10294
project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision4'
10395
self.progen_gen_file(project_data)

tools/export/uvision5.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ def generate(self):
7878
# asm flags only, common are not valid within uvision project, they are armcc specific
7979
project_data['misc']['asm_flags'] = [asm_flag_string]
8080
# cxx flags included, as uvision have them all in one tab
81-
project_data['misc']['c_flags'] = list(set(self.flags['common_flags'] + self.flags['c_flags'] + self.flags['cxx_flags']))
81+
project_data['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']
82+
+ self.progen_flags['common_flags']
83+
+ self.progen_flags['c_flags']
84+
+ self.progen_flags['cxx_flags']))
8285
# not compatible with c99 flag set in the template
8386
project_data['misc']['c_flags'].remove("--c99")
8487
# cpp is not required as it's implicit for cpp files
@@ -88,15 +91,5 @@ def generate(self):
8891
project_data['misc']['ld_flags'] = self.flags['ld_flags']
8992

9093
i = 0
91-
for macro in self.symbols:
92-
# armasm does not like floating numbers in macros, timestamp to int
93-
if macro.startswith('MBED_BUILD_TIMESTAMP'):
94-
timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
95-
project_data['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
96-
# armasm does not even accept MACRO=string
97-
if macro.startswith('MBED_USERNAME'):
98-
project_data['macros'].pop(i)
99-
i += 1
100-
project_data['macros'].append('__ASSERT_MSG')
10194
project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision5'
10295
self.progen_gen_file(project_data)

tools/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from shutil import move, rmtree
1010
from argparse import ArgumentParser
11-
from os.path import normpath
11+
from os.path import normpath, realpath
1212

1313
from tools.paths import EXPORT_DIR, MBED_BASE, MBED_LIBRARIES
1414
from tools.export import EXPORTERS, mcu_ide_matrix
@@ -39,11 +39,11 @@ def setup_project(ide, target, program=None, source_dir=None, build=None):
3939
if source_dir:
4040
# --source is used to generate IDE files to toolchain directly
4141
# in the source tree and doesn't generate zip file
42-
project_dir = source_dir[0]
42+
project_dir = join(source_dir[0],'projectfiles',ide+"_"+target)
4343
if program:
4444
project_name = TESTS[program]
4545
else:
46-
project_name = basename(normpath(source_dir[0]))
46+
project_name = basename(normpath(realpath(source_dir[0])))
4747
src_paths = source_dir
4848
lib_paths = None
4949
else:

tools/project_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ def export_project(src_paths, export_path, target, ide,
214214
jobs=jobs, notify=notify, silent=silent,
215215
verbose=verbose, extra_verbose=extra_verbose,
216216
config=config)
217-
218217
# The first path will give the name to the library
219218
if name is None:
220219
name = basename(normpath(abspath(src_paths[0])))
@@ -229,6 +228,8 @@ def export_project(src_paths, export_path, target, ide,
229228

230229
if zip_proj:
231230
subtract_basepath(resources, export_path)
231+
else:
232+
resources.relative_to(export_path)
232233

233234
# Change linker script if specified
234235
if linker_script is not None:

0 commit comments

Comments
 (0)