VirtualBox

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

Last change on this file since 42738 was 39207, checked in by vboxsync, 13 years ago

python on lion, hacking in progress...

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1#!/usr/bin/python
2#
3# Copyright (C) 2009 Oracle Corporation
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
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", dllpre+"python"+v+dllsuff)
27
28 if bitness_magic == 1:
29 lib64 = os.path.join(p, "lib", "64", dllpre+"python"+v+dllsuff)
30 elif bitness_magic == 2:
31 lib64 = os.path.join(p, "lib64", dllpre+"python"+v+dllsuff)
32 if not os.path.isfile(lib64):
33 lib64 = lib
34 else:
35 lib64 = None
36 return [os.path.join(p, "include", "python"+v),
37 lib,
38 lib64]
39
40def print_vars(vers, known, sep, bitness_magic):
41 print "VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep)
42 if bitness_magic > 0:
43 print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)
44 else:
45 print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)
46
47
48def main(argv):
49 global prefixes
50 global versions
51
52 dllpre = "lib"
53 dllsuff = ".so"
54 bitness_magic = 0
55
56 if len(argv) > 1:
57 target = argv[1]
58 else:
59 target = sys.platform
60
61 if len(argv) > 2:
62 arch = argv[2]
63 else:
64 arch = "unknown"
65
66 if len(argv) > 3:
67 multi = int(argv[3])
68 else:
69 multi = 1
70
71 if multi == 0:
72 prefixes = ["/usr"]
73 versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1])]
74
75 if target == 'darwin':
76 ## @todo Pick up the locations from VBOX_PATH_MACOSX_SDK_10_*.
77 prefixes = ['/Developer/SDKs/MacOSX10.4u.sdk/usr',
78 '/Developer/SDKs/MacOSX10.5.sdk/usr',
79 '/Developer/SDKs/MacOSX10.6.sdk/usr',
80 '/Developer/SDKs/MacOSX10.7.sdk/usr']
81 dllsuff = '.dylib'
82
83 if target == 'solaris' and arch == 'amd64':
84 bitness_magic = 1
85
86 if target == 'linux' and arch == 'amd64':
87 bitness_magic = 2
88
89 for v in versions:
90 for p in prefixes:
91 c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
92 if c is not None:
93 known[v] = c
94 break
95 keys = known.keys()
96 # we want default to be the lowest versioned Python
97 keys.sort()
98 d = None
99 # We need separator other than newline, to sneak through $(shell)
100 sep = "|"
101 for k in keys:
102 if d is None:
103 d = k
104 vers = k.replace('.', '')
105 print_vars(vers, known[k], sep, bitness_magic)
106 if d is not None:
107 print_vars("DEF", known[d], sep, bitness_magic)
108
109if __name__ == '__main__':
110 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