VirtualBox

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

Last change on this file since 47538 was 46230, checked in by vboxsync, 12 years ago

python whitespace fix

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