| 1 |
import shutil |
| 2 |
import glob |
| 3 |
import os |
| 4 |
import pdb |
| 5 |
from subprocess import call |
| 6 |
|
| 7 |
def change_link(link,new_link, bin_file): |
| 8 |
arguments = ['-change', link, new_link, bin_file] |
| 9 |
retcode = call(['install_name_tool'] + arguments) |
| 10 |
if retcode != 0: |
| 11 |
print "Failed ---------" |
| 12 |
print "changed link:", link, "to", new_link, 'in', bin_file, 'ret:', retcode |
| 13 |
|
| 14 |
def change_id(new_id, file_name): |
| 15 |
arguments = ['-id', new_id, file_name] |
| 16 |
retcode = call(['install_name_tool'] + arguments) |
| 17 |
print "changed id:", new_id, 'in', file_name, 'ret:', retcode |
| 18 |
|
| 19 |
def adjust_link(old_link, new_link, app_name, bin_name, suffix = '64'): |
| 20 |
|
| 21 |
change_id(new_link, app_name + '/Contents/Frameworks/' + new_link[new_link.rindex('/') + 1:]) |
| 22 |
change_link(old_link, new_link, app_name + '/Contents/Frameworks/CsoundLib%s.framework/Versions/5.2/CsoundLib%s'%(suffix, suffix)) |
| 23 |
change_link(old_link, new_link, app_name + '/Contents/Frameworks/CsoundLib%s.framework/Versions/5.2/lib_csnd.dylib'%suffix) |
| 24 |
|
| 25 |
def copy_files(app_name, bin_name, doubles=True): |
| 26 |
suffix = '64' if doubles else '' |
| 27 |
cs_framework = '/Library/Frameworks/CsoundLib%s.framework'%suffix |
| 28 |
try: |
| 29 |
shutil.copytree(cs_framework, app_name + '/Contents/Frameworks/CsoundLib%s.framework'%suffix, symlinks=True ) |
| 30 |
except Exception: |
| 31 |
print "Warning: Csound Framework not copied" |
| 32 |
pass |
| 33 |
|
| 34 |
libs = { 'libsndfile.1.dylib': 'libsndfile.1.dylib', |
| 35 |
'libportaudio.2.dylib': 'libportaudio.dylib', |
| 36 |
'libportmidi.dylib': 'libportmidi.dylib', |
| 37 |
|
| 38 |
'liblo.0.dylib' : 'liblo.dylib', |
| 39 |
'libfltk.1.3.dylib' : 'libfltk.dylib', |
| 40 |
'libfltk_images.1.3.dylib' : 'libfltk_images.dylib', |
| 41 |
'libfluidsynth.1.dylib' : 'libfluidsynth.dylib', |
| 42 |
'libpng12.0.dylib' : 'libpng12.dylib', |
| 43 |
'libfluidsynth.1.dylib' : 'libfluidsynth.dylib'} |
| 44 |
|
| 45 |
lib_dir = '/usr/local/lib/' |
| 46 |
for lib, dest_lib in libs.items(): |
| 47 |
shutil.copy(lib_dir + lib, app_name + '/Contents/Frameworks/' + dest_lib ) |
| 48 |
adjust_link('/usr/local/lib/' + lib , '@executable_path/../Frameworks/' + dest_lib, app_name, bin_name, suffix) |
| 49 |
|
| 50 |
change_link('/Library/Frameworks/CsoundLib%s.framework/Versions/5.2/CsoundLib%s'%(suffix,suffix), |
| 51 |
'@executable_path/../Frameworks/CsoundLib%s.framework/Versions/5.2/CsoundLib%s'%(suffix,suffix), |
| 52 |
bin_name) |
| 53 |
change_link('/Library/Frameworks/CsoundLib%s.framework/Versions/5.2/lib_csnd.dylib'%suffix, |
| 54 |
'@executable_path/../Frameworks/CsoundLib%s.framework/Versions/5.2/lib_csnd.dylib'%suffix, |
| 55 |
bin_name) |
| 56 |
change_link('/Library/Frameworks/CsoundLib%s.framework/Versions/5.2/CsoundLib%s'%(suffix,suffix), |
| 57 |
'@executable_path/../Frameworks/CsoundLib%s.framework/Versions/5.2/CsoundLib%s'%(suffix,suffix), |
| 58 |
app_name + '/Contents/Frameworks/CsoundLib%s.framework/Versions/5.2/lib_csnd.dylib'%suffix) |
| 59 |
|
| 60 |
|
| 61 |
change_link('/usr/local/lib/libfltk.1.3.dylib', |
| 62 |
'@executable_path/../libfltk.dylib', |
| 63 |
app_name + '/Contents/Frameworks/libfltk_images.dylib') |
| 64 |
change_link('/usr/local/lib/libpng12.0.dylib', |
| 65 |
'@executable_path/../libpng12.dylib', |
| 66 |
app_name + '/Contents/Frameworks/libfltk_images.dylib') |
| 67 |
|
| 68 |
opcode_dir = '/Content/Frameworks/CsoundLib%s.framework/Resources/Opcodes%s'%(suffix,suffix) |
| 69 |
opcode_libs = glob.glob(app_name + opcode_dir + '/*.dylib') |
| 70 |
|
| 71 |
for op_lib in opcode_libs: |
| 72 |
for dep_lib, dep_dest_lib in libs.items(): |
| 73 |
change_link('/usr/local/lib/' + dep_lib , '@executable_path/../Frameworks/' + dep_dest_lib, |
| 74 |
op_lib) |
| 75 |
change_link('/usr/local/lib/' + dep_lib , '@executable_path/../Frameworks/' + dep_dest_lib, |
| 76 |
op_lib) |
| 77 |
change_link('/Library/Frameworks/CsoundLib%s.framework/Versions/5.2/CsoundLib%s'%(suffix,suffix), |
| 78 |
'@executable_path/../Frameworks/CsoundLib%s.framework/Versions/5.2/CsoundLib%s'%(suffix,suffix), |
| 79 |
op_lib) |
| 80 |
|
| 81 |
if (not os.path.exists('build')): |
| 82 |
os.mkdir("build") |
| 83 |
|
| 84 |
os.chdir("build") |
| 85 |
qute_app_dir = 'bin/' |
| 86 |
qtbindir = '/Users/acabrera/QtSDK/Desktop/Qt/4.8.1/gcc/bin/' |
| 87 |
qmake = qtbindir + "qmake" |
| 88 |
macdeployqt = qtbindir + "macdeployqt" |
| 89 |
|
| 90 |
doubles = False |
| 91 |
os.system(qmake + " /Users/acabrera/src/qutecsound/trunk/qutecsound/QuteApp/QuteApp.pro -r -spec macx-g++ CONFIG+=release CONFIG+=buildFloats") |
| 92 |
|
| 93 |
os.system("make -w") |
| 94 |
binary = 'QuteApp_' + ('d' if doubles else 'f') |
| 95 |
pdb.set_trace() |
| 96 |
os.system(macdeployqt + ' ' + qute_app_dir + binary + '.app') |
| 97 |
copy_files(qute_app_dir + binary + '.app', qute_app_dir + binary + '.app/Contents/MacOS/' + binary, doubles) |
| 98 |
if (os.path.exists(qute_app_dir + '../../../src/res/osx/' + binary + '.app')): |
| 99 |
shutil.rmtree(qute_app_dir + '../../../src/res/osx/' + binary + '.app') |
| 100 |
shutil.copytree(qute_app_dir + binary + '.app', qute_app_dir + '../../../src/res/osx/' + binary + '.app' , symlinks=True ) |
| 101 |
|
| 102 |
doubles = True |
| 103 |
os.system(qmake + " /Users/acabrera/src/qutecsound/trunk/qutecsound/QuteApp/QuteApp.pro -r -spec macx-g++ CONFIG+=release CONFIG+=buildDoubles") |
| 104 |
|
| 105 |
os.system("make -w") |
| 106 |
binary = 'QuteApp_' + ('d' if doubles else 'f') |
| 107 |
os.system(macdeployqt + ' ' + qute_app_dir + binary + '.app') |
| 108 |
copy_files(qute_app_dir + binary + '.app', qute_app_dir + binary + '.app/Contents/MacOS/' + binary, doubles) |
| 109 |
if (os.path.exists(qute_app_dir + '../../../src/res/osx/' + binary + '.app')): |
| 110 |
shutil.rmtree(qute_app_dir + '../../../src/res/osx/' + binary + '.app') |
| 111 |
shutil.copytree(qute_app_dir + binary + '.app', qute_app_dir + '../../../src/res/osx/' + binary + '.app' , symlinks=True ) |
| 112 |
|
| 113 |
|