]> git.saurik.com Git - wxWidgets.git/blame - distrib/scripts/mac/lipo-dir.py
simplifying code, removing outdated API
[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):
867518a5
KO
27 if os.path.exists(outputfile):
28 os.remove(outputfile)
cc669f24
KO
29 linkto = os.readlink(fullpath)
30
31 if linkto.startswith(ppc_basedir):
32 linkto = linkto.replace(ppc_basedir, outputdir)
33 elif linkto.startswith(intel_basedir):
34 linkto = linkto.replace(intel_basedir, outputdir)
35
36 os.symlink(linkto, outputfile)
37
38 elif not os.path.isdir(fullpath):
39 shutil.copy(fullpath, outputfile)
40
41
42if __name__ == "__main__":
43 if len(sys.argv) < 4:
44 print "Usage: %s <ppcdir> <inteldir> <outputdir>"
45 print ""
46 print "Takes a directory containing a Mac ppc application, and a directory"
47 print "containing a Mac intel application, and merges them into a universal"
48 print "binary."
49 sys.exit(1)
50
51 ppc_basedir = sys.argv[1]
52 intel_basedir = sys.argv[2]
53 outputdir = sys.argv[3]
54
55 os.path.walk(ppc_basedir, lipo_walker, None)
867518a5 56