コード例 #1
0
def main():
    if sys.version_info[0] != 2 or sys.version_info[1] != 7:
        print(
            "Note: You are using Python %d.%d.%d. Python 3 support is new, please report any problems "
            "you encounter. Search for 'Setting the Python Interpreter' in the ESP-IDF docs if you want to use "
            "Python 2.7." % sys.version_info[:3])

    # Add actions extensions
    try:
        add_action_extensions(
            {
                "build_target": build_target,
                "reconfigure": reconfigure,
                "flash": flash,
                "monitor": monitor,
                "clean": clean,
                "fullclean": fullclean
            }, ACTIONS)
    except NameError:
        pass

    parser = argparse.ArgumentParser(
        description='ESP-IDF build management tool')
    parser.add_argument('-p',
                        '--port',
                        help="Serial port",
                        default=os.environ.get('ESPPORT', None))
    parser.add_argument('-b',
                        '--baud',
                        help="Baud rate",
                        default=os.environ.get('ESPBAUD', 460800))
    parser.add_argument('-C',
                        '--project-dir',
                        help="Project directory",
                        default=os.getcwd())
    parser.add_argument('-B',
                        '--build-dir',
                        help="Build directory",
                        default=None)
    parser.add_argument('-G',
                        '--generator',
                        help="Cmake generator",
                        choices=GENERATOR_CMDS.keys())
    parser.add_argument('-n',
                        '--no-warnings',
                        help="Disable Cmake warnings",
                        action="store_true")
    parser.add_argument('-v',
                        '--verbose',
                        help="Verbose build output",
                        action="store_true")
    parser.add_argument('-D',
                        '--define-cache-entry',
                        help="Create a cmake cache entry",
                        nargs='+')
    parser.add_argument(
        '--no-ccache',
        help=
        "Disable ccache. Otherwise, if ccache is available on the PATH then it will be used for faster builds.",
        action="store_true")
    parser.add_argument('actions',
                        help="Actions (build targets or other operations)",
                        nargs='+',
                        choices=ACTIONS.keys())

    # Add arguments extensions
    try:
        add_argument_extensions(parser)
    except NameError:
        pass

    args = parser.parse_args()

    check_environment()

    # Advanced parameter checks
    if args.build_dir is not None and os.path.realpath(
            args.project_dir) == os.path.realpath(args.build_dir):
        raise FatalError(
            "Setting the build directory to the project directory is not supported. Suggest dropping --build-dir option, the default is a 'build' subdirectory inside the project directory."
        )
    if args.build_dir is None:
        args.build_dir = os.path.join(args.project_dir, "build")
    args.build_dir = os.path.realpath(args.build_dir)

    completed_actions = set()

    def execute_action(action, remaining_actions):
        (function, dependencies, order_dependencies) = ACTIONS[action]
        # very simple dependency management, build a set of completed actions and make sure
        # all dependencies are in it
        for dep in dependencies:
            if not dep in completed_actions:
                execute_action(dep, remaining_actions)
        for dep in order_dependencies:
            if dep in remaining_actions and not dep in completed_actions:
                execute_action(dep, remaining_actions)

        if action in completed_actions:
            pass  # we've already done this, don't do it twice...
        elif function in ACTIONS:  # alias of another action
            execute_action(function, remaining_actions)
        else:
            function(action, args)

        completed_actions.add(action)

    actions = list(args.actions)
    while len(actions) > 0:
        execute_action(actions[0], actions[1:])
        actions.pop(0)

    print_closing_message(args)
コード例 #2
0
def main():
    if sys.version_info[0] != 2 or sys.version_info[1] != 7:
        print("Note: You are using Python %d.%d.%d. Python 3 support is new, please report any problems "
              "you encounter. Search for 'Setting the Python Interpreter' in the ESP-IDF docs if you want to use "
              "Python 2.7." % sys.version_info[:3])

    # Add actions extensions
    try:
        add_action_extensions({
            "build_target": build_target,
            "reconfigure": reconfigure,
            "flash": flash,
            "monitor": monitor,
            "clean": clean,
            "fullclean": fullclean
        }, ACTIONS)
    except NameError:
        pass

    parser = argparse.ArgumentParser(description='ESP-IDF build management tool')
    parser.add_argument('-p', '--port', help="Serial port",
                        default=os.environ.get('ESPPORT', None))
    parser.add_argument('-b', '--baud', help="Baud rate",
                        default=os.environ.get('ESPBAUD', 460800))
    parser.add_argument('-C', '--project-dir', help="Project directory", default=os.getcwd())
    parser.add_argument('-B', '--build-dir', help="Build directory", default=None)
    parser.add_argument('-G', '--generator', help="Cmake generator", choices=GENERATOR_CMDS.keys())
    parser.add_argument('-n', '--no-warnings', help="Disable Cmake warnings", action="store_true")
    parser.add_argument('-v', '--verbose', help="Verbose build output", action="store_true")
    parser.add_argument('-D', '--define-cache-entry', help="Create a cmake cache entry", nargs='+')
    parser.add_argument('--no-ccache', help="Disable ccache. Otherwise, if ccache is available on the PATH then it will be used for faster builds.",
                        action="store_true")
    parser.add_argument('actions', help="Actions (build targets or other operations)", nargs='+',
                        choices=ACTIONS.keys())

    # Add arguments extensions
    try:
        add_argument_extensions(parser)
    except NameError:
        pass

    args = parser.parse_args()

    check_environment()

    # Advanced parameter checks
    if args.build_dir is not None and os.path.realpath(args.project_dir) == os.path.realpath(args.build_dir):
        raise FatalError("Setting the build directory to the project directory is not supported. Suggest dropping "
                         "--build-dir option, the default is a 'build' subdirectory inside the project directory.")
    if args.build_dir is None:
        args.build_dir = os.path.join(args.project_dir, "build")
    args.build_dir = os.path.realpath(args.build_dir)

    completed_actions = set()

    def execute_action(action, remaining_actions):
        (function, dependencies, order_dependencies) = ACTIONS[action]
        # very simple dependency management, build a set of completed actions and make sure
        # all dependencies are in it
        for dep in dependencies:
            if dep not in completed_actions:
                execute_action(dep, remaining_actions)
        for dep in order_dependencies:
            if dep in remaining_actions and dep not in completed_actions:
                execute_action(dep, remaining_actions)

        if action in completed_actions:
            pass  # we've already done this, don't do it twice...
        elif function in ACTIONS:  # alias of another action
            execute_action(function, remaining_actions)
        else:
            function(action, args)

        completed_actions.add(action)

    actions = list(args.actions)
    while len(actions) > 0:
        execute_action(actions[0], actions[1:])
        actions.pop(0)

    print_closing_message(args)