예제 #1
0
def STATIC_LIBRARY(name, *args):
    """
    create one StaticLibrary object
    Args:
        name : the name of .a file
        args : the variable number of SyntagTag.TagSources, SyntaxTag.TagLibs object
    """
    # to check name of result file
    if not Function.CheckName(name):
        raise BrocArgumentIllegalError(
            "name(%s) in STATIC_LIBRARY is illegal" % name)

    tag_libs = SyntaxTag.TagLibs()
    tag_sources = SyntaxTag.TagSources()
    for arg in args:
        if isinstance(arg, SyntaxTag.TagSources):
            tag_sources.AddSVs(arg.V())
        elif isinstance(arg, SyntaxTag.TagLibs):
            tag_libs.AddSVs(arg.V())
        else:
            raise BrocArgumentIllegalError("arguments (%s) in STATIC_LIBRARY is illegal" % \
                                          type(arg))
    env = Environment.GetCurrent()
    lib = Target.StaticLibrary(name, env, tag_sources, tag_libs)
    if len(tag_sources.V()):
        if not env.AppendTarget(lib):
            raise BrocArgumentIllegalError(
                "STATIC_LIBRARY(%s) exists already" % name)
    else:
        # .a file has been built already, just copy it from code directory to output directory
        lib.DoCopy()
예제 #2
0
def Sources(*ss):
    """
    create a group of Sources object
    all source file should beneathes the directory of module, if not will raise NotInSelfModuleError
    avoid containing wildcard in ss, so you can use GLOB gathering files firstly, and take the result of GLOB as ss
    Args:
        ss : a variable number of artuments, all string arguments in ss will be regarded as
             source file, the file can be .c, .cpp and so on, and the reset arguments are
             regarded as compile flags
    Returns:
        TagSources Object
    """
    tag = SyntaxTag.TagSources()
    if sys.argv[0] == 'PLANISH':
        return tag
    # FIX ME: you can extend wildcard
    files, args = _ParseNameAndArgs(*ss)
    env = Environment.GetCurrent()
    all_files = GLOB(" ".join(files)).split(' ')
    for f in all_files:
        if not f.startswith(os.path.join("broc_out", env.ModuleCVSPath())):
            f = os.path.join(os.path.dirname(env.BrocCVSPath()), f)
        src = _CreateSources(f, args)
        tag.AddSV(src)

    return tag