]> git.saurik.com Git - wxWidgets.git/blame - distrib/scripts/mac/lipo-dir.py
compilation fix for ASCII STL build (#9661)
[wxWidgets.git] / distrib / scripts / mac / lipo-dir.py
CommitLineData
cc669f24
KO
1import os, sys, shutil
2
3outputdir = "."
4ppc_basedir = "."
5intel_basedir = "."
6
7def lipo_walker(data, dirname, names):
8 global outputdir
9 global ppc_basedir
10 global intel_basedir
11
12 for name in names:
13 fullpath = os.path.join(dirname, name)
14 intel_fullpath = fullpath.replace(ppc_basedir, intel_basedir)
15 outputfile = fullpath.replace(ppc_basedir, outputdir)
16 outdir = os.path.dirname(outputfile)
17 if not os.path.exists(outdir):
18 os.makedirs(outdir)
19
20 # this call will only succeed if the file is a binary that can
21 # be lipoed.
22 if not os.path.islink(fullpath) and os.system("lipo -info %s" % fullpath) == 0:
23 if os.system("lipo -output %s -create %s %s" % (outputfile, fullpath, intel_fullpath)) == 0:
24 print "Successfully created %s" % outputfile
25 else:
26 if os.path.islink(fullpath):
27 linkto = os.readlink(fullpath)
28
29 if linkto.startswith(ppc_basedir):
30 linkto = linkto.replace(ppc_basedir, outputdir)
31 elif linkto.startswith(intel_basedir):
32 linkto = linkto.replace(intel_basedir, outputdir)
33
34 os.symlink(linkto, outputfile)
35
36 elif not os.path.isdir(fullpath):
37 shutil.copy(fullpath, outputfile)
38
39
40if __name__ == "__main__":
41 if len(sys.argv) < 4:
42 print "Usage: %s <ppcdir> <inteldir> <outputdir>"
43 print ""
44 print "Takes a directory containing a Mac ppc application, and a directory"
45 print "containing a Mac intel application, and merges them into a universal"
46 print "binary."
47 sys.exit(1)
48
49 ppc_basedir = sys.argv[1]
50 intel_basedir = sys.argv[2]
51 outputdir = sys.argv[3]
52
53 os.path.walk(ppc_basedir, lipo_walker, None)
54