def autoconf_stuff(option, item): optionu = string.upper(option) hstr = '/* automatically generated */\n' hstr = hstr + '/* ' + gendetails.gendetails() + ' */\n' mkstr = '' st = {} st['hstr'] = hstr st['mkstr'] = mkstr st['optionu'] = optionu def define(st, value, postfix=''): if value: st['hstr'] = st['hstr'] + '#define CONFIG_' + st[ 'optionu'] + postfix + ' 1\n' st['mkstr'] = st['mkstr'] + 'CONFIG_' + st[ 'optionu'] + postfix + '=y\n' else: st['hstr'] = st['hstr'] + '#undef CONFIG_' + st[ 'optionu'] + postfix + '\n' st['mkstr'] = st['mkstr'] + '#CONFIG_' + st[ 'optionu'] + postfix + ' is undefined\n' v = item.options['value'] # v is now an integer index = 0 t = item.options['type'] if t == 'bool': if v: define(st, 1) else: define(st, 0) if t == 'quad': st['hstr'] = st['hstr'] + '#define CONFIG_' + st[ 'optionu'] + '_VALUE ' + ` v ` + '\n' if v == 0: define(st, 0) else: define(st, 1) for i in range(1, 4): define(st, i <= v, '_' + ['NONE', 'SUPPORT', 'BUILD', 'NBF'][i]) if type(t) == type([]): st['hstr'] = st['hstr'] + '#define CONFIG_' + st[ 'optionu'] + '_VALUE ' + ` v ` + '\n' for i in range(0, len(t)): (valid, description, value) = t[i] define(st, i == v, '_' + value) return (st['hstr'], st['mkstr'])
def autoconf_stuff(option, item): optionu = string.upper(option) hstr = '/* automatically generated */\n' hstr = hstr + '/* '+gendetails.gendetails()+' */\n' mkstr = '' st = {} st['hstr'] = hstr st['mkstr'] = mkstr st['optionu'] = optionu def define( st, value, postfix = ''): if value: st['hstr'] = st['hstr'] + '#define CONFIG_'+st['optionu']+postfix+' 1\n' st['mkstr'] = st['mkstr'] + 'CONFIG_'+st['optionu']+postfix+'=y\n' else: st['hstr'] = st['hstr'] + '#undef CONFIG_'+st['optionu']+postfix+'\n' st['mkstr'] = st['mkstr'] + '#CONFIG_'+st['optionu']+postfix+' is undefined\n' v = item.options['value'] # v is now an integer index = 0 t = item.options['type'] if t == 'bool': if v: define(st,1) else: define(st,0) if t == 'quad': st['hstr'] = st['hstr'] + '#define CONFIG_'+st['optionu']+'_VALUE '+`v`+'\n' if v == 0: define(st,0) else: define(st,1) for i in range(1,4): define(st, i<=v, '_'+['NONE', 'SUPPORT', 'BUILD', 'NBF'][i]) if type(t) == type([]): st['hstr'] = st['hstr'] + '#define CONFIG_'+st['optionu']+'_VALUE '+`v`+'\n' for i in range(0, len(t)): (valid, description, value) = t[i] define(st, i == v, '_'+value) return (st['hstr'], st['mkstr'])
def genmakefile(item): path = item.get_path() if not path: return if item.get_make_flag('custom'): return cl = item.get_class() if cl == 'ntsc' or cl == 'primal' or not cl: sys.stderr.write('For item ' + item.get_path() + ', cannot handle class ' + ` item.get_class() ` + '\n') raise MakefileClassNotSupported, cl pathsplit = string.split(path, '/') rootrelpath = string.join(['..'] * len(pathsplit), '/') str = """ ###################################################################### # # # Makefile autogenerated by glue/genmakefile.py # # # ###################################################################### """ str = str + '# ' + gendetails.gendetails() + '\n' str = str + '# directory ' + path + '\n\n' str = str + '# build item name ' + item.get_name() + '\n\n' str = str + 'ROOT = ' + rootrelpath + '\n' if buildkindmap.has_key(cl): str = str + 'CFILES = $(wildcard *.c)\n' str = str + 'ASFILES = $(wildcard *.S)\n' if cl == 'posixprogram': str = str + 'PERSONALITY_LIBS = $(ROOT)/lib/static/posix/libposix.a\n' if item.get_make_flag('libdebug'): str = str + """ EXTRA_LIBS += $(ROOT)/lib/static/debug/libdebug.a """ if item.get_make_flag('libio'): str = str + """ EXTRA_LIBS += $(ROOT)/lib/static/io/libio.a """ if item.get_make_flag('libmesa'): str = str + """ LOCAL_INC = -I $(ROOT)/lib/static/mesa/include EXTRA_LIBS += $(ROOT)/lib/static/mesa/libmesa.a """ if item.get_make_flag('modmesa'): str = str + """ LOCAL_INC = -I $(ROOT)/mod/ws/mesa/include LOCAL_DEF = -DMESA_AS """ if item.get_make_flag('libsocket'): str = str + """ EXTRA_LIBS += $(ROOT)/lib/static/socket/libsocket.a """ if item.get_make_flag('libsunrpc'): str = str + """ LOCAL_INC = -I$(ROOT)/lib/static/sunrpc/h EXTRA_LIBS += $(ROOT)/lib/static/sunrpc/librpc.a """ ###################################################################### # bonus bits and pieces if item.get_make_flag('includedate'): str = str + """ LOCAL_OBJS = date.gen.o """ # the bin producing line itself if buildkindmap.has_key(cl): str = str + buildkindmap[cl] + ' = ' + item.get_binary_object_name( ) + '\n\n' ###################################################################### # generate subdirs stuff str = str + 'include $(ROOT)/mk/autoconf.mk\n' subdirsmap = item.get_subdirs() subdirslist = subdirsmap.keys() subdirslist.sort() for subdir in subdirslist: #print path,'has subdirectory',subdir subitem = subdirsmap[subdir] requires = subitem.options['requires'] count = 0 try: for require in requires + [subitem.name]: if type(require) == type((1, 2)): if not blueprint.db.has_key(require[0]): sys.stderr.write( 'Requirement %s of item %s is not in the database\n' % (require[0], item.name)) sys.exit(1) subitem = blueprint.db[require[0]] tail = '_' + subitem.options['type'][require[1]][2] else: if not blueprint.db.has_key(require): str = str + '# subdir %s for item %s is not available because requirement %s is missing\n' % ( subdir, item.name, require) raise BrokenRequirement subitem = blueprint.db[require] tail = '' if subitem.options.has_key('type'): if subitem.options['type'] == 'quad': tail = tail + '_BUILD' if subitem.options.has_key('associated_cpp_name'): assoc = subitem.options['associated_cpp_name'] str = str + 'ifdef CONFIG_' + assoc + tail + '\n' count = count + 1 else: str = str + '# also requires build item ' + ` require ` + ' but that option is not configurable\n' str = str + 'SUBDIRS += ' + subdir + '\n' for i in range(0, count): str = str + 'endif\n' except BrokenRequirement: pass ###################################################################### # including of other make files if item.get_make_flag('localrules'): str = str + 'include $(ROOT)/mk/local.rules.mk\n' str = str + 'include $(ROOT)/mk/rules.mk\n' ###################################################################### # autogeneration stuff if item.get_make_flag('includedate'): str = str + """ date.gen.o: FRC echo "const char * const cline_date = \\"`date`\\";" > date.gen.c $(CC) -c date.gen.c $(RM) date.gen.c """ ###################################################################### # Installation stuff if item.get_make_flag('donotinstall'): str = str + 'INSTALLNAME = donotinstall\n' if item.get_make_flag('install'): l = item.get_make_flag('install') for installitem in l: str = str + 'ifdef INSTDIR\n' str = str + ' install::\n\tcp -f ' + installitem + ' $(INSTDIR)\n\n' str = str + ' installmost:: $(INSTDIR)/' + installitem + '\n\n' str = str + ' $(INSTDIR)/' + installitem + ': ' + installitem + '\n\tcp -f ' + installitem + ' $(INSTDIR)\n' str = str + 'endif\n' ###################################################################### # possibly write out the makefile buildutils.generate(treeinfo.build_tree_dir + '/' + path + '/Makefile', str) # succeeded return 1
namespaces[namespace][entry] = (item, symbol) Verbosity("") for item in blobdirlist.values(): for (filename, handlename, namespacename) in item.get_bloblist(): namespaces["nprimal"]["blob>" + namespacename] = (item, handlename) o = open(sys.argv[1], "w") if len(sys.argv) == 3: depfilename = sys.argv[2] else: depfilename = sys.argv[1] + ".d" depo = open(depfilename, "w") depo.write(sys.argv[1] + " : " + string.join(deps, " ")) o.write("# This file is autogenerated by gennbf.py; do not edit\n") o.write("# " + gendetails.gendetails() + "\n") # the string to add on to all paths relpath = "../../../" # the stuff we have to have o.write("ntsc " + relpath + ntsc.get_path() + "/" + ntsc.get_binary_object_name() + "\n") # write out lines to alias all the items # write out the modules, putting ones in reqstartorder at the start # reqstatorder = ['NemesisVPix86', 'libc', 'TrivWr'] reqstatorder = [] outsofar = {} outputorder = [] for reqpos in reqstatorder:
def genmakefile(item): path = item.get_path() if not path: return if item.get_make_flag('custom'): return cl = item.get_class() if cl == 'ntsc' or cl == 'primal' or not cl: sys.stderr.write('For item '+item.get_path()+', cannot handle class '+`item.get_class()`+'\n') raise MakefileClassNotSupported,cl pathsplit = string.split(path, '/') rootrelpath = string.join(['..']* len(pathsplit), '/') str = """ ###################################################################### # # # Makefile autogenerated by glue/genmakefile.py # # # ###################################################################### """ str = str + '# '+gendetails.gendetails() + '\n' str = str + '# directory '+path+'\n\n' str = str + '# build item name '+item.get_name()+'\n\n' str = str + 'ROOT = ' + rootrelpath + '\n' if buildkindmap.has_key(cl): str = str + 'CFILES = $(wildcard *.c)\n' str = str + 'ASFILES = $(wildcard *.S)\n' if cl == 'posixprogram': str = str + 'PERSONALITY_LIBS = $(ROOT)/lib/static/posix/libposix.a\n' if item.get_make_flag('libdebug'): str = str + """ EXTRA_LIBS += $(ROOT)/lib/static/debug/libdebug.a """ if item.get_make_flag('libio'): str = str + """ EXTRA_LIBS += $(ROOT)/lib/static/io/libio.a """ if item.get_make_flag('libmesa'): str = str + """ LOCAL_INC = -I $(ROOT)/lib/static/mesa/include EXTRA_LIBS += $(ROOT)/lib/static/mesa/libmesa.a """ if item.get_make_flag('modmesa'): str = str + """ LOCAL_INC = -I $(ROOT)/mod/ws/mesa/include LOCAL_DEF = -DMESA_AS """ if item.get_make_flag('libsocket'): str = str + """ EXTRA_LIBS += $(ROOT)/lib/static/socket/libsocket.a """ if item.get_make_flag('libsunrpc'): str = str + """ LOCAL_INC = -I$(ROOT)/lib/static/sunrpc/h EXTRA_LIBS += $(ROOT)/lib/static/sunrpc/librpc.a """ ###################################################################### # bonus bits and pieces if item.get_make_flag('includedate'): str = str + """ LOCAL_OBJS = date.gen.o """ # the bin producing line itself if buildkindmap.has_key(cl): str = str + buildkindmap[cl] + ' = '+item.get_binary_object_name() + '\n\n' ###################################################################### # generate subdirs stuff str = str + 'include $(ROOT)/mk/autoconf.mk\n' subdirsmap = item.get_subdirs() subdirslist = subdirsmap.keys() subdirslist.sort() for subdir in subdirslist: #print path,'has subdirectory',subdir subitem = subdirsmap[subdir] requires = subitem.options['requires'] count = 0 try: for require in requires + [subitem.name]: if type(require) == type((1,2)): if not blueprint.db.has_key(require[0]): sys.stderr.write('Requirement %s of item %s is not in the database\n'% (require[0], item.name)) sys.exit(1) subitem = blueprint.db[require[0]] tail = '_'+subitem.options['type'][require[1]][2] else: if not blueprint.db.has_key(require): str = str + '# subdir %s for item %s is not available because requirement %s is missing\n' % (subdir, item.name, require) raise BrokenRequirement subitem = blueprint.db[require] tail = '' if subitem.options.has_key('type'): if subitem.options['type'] == 'quad': tail = tail + '_BUILD' if subitem.options.has_key('associated_cpp_name'): assoc = subitem.options['associated_cpp_name'] str = str + 'ifdef CONFIG_'+assoc+tail+'\n' count = count + 1 else: str = str + '# also requires build item '+`require`+' but that option is not configurable\n' str = str + 'SUBDIRS += '+subdir+'\n' for i in range(0,count): str = str + 'endif\n' except BrokenRequirement: pass ###################################################################### # including of other make files if item.get_make_flag('localrules'): str = str + 'include $(ROOT)/mk/local.rules.mk\n' str = str + 'include $(ROOT)/mk/rules.mk\n' ###################################################################### # autogeneration stuff if item.get_make_flag('includedate'): str = str + """ date.gen.o: FRC echo "const char * const cline_date = \\"`date`\\";" > date.gen.c $(CC) -c date.gen.c $(RM) date.gen.c """ ###################################################################### # Installation stuff if item.get_make_flag('donotinstall'): str = str + 'INSTALLNAME = donotinstall\n' if item.get_make_flag('install'): l = item.get_make_flag('install') for installitem in l: str = str + 'ifdef INSTDIR\n' str = str + ' install::\n\tcp -f '+installitem+' $(INSTDIR)\n\n' str = str + ' installmost:: $(INSTDIR)/'+installitem+'\n\n' str = str + ' $(INSTDIR)/'+installitem+': '+installitem+'\n\tcp -f '+installitem+' $(INSTDIR)\n' str = str + 'endif\n' ###################################################################### # possibly write out the makefile buildutils.generate(treeinfo.build_tree_dir+ '/' +path + '/Makefile', str) # succeeded return 1
'optionu'] + '_VALUE ' + ` v ` + '\n' for i in range(0, len(t)): (valid, description, value) = t[i] define(st, i == v, '_' + value) return (st['hstr'], st['mkstr']) if not os.path.isdir(build_tree_dir + '/h/autoconf'): os.mkdir(build_tree_dir + '/h/autoconf') ks = [] for item in blueprint.items: if item.options.has_key('associated_cpp_name'): ks.append((item, item.options['associated_cpp_name'])) fullmkstr = '#autogenerated by ' + gendetails.gendetails() + '\n' for (item, configoption) in ks: try: (hstr, mkstr) = autoconf_stuff(configoption, item) fullmkstr = fullmkstr + mkstr buildutils.generate( build_tree_dir + '/h/autoconf/' + string.lower(configoption) + '.h', hstr) except KeyError: sys.stderr.write('Warning; no blueprint data for ' + ` configoption ` + '\n') for item in blueprint.items: if item.options.has_key('path'): if item.options.has_key('makevars'): for key in item['makevars'].keys():
if type(t) == type([]): st['hstr'] = st['hstr'] + '#define CONFIG_'+st['optionu']+'_VALUE '+`v`+'\n' for i in range(0, len(t)): (valid, description, value) = t[i] define(st, i == v, '_'+value) return (st['hstr'], st['mkstr']) if not os.path.isdir(build_tree_dir+'/h/autoconf'): os.mkdir(build_tree_dir+'/h/autoconf') ks = [] for item in blueprint.items: if item.options.has_key('associated_cpp_name'): ks.append( (item, item.options['associated_cpp_name'])) fullmkstr = '#autogenerated by '+gendetails.gendetails()+'\n' for (item,configoption) in ks: try: (hstr, mkstr) = autoconf_stuff(configoption, item) fullmkstr = fullmkstr + mkstr buildutils.generate(build_tree_dir+'/h/autoconf/'+string.lower(configoption)+'.h', hstr) except KeyError: sys.stderr.write('Warning; no blueprint data for '+`configoption`+'\n') for item in blueprint.items: if item.options.has_key('path'): if item.options.has_key('makevars'): for key in item['makevars'].keys(): fullmkstr = fullmkstr + key+'_'+item.options['path']+'\t+= '+item['makevars'][key]+'\n'
namespaces[namespace][entry] = (item, symbol) Verbosity('') for item in blobdirlist.values(): for (filename, handlename, namespacename) in item.get_bloblist(): namespaces['nprimal']['blob>'+namespacename] = (item, handlename) o = open(sys.argv[1], 'w') if len(sys.argv)==3: depfilename = sys.argv[2] else: depfilename = sys.argv[1]+'.d' depo = open(depfilename, 'w') depo.write(sys.argv[1] + ' : ' + string.join(deps, ' ')) o.write('# This file is autogenerated by gennbf.py; do not edit\n') o.write('# '+gendetails.gendetails()+'\n') # the string to add on to all paths relpath = '../../../' # the stuff we have to have o.write('ntsc '+relpath+ntsc.get_path()+'/'+ntsc.get_binary_object_name()+'\n') # write out lines to alias all the items # write out the modules, putting ones in reqstartorder at the start #reqstatorder = ['NemesisVPix86', 'libc', 'TrivWr'] reqstatorder = [] outsofar = {} outputorder = [] for reqpos in reqstatorder: