def clean(source_dir):
    if exists(EXPORT_DIR):
        rmtree(EXPORT_DIR)
    for cls in EXPORTERS.values():
        try:
            cls.clean(basename(abspath(source_dir[0])))
        except (NotImplementedError, IOError, OSError):
            pass
    for f in list(EXPORTERS.values())[0].CLEAN_FILES:
        try:
            remove(f)
        except (IOError, OSError):
            pass

    return export_project(src,
                          project_dir,
                          target,
                          ide,
                          name=name,
                          macros=macros,
                          libraries_paths=lib,
                          zip_proj=zip_name,
                          build_profile=build_profile,
                          notify=notify,
                          app_config=app_config,
                          ignore=ignore)
Beispiel #2
0
def export(target, ide, build=None, src=None, macros=None, project_id=None,
           zip_proj=False, build_profile=None, export_path=None, silent=False,
           app_config=None):
    """Do an export of a project.

    Positional arguments:
    target - MCU that the project will compile for
    ide - the IDE or project structure to export to

    Keyword arguments:
    build - to use the compiled mbed libraries or not
    src - directory or directories that contain the source to export
    macros - extra macros to add to the project
    project_id - the name of the project
    clean - start from a clean state before exporting
    zip_proj - create a zip file or not

    Returns an object of type Exporter (tools/exports/exporters.py)
    """
    project_dir, name, src, lib = setup_project(ide, target, program=project_id,
                                                source_dir=src, build=build, export_path=export_path)

    zip_name = name+".zip" if zip_proj else None

    return export_project(src, project_dir, target, ide, name=name,
                          macros=macros, libraries_paths=lib, zip_proj=zip_name,
                          build_profile=build_profile, silent=silent,
                          app_config=app_config)
Beispiel #3
0
def export(target, ide, build=None, src=None, macros=None, project_id=None,
           zip_proj=False, build_profile=None, export_path=None, notify=None,
           app_config=None, ignore=None):
    """Do an export of a project.

    Positional arguments:
    target - MCU that the project will compile for
    ide - the IDE or project structure to export to

    Keyword arguments:
    build - to use the compiled mbed libraries or not
    src - directory or directories that contain the source to export
    macros - extra macros to add to the project
    project_id - the name of the project
    clean - start from a clean state before exporting
    zip_proj - create a zip file or not
    ignore - list of paths to add to mbedignore

    Returns an object of type Exporter (tools/exports/exporters.py)
    """
    project_dir, name, src, lib = setup_project(ide, target, program=project_id,
                                                source_dir=src, build=build, export_path=export_path)

    zip_name = name+".zip" if zip_proj else None

    return export_project(src, project_dir, target, ide, name=name,
                          macros=macros, libraries_paths=lib, zip_proj=zip_name,
                          build_profile=build_profile, notify=notify,
                          app_config=app_config, ignore=ignore)
Beispiel #4
0
def export(target,
           ide,
           build=None,
           src=None,
           macros=None,
           project_id=None,
           zip_proj=False,
           build_profile=None,
           export_path=None,
           notify=None,
           app_config=None,
           ignore=None,
           resource_filter=None):
    """Do an export of a project.

    Positional arguments:
    target - MCU that the project will compile for
    ide - the IDE or project structure to export to

    Keyword arguments:
    build - to use the compiled mbed libraries or not
    src - directory or directories that contain the source to export
    macros - extra macros to add to the project
    project_id - the name of the project
    clean - start from a clean state before exporting
    zip_proj - create a zip file or not
    ignore - list of paths to add to mbedignore
    resource_filter - can be used for filtering out resources after scan

    Returns an object of type Exporter (tools/exports/exporters.py)
    """
    project_dir, name, src, lib = setup_project(
        ide,
        target,
        bool(zip_proj),
        program=project_id,
        source_dir=src,
        build=build,
        export_path=export_path,
    )

    zip_name = name + ".zip" if zip_proj else None

    return export_project(src,
                          project_dir,
                          target,
                          ide,
                          name=name,
                          macros=macros,
                          libraries_paths=lib,
                          zip_proj=zip_name,
                          build_profile=build_profile,
                          notify=TerminalNotifier(),
                          app_config=app_config,
                          ignore=ignore,
                          resource_filter=resource_filter)
def export(target,
           ide,
           build=None,
           src=None,
           macros=None,
           project_id=None,
           zip_proj=False,
           build_profile=None,
           export_path=None,
           notify=None,
           app_config=None,
           ignore=None):
    """Do an export of a project.

    Positional arguments:
    target - MCU that the project will compile for
    ide - the IDE or project structure to export to

    Keyword arguments:
    build - to use the compiled mbed libraries or not
    src - directory or directories that contain the source to export
    macros - extra macros to add to the project
    project_id - the name of the project
    clean - start from a clean state before exporting
    zip_proj - create a zip file or not
    ignore - list of paths to add to mbedignore

    Returns an object of type Exporter (tools/exports/exporters.py)
    """
    ###################################
    # mbed Classic/2.0/libary support #

    # Find build system profile
    profile = None
    targets_json = None
    for path in src:
        profile = find_build_profile(path) or profile
        if profile:
            targets_json = join(dirname(dirname(abspath(__file__))),
                                'legacy_targets.json')
        else:
            targets_json = find_targets_json(path) or targets_json

    # Apply targets.json to active targets
    if targets_json:
        notify.info("Using targets from %s" % targets_json)
        set_targets_json_location(targets_json)

    # Apply profile to toolchains
    if profile:

        def init_hook(self):
            profile_data = get_toolchain_profile(self.name, profile)
            if not profile_data:
                return
            notify.info("Using toolchain %s profile %s" % (self.name, profile))

            for k, v in profile_data.items():
                if self.flags.has_key(k):
                    self.flags[k] = v
                else:
                    setattr(self, k, v)

        mbedToolchain.init = init_hook

    # mbed Classic/2.0/libary support #
    ###################################

    project_dir, name, src, lib = setup_project(
        ide,
        target,
        bool(zip_proj),
        program=project_id,
        source_dir=src,
        build=build,
        export_path=export_path,
    )

    zip_name = name + ".zip" if zip_proj else None

    return export_project(src,
                          project_dir,
                          target,
                          ide,
                          name=name,
                          macros=macros,
                          libraries_paths=lib,
                          zip_proj=zip_name,
                          build_profile=build_profile,
                          notify=TerminalNotifier(),
                          app_config=app_config,
                          ignore=ignore)