VirtualBox

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

Last change on this file since 50477 was 48282, checked in by vboxsync, 11 years ago

32-bit main API on 64-bit solaris.

  • 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"""
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",]
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 print "VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep)
47 else:
48 print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)
49
50
51def main(argv):
52 global prefixes
53 global versions
54
55 dllpre = "lib"
56 dllsuff = ".so"
57 bitness_magic = 0
58
59 if len(argv) > 1:
60 target = argv[1]
61 else:
62 target = sys.platform
63
64 if len(argv) > 2:
65 arch = argv[2]
66 else:
67 arch = "unknown"
68
69 if len(argv) > 3:
70 multi = int(argv[3])
71 else:
72 multi = 1
73
74 if multi == 0:
75 prefixes = ["/usr"]
76 versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1])]
77
78 if target == 'darwin':
79 ## @todo Pick up the locations from VBOX_PATH_MACOSX_SDK_10_*.
80 prefixes = ['/Developer/SDKs/MacOSX10.4u.sdk/usr',
81 '/Developer/SDKs/MacOSX10.5.sdk/usr',
82 '/Developer/SDKs/MacOSX10.6.sdk/usr',
83 '/Developer/SDKs/MacOSX10.7.sdk/usr']
84 dllsuff = '.dylib'
85
86 if target == 'solaris' and arch == 'amd64':
87 bitness_magic = 1
88
89 if target == 'linux' and arch == 'amd64':
90 bitness_magic = 2
91
92 for v in versions:
93 for p in prefixes:
94 c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
95 if c is not None:
96 known[v] = c
97 break
98 keys = known.keys()
99 # we want default to be the lowest versioned Python
100 keys.sort()
101 d = None
102 # We need separator other than newline, to sneak through $(shell)
103 sep = "|"
104 for k in keys:
105 if d is None:
106 d = k
107 vers = k.replace('.', '')
108 print_vars(vers, known[k], sep, bitness_magic)
109 if d is not None:
110 print_vars("DEF", known[d], sep, bitness_magic)
111
112if __name__ == '__main__':
113 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