mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Create projectfiles directory when exporting
Compatible with new c/asm/cpp flag separation.pull/2245/head
							parent
							
								
									e5de39efff
								
							
						
					
					
						commit
						2196d50e72
					
				| 
						 | 
				
			
			@ -71,18 +71,9 @@ class Exporter(object):
 | 
			
		|||
        jinja_loader = FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
 | 
			
		||||
        self.jinja_environment = Environment(loader=jinja_loader)
 | 
			
		||||
        self.resources = resources
 | 
			
		||||
        self.symbols = self.toolchain.get_symbols()
 | 
			
		||||
        self.generated_files = []
 | 
			
		||||
        self.builder_files_dict = {}
 | 
			
		||||
 | 
			
		||||
        # Add extra symbols and config file symbols to the Exporter's list of
 | 
			
		||||
        # symbols.
 | 
			
		||||
        config_macros = self.toolchain.config.get_config_data_macros()
 | 
			
		||||
        if config_macros:
 | 
			
		||||
            self.symbols.extend(config_macros)
 | 
			
		||||
        if extra_symbols:
 | 
			
		||||
            self.symbols.extend(extra_symbols)
 | 
			
		||||
 | 
			
		||||
    def get_toolchain(self):
 | 
			
		||||
        """A helper getter function that we should probably eliminate"""
 | 
			
		||||
        return self.TOOLCHAIN
 | 
			
		||||
| 
						 | 
				
			
			@ -98,8 +89,6 @@ class Exporter(object):
 | 
			
		|||
        common_flags - common options
 | 
			
		||||
        """
 | 
			
		||||
        config_header = self.toolchain.get_config_header()
 | 
			
		||||
        config_header = relpath(config_header,
 | 
			
		||||
                                self.resources.file_basepath[config_header])
 | 
			
		||||
        flags = {key + "_flags": value for key, value
 | 
			
		||||
                 in self.toolchain.flags.iteritems()}
 | 
			
		||||
        asm_defines = ["-D" + symbol for symbol in self.toolchain.get_symbols(True)]
 | 
			
		||||
| 
						 | 
				
			
			@ -108,6 +97,8 @@ class Exporter(object):
 | 
			
		|||
        flags['c_flags'] += c_defines
 | 
			
		||||
        flags['cxx_flags'] += c_defines
 | 
			
		||||
        if config_header:
 | 
			
		||||
            config_header = relpath(config_header,
 | 
			
		||||
                                    self.resources.file_basepath[config_header])
 | 
			
		||||
            flags['c_flags'] += self.toolchain.get_config_option(config_header)
 | 
			
		||||
            flags['cxx_flags'] += self.toolchain.get_config_option(
 | 
			
		||||
                config_header)
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +153,7 @@ class Exporter(object):
 | 
			
		|||
        project_data['source_files_lib'] = grouped(self.resources.libraries)
 | 
			
		||||
        project_data['output_dir']['path'] = self.export_dir
 | 
			
		||||
        project_data['linker_file'] = self.resources.linker_script
 | 
			
		||||
        project_data['macros'] = self.symbols
 | 
			
		||||
        project_data['macros'] = []
 | 
			
		||||
        project_data['build_dir'] = 'build'
 | 
			
		||||
        project_data['template'] = None
 | 
			
		||||
        project_data['name'] = self.project_name
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,7 +79,10 @@ class Uvision4(Exporter):
 | 
			
		|||
        # asm flags only, common are not valid within uvision project, they are armcc specific
 | 
			
		||||
        project_data['misc']['asm_flags'] = [asm_flag_string]
 | 
			
		||||
        # cxx flags included, as uvision have them all in one tab
 | 
			
		||||
        project_data['misc']['c_flags'] = list(set(self.flags['common_flags'] + self.flags['c_flags'] + self.flags['cxx_flags']))
 | 
			
		||||
        project_data['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']
 | 
			
		||||
                                                   + self.progen_flags['common_flags']
 | 
			
		||||
                                                   + self.progen_flags['c_flags']
 | 
			
		||||
                                                   + self.progen_flags['cxx_flags']))
 | 
			
		||||
        # not compatible with c99 flag set in the template
 | 
			
		||||
        project_data['misc']['c_flags'].remove("--c99")
 | 
			
		||||
        # cpp is not required as it's implicit for cpp files
 | 
			
		||||
| 
						 | 
				
			
			@ -88,16 +91,5 @@ class Uvision4(Exporter):
 | 
			
		|||
        project_data['misc']['c_flags'].remove("--no_vla")
 | 
			
		||||
        project_data['misc']['ld_flags'] = self.flags['ld_flags']
 | 
			
		||||
 | 
			
		||||
        i = 0
 | 
			
		||||
        for macro in self.symbols:
 | 
			
		||||
            # armasm does not like floating numbers in macros, timestamp to int
 | 
			
		||||
            if macro.startswith('MBED_BUILD_TIMESTAMP'):
 | 
			
		||||
                timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
 | 
			
		||||
                project_data['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
 | 
			
		||||
            # armasm does not even accept MACRO=string
 | 
			
		||||
            if macro.startswith('MBED_USERNAME'):
 | 
			
		||||
                project_data['macros'].pop(i)
 | 
			
		||||
            i += 1
 | 
			
		||||
        project_data['macros'].append('__ASSERT_MSG')
 | 
			
		||||
        project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision4'
 | 
			
		||||
        self.progen_gen_file(project_data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,7 +78,10 @@ class Uvision5(Exporter):
 | 
			
		|||
        # asm flags only, common are not valid within uvision project, they are armcc specific
 | 
			
		||||
        project_data['misc']['asm_flags'] = [asm_flag_string]
 | 
			
		||||
        # cxx flags included, as uvision have them all in one tab
 | 
			
		||||
        project_data['misc']['c_flags'] = list(set(self.flags['common_flags'] + self.flags['c_flags'] + self.flags['cxx_flags']))
 | 
			
		||||
        project_data['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']
 | 
			
		||||
                                                   + self.progen_flags['common_flags']
 | 
			
		||||
                                                   + self.progen_flags['c_flags']
 | 
			
		||||
                                                   + self.progen_flags['cxx_flags']))
 | 
			
		||||
        # not compatible with c99 flag set in the template
 | 
			
		||||
        project_data['misc']['c_flags'].remove("--c99")
 | 
			
		||||
        # cpp is not required as it's implicit for cpp files
 | 
			
		||||
| 
						 | 
				
			
			@ -88,15 +91,5 @@ class Uvision5(Exporter):
 | 
			
		|||
        project_data['misc']['ld_flags'] = self.flags['ld_flags']
 | 
			
		||||
 | 
			
		||||
        i = 0
 | 
			
		||||
        for macro in self.symbols:
 | 
			
		||||
            # armasm does not like floating numbers in macros, timestamp to int
 | 
			
		||||
            if macro.startswith('MBED_BUILD_TIMESTAMP'):
 | 
			
		||||
                timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
 | 
			
		||||
                project_data['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
 | 
			
		||||
            # armasm does not even accept MACRO=string
 | 
			
		||||
            if macro.startswith('MBED_USERNAME'):
 | 
			
		||||
                project_data['macros'].pop(i)
 | 
			
		||||
            i += 1
 | 
			
		||||
        project_data['macros'].append('__ASSERT_MSG')
 | 
			
		||||
        project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision5'
 | 
			
		||||
        self.progen_gen_file(project_data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@ sys.path.insert(0, ROOT)
 | 
			
		|||
 | 
			
		||||
from shutil import move, rmtree
 | 
			
		||||
from argparse import ArgumentParser
 | 
			
		||||
from os.path import normpath
 | 
			
		||||
from os.path import normpath, realpath
 | 
			
		||||
 | 
			
		||||
from tools.paths import EXPORT_DIR, MBED_BASE, MBED_LIBRARIES
 | 
			
		||||
from tools.export import EXPORTERS, mcu_ide_matrix
 | 
			
		||||
| 
						 | 
				
			
			@ -39,11 +39,11 @@ def setup_project(ide, target, program=None, source_dir=None, build=None):
 | 
			
		|||
    if source_dir:
 | 
			
		||||
        # --source is used to generate IDE files to toolchain directly
 | 
			
		||||
        # in the source tree and doesn't generate zip file
 | 
			
		||||
        project_dir = source_dir[0]
 | 
			
		||||
        project_dir = join(source_dir[0],'projectfiles',ide+"_"+target)
 | 
			
		||||
        if program:
 | 
			
		||||
            project_name = TESTS[program]
 | 
			
		||||
        else:
 | 
			
		||||
            project_name = basename(normpath(source_dir[0]))
 | 
			
		||||
            project_name = basename(normpath(realpath(source_dir[0])))
 | 
			
		||||
        src_paths = source_dir
 | 
			
		||||
        lib_paths = None
 | 
			
		||||
    else:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -214,7 +214,6 @@ def export_project(src_paths, export_path, target, ide,
 | 
			
		|||
                                  jobs=jobs, notify=notify, silent=silent,
 | 
			
		||||
                                  verbose=verbose, extra_verbose=extra_verbose,
 | 
			
		||||
                                  config=config)
 | 
			
		||||
 | 
			
		||||
    # The first path will give the name to the library
 | 
			
		||||
    if name is None:
 | 
			
		||||
        name = basename(normpath(abspath(src_paths[0])))
 | 
			
		||||
| 
						 | 
				
			
			@ -229,6 +228,8 @@ def export_project(src_paths, export_path, target, ide,
 | 
			
		|||
 | 
			
		||||
    if zip_proj:
 | 
			
		||||
        subtract_basepath(resources, export_path)
 | 
			
		||||
    else:
 | 
			
		||||
        resources.relative_to(export_path)
 | 
			
		||||
 | 
			
		||||
    # Change linker script if specified
 | 
			
		||||
    if linker_script is not None:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue