Mercurial > pygame
annotate make_prebuilt.py @ 1849:301bc61643a9 math_module
merged changes from trunk
| author | lorenz |
|---|---|
| date | Mon, 16 Nov 2009 18:31:40 +0000 |
| parents | 02c1e8e9c102 |
| children | db7447dd124d |
| rev | line source |
|---|---|
|
1355
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
1 import msys |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
2 from distutils.extension import read_setup_file |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
3 |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
4 import os |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
5 import re |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
6 import sys |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
7 |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
8 prebuilt_dir = 'prebuilt' |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
9 lib_subdir = 'lib' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
10 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
11 class MakePrebuiltError(Exception): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
12 pass |
|
1355
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
13 |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
14 def file_copy(src, dest): |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
15 if os.path.isdir(dest): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
16 dest = os.path.join(dest, os.path.split(src)[1]) |
|
1355
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
17 s = open(src, 'rb') |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
18 try: |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
19 d = open(dest, 'wb') |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
20 try: |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
21 d.write(s.read()) |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
22 print "%s => %s" % (src, dest) |
|
1355
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
23 finally: |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
24 d.close() |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
25 finally: |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
26 s.close() |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
27 |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
28 def find_import_libraries(path, roots): |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
29 match = re.compile(r'lib(%s)\.dll\.a$' % '|'.join(roots)).match |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
30 return [name for name in os.listdir(path) if match(name) is not None] |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
31 |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
32 def copy_dir(src, dest): |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
33 if dest == '.': |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
34 ignore, dest = os.path.split(src) |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
35 if src == dest: |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
36 raise IOError("%s: Source and destination are identical" % src) |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
37 mkdir(dest) |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
38 for name in os.listdir(src): |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
39 src_path = os.path.join(src, name) |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
40 if os.path.isfile(src_path): |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
41 file_copy(src_path, os.path.join(dest, name)) |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
42 |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
43 def confirm(message): |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
44 "ask a yes/no question, return result" |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
45 reply = msys.msys_raw_input("\n%s [Y/n]:" % message) |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
46 if reply and reply[0].lower() == 'n': |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
47 return 0 |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
48 return 1 |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
49 |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
50 created_dirs = set() |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
51 |
|
1355
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
52 def mkdir(path): |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
53 path = os.path.abspath(path) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
54 if path in created_dirs: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
55 pass |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
56 elif not os.path.exists(path): |
|
1355
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
57 os.mkdir(path) |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
58 created_dirs.add(path) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
59 elif not os.path.isdir(path): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
60 raise MakePrebuiltError("%s is not a directory" % path) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
61 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
62 def main(dest_dir=None): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
63 # Top level directories. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
64 if dest_dir is None: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
65 dest_dir = prebuilt_dir |
|
1371
63d0c0d28d59
Give make_prebuilt.py some command line argument checking
Lenard Lindstrom <len-l@telus.net>
parents:
1362
diff
changeset
|
66 if re.match(r'([A-Za-z]:){0,1}[^"<>:|?*]+$', dest_dir) is None: |
|
63d0c0d28d59
Give make_prebuilt.py some command line argument checking
Lenard Lindstrom <len-l@telus.net>
parents:
1362
diff
changeset
|
67 print "Invalid directory path name %s" % dest_dir |
|
63d0c0d28d59
Give make_prebuilt.py some command line argument checking
Lenard Lindstrom <len-l@telus.net>
parents:
1362
diff
changeset
|
68 return 1 |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
69 dest_dir = os.path.abspath(dest_dir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
70 if os.path.isdir(dest_dir): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
71 if not confirm("Directory %s already exists;\ncontinue" % dest_dir): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
72 return 1 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
73 mkdir(dest_dir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
74 m = msys.Msys() |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
75 src_dir = os.path.join(m.msys_root, 'local') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
76 prebuilt_template = os.path.abspath('prebuilt-template') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
77 dest_lib_dir = os.path.join(dest_dir, lib_subdir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
78 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
79 # Read setup file. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
80 src_file = os.path.join(prebuilt_template, 'Setup_Win.in') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
81 file_copy(src_file, dest_dir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
82 deps = read_setup_file(src_file) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
83 setup_in = open(src_file) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
84 match = re.compile('[A-Z_][A-Z0-9_]* *=(.*)').match |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
85 header_dir_pat = re.compile(' -I([^ ]+)') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
86 lib_pat = re.compile(' -l([^ ]+)') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
87 macros = [] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
88 for line in setup_in: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
89 matches = match(line) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
90 if matches is not None: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
91 flags = matches.group(1) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
92 header_dirs = header_dir_pat.findall(flags) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
93 libs = lib_pat.findall(flags) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
94 macros.append((header_dirs, libs)) |
|
1355
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
95 |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
96 # Copy DLLs. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
97 src_bin_dir = os.path.join(src_dir, 'bin') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
98 have_dlls = set() |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
99 for dep in deps: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
100 path_elements = dep.library_dirs[0].split('/') # / required by setup. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
101 dll_name = path_elements[-1] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
102 src_dll_path = os.path.join(src_bin_dir, dll_name) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
103 if os.path.exists(src_dll_path): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
104 if path_elements[0] == '.': |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
105 path_elements = path_elements[2:] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
106 else: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
107 path_elements = path_elements[1:] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
108 dest_dll_dir = dest_dir |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
109 for dir_name in path_elements[:-1]: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
110 dest_dll_dir = os.path.join(dest_dll_dir, dir_name) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
111 mkdir(dest_dll_dir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
112 file_copy(os.path.join(src_bin_dir, dll_name), |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
113 os.path.join(dest_dll_dir, dll_name)) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
114 have_dlls.add(dep.name[8:]) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
115 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
116 # Copy required import libraries only. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
117 copied_files = set() |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
118 src_lib_dir = os.path.join(src_dir, 'lib') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
119 mkdir(dest_lib_dir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
120 for ignore, libs in macros: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
121 use = False |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
122 for lib in libs: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
123 if lib in have_dlls: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
124 use = True |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
125 break |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
126 if use and lib not in copied_files: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
127 copied_files.add(lib) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
128 lib_name = 'lib%s.dll.a' % lib |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
129 src_lib_path = os.path.join(src_lib_dir, lib_name) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
130 if not os.path.exists(src_lib_path): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
131 print "Missing import library %s" % lib_name |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
132 return 1 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
133 file_copy(src_lib_path, os.path.join(dest_lib_dir, lib_name)) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
134 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
135 # Copy required header directories only. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
136 copied_dirs = set() |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
137 for header_dirs, libs in macros: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
138 use = False |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
139 for lib in libs: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
140 if lib in have_dlls: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
141 use = True |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
142 break |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
143 if use: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
144 for header_dir in header_dirs: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
145 path_elements = header_dir.split('/') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
146 if path_elements[0] == '.': |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
147 path_elements = path_elements[2:] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
148 else: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
149 path_elements = path_elements[1:] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
150 src_header_dir = os.path.join(src_dir, *path_elements) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
151 if not os.path.exists(src_header_dir): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
152 print "Missing include directory %s" % src_header_dir |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
153 return 1 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
154 dest_header_dir = dest_dir |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
155 for dir_name in path_elements: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
156 dest_header_dir = os.path.join(dest_header_dir, dir_name) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
157 mkdir(dest_header_dir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
158 if not src_header_dir in copied_dirs: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
159 copy_dir(src_header_dir, dest_header_dir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
160 copied_dirs.add(src_header_dir) |
| 1839 | 161 if 'SDL' in have_dlls: |
| 162 # For MSVC use SDL_config_win32.h in place of configure | |
| 163 # generated SDL_config.h. | |
| 164 file_copy( | |
| 165 os.path.join(src_dir, 'include', 'SDL', 'SDL_config_win32.h'), | |
| 166 os.path.join(dest_dir, 'include', 'SDL', 'SDL_config.h')) | |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
167 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
168 # msvcr71.dll linking support. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
169 src_msvcr71_dir = os.path.join(src_dir, 'lib', 'msvcr71') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
170 dest_msvcr71_dir = os.path.join(dest_dir, 'lib', 'msvcr71') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
171 copy_dir(src_msvcr71_dir, dest_msvcr71_dir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
172 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
173 # Def file bat. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
174 make_defs = open(os.path.join(dest_lib_dir, 'MakeDefs.bat'), 'w') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
175 try: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
176 make_defs.write('@echo off\n' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
177 'rem Make .def files needed for .lib file creation.\n' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
178 'rem Requires pexports.exe on the search path\n' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
179 'rem (found in altbinutils-pe as SourceForge,\n' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
180 'rem http://sourceforge.net/projects/mingwrep/).\n\n') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
181 for dep in deps: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
182 dll_name = os.path.split(dep.library_dirs[0])[1] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
183 lib = dep.name[8:] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
184 lib_name = 'lib%s.dll.a' % lib |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
185 if os.path.exists(os.path.join(dest_lib_dir, lib_name)): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
186 start = '' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
187 else: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
188 start = 'rem ' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
189 make_defs.write('%spexports %s >%s.def\n' % |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
190 (start, dll_name, lib)) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
191 finally: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
192 make_defs.close() |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
193 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
194 # Lib import files bat. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
195 make_libs = open(os.path.join(dest_lib_dir, 'MakeLibs.bat'), 'w') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
196 try: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
197 make_libs.write('@echo off\n' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
198 'rem Make .lib import libraries.\n' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
199 'rem Requires Visual C++ Studio or Toolkit.\n' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
200 'rem VCVARS32.BAT (VCVARS64.BAT (?) for 64 bit build)\n' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
201 'rem must be run first to use LIB.EXE.\n\n') |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
202 for dep in deps: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
203 dll_name = os.path.split(dep.library_dirs[0])[1] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
204 lib = dep.name[8:] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
205 lib_name = 'lib%s.dll.a' % lib |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
206 if os.path.exists(os.path.join(dest_lib_dir, lib_name)): |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
207 start = '' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
208 else: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
209 start = 'rem ' |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
210 make_libs.write('%sLIB.EXE /NOLOGO /DEF:%s.def /MACHINE:IX86 /OUT:%s.lib\n' % |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
211 (start, lib, lib)) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
212 finally: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
213 make_libs.close() |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
214 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
215 # Top level make batch file for 32 bit build. |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
216 file_copy(os.path.join(prebuilt_template, 'Make32.bat'), dest_lib_dir) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
217 |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
218 return 0 |
|
1355
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
219 |
|
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
220 if __name__ =='__main__': |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
221 dest_dir = None |
|
1355
8a239e483d1a
Preliminary Windows prebuilt make utility
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
222 if len(sys.argv) > 1: |
|
1362
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
223 dest_dir = sys.argv[1] |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
224 try: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
225 sys.exit(main(dest_dir)) |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
226 except MakePrebuiltError, e: |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
227 print "*** %s; execution halted" % e |
|
625543bfbaa0
dep build fix and polished up prebuilt make script
Lenard Lindstrom <len-l@telus.net>
parents:
1357
diff
changeset
|
228 sys.exit(1) |
