コード例 #1
0
def regenerate_project_by_dir(project_path, suppress_showing_solution,
                              linux_build_type, pause_on_failure):
    project_name = os.path.basename(project_path.strip('\\'))
    nap_root = os.path.abspath(os.path.join(project_path, os.pardir,
                                            os.pardir))
    script_path = os.path.join(nap_root, 'tools', 'platform',
                               'regenerate_project_by_name.py')

    # Determine our Python interpreter location
    python = get_python_path()

    cmd = [python, script_path, project_name]
    # Add our build type for Linux
    if linux_build_type != None:
        cmd.append(linux_build_type)
    # If we don't want to show the solution and we weren't not on Linux specify that
    if suppress_showing_solution:
        cmd.append('--no-show')
    exit_code = call(cmd)

    # Pause to display output in case we're running from Windows Explorer / macOS Finder
    if exit_code != 0 and pause_on_failure:
        print("Press key to close...")

        # Read a char from console
        read_console_char()

    return exit_code
コード例 #2
0
def package_project_by_dir(project_path, include_napkin, zip_package, show, pause_on_package):
    project_name = os.path.basename(project_path.strip('\\'))
    nap_root = os.path.abspath(os.path.join(project_path, os.pardir, os.pardir))
    script_path = os.path.join(nap_root, 'tools', 'platform', 'package_project_by_name.py')

    # Determine our Python interpreter location
    python = get_python_path()

    # Build our command
    cmd = [python, script_path, project_name]
    if not include_napkin:
        cmd.append('--no-napkin')
    if not zip_package:
        cmd.append('--no-zip')
    if not show:
        cmd.append('--no-show')
    exit_code = call(cmd)

    # Pause to display output in case we're running from Windows Explorer / macOS Finder
    if pause_on_package:
        print("Press key to close...")

        # Read a char from console
        read_console_char()

    return exit_code
コード例 #3
0
def upgrade_project(project_name):
    # Find the project
    project_path = find_project(project_name)
    if project_path is None:
        return ERROR_MISSING_PROJECT

    script_path = os.path.join(os.path.dirname(__file__),
                               'project_and_module_updater.py')

    python = get_python_path()
    cmd = [python, script_path, 'UPGRADE_PROJECT', project_path]
    return call(cmd)
コード例 #4
0
def create_module(module_name, generate_solution):
    print("Creating module %s in user_modules/mod_%s" %
          (module_name, module_name.lower()))

    # Set our paths
    script_path = os.path.dirname(os.path.realpath(__file__))
    nap_root = os.path.abspath(os.path.join(script_path, os.pardir, os.pardir))
    cmake_template_dir = os.path.abspath(
        os.path.join(nap_root, 'cmake', 'module_creator'))
    module_path = os.path.abspath(
        os.path.join(nap_root, 'user_modules', 'mod_%s' % module_name.lower()))
    duplicate_module_path = os.path.abspath(
        os.path.join(nap_root, 'modules', 'mod_%s' % module_name.lower()))

    # Check for existing module with same name
    if os.path.exists(module_path):
        print("Error: Module with name %s already exists" % module_name)
        sys.exit(ERROR_EXISTING_MODULE)

    # Check for existing NAP module with same name
    if os.path.exists(duplicate_module_path):
        print("Error: NAP module exists with same name '%s'" % module_name)
        sys.exit(ERROR_EXISTING_MODULE)

    # Create module from template
    cmake = get_cmake_path()
    cmd = [
        cmake,
        '-DMODULE_NAME_PASCALCASE=%s' % module_name, '-P',
        'module_creator.cmake'
    ]
    if call(cmd, cwd=cmake_template_dir) != 0:
        print("Module creation failed")
        sys.exit(ERROR_CMAKE_CREATION_FAILURE)

    # Solution generation
    if generate_solution:
        print("Module created")
        print("Generating solution")

        # Determine our Python interpreter location
        python = get_python_path()

        cmd = [
            python, './tools/platform/regenerate_module_by_name.py',
            module_name.lower()
        ]
        if call(cmd, cwd=nap_root) != 0:
            print("Solution generation failed")
            sys.exit(ERROR_SOLUTION_GENERATION_FAILURE)
    else:
        print("Module created in %s" % os.path.relpath(module_path))
コード例 #5
0
def upgrade_module(module_name):
    # If module name is prefixed with mod_ remove it
    if module_name.startswith('mod_'):
        module_name = module_name[4:]

    # Find the module
    module_path = find_module(module_name)
    if module_path is None:
        return ERROR_MISSING_MODULE

    script_path = os.path.join(os.path.dirname(__file__),
                               'project_and_module_updater.py')

    python = get_python_path()
    cmd = [python, script_path, 'UPGRADE_MODULE', module_path]
    return call(cmd)
コード例 #6
0
def build_project_by_dir(project_path, build_type, pause_on_failed_build):
    project_name = os.path.basename(os.path.abspath(project_path.strip('\\')))
    nap_root = os.path.abspath(os.path.join(project_path, os.pardir,
                                            os.pardir))
    script_path = os.path.join(nap_root, 'tools', 'platform',
                               'cli_single_project_build.py')

    # Determine our Python interpreter location
    python = get_python_path()

    cmd = [python, script_path, project_name]
    if build_type != None:
        cmd.append('--build-type=%s' % build_type)
    exit_code = call(cmd)

    # Pause to display output in case we're running from Windows Explorer / macOS Finder
    if exit_code != 0 and pause_on_failed_build:
        print("Press key to close...")

        # Read a char from console
        read_console_char()

    return exit_code
コード例 #7
0
def regenerate_module_by_dir(module_path, linux_build_type=None):
    module_name = os.path.basename(module_path.strip('\\'))
    nap_root = os.path.abspath(os.path.join(module_path, os.pardir, os.pardir))
    script_path = os.path.join(nap_root, 'tools', 'platform',
                               'regenerate_module_by_name.py')

    # Determine our Python interpreter location
    python = get_python_path()

    cmd = [python, script_path, module_name]
    # Add our build type for Linux
    if linux_build_type != None:
        cmd.append(linux_build_type)
    exit_code = call(cmd)

    # Pause to display output in case we're running from Windows Explorer / macOS Finder
    if exit_code != 0 and not sys.platform.startswith('linux'):
        print("Press key to close...")

        # Read a char from console
        read_console_char()

    return exit_code
コード例 #8
0
def create_project_module(project_name, update_project_json, generate_solution,
                          show_solution):
    # Ensure project exists
    project_path = find_project(project_name, True)
    if project_path is None:
        print("Error: can't find project with name '%s'" % project_name)
        sys.exit(ERROR_MISSING_PROJECT)

    # Load camelcase project name from project.json
    module_name = get_camelcase_project_name(project_name)

    # Set our paths
    module_path = os.path.join(project_path, 'module')
    script_path = os.path.dirname(os.path.realpath(__file__))
    nap_root = os.path.abspath(os.path.join(script_path, os.pardir, os.pardir))
    cmake_template_dir = os.path.abspath(
        os.path.join(nap_root, 'cmake', 'module_creator'))
    user_module_path = os.path.abspath(
        os.path.join(nap_root, 'user_modules', 'mod_%s' % module_name.lower()))
    duplicate_module_path = os.path.abspath(
        os.path.join(nap_root, 'modules', 'mod_%s' % module_name.lower()))

    # Ensure project doesn't already have module
    if os.path.exists(module_path):
        print("Error: '%s' already has a module" % project_name)
        sys.exit(ERROR_EXISTING_MODULE)

    # Check for existing module with same name
    if os.path.exists(user_module_path):
        print("Error: User module with name %s already exists" % module_name)
        sys.exit(ERROR_EXISTING_MODULE)

    # Check for existing NAP module with same name
    if os.path.exists(duplicate_module_path):
        print("Error: NAP module exists with same name '%s'" % module_name)
        sys.exit(ERROR_EXISTING_MODULE)

    print("Creating project module mod_%s for project %s in %s" %
          (module_name.lower(), module_name, module_path))

    # Create module from template
    cmake = get_cmake_path()
    cmd = [
        cmake,
        '-DMODULE_NAME_PASCALCASE=%s' % module_name, '-DPROJECT_MODULE=1',
        '-DPROJECT_MODULE_PROJECT_PATH=%s' % project_path, '-P',
        'module_creator.cmake'
    ]
    if call(cmd, cwd=cmake_template_dir) != 0:
        print("Module creation failed")
        sys.exit(ERROR_CMAKE_CREATION_FAILURE)

    if update_project_json:
        # Update project.json
        add_module_to_project_json(project_name,
                                   'mod_%s' % module_name.lower())

        # Solution regeneration
        if generate_solution:
            print("Module created")
            print("Regenerating solution")

            # Determine our Python interpreter location
            python = get_python_path()

            cmd = [
                python, './tools/platform/regenerate_project_by_name.py',
                project_name
            ]
            if not show_solution and not sys.platform.startswith('linux'):
                cmd.append('--no-show')
            if call(cmd, cwd=nap_root) != 0:
                print("Solution generation failed")
                sys.exit(ERROR_SOLUTION_GENERATION_FAILURE)

    print("Project module created in %s" % os.path.relpath(module_path))
コード例 #9
0
ファイル: create_project.py プロジェクト: AartOdding/nap
def create_project(project_name, module_list, with_module, generate_solution,
                   show_solution):
    print("Creating project %s" % project_name)

    # Set our paths
    script_path = os.path.dirname(os.path.realpath(__file__))
    nap_root = os.path.join(script_path, os.pardir, os.pardir)

    cmake_template_dir = os.path.abspath(
        os.path.join(nap_root, 'cmake', 'project_creator'))
    project_path = os.path.abspath(
        os.path.join(nap_root, 'projects', '%s' % project_name.lower()))

    # Check for duplicate project
    if not find_project(project_name, True) is None:
        print("Error: demo, example or project exists with same name '%s'" %
              project_name)
        return ERROR_EXISTING_PROJECT

    # Create project from template
    input_module_list = module_list.lower().replace(',', ';')
    cmake = get_cmake_path()
    cmd = [
        cmake,
        '-DPROJECT_NAME_PASCALCASE=%s' % project_name,
        '-DMODULE_LIST=%s' % input_module_list, '-P', 'project_creator.cmake'
    ]
    if call(cmd, cwd=cmake_template_dir) != 0:
        print("Project creation failed")
        return ERROR_CMAKE_CREATION_FAILURE

    # Add project module on request
    if with_module:
        # Create module from template
        cmake_template_dir = os.path.abspath(
            os.path.join(nap_root, 'cmake', 'module_creator'))
        input_module_list = PROJECT_MODULE_MODULE_LIST.lower().replace(
            ',', ';')
        cmd = [
            cmake,
            '-DMODULE_NAME_PASCALCASE=%s' % project_name, '-DPROJECT_MODULE=1',
            '-DPROJECT_MODULE_PROJECT_PATH=%s' % project_path,
            '-DPROJECT_MODULE_MODULE_LIST=%s' % input_module_list, '-P',
            'module_creator.cmake'
        ]
        if call(cmd, cwd=cmake_template_dir) != 0:
            print("Project module creation failed")
            sys.exit(ERROR_CMAKE_MODULE_CREATION_FAILURE)

        # Update project.json
        add_module_to_project_json(project_name,
                                   'mod_%s' % project_name.lower())

    # Solution generation
    if generate_solution:
        print("Project created")
        print("Generating solution")

        # Determine our Python interpreter location
        python = get_python_path()

        cmd = [
            python, './tools/platform/regenerate_project_by_name.py',
            project_name
        ]
        if not show_solution and not sys.platform.startswith('linux'):
            cmd.append('--no-show')
        if call(cmd, cwd=nap_root) != 0:
            print("Solution generation failed")
            return ERROR_SOLUTION_GENERATION_FAILURE
    else:
        print("Project created in %s" % os.path.relpath(project_path))

    return 0
コード例 #10
0
ファイル: upgrade_all.py プロジェクト: AartOdding/nap
def upgrade_all():
    script_path = os.path.join(os.path.dirname(__file__),
                               'project_and_module_updater.py')
    python = get_python_path()
    cmd = [python, script_path, 'UPGRADE_ALL']
    return call(cmd)