⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.py

📁 C++ 编写的EROS RTOS
💻 PY
📖 第 1 页 / 共 2 页
字号:
#    global conf_targets##    conf_targets = conf_targets + [conf_name + name]#publish('target')def isoption(name):    if (conf_options.has_key(name)):        return conf_options[name]    elif (conf_primoptions.has_key(name)):        return conf_primoptions[name]    else:	error("Unknown option \"%s\"" % name)publish('isoption')def ifdevice(name):    if (config_by_name.has_key(name)): return 1    else: return 0publish('ifdevice')def pseudo_device(name, count=1):    global targdir    filename = "%s/%s.h" % (targdir,name)    out = open(filename, 'w')    out.truncate()    cpp_define = "#define N%s %d" % (string.upper(name), count)    out.write("%s\n" % cpp_define)    out.close()#    print (filename, cpp_define)publish('pseudo_device')#root = ConfTemplate("root", DC_INSTANCE, parent = None, irq = None, port = None, mem = None, sz=0)#main = ConfTemplate("mainboard", DC_BUS, parent = root, irq = None, port = None, mem = None, sz=0)#add_conf(root)#add_conf(main)cleanup_targdir()def include(name):    execfile(name, config_name_table)publish('include')#################################################### Now process the machine description file.##################################################execfile(sys.argv[1], config_name_table, {})#def ctrlr_stmt(l, cls):#    global parent_objects#    global config_table##    # Device name takes one of two forms:  cccc or cccc?#    RE_devname.match(l[1])#    devname = RE_devname.group(1)#    isunique = RE_devname.group(2)##    if len(l) < 4:#	error ("device must be attached!")##    if (l[2] != "at"):#    	error ("device statement expects 'at'")##    print parent_objects#    if (not parent_objects.has_key(l[3])):#    	error ("device must be attached to controller or bus")##    parent = parent_objects[l[3]]##    print "parent is"#    print parent##    dev = DeviceInfo(devname, parent, cls)##    dev.process_options(l[4:], cls != 'dev')##    config_table = config_table + [ dev ];#    if (cls != 'dev'):#	parent_objects[l[0]] = dev;# print config_tabledef dump_ac_types(out):    out.write("\n/* Driver structure declarations: */\n");    for i in range(len(config_table)):	tmpl = config_table[i]	out.write("extern struct Driver ac_%s;\n" % tmpl.name);def dump_table(name, tbl, out):    out.write("\nstatic int32_t %s[] = {" % name)    for p in range(len(tbl)-1):	if (p % 8 == 0):	    out.write("\n")	value = tbl[p]	if (value == -1):	    out.write(" -1,")	else:	    out.write(" 0x%x," % value)    ndx = len(tbl)-1    value = tbl[len(tbl)-1]    if (ndx % 8 == 0): out.write("\n")    if (value == -1):	out.write(" -1")    else:	out.write(" 0x%x" % value)    out.write("\n};\n")def dump_optvar(out):    for b in device_classes.keys():	if b < 0: continue;	# that one is a placeholder	if b in conf_busses:	    out.write("CONFIG_%s=1\n" % device_classes[b][3:])	else:	    out.write("CONFIG_%s=0\n" % device_classes[b][3:])    for o in conf_options.keys():        if conf_options[o]:	    out.write("OPT_%s=1\n" % string.upper(o))	else:	    out.write("OPT_%s=0\n" % string.upper(o))    for o in conf_primoptions.keys():        if conf_primoptions[o]:	    out.write("PRIMOPT_%s=1\n" % string.upper(o))	else:	    out.write("PRIMOPT_%s=0\n" % string.upper(o))def dump_options(out):    for b in device_classes.keys():	if b in conf_busses:	    out.write("OPTIONS += -DCONFIG_%s=1\n" % device_classes[b][3:])    for o in conf_options.keys():	if conf_options[o]:	    out.write("OPTIONS += -DOPTION_%s=1\n" % string.upper(o))    for o in conf_primoptions.keys():	if conf_primoptions[o]:	    out.write("OPTIONS += -D%s=1\n" % string.upper(o))    for c in conf_cpus:	out.write("OPTIONS += -DCPU_%s=1\n" % string.upper(c))    out.write("OPTIONS += -DARCH_%s=1\n" % string.upper(conf_arch))    out.write("OPTIONS += -DMACHINE_%s=1\n" % string.upper(conf_machine))def dump_options_header(out):    for b in device_classes.keys():	if b in conf_busses:	    out.write("#define CONFIG_%s 1\n" % device_classes[b][3:])    for o in conf_options.keys():	if conf_options[o]:	    out.write("#define OPTION_%s 1\n" % string.upper(o))    for o in conf_primoptions.keys():	if conf_primoptions[o]:	    out.write("#define %s 1\n" % string.upper(o))    for c in conf_cpus:	out.write("#define CPU_%s 1\n" % string.upper(c))    out.write("#define ARCH_%s 1\n" % string.upper(conf_arch))    out.write("#define MACHINE_%s 1\n" % string.upper(conf_machine))#def dump_targets(out):#    for o in conf_targets:#        out.write("TARGETS += %s\n" % o)# dump_options(sys.stdout)# print globals().keys()#################################################### Now process the file list.##################################################filenames = "files.%s" % conf_machinesrc_file_list = []obj_file_list = []config_name_table = { }################################################### We permit files to be multiply specified,## because this allows the machine-dependent## code to pull forward some files that must## be co-located for IPC performance.#################################################def file(name, condition = not None):    global src_file_list    global obj_file_list    if (condition and not name in src_file_list):	src_file_list = src_file_list + [name]	ofile = os.path.basename(name)	ofile = os.path.splitext(ofile)[0]	ofile = ofile + ".o"	ofile = "$(BUILDDIR)/" + ofile	obj_file_list = obj_file_list + [ofile]publish('file')publish('include')publish('ifdevice')publish('BT_BASE')publish('BT_PCI')publish('BT_EISA')publish('BT_ISA')publish('BT_SCSI')for i in conf_options.keys():    config_name_table[i] = conf_options[i]for i in conf_primoptions.keys():    config_name_table[i] = conf_primoptions[i]for i in conf_cpus:    config_name_table[i] = 1#for i in range(len(config_table)):#    config_name_table[config_table[i].name] = 1def publish(x):    config_name_table[x] = globals()[x]execfile(filenames, config_name_table)################################################### Cross-check the dependencies:###################################################for nm in depends_on.keys():    global depends_on    buggered = 0        for require in depends_on[nm]:        if option_value(nm) and not option_value(require):            print("Error: \"%s\" depends on \"%s\"" % (nm , require))            buggered = buggered + 1    if (buggered):        error("%d dependency errors" % buggered)################################################### Generate the makefile fragment for the files###################################################makefiletemplate = "Makefile.%s" % conf_machinemakefilename = "%s/Makefile" % targdiroptfilefilename = "%s/options.h" % targdirprint "building makefile %s" % makefilenametemplate = open(makefiletemplate, 'r')out = open(makefilename, 'w')out.truncate()for line in template.readlines():    if (line == "%config\n"):	out.write("CONFIG=%s\n" % conf_name)    #elif (line == "%targets\n"):	#dump_targets(out)    elif (line == "%optvar\n"):	dump_optvar(out)    elif (line == "%options\n"):	dump_options(out)    elif (line == "%objects\n"):	for o in obj_file_list:	    out.write("OBJECTS += %s\n" % o)    elif (line == "%depend\n"):	for f in src_file_list:	    ofile = os.path.basename(f)	    suffix =  os.path.splitext(ofile)[1]	    ofile = os.path.splitext(ofile)[0]	    out.write("$(BUILDDIR)/%s.o: $(TOP)/%s\n" % (ofile, f))	    if (suffix == ".c"):		out.write("\t$(C_BUILD)\n\n")	    elif (suffix == ".cxx"):		out.write("\t$(CXX_BUILD)\n\n")	    elif (suffix == ".S"):		out.write("\t$(ASM_BUILD)\n\n")	    out.write("$(BUILDDIR)/.%s.m: $(TOP)/%s\n" % (ofile, f))	    if (suffix == ".c"):		out.write("\t$(C_DEP)\n\n")	    elif (suffix == ".cxx"):		out.write("\t$(CXX_DEP)\n\n")	    elif (suffix == ".S"):		out.write("\t$(ASM_DEP)\n\n")    else:	out.write(line)out.close()################################################### Generate the compile-time options file#################################################optfilename = "%s/kernel-config.h" % targdirout = open(optfilename, 'w')out.truncate()dump_options_header(out)out.close

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -