Esempio n. 1
0
 def isstd(self):
     ## FIXME: This is an ugly hack because mac uses
     ## somewhat wonky makefiles
     if 'mac-pb' in sysinfo.family_list:
         return 0
     amfl = string.lower(self.amf())
     return bldreg.get("standard_makefile", amfl, 0)
Esempio n. 2
0
 def isstd(self):
     ## FIXME: This is an ugly hack because mac uses
     ## somewhat wonky makefiles
     if 'mac-pb' in sysinfo.family_list:
         return 0
     amfl=string.lower(self.amf())
     return bldreg.get("standard_makefile",amfl,0)
Esempio n. 3
0
def module_from_file(file):
    if module_from_file_cache.has_key(file):
        return module_from_file_cache[file]

    module = file
    parts = []
    root = [ ":", ".", "", "..","/","\\"]
    while 1:
        tmp = os.path.split(module)
        parts.append(tmp[1])
        if tmp[0] in root:
            break
        root.append(tmp[0])
        module = tmp[0]

    parts.reverse()
    mparts = []
    while parts:
        module=string.join(parts, "/")
        id=bldreg.get("bifmodule_path_to_id",string.lower(module),None)
        if id:
            module_from_file_cache[file]=id
            return id
        parts=parts[:-1]
    return None
Esempio n. 4
0
def module_from_file(file):
    if module_from_file_cache.has_key(file):
        return module_from_file_cache[file]

    module = file
    parts = []
    root = [":", ".", "", "..", "/", "\\"]
    while 1:
        tmp = os.path.split(module)
        parts.append(tmp[1])
        if tmp[0] in root:
            break
        root.append(tmp[0])
        module = tmp[0]

    parts.reverse()
    mparts = []
    while parts:
        module = string.join(parts, "/")
        id = bldreg.get("bifmodule_path_to_id", string.lower(module), None)
        if id:
            module_from_file_cache[file] = id
            return id
        parts = parts[:-1]
    return None
Esempio n. 5
0
def GetPath(sdk_name):
    """This returns the path to a named SDK"""
    path = bldreg.get("sdk",string.lower(sdk_name),None)

    if not path:
        path=os.environ.get(sdk_name, os.environ.get(string.upper(sdk_name)))

    return path
Esempio n. 6
0
def GetPath(sdk_name):
    """This returns the path to a named SDK"""
    path = bldreg.get("sdk", string.lower(sdk_name), None)

    if not path:
        path = os.environ.get(sdk_name, os.environ.get(string.upper(sdk_name)))

    return path
Esempio n. 7
0
def GetModuleDependencies(project, modname=None):
    try:
        return project.__recursive_dependency_check_done__
    except:
        if modname == None:
            module_directory = project.module_directory()
            modname = module_from_file(module_directory)
        if not modname:
            return {}
        done = {modname: 1}
        bifdeps = [modname]
        for d in bifdeps:
            for n in bldreg.get("bifmodule_deplist", d, []):
                if not done.has_key(n):
                    bifdeps.append(n)
                    done[n] = 1

        project.__recursive_dependency_check_done__ = done
        #print "dependencies %s => %s" % (repr(modname), repr(done))
        return done
Esempio n. 8
0
def GetModuleDependencies(project, modname = None):
    try:
        return project.__recursive_dependency_check_done__
    except:
        if modname == None:
            module_directory = project.module_directory()
            modname = module_from_file(module_directory)
        if not modname:
            return {}
        done = { modname:1 }
        bifdeps = [ modname ]
        for d in bifdeps:
            for n in  bldreg.get("bifmodule_deplist",d,[]):
                if not done.has_key(n):
                    bifdeps.append(n)
                    done[n]=1

        project.__recursive_dependency_check_done__ = done
        #print "dependencies %s => %s" % (repr(modname), repr(done))
        return done
Esempio n. 9
0
def CheckModuleSourceDependencies_rel(platform, project, type, paths):
    # I feel nice, so we check aginainst the recursive tree of
    # dependencies rather than against just the dependencies in this
    # module... /Hubbe

    module_directory = project.module_directory()
    modname = module_from_file(module_directory)

    if not modname:
        return

    try:
        done = project.__recursive_source_dependency_check_done__
    except:
        done = GetModuleDependencies(project, modname).copy()
        bifdeps = done.keys()

        for d in bifdeps:
            for n in bldreg.get("bifmodule_source_deplist", d, []):
                if not done.has_key(n):
                    bifdeps.append(n)
                    done[n] = 1

        project.__recursive_source_dependency_check_done__ = done

    warnings_printed = globals().get("__umake_warnings_printed_cache__", {})

    for path in paths:
        m = module_from_file_rel(project, path)
        if m:
            if not done.has_key(m):
                w = modname + ":" + m
                if not warnings_printed.has_key(w):
                    print "Warning: Missing BIF source dep %s (%s %s)" % (
                        repr(m), type, path)
                    warnings_printed[w] = 1

    globals()["__umake_warnings_printed_cache__"] = warnings_printed
Esempio n. 10
0
def CheckModuleSourceDependencies_rel(platform, project, type, paths):
    # I feel nice, so we check aginainst the recursive tree of
    # dependencies rather than against just the dependencies in this
    # module... /Hubbe

    module_directory = project.module_directory()
    modname = module_from_file(module_directory)

    if not modname:
        return

    try:
        done = project.__recursive_source_dependency_check_done__
    except:
        done = GetModuleDependencies(project, modname).copy()
        bifdeps = done.keys()

        for d in bifdeps:
            for n in bldreg.get("bifmodule_source_deplist",d,[]):
                if not done.has_key(n):
                    bifdeps.append(n)
                    done[n]=1

        project.__recursive_source_dependency_check_done__ = done

    warnings_printed = globals().get("__umake_warnings_printed_cache__",{})
        
    for path in paths:
        m = module_from_file_rel(project, path)
        if m:
            if not done.has_key(m):
                w = modname +":" + m
                if not warnings_printed.has_key(w):
                    print "Warning: Missing BIF source dep %s (%s %s)" % (repr(m), type, path)
                    warnings_printed[w]=1

    globals()["__umake_warnings_printed_cache__"]=warnings_printed
Esempio n. 11
0
def WriteDLLTab(platform, project, plugin_list):
    """Write the dlltab.cpp file, and include it in the project source list.
    The dlltab.cpp file defines a global function table used by
    pnmisc/dllaccess.cpp for loading staticly linked plugins."""

    externsection = []
    tablesection = []
    dlltypesection = []


    includes = [ ]
    
    header1 = """
/* This file is generated automatically.  Please do not edit. */
"""
    
    structs = """

typedef struct DLLMAP {
        const char * dllName;
        const char * entryPoint;
        int          pluginType;
        void *       funcptr;
} DLLMAP;

extern const DLLMAP g_dllMap [];

typedef struct DLLTYPEMAP {
        const char * dllName;
        int          pluginType;
} DLLTYPEMAP;

extern const DLLTYPEMAP g_dllTypeMap[];

    """

    for target in plugin_list:
        ## retrieve the dll type from the registry
        try:
            dll_type = bldreg.get_value('dll_type', target)
        except KeyError:
            umake_lib.fatal('cannot find [dll_type] for target %s in registry' % (target))
    
        if dll_type == 'codec':
            my_type = 'DLLTYPE_CODEC'
        elif dll_type == 'common':
            my_type = 'DLLTYPE_COMMON'
        else:
            my_type = 'DLLTYPE_PLUGIN'

        dlltypesection.append('\t{ "%s", %s },' % (target, my_type))


        ## retrieve the dll entrypoints from the registry
        try:
            exported_functions = bldreg.get_value('export', target)
        except KeyError:
            umake_lib.fatal('cannot find exported functions for target %s in registry' % (target))

        exported_function_list = string.split(exported_functions, ',')

        for symbol in exported_function_list:
            tmp =  bldreg.get("export_protos",
                              target+"::"+symbol,
                              ["", None, None])

            if type(tmp) == types.StringType:
                tmp = [ tmp, None, None ]

            args, include, path = tmp

            if include and include not in includes:
                includes.append(include)

            if path:
                project.AddModuleIncludes(path)
                
            externsection.append('STDAPI entrypoint_for_%s_%s (%s);' % (target, symbol, args))
            
            tablesection.append(
                '\t{"%s", "%s", %s, (void*)entrypoint_for_%s_%s},' % (
                    target, symbol, my_type, target, symbol))

        ## add the static target to the library list
        try:
            target_lib = bldreg.get_value('targets', target)
        except KeyError:
            umake_lib.fatal('cannot rfind [targets] path for target %s in registry' % (target))

        handle = bldreg.get("file_to_handle", target_lib, None)
        if handle:
            project.AddModuleLibraries(handle)
        else:
            umake_lib.warning("codegen couldn't find which module created '%s'" % target_lib)
            target_lib = os.path.join(project.src_root_path, target_lib)
            project.AddLibraries(target_lib)
            

    ## FIXME: these should not be hardcoded!
    includes.append("dllacces.h")
    includes.append("dllpath.h")

    dlltab = open("dlltab.cpp", "w")
    def emit(x = "", tab = dlltab) :
        tab.write(x + "\n")
                        
    emit(header1)
    for i in includes:
        emit('#include "%s"' % i)
    emit(structs) 
    emit()
    emit(string.joinfields(externsection, "\n"))
    emit()
    emit()
    emit("const DLLTYPEMAP g_dllTypeMap[] = {")
    emit(string.joinfields(dlltypesection, "\n"))
    emit("\t{NULL, 0}\n};")
    emit("const DLLMAP g_dllMap[] = {")
    emit(string.joinfields(tablesection, "\n"))
    emit("\t{NULL, NULL, 0, NULL}\n};\n")

    ## have dlltab.cpp automagicly added to the source list
    project.AddSources("dlltab.cpp")
Esempio n. 12
0
    def compile_remotely(self, dir):
        global client_manager
        if not client_manager:
            client_manager = ClientManager()

        dir = os.getcwd()
        run_nmake = 0
        cc = 0
        chaingang.chdir_lock.release()
        unlocked = 1
        try:
            ## Get a host to compile on
            import bfclient
            import bprotocol
            self.mtime_cache = {}

            amf = self.amf()
            amfl = string.lower(amf)
            std = self.isstd()

            ## DEBUG
            #print "STD[%s]=%d" % (amf, std)

            cc = client_manager.get(std)
            if not cc.is_self():
                #print "GOT REMOTE"
                t1 = time.time()
                client = cc.clientdata.client.sock

                file_hash = {}

                src_root = bldreg.get("build", "path", None)

                src_root = os.path.normpath(os.path.join(dir, src_root))
                if src_root[-1] != os.sep:
                    src_root = src_root + os.sep

                to_do = 0
                makefiles = [amf]
                for amf in makefiles:
                    file_hash[amf] = 1
                    amfl = string.lower(amf)
                    alias = bldreg.get("alias", amfl, None)
                    if alias:
                        makefiles.extend(alias)
                    else:
                        path, file = os.path.split(amf)
                        (t, SR, relpath) = \
                                self.parse_makefile(os.path.join(src_root, path),
                                                    file, file_hash, src_root)
                        to_do = to_do + t
                t2 = time.time()
                #print "Makefiles parsed in %f seconds" % (t2 - t1)
                if not to_do:
                    #print "NOTHING TO DO"
                    return (0, "")  ## Nothing to do
                else:
                    #print "Archiving files..."
                    archive_path = os.path.join(dir, "remotefiles.rna")

                    new_list = []
                    for f in file_hash.keys():
                        mt = self.mtime(os.path.join(dir, f))
                        if cc.files.get(f) != mt:
                            cc.files[f] = mt
                            new_list.append(f)

                    import archive
                    archive.RNA(archive_path, src_root, 0).Archive(new_list)

                    t3 = time.time()
                    #print "Archive done in %f seconds, building " % (t3 - t2)

                    message = bprotocol.Message("BUILD")
                    message.SetAttrib("system_id", os.environ.get("SYSTEM_ID"))
                    message.SetAttrib("chdir", relpath)
                    message.SetAttrib("target", "make")
                    message.SetAttrib("cmd",
                                      "nmake /nologo /i SUBMAKEFLAGS=/i")
                    client.SendMessage2(message, open(archive_path, "rb"))
                    msg = client.WaitForMessage2()

                    status = int(msg.attrib["retcode"])

                    t4 = time.time()

                    #print "Compile done in %f seconds, status=%d" % (t4-t3, status)
                    message = bprotocol.Message("GET FILE")
                    message.SetAttrib("path", "remote-result.rna")
                    client.SendMessage2(message)
                    msg = client.WaitForMessage2()
                    results = os.path.join(dir, "remote-result.rna")
                    client.RecieveFile(msg, open(results, "wb"))

                    client_manager.release(cc)
                    cc = 0

                    ## Get a localhost lock for the rest of this compile
                    #if status != 0:
                    #    cc=client_manager.get(0,1)
                    cc = client_manager.get(0, 1)

                    chaingang.chdir_lock.acquire()
                    unlocked = 0
                    os.chdir(dir)

                    t5 = time.time()
                    #print "Fetched file in %f seconds" % (t5-t4)

                    archive.RNA(results, src_root, 0, 0).Extract()

                    t6 = time.time()
                    #print "Decompress done in %f seconds" % (t6-t5)

                    #if status == 0:
                    #    return (0,"")

                    return self.make_objects2()

            if cc and cc.is_self():
                #print "GOT SELF"
                if unlocked:
                    chaingang.chdir_lock.acquire()
                    unlocked = 0
                    os.chdir(dir)
                #return self.low_make_all()
                return Compile.make_objects(self)

        finally:
            if cc:
                client_manager.release(cc)
            if unlocked:
                chaingang.chdir_lock.acquire()
                os.chdir(dir)
Esempio n. 13
0
    def compile_remotely(self, dir):
        global client_manager
        if not client_manager:
            client_manager=ClientManager()
    
        dir=os.getcwd()
        run_nmake=0
        cc=0
        chaingang.chdir_lock.release()
        unlocked=1
        try:
            ## Get a host to compile on
            import bfclient
            import bprotocol
            self.mtime_cache={}
    
            amf=self.amf()
            amfl=string.lower(amf)
            std=self.isstd()
    
            ## DEBUG
            #print "STD[%s]=%d" % (amf, std)
    
            cc=client_manager.get(std)
            if not cc.is_self():
                #print "GOT REMOTE"
                t1=time.time()
                client=cc.clientdata.client.sock
        
                file_hash = {}
        
                src_root=bldreg.get("build","path", None)

                src_root=os.path.normpath(os.path.join(dir, src_root))
                if src_root[-1] != os.sep:
                    src_root = src_root + os.sep
        
                to_do=0
                makefiles = [amf]
                for amf in makefiles:
                    file_hash[amf]=1
                    amfl=string.lower(amf)
                    alias=bldreg.get("alias",amfl,None)
                    if alias:
                        makefiles.extend(alias)
                    else:
                        path, file = os.path.split(amf)
                        (t, SR, relpath) = \
                                self.parse_makefile(os.path.join(src_root, path),
                                                    file, file_hash, src_root)
                        to_do=to_do+t
                t2=time.time()
                #print "Makefiles parsed in %f seconds" % (t2 - t1)
                if not to_do:
                    #print "NOTHING TO DO"
                    return (0,"")  ## Nothing to do
                else:
                    #print "Archiving files..."
                    archive_path=os.path.join(dir,"remotefiles.rna")
                    
                    new_list=[]
                    for f in file_hash.keys():
                        mt=self.mtime(os.path.join(dir, f))
                        if cc.files.get(f) != mt:
                            cc.files[f]=mt
                            new_list.append(f)

                    import archive
                    archive.RNA( archive_path, src_root, 0).Archive(new_list)

                    t3=time.time()
                    #print "Archive done in %f seconds, building " % (t3 - t2)
            
                    message=bprotocol.Message("BUILD")
                    message.SetAttrib("system_id",os.environ.get("SYSTEM_ID"))
                    message.SetAttrib("chdir", relpath)
                    message.SetAttrib("target", "make")
                    message.SetAttrib("cmd", "nmake /nologo /i SUBMAKEFLAGS=/i")
                    client.SendMessage2(message, open(archive_path,"rb"))
                    msg=client.WaitForMessage2()

                    status=int(msg.attrib["retcode"])

                    t4=time.time()

                    #print "Compile done in %f seconds, status=%d" % (t4-t3, status)            
                    message=bprotocol.Message("GET FILE")
                    message.SetAttrib("path","remote-result.rna")
                    client.SendMessage2(message)
                    msg=client.WaitForMessage2()
                    results=os.path.join(dir,"remote-result.rna")
                    client.RecieveFile(msg, open(results, "wb"))
            
                    client_manager.release(cc)
                    cc=0

                    ## Get a localhost lock for the rest of this compile
                    #if status != 0:
                    #    cc=client_manager.get(0,1)
                    cc=client_manager.get(0,1)

                    chaingang.chdir_lock.acquire()
                    unlocked=0
                    os.chdir(dir)

                    t5=time.time()
                    #print "Fetched file in %f seconds" % (t5-t4)

                    archive.RNA( results, src_root, 0, 0).Extract()

                    t6=time.time()
                    #print "Decompress done in %f seconds" % (t6-t5)

                    #if status == 0:
                    #    return (0,"")

                    return self.make_objects2()


            if cc and cc.is_self():
                #print "GOT SELF"
                if unlocked:
                    chaingang.chdir_lock.acquire()
                    unlocked=0
                    os.chdir(dir)
                #return self.low_make_all()
                return Compile.make_objects(self)

        finally:
            if cc:
               client_manager.release(cc)
            if unlocked:
               chaingang.chdir_lock.acquire()
               os.chdir(dir)
Esempio n. 14
0
    def __init__(self):
        self.bif_data_cache=None
        
        ## remember the working directory so the build
        ## system doesn't get confused by keyboard interrupts
        self.working_path = os.getcwd()

        self.cvs_tag = bldreg.get_value_default('build','cvs_tag',"")
        self.cvs_date = bldreg.get_value_default('build','cvs_date',"")

        ## default branch to build
        try:
            build_branch = os.environ["BUILD_BRANCH"]
        except KeyError:
            build_branch = "helix"
        self.build_branch = bldreg.get_value_default(
            "build", "branch", build_branch)

        ## get a list of possible build branches
        update=1

        if ( bldreg.get("build","last_cvs_date",None) == self.cvs_date and
             bldreg.get("build","last_cvs_tag",None) == self.cvs_tag and
             bldreg.get("build","last_branch",None) == self.build_branch):
            update=2

        self.branch_list = branchlist.BranchList(self.cvs_tag, self.cvs_date, update)
        self.profile_list = None


        ## Default command line
        self.history = bldreg.get_value_default('build','history', [])

        self.flags = bldreg.get_value_default('build', 'arguments', None)
        self.targets = bldreg.get_value_default('build', 'targets', None)
        self.profile = bldreg.get_value_default('build','profile', None)

        if not self.profile or not self.targets or self.flags == None:
            bif_data = self.GetBIF()
            if not bif_data:
                ## An old branch
                self.build_branch = "RealMedia"
                bif_data = self.GetBIF()
                if not bif_data:
                    branches = self.branch_list.get_list()
                    if not branches:
                        print "No BIF branches found, please configure your .buildrc!"
                        sys.exit(1)
                    self.build_branch=branches[0]
                    bif_data = self.GetBIF()
                    if not bif_data:
                        print "No BIF files found, please configure your .buildrc!"
                        sys.exit(1)
            
            if not self.profile:
                self.profile = bif_data.default_profile
                if not self.profile:
                    self.profile = "default"
                bldreg.set_value('build','profile',self.profile)

            if not self.targets:
                self.targets = string.split(bif_data.default_target)
                if not self.targets:
                    self.targets = [ "splay" ]
                bldreg.set_value('build','targets',self.targets)

            if self.flags == None:
                self.flags = []
                flags = string.split(bif_data.default_options)
                for flag in flags:
                    flag = "-t"+flag
                    if flag not in self.flags:
                        self.flags.append(flag)

                bldreg.set_value('build','arguments',self.flags)


        if not self.profile:
            self.profile="default"
            
        self.menu = [
            (self.BIFMenuOption, self.SetBIFBranch),
            (self.TargetMenuOption, self.SetTarget),
            (self.ProfileMenuOption, self.SetProfile),
            (self.BuildMenuOption, self.Build),
            ("Toggle make depend & makefiles (-e -n)", self.Toggle, "-e","-n"),
            ("Toggle release (-trelease)", self.Toggle, "-trelease"),
            ("Toggle 'make clean'  (-c)", self.Toggle, "-c"),
            ("Toggle clobber (Dangerous!) (-C)", self.Toggle, "-C"),
            ("Toggle halt-on-error (-p green)", self.Toggle, "-p","green"),
            ("Toggle verbose mode (-v)", self.Toggle, "-v"),
            ("Toggle static build (-tnodll)", self.Toggle, "-tnodll"),
            ("Checkout source for selected target now", self.CheckoutSource),
            (self.TagMenuOption, self.SetTag),
            ("Help Page (full help in build/doc/index.html)", self.Help)]
Esempio n. 15
0
    def __init__(self):
        self.bif_data_cache = None

        ## remember the working directory so the build
        ## system doesn't get confused by keyboard interrupts
        self.working_path = os.getcwd()

        self.cvs_tag = bldreg.get_value_default('build', 'cvs_tag', "")
        self.cvs_date = bldreg.get_value_default('build', 'cvs_date', "")

        ## default branch to build
        try:
            build_branch = os.environ["BUILD_BRANCH"]
        except KeyError:
            build_branch = "helix"
        self.build_branch = bldreg.get_value_default("build", "branch",
                                                     build_branch)

        ## get a list of possible build branches
        update = 1

        if (bldreg.get("build", "last_cvs_date", None) == self.cvs_date
                and bldreg.get("build", "last_cvs_tag", None) == self.cvs_tag
                and bldreg.get("build", "last_branch",
                               None) == self.build_branch):
            update = 2

        self.branch_list = branchlist.BranchList(self.cvs_tag, self.cvs_date,
                                                 update)
        self.profile_list = None

        ## Default command line
        self.history = bldreg.get_value_default('build', 'history', [])

        self.flags = bldreg.get_value_default('build', 'arguments', None)
        self.targets = bldreg.get_value_default('build', 'targets', None)
        self.profile = bldreg.get_value_default('build', 'profile', None)

        if not self.profile or not self.targets or self.flags == None:
            bif_data = self.GetBIF()
            if not bif_data:
                ## An old branch
                self.build_branch = "RealMedia"
                bif_data = self.GetBIF()
                if not bif_data:
                    branches = self.branch_list.get_list()
                    if not branches:
                        print "No BIF branches found, please configure your .buildrc!"
                        sys.exit(1)
                    self.build_branch = branches[0]
                    bif_data = self.GetBIF()
                    if not bif_data:
                        print "No BIF files found, please configure your .buildrc!"
                        sys.exit(1)

            if not self.profile:
                self.profile = bif_data.default_profile
                if not self.profile:
                    self.profile = "default"
                bldreg.set_value('build', 'profile', self.profile)

            if not self.targets:
                self.targets = string.split(bif_data.default_target)
                if not self.targets:
                    self.targets = ["splay"]
                bldreg.set_value('build', 'targets', self.targets)

            if self.flags == None:
                self.flags = []
                flags = string.split(bif_data.default_options)
                for flag in flags:
                    flag = "-t" + flag
                    if flag not in self.flags:
                        self.flags.append(flag)

                bldreg.set_value('build', 'arguments', self.flags)

        if not self.profile:
            self.profile = "default"

        self.menu = [
            (self.BIFMenuOption, self.SetBIFBranch),
            (self.TargetMenuOption, self.SetTarget),
            (self.ProfileMenuOption, self.SetProfile),
            (self.BuildMenuOption, self.Build),
            ("Toggle make depend & makefiles (-e -n)", self.Toggle, "-e",
             "-n"), ("Toggle release (-trelease)", self.Toggle, "-trelease"),
            ("Toggle 'make clean'  (-c)", self.Toggle, "-c"),
            ("Toggle clobber (Dangerous!) (-C)", self.Toggle, "-C"),
            ("Toggle halt-on-error (-p green)", self.Toggle, "-p", "green"),
            ("Toggle verbose mode (-v)", self.Toggle, "-v"),
            ("Toggle static build (-tnodll)", self.Toggle, "-tnodll"),
            ("Checkout source for selected target now", self.CheckoutSource),
            (self.TagMenuOption, self.SetTag),
            ("Help Page (full help in build/doc/index.html)", self.Help)
        ]