VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/python/gen_python_deps.py@ 28367

Last change on this file since 28367 was 28367, checked in by vboxsync, 15 years ago

python: single Python selection support in multiversion

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1#!/usr/bin/python
2#
3# Copyright (C) 2009 Sun Microsystems, Inc.
4#
5# This file is part of VirtualBox Open Source Edition (OSE), as
6# available from http://www.virtualbox.org. This file is free software;
7# you can redistribute it and/or modify it under the terms of the GNU
8# General Public License (GPL) as published by the Free Software
9# Foundation, in version 2 as it comes in the "COPYING" file of the
10# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
11# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
12#
13# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
14# Clara, CA 95054 USA or visit http://www.sun.com if you need
15# additional information or have any questions.
16#
17
18
19import os,sys
20
21versions = ["2.3", "2.4", "2.5", "2.6", "2.7", "2.8"]
22prefixes = ["/usr", "/usr/local", "/opt", "/opt/local"]
23known = {}
24
25def checkPair(p, v,dllpre,dllsuff, bitness_magic):
26 file = os.path.join(p, "include", "python"+v, "Python.h")
27 if not os.path.isfile(file):
28 return None
29
30 lib = os.path.join(p, "lib", dllpre+"python"+v+dllsuff)
31
32 if bitness_magic == 1:
33 lib64 = os.path.join(p, "lib", "64", dllpre+"python"+v+dllsuff)
34 elif bitness_magic == 2:
35 lib64 = os.path.join(p, "lib64", dllpre+"python"+v+dllsuff)
36 if not os.path.isfile(lib64):
37 lib64 = lib
38 else:
39 lib64 = None
40 return [os.path.join(p, "include", "python"+v),
41 lib,
42 lib64]
43
44def print_vars(vers, known, sep, bitness_magic):
45 print "VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep)
46 if bitness_magic > 0:
47 print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)
48 else:
49 print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)
50
51
52def main(argv):
53 global prefixes
54 global versions
55
56 dllpre = "lib"
57 dllsuff = ".so"
58 bitness_magic = 0
59
60 if len(argv) > 1:
61 target = argv[1]
62 else:
63 target = sys.platform
64
65 if len(argv) > 2:
66 arch = argv[2]
67 else:
68 arch = "unknown"
69
70 if len(argv) > 3:
71 multi = int(argv[3])
72 else:
73 multi = 1
74
75 if multi == 0:
76 prefixes = ["/usr"]
77 versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1])]
78
79 if target == 'darwin':
80 prefixes.insert(0, '/Developer/SDKs/MacOSX10.4u.sdk/usr')
81 prefixes.insert(0, '/Developer/SDKs/MacOSX10.5.sdk/usr')
82 # Python 2.3 on Darwin buildbox is bad
83 # /Developer/SDKs/MacOSX10.4u.sdk/usr/include/python2.3/pyport.h:554:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).
84 versions.remove("2.3")
85 dllsuff = '.dylib'
86
87 if target == 'solaris' and arch == 'amd64':
88 bitness_magic = 1
89
90 if target == 'linux' and arch == 'amd64':
91 bitness_magic = 2
92
93 for v in versions:
94 for p in prefixes:
95 c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
96 if c is not None:
97 known[v] = c
98 break
99 keys = known.keys()
100 # we want default to be the lowest versioned Python
101 keys.sort()
102 d = None
103 # We need separator other than newline, to sneak through $(shell)
104 sep = "|"
105 for k in keys:
106 if d is None:
107 d = k
108 vers = k.replace('.', '')
109 print_vars(vers, known[k], sep, bitness_magic)
110 if d is not None:
111 print_vars("DEF", known[d], sep, bitness_magic)
112
113if __name__ == '__main__':
114 main(sys.argv)
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette