Exemplo n.º 1
0
def generate_headers(src_files, out_root, doc_root):
    """Generate headers with a Python methoddef array and html
    documentation tables for the listed source files.

    The list should contain tuples of names and paths:
      [(desired-method-def-name, cpp-file-path),...]

    The name is used for the generated method-def:
      static PyMethodDef <name>_methods[].

    doc_root indicates the folder where the generated
    html-documentation should be stored.

    The generated header will be named the same as the source file,
    but with .cpp stripped and -methoddef.hh appended.

    The html file will be named the same as the source-file but
    with .cpp stripped and -methods.txt appended."

    """

    if not os.path.exists(out_root):
        os.makedirs(out_root)
    did_print_heading = False
    changed = False
    for (name, files) in src_files:
        if files.__class__ == str:
            src = files
            files = (src, )
        else:
            src = files[0]

        dst = src.replace(".hh", "-methoddef.hh")
        dst = dst.replace(".cpp", "-methoddef.hh")
        dst = os.path.join(out_root, os.path.split(dst)[1])

        dst_doc = src.replace(".hh", '-methods.txt')
        dst_doc = dst_doc.replace(".cpp", '-methods.txt')
        dst_doc_filename = os.path.split(dst_doc)[1]
        dst_doc_filename = os.path.join(doc_root, dst_doc_filename)

        dst_prop_doc = src.replace(".cpp", '-properties.txt')
        dst_doc_prop_filename = os.path.split(dst_prop_doc)[1]
        dst_doc_prop_filename = os.path.join(doc_root, dst_doc_prop_filename)

        if util.changed(src, dst):
            if not did_print_heading:
                print("* Generating Python method definitions.")
                did_print_heading = True
            generate(files, dst, dst_doc_filename, dst_doc_prop_filename, name)
            changed = True
    if not changed:
        print("* Python method definitions up to date.")
def generate_headers(src_files, out_root, doc_root):
    """Generate headers with a Python methoddef array and html
    documentation tables for the listed source files.

    The list should contain tuples of names and paths:
      [(desired-method-def-name, cpp-file-path),...]

    The name is used for the generated method-def:
      static PyMethodDef <name>_methods[].

    doc_root indicates the folder where the generated
    html-documentation should be stored.

    The generated header will be named the same as the source file,
    but with .cpp stripped and -method-def.hh appended.

    The html file will be named the same as the source-file but
    with .cpp stripped and -methods.txt appended."

    """

    if not os.path.exists(out_root):
        os.makedirs(out_root)
    did_print_heading = False
    changed = False
    for (name, files) in src_files:
        if files.__class__  == str:
            src = files
            files = (src,)
        else:
            src = files[0]

        dst = src.replace(".hh", "-method-def.hh")
        dst = dst.replace(".cpp", "-method-def.hh")
        dst = os.path.join(out_root, os.path.split(dst)[1])

        dst_doc = src.replace(".hh", '-methods.txt')
        dst_doc = dst_doc.replace(".cpp", '-methods.txt')
        dst_doc_filename = os.path.split(dst_doc)[1]
        dst_doc_filename = os.path.join(doc_root, dst_doc_filename)

        dst_prop_doc = src.replace(".cpp", '-properties.txt')
        dst_doc_prop_filename = os.path.split(dst_prop_doc)[1]
        dst_doc_prop_filename = os.path.join(doc_root, dst_doc_prop_filename)

        if util.changed(src, dst):
            if not did_print_heading:
                print("* Generating Python method definitions.")
                did_print_heading = True
            generate(files, dst, dst_doc_filename, dst_doc_prop_filename, name)
            changed = True
    if not changed:
        print("* Python method definitions up to date.")
Exemplo n.º 3
0
def _modified_directly(source_files, obj_root, obj_ext):
    """Returns the cpp-files which are modified more recently than their
    object files.

    """
    modified = []
    for cpp in source_files:
        obj_file = _to_obj(obj_root, cpp, obj_ext)
        if util.changed(cpp, obj_file):
            modified.append(cpp)

    return set(modified)
Exemplo n.º 4
0
def _modified_directly(source_files, obj_root, obj_ext):
    """Returns the cpp-files which are modified more recently than their
    object files.

    """
    modified = []
    for cpp in source_files:
        obj_file = os.path.join(obj_root,
                                os.path.split(cpp)[1].replace('.cpp', obj_ext))
        if util.changed(cpp, obj_file):
            modified.append(cpp)

    return set(modified)
Exemplo n.º 5
0
def _modified_dependencies(deps, obj_root, obj_ext, ignore):
    """Returns the cpp-files for which an object file is older than a
    header it depends on.

    """
    modified_deps = []
    for incl in deps:
        for cpp in deps.get(incl, []):
            cpp = clean_file_name(cpp)

            objFile = _to_obj(obj_root, cpp, obj_ext)
            if cpp not in ignore and util.changed(incl, objFile):
                modified_deps.append(cpp)

    return set(modified_deps)
def compile_resources(faintRoot, wxRoot):
    targetFile = os.path.join(faintRoot.replace("/", "\\"), "build", "objs",
                              "faint.res")
    sourceFile = os.path.join(faintRoot.replace("/", "\\"), "faint.rc")
    if not changed(sourceFile, targetFile):
        print("Resources unchanged.")
        return targetFile

    cmd = 'rc /fo "%s" /I"%s\\include" "%s\\faint.rc"' % (targetFile, wxRoot,
                                                          faintRoot)
    resourceCompile = subprocess.Popen(cmd)
    if resourceCompile.wait() != 0:
        print("Compiling resources failed")
        exit(1)
    return targetFile
Exemplo n.º 7
0
def _modified_dependencies(deps, obj_root, obj_ext, ignore):
    """Returns the cpp-files for which an object file is older than a
    header it depends on.

    """
    modified_deps = []
    for incl in deps:
        for cpp in deps.get(incl, []):
            cpp = clean_file_name(cpp)

            objFile = _to_obj(obj_root, cpp, obj_ext)
            if cpp not in ignore and util.changed(incl, objFile):
                modified_deps.append(cpp)

    return set(modified_deps)
Exemplo n.º 8
0
def compile_resources(faintRoot, target_folder, wxRoot, out, err):
    # Fixme: Pass .rc path instead
    targetFile = os.path.join(target_folder, "faint.res")
    sourceFile = os.path.join(faintRoot.replace("/", "\\"), "graphics", "faint.rc")

    if not changed(sourceFile, targetFile):
        return targetFile

    cmd = 'rc /fo "%s" /I"%s\\include" "%s\\graphics\\faint.rc"' % (
        targetFile, wxRoot, faintRoot)
    resourceCompile = subprocess.Popen(cmd, 0, None, None, out, err)

    if resourceCompile.wait() != 0:
        print("Compiling resources failed")
        exit(1)

    return targetFile
def compile_resources(faintRoot, target_folder, wxRoot, out, err):
    # Fixme: Pass .rc path instead
    targetFile = os.path.join(target_folder, "faint.res")
    sourceFile = os.path.join(faintRoot.replace("/", "\\"), "graphics",
                              "faint.rc")

    if not changed(sourceFile, targetFile):
        return targetFile

    cmd = 'rc /fo "%s" /I"%s\\include" "%s\\graphics\\faint.rc"' % (
        targetFile, wxRoot, faintRoot)
    resourceCompile = subprocess.Popen(cmd, 0, None, None, out, err)

    if resourceCompile.wait() != 0:
        print("Compiling resources failed")
        exit(1)

    return targetFile
def generate(hh_path, help_path):
    if util.changed(__file__, hh_path):
        generate_header(hh_path)

    if util.changed(__file__, help_path):
        generate_help(help_path)
Exemplo n.º 11
0
def generate(hh_path, help_path):
    if util.changed(__file__, hh_path):
        generate_header(hh_path)

    if util.changed(__file__, help_path):
        generate_help(help_path)