1 #!/usr/bin/python 2 # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style license that can be 4 # found in the LICENSE file. 5 6 # This is the setup script for pyxinput autotest dependency, which 7 # will be called at emerge stage. 8 9 import logging 10 import os 11 12 import ctypesgencore 13 14 from autotest_lib.client.bin import utils 15 16 17 version = 1 18 19 def setup(topdir): 20 class Opt(object): 21 """Object to hold ctypesgen parseing options""" 22 def __init__(self, attrs): 23 for attr in attrs: 24 setattr(self, attr, attrs[attr]) 25 26 def gen(self): 27 """Generate outputs""" 28 desc = ctypesgencore.parser.parse(self.headers, self) 29 ctypesgencore.processor.process(desc, self) 30 ctypesgencore.printer.WrapperPrinter(self.output, self, desc) 31 32 os.chdir(os.path.join(topdir, 'src')) 33 34 # Generate xlib.py 35 opt = Opt(ctypesgencore.options.default_values) 36 opt.libraries = ['X11'] 37 opt.headers = ['/usr/include/X11/Xlib.h', 38 '/usr/include/X11/X.h', 39 '/usr/include/X11/Xutil.h'] 40 opt.output = 'xlib.py' 41 opt.other_known_names = ['None'] 42 opt.gen() 43 44 # Generate xi2.py 45 opt = Opt(ctypesgencore.options.default_values) 46 opt.libraries = ['Xi'] 47 opt.headers = ['/usr/include/X11/extensions/XI2.h', 48 '/usr/include/X11/extensions/XInput2.h'] 49 opt.output = 'xi2.py' 50 opt.other_known_names = ['None'] 51 opt.gen() 52 53 os.chdir(topdir) 54 55 pwd = os.getcwd() 56 utils.update_version(pwd + '/src', True, version, setup, pwd) 57