Пример #1
0
def createModule(name, location, options):
    include_path = paths.pathToInclude(location)
    seqan_path = os.path.join(include_path, 'seqan')
    module_path = os.path.join(seqan_path, name)
    header_path = os.path.join(seqan_path, '%s.h' % name)
    print 'Creating module in %s' % module_path
    if options.create_dirs and not _checkTargetPaths(module_path, options):
        return 1
    if options.create_dirs and not _checkTargetPaths(header_path, options):
        return 1
    print '  Module path is: %s' % module_path
    print '  Module header path is: %s' % header_path
    print ''
    if options.create_dirs:
        # Create directory.
        createDirectory(module_path, options.dry_run)
    if options.create_programs:
        # Copy over module header.
        source_file = paths.pathToTemplate('module_template', 'module.h')
        target_file = header_path
        replacements = buildReplacements('module', name, seqan_path,
                                         target_file, options)
        res = configureFile(target_file, source_file, replacements,
                            options.dry_run, options)
        if res: return res
        # Copy over header inside module.
        source_file = paths.pathToTemplate('module_template', 'header.h')
        target_file = os.path.join(module_path, '%s_base.h' % name)
        replacements = buildReplacements('module', name, seqan_path,
                                         target_file, options)
        res = configureFile(target_file, source_file, replacements,
                            options.dry_run, options)
        if res: return res
    return 0
Пример #2
0
def createApp(name, location, options):
    target_path = paths.pathToApp(location, name)
    print 'Creating app in %s' % target_path
    if options.create_dirs and not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    if options.create_programs:
        # Create directory.
        createDirectory(target_path, options.dry_run)
        # Copy over .cpp file for app and perform replacements.
        source_file = paths.pathToTemplate('app_template', 'app.cpp')
        target_file = os.path.join(target_path, '%s.cpp' % name)
        replacements = buildReplacements('app', name, location, target_file,
                                         options)
        res = configureFile(target_file, source_file, replacements,
                            options.dry_run, options)
        if res: return res
    if options.create_cmakelists:
        # Copy over CMakeLists.txt file for app and perform replacements.
        source_file = paths.pathToTemplate('app_template', 'CMakeLists.txt')
        target_file = os.path.join(target_path, 'CMakeLists.txt')
        replacements = buildReplacements('app', name, location, target_file,
                                         options)
        res = configureFile(target_file, source_file, replacements,
                            options.dry_run, options)
        if res: return res
    return 0
Пример #3
0
def createApp(name, location, options):
    target_path = paths.pathToApp(location, name)
    print 'Creating app in %s' % target_path
    if options.create_dirs and not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    if options.create_programs:
        # Create directory.
        createDirectory(target_path, options.dry_run)
        # Copy over .cpp file for app and perform replacements.
        source_file = paths.pathToTemplate('app_template', 'app.cpp')
        target_file = os.path.join(target_path, '%s.cpp' % name)
        replacements = buildReplacements('app', name, location, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
    if options.create_infos:
        # Copy over INFO file for app and perform replacements.
        source_file = paths.pathToTemplate('app_template', 'INFO')
        target_file = os.path.join(target_path, 'INFO')
        replacements = buildReplacements('app', name, location, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
    if options.create_cmakelists:
        # Copy over CMakeLists.txt file for app and perform replacements.
        source_file = paths.pathToTemplate('app_template', 'CMakeLists.txt')
        target_file = os.path.join(target_path, 'CMakeLists.txt')
        replacements = buildReplacements('app', name, location, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
    return 0
Пример #4
0
def createTest(name, location, options):
    target_path = paths.pathToTest(location, name)
    print 'Creating test in %s' % target_path
    if options.create_dirs and not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    if options.create_dirs:
        # Create directory.
        createDirectory(target_path, options.dry_run)
    if options.create_programs:
        # Copy over .cpp file for test and perform replacements.
        source_file = paths.pathToTemplate('test_template', 'test.cpp')
        target_file = os.path.join(target_path, 'test_%s.cpp' % name)
        replacements = buildReplacements('test', name, location, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
        # Copy over .h file for test and perform replacements.
        source_file = paths.pathToTemplate('test_template', 'test.h')
        target_file = os.path.join(target_path, 'test_%s.h' % name)
        replacements = buildReplacements('test', name, location, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
    if options.create_cmakelists:
        # Copy over CMakeLists.txt file for test and perform replacements.
        source_file = paths.pathToTemplate('test_template', 'CMakeLists.txt')
        target_file = os.path.join(target_path, 'CMakeLists.txt')
        replacements = buildReplacements('test', name, location, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
    return 0
Пример #5
0
def createModule(name, location, options):
    include_path = paths.pathToInclude(location)
    seqan_path = os.path.join(include_path, 'seqan')
    module_path = os.path.join(seqan_path, name)
    header_path = os.path.join(seqan_path, '%s.h' % name)
    print 'Creating module in %s' % module_path
    if options.create_dirs and not _checkTargetPaths(module_path, options):
        return 1
    if options.create_dirs and not _checkTargetPaths(header_path, options):
        return 1
    print '  Module path is: %s' % module_path
    print '  Module header path is: %s' % header_path
    print ''
    if options.create_dirs:
        # Create directory.
        createDirectory(module_path, options.dry_run)
    if options.create_programs:
        # Copy over module header.
        source_file = paths.pathToTemplate('module_template', 'module.h')
        target_file = header_path
        replacements = buildReplacements('module', name, seqan_path, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
        # Copy over header inside module.
        source_file = paths.pathToTemplate('module_template', 'header.h')
        target_file = os.path.join(module_path, '%s_base.h' % name)
        replacements = buildReplacements('module', name, seqan_path, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
    return 0
Пример #6
0
def createRepository(location, options):
    print 'Creating module %s' % location
    target_path = paths.pathToRepository(location)
    if options.create_dirs and not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    if options.create_dirs:
        # Create directories.
        createDirectory(target_path, options.dry_run)
        createDirectory(os.path.join(target_path, 'apps'), options.dry_run)
        createDirectory(os.path.join(target_path, 'demos'), options.dry_run)
        createDirectory(os.path.join(target_path, 'include'), options.dry_run)
        createDirectory(os.path.join(target_path, 'include', 'seqan'),
                        options.dry_run)
        createDirectory(os.path.join(target_path, 'tests'), options.dry_run)
    if options.create_cmakelists:
        # Copy over file ${REPOSITORY}/CMakeLists.txt.
        target_file = os.path.join(target_path, 'CMakeLists.txt')
        source_file = paths.pathToTemplate('repository_template',
                                           'CMakeLists.txt')
        replacements = buildReplacements('repository', location, target_path,
                                         target_file, options)
        configureFile(target_file, source_file, replacements, options.dry_run,
                      options)
        # Copy over file ${REPOSITORY}/apps/CMakeLists.txt.
        target_file = os.path.join(target_path, 'apps', 'CMakeLists.txt')
        source_file = paths.pathToTemplate('repository_template',
                                           'apps_CMakeLists.txt')
        replacements = buildReplacements('repository', location, target_path,
                                         target_file, options)
        configureFile(target_file, source_file, replacements, options.dry_run,
                      options)
        # Copy over file ${REPOSITORY}/tests/CMakeLists.txt.
        target_file = os.path.join(target_path, 'tests', 'CMakeLists.txt')
        source_file = paths.pathToTemplate('repository_template',
                                           'tests_CMakeLists.txt')
        replacements = buildReplacements('repository', location, target_path,
                                         target_file, options)
        configureFile(target_file, source_file, replacements, options.dry_run,
                      options)
        # Copy over file ${REPOSITORY}/demos/CMakeLists.txt.
        target_file = os.path.join(target_path, 'demos', 'CMakeLists.txt')
        source_file = paths.pathToTemplate('repository_template',
                                           'demos_CMakeLists.txt')
        replacements = buildReplacements('repository', location, target_path,
                                         target_file, options)
        configureFile(target_file, source_file, replacements, options.dry_run,
                      options)
    return 0
Пример #7
0
def createAppTests(location, options):
    print 'Creating app tests at %s' % location
    tests_location = os.path.join(location, 'tests')
    target_path = paths.pathToRepository(tests_location)
    if options.create_dirs and not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''

    # Create directories.
    if options.create_dirs:
        createDirectory(target_path, options.dry_run)

    # Copy over file ${APP}/tests/generate_outputs.sh
    target_file = os.path.join(target_path, 'generate_outputs.sh')
    source_file = paths.pathToTemplate('app_tests_template',
                                       'generate_outputs.sh')
    replacements = buildReplacements('app_tests', location, target_path,
                                     target_file, options)
    configureFile(target_file, source_file, replacements, options.dry_run,
                  options)
    # Copy over file ${APP}/tests/run_tests.py
    target_file = os.path.join(target_path, 'run_tests.py')
    source_file = paths.pathToTemplate('app_tests_template', 'run_tests.py')
    replacements = buildReplacements('app_tests', location, target_path,
                                     target_file, options)
    configureFile(target_file, source_file, replacements, options.dry_run,
                  options)

    print '=' * 80
    print 'Do not forget to add the tests in %s:' % os.path.join(
        location, 'CMakeLists.txt')
    print ''
    print '# Add app tests if Python interpreter could be found.'
    print 'if(PYTHONINTERP_FOUND)'
    print '  add_test(NAME app_test_%s COMMAND ${PYTHON_EXECUTABLE}' % os.path.split(
        location)[-1]
    print '    ${CMAKE_CURRENT_SOURCE_DIR}/tests/run_tests.py ${CMAKE_SOURCE_DIR}'
    print '    ${CMAKE_BINARY_DIR})'
    print 'endif(PYTHONINTERP_FOUND)'
    print '=' * 80

    return 0
Пример #8
0
def createLibraryHeader(name, location, options):
    target_path = paths.pathToHeader(location, name)
    print 'Creating library header in %s' % target_path
    if not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    # Copy over .h file for app and perform replacements.
    source_file = paths.pathToTemplate('header_template', 'library_header.h')
    target_file = os.path.join(target_path)
    replacements = buildReplacements('library_header', name, location, target_file, options)
    res = configureFile(target_file, source_file, replacements, options.dry_run, options)
    if res: return res
    return 0
Пример #9
0
def createLibraryHeader(name, location, options):
    target_path = paths.pathToHeader(location, name)
    print 'Creating library header in %s' % target_path
    if not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    # Copy over .h file for app and perform replacements.
    source_file = paths.pathToTemplate('header_template', 'library_header.h')
    target_file = os.path.join(target_path)
    replacements = buildReplacements('library_header', name, location, target_file, options)
    res = configureFile(target_file, source_file, replacements, options.dry_run, options)
    if res: return res
    return 0
Пример #10
0
def createRepository(location, options):
    print 'Creating module %s' % location
    target_path = paths.pathToRepository(location)
    if options.create_dirs and not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    if options.create_dirs:
        # Create directories.
        createDirectory(target_path, options.dry_run)
        createDirectory(os.path.join(target_path, 'apps'), options.dry_run)
        createDirectory(os.path.join(target_path, 'demos'), options.dry_run)
        createDirectory(os.path.join(target_path, 'include'), options.dry_run)
        createDirectory(os.path.join(target_path, 'include', 'seqan'), options.dry_run)
        createDirectory(os.path.join(target_path, 'tests'), options.dry_run)
    if options.create_cmakelists:
        # Copy over file ${REPOSITORY}/CMakeLists.txt.
        target_file = os.path.join(target_path, 'CMakeLists.txt')
        source_file = paths.pathToTemplate('repository_template', 'CMakeLists.txt')
        replacements = buildReplacements('repository', location, target_path, target_file, options)
        configureFile(target_file, source_file, replacements, options.dry_run, options)
        # Copy over file ${REPOSITORY}/apps/CMakeLists.txt.
        target_file = os.path.join(target_path, 'apps', 'CMakeLists.txt')
        source_file = paths.pathToTemplate('repository_template', 'apps_CMakeLists.txt')
        replacements = buildReplacements('repository', location, target_path, target_file, options)
        configureFile(target_file, source_file, replacements, options.dry_run, options)
        # Copy over file ${REPOSITORY}/tests/CMakeLists.txt.
        target_file = os.path.join(target_path, 'tests', 'CMakeLists.txt')
        source_file = paths.pathToTemplate('repository_template', 'tests_CMakeLists.txt')
        replacements = buildReplacements('repository', location, target_path, target_file, options)
        configureFile(target_file, source_file, replacements, options.dry_run, options)
        # Copy over file ${REPOSITORY}/demos/CMakeLists.txt.
        target_file = os.path.join(target_path, 'demos', 'CMakeLists.txt')
        source_file = paths.pathToTemplate('repository_template', 'demos_CMakeLists.txt')
        replacements = buildReplacements('repository', location, target_path, target_file, options)
        configureFile(target_file, source_file, replacements, options.dry_run, options)
    return 0
Пример #11
0
def createAppTests(location, options):
    print 'Creating app tests at %s' % location
    tests_location = os.path.join(location, 'tests')
    target_path = paths.pathToRepository(tests_location)
    if options.create_dirs and not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''

    # Create directories.
    if options.create_dirs:
        createDirectory(target_path, options.dry_run)

    # Copy over file ${APP}/tests/generate_outputs.sh
    target_file = os.path.join(target_path, 'generate_outputs.sh')
    source_file = paths.pathToTemplate('app_tests_template', 'generate_outputs.sh')
    replacements = buildReplacements('app_tests', location, target_path, target_file, options)
    configureFile(target_file, source_file, replacements, options.dry_run, options)
    # Copy over file ${APP}/tests/run_tests.py
    target_file = os.path.join(target_path, 'run_tests.py')
    source_file = paths.pathToTemplate('app_tests_template', 'run_tests.py')
    replacements = buildReplacements('app_tests', location, target_path, target_file, options)
    configureFile(target_file, source_file, replacements, options.dry_run, options)

    print '=' * 80
    print 'Do not forget to add the tests in %s:' % os.path.join(location, 'CMakeLists.txt')
    print ''
    print '# Add app tests if Python interpreter could be found.'
    print 'if(PYTHONINTERP_FOUND)'
    print '  add_test(NAME app_test_%s COMMAND ${PYTHON_EXECUTABLE}' % os.path.split(location)[-1]
    print '    ${CMAKE_CURRENT_SOURCE_DIR}/tests/run_tests.py ${CMAKE_SOURCE_DIR}'
    print '    ${CMAKE_BINARY_DIR})'
    print 'endif(PYTHONINTERP_FOUND)'
    print '=' * 80
    
    return 0
Пример #12
0
def createHeader(name, location, options):
    target_path = paths.pathToHeader(location, name)
    print 'Creating (non-library) header in %s' % target_path
    if not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    # Copy over .h file for app and perform replacements.
    source_file = paths.pathToTemplate('header_template', 'header.h')
    target_file = os.path.join(target_path)
    replacements = buildReplacements('header', name, location, target_file, options)
    res = configureFile(target_file, source_file, replacements, options.dry_run, options)
    if res: return res
    print 'NOTE: Do not forget to add the header to the CMakeLists.txt file!'
    return 0
Пример #13
0
def createDemo(name, location, options):
    target_path = paths.pathToDemo(location, name)
    print 'Creating demo in %s' % target_path
    if options.create_dirs and not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    if options.create_programs:
        # Copy over .cpp file for app and perform replacements.
        source_file = paths.pathToTemplate('demo_template', 'demo.cpp')
        target_file = os.path.join(target_path)
        replacements = buildReplacements('demo', name, location, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
    return 0
Пример #14
0
def createHeader(name, location, options):
    target_path = paths.pathToHeader(location, name)
    print 'Creating (non-library) header in %s' % target_path
    if not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    # Copy over .h file for app and perform replacements.
    source_file = paths.pathToTemplate('header_template', 'header.h')
    target_file = os.path.join(target_path)
    replacements = buildReplacements('header', name, location, target_file, options)
    res = configureFile(target_file, source_file, replacements, options.dry_run, options)
    if res: return res
    print 'NOTE: Do not forget to add the header to the CMakeLists.txt file!'
    return 0
Пример #15
0
def createDemo(name, location, options):
    target_path = paths.pathToDemo(location, name)
    print 'Creating demo in %s' % target_path
    if options.create_dirs and not _checkTargetPaths(target_path, options):
        return 1
    print '  Target path is: %s' % target_path
    print ''
    if options.create_programs:
        # Copy over .cpp file for app and perform replacements.
        source_file = paths.pathToTemplate('demo_template', 'demo.cpp')
        target_file = os.path.join(target_path)
        replacements = buildReplacements('demo', name, location, target_file, options)
        res = configureFile(target_file, source_file, replacements, options.dry_run, options)
        if res: return res
    return 0