[maemo-commits] [maemo-commits] r8242 - in projects/haf/trunk/python-dbus: . dbus
From: osantana at stage.maemo.org osantana at stage.maemo.orgDate: Tue Nov 21 20:23:03 EET 2006
- Previous message: [maemo-commits] r8241 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop src
- Next message: [maemo-commits] r8243 - projects/haf/trunk/python-dbus
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: osantana Date: 2006-11-21 20:22:58 +0200 (Tue, 21 Nov 2006) New Revision: 8242 Modified: projects/haf/trunk/python-dbus/dbus/extract.py projects/haf/trunk/python-dbus/setup.py Log: - fixed build scripts to compile in scratchbox Modified: projects/haf/trunk/python-dbus/dbus/extract.py =================================================================== --- projects/haf/trunk/python-dbus/dbus/extract.py 2006-11-21 17:03:05 UTC (rev 8241) +++ projects/haf/trunk/python-dbus/dbus/extract.py 2006-11-21 18:22:58 UTC (rev 8242) @@ -138,31 +138,31 @@ return functions class Writer: - def __init__(self, filename, enums, typedefs, functions): + def __init__(self, filename, enums, typedefs, functions, output): if not (enums or typedefs or functions): return - print 'cdef extern from "%s":' % filename + self.output = output + self.output.write('cdef extern from "%s":\n' % filename) self.output_enums(enums) self.output_typedefs(typedefs) self.output_functions(functions) - print ' pass' - print + self.output.write(' pass\n\n') def output_enums(self, enums): for enum in enums: - print ' ctypedef enum %s:' % enum[0] + self.output.write(' ctypedef enum %s:\n' % enum[0]) if enum[1] == 0: for item in enum[2]: - print ' %s' % item + self.output.write(' %s\n' % item) else: i = 0 for item in enum[2]: - print ' %s' % item -# print ' %s = 1 << %d' % (item, i) + self.output.write(' %s\n' % item) i += 1 - print + self.output.write('\n') + def output_typedefs(self, typedefs): for typedef in typedefs: if typedef.find('va_list') != -1: @@ -172,9 +172,9 @@ if parts[0] == 'struct': if parts[-2] == parts[-1]: parts = parts[:-1] - print ' ctypedef %s' % ' '.join(parts) + self.output.write(' ctypedef %s\n' % ' '.join(parts)) else: - print ' ctypedef %s' % typedef + self.output.write(' ctypedef %s\n' % typedef) def output_functions(self, functions): for func, ret, args in functions: @@ -188,36 +188,28 @@ continue if str.strip() == 'void': continue - print ' %-20s %s (%s)' % (ret, func, str) + self.output.write(' %-20s %s (%s)\n' % (ret, func, str)) -def do_buffer(name, buffer): +def do_buffer(name, buffer, output): functions = find_functions(buffer) typedefs = find_typedefs(buffer) enums = find_enums(buffer) - Writer(name, enums, typedefs, functions) + Writer(name, enums, typedefs, functions, output) -def do_header(filename, name=None): - if name == None: - name = filename - +def do_header(name, output): buffer = "" - for line in open(filename).readlines(): + for line in open(name).readlines(): if line[0] == '#': continue buffer += line - print '# -- %s -- ' % filename - do_buffer(name, buffer) + output.write('# -- %s --\n' % filename) + do_buffer(name, buffer, output) def main(filename, flags, output=None): - old_stdout = None - if output is not None: - old_stdout = sys.stdout - sys.stdout = output - if filename.endswith('.h'): - do_header(filename) + do_header(filename, output) return cppflags = ' '.join(flags) @@ -228,18 +220,13 @@ if match: filename = match.group(1) - print >>sys.stderr, "matched %s" % (filename) command = "echo '%s'|cpp %s" % (line, cppflags) - output = commands.getoutput(command) - print >>sys.stderr, "output %s" % (output) - do_buffer(filename, output) + buffer = commands.getoutput(command) + do_buffer(filename, buffer, output) else: - print line[:-1] + output.write("%s\n" % (line.rstrip())) fd.close() - if old_stdout is not None: - sys.stdout = old_stdout - if __name__ == '__main__': main(sys.argv[1], sys.argv[2:]) Modified: projects/haf/trunk/python-dbus/setup.py =================================================================== --- projects/haf/trunk/python-dbus/setup.py 2006-11-21 17:03:05 UTC (rev 8241) +++ projects/haf/trunk/python-dbus/setup.py 2006-11-21 18:22:58 UTC (rev 8242) @@ -1,5 +1,6 @@ import os import sys +from subprocess import * sys.path.append("dbus") @@ -24,79 +25,80 @@ remove("dbus/dbus_bindings.pxd") remove("dbus/dbus_bindings.c") remove("dbus/dbus_glib_bindings.c") + remove("test/dbus_python_check.pyo") remove("ChangeLog") -includedirs_flag = ['-I.'] -dbus_includes = ['.'] -dbus_glib_includes = ['.'] -pipe = os.popen3("pkg-config --cflags dbus-1") -output = pipe[1].read().strip() -error = pipe[2].read().strip() -for p in pipe: - p.close() -if error: - print "ERROR: running pkg-config (%s)" % (error) - raise SystemExit -includedirs_flag.extend(output.split()) -dbus_includes.extend([ x.replace("-I", "") for x in output.split() ]) +def run(cmd): + try: + p = Popen(' '.join(cmd), shell=True, + stdin=PIPE, stdout=PIPE, stderr=PIPE, + close_fds=True + ) + except Exception, e: + print >>sys.stderr, "ERROR: running %s (%s)" % (' '.join(cmd), e) + raise SystemExit -pipe = os.popen3("pkg-config --cflags dbus-glib-1") -output = pipe[1].read().strip() -error = pipe[2].read().strip() -for p in pipe: - p.close() -if error: - print "ERROR: running pkg-config (%s)" % (error) - raise SystemExit -includedirs_flag.extend(output.split()) -dbus_glib_includes.extend([ x.replace("-I", "") for x in output.split() ]) + return p.stdout.read().strip(), p.stderr.read().strip() -#create ChangeLog only if this is a git repo -if os.path.exists(".git"): - pipe = os.popen3("git-log --stat") - output = pipe[1].read().strip() - error = pipe[2].read().strip() - for p in pipe: - p.close() +def check_package(names, parms): + cmd = [ "pkg-config" ] + if isinstance(parms, list): + cmd += parms + else: + cmd.append(parms) + if isinstance(names, list): + cmd += names + else: + cmd.append(names) + + output, error = run(cmd) + if error: - print "ERROR: running git-log (%s)" % (error) + print >>sys.stderr, "ERROR: checking %s:\n%s" % (names, error) raise SystemExit - file = open("ChangeLog", "w") - file.writelines(output) - file.close() + return output + +includedirs_flag = ['-I.', '-Idbus/'] +dbus_includes = ['.'] +dbus_glib_includes = ['.'] dbus_libs = [] dbus_glib_libs = [] -pipe = os.popen3("pkg-config --libs-only-L dbus-1") -output = pipe[1].read().strip() -error = pipe[2].read().strip() -for p in pipe: - p.close() -if error: - print "ERROR: running pkg-config (%s)" % (error) - raise SystemExit -dbus_libs.extend([ x.replace("-L", "") for x in output.split() ]) +output = check_package("dbus-1", "--cflags").split() +dbus_includes.extend([ x.replace("-I", "") for x in output ]) +includedirs_flag.extend(output) -pipe = os.popen3("pkg-config --libs-only-L dbus-glib-1") -output = pipe[1].read().strip() -error = pipe[2].read().strip() -for p in pipe: - p.close() -if error: - print "ERROR: running pkg-config (%s)" % (error) - raise SystemExit -dbus_glib_libs.extend([ x.replace("-L", "") for x in output.split() ]) +output = check_package("dbus-1", "--libs-only-L").split() +dbus_libs.extend([ x.replace("-L", "") for x in output ]) +output = check_package("dbus-glib-1", "--cflags").split() +dbus_glib_includes.extend([ x.replace("-I", "") for x in output ]) +includedirs_flag.extend(output) + +output = check_package("dbus-glib-1", "--libs-only-L").split() +dbus_glib_libs.extend([ x.replace("-L", "") for x in output ]) + output = open("dbus/dbus_bindings.pxd", 'w') -includedirs_flag.append('-Idbus/') extract.main("dbus/dbus_bindings.pxd.in", includedirs_flag, output) output.close() +#create ChangeLog only if this is a git repo +if os.path.exists(".git"): + output, error = run(["git-log", "--stat"]) + + if error: + print "ERROR: running git-log (%s)" % (error) + raise SystemExit + + file = open("ChangeLog", "w") + file.writelines(output) + file.close() + long_desc = '''D-BUS is a message bus system, a simple way for applications to talk to one another.
- Previous message: [maemo-commits] r8241 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop src
- Next message: [maemo-commits] r8243 - projects/haf/trunk/python-dbus
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]