From 1cb2e36350ef7e3221f818f72b8cc9f7546c3c37 Mon Sep 17 00:00:00 2001
From: Marco Biasini <marco.biasini@unibas.ch>
Date: Fri, 1 Jun 2012 10:27:52 +0200
Subject: [PATCH] add support for minimalistic OST standalone on MacOS X

---
 cmake_support/OST.cmake    |  2 +-
 deployment/macos/deploy.py | 10 +++++++--
 deployment/macos/deps.py   | 42 +++++++++++++++++++++++++-------------
 3 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/cmake_support/OST.cmake b/cmake_support/OST.cmake
index ce0ee563e..3fd6a45f3 100644
--- a/cmake_support/OST.cmake
+++ b/cmake_support/OST.cmake
@@ -303,7 +303,7 @@ macro(executable)
     message(FATAL_ERROR "invalid use of executable(): a name must be provided")
   endif()
   add_executable(${_ARG_NAME} ${_ARG_SOURCES})
-  if (APPLE AND NOT _ARG_NO_RPATH AND NOT _ARG_STATIC)
+  if (APPLE AND NOT _ARG_NO_RPATH AND NOT ENABLE_STATIC)
     set_target_properties(${_ARG_NAME} PROPERTIES
                           LINK_FLAGS "-Wl,-rpath,@loader_path/../lib")
   endif()
diff --git a/deployment/macos/deploy.py b/deployment/macos/deploy.py
index 51246c532..82a20a066 100644
--- a/deployment/macos/deploy.py
+++ b/deployment/macos/deploy.py
@@ -10,12 +10,18 @@ p.add_option('--no_rpath', action='store_true',
              default=False)
 p.add_option('--macports_workaround', action='store_true', default=False)
 p.add_option('--dmg', action='store_true', default=False)
+p.add_option('--no-gui', action='store_true', default=False)
 opts, args=p.parse_args()
 deps.make_standalone('../../stage', 'standalone', True, 
                      opts.no_rpath, 
-                     macports_workaround=opts.macports_workaround)
+                     macports_workaround=opts.macports_workaround,
+                     no_gui=opts.no_gui)
 if os.path.exists('DNG.app'):
   shutil.rmtree('DNG.app')
+if opts.no_gui:
+  out_dir='ost-%s' % ost.VERSION
+  shutil.move('standalone', out_dir)
+  sys.exit(0)
 bundle.create_bundle('DNG', opts.bundle)
 if opts.bundle:
   shutil.copytree('../../examples', 'DNG.app/Contents/examples')
@@ -23,4 +29,4 @@ if opts.bundle:
   os.system('rm -rf DNG.app/Contents/examples/code_fragments/')
   if opts.dmg:
     os.system('rm -rf openstructure.dmg')
-    os.system('hdiutil create -srcFolder DNG.app openstructure.dmg')
\ No newline at end of file
+    os.system('hdiutil create -srcFolder DNG.app openstructure.dmg')
diff --git a/deployment/macos/deps.py b/deployment/macos/deps.py
index e8bcc7978..68f73d977 100644
--- a/deployment/macos/deps.py
+++ b/deployment/macos/deps.py
@@ -68,19 +68,23 @@ def collect_deps(stage_dir, components, binaries, libexec_binaries,
         _deps_for_lib(so_file, pool)
   return pool
 
-BINARIES=['chemdict_tool', 'tmalign', 'tmscore']
-LIBEXEC_BINARIES=['gosty']
-COMPONENTS=['mol', 'geom', 'conop', 'gfx', 'gui', 'seq_alg', 'seq', 
-            'img', 'img_alg', 'info', 'io', 'db', 'base']
-SCRIPTS=['dng', 'ost']
 LIBEXEC_SCRIPTS=['ost_config']
-
+LIBEXEC_BINARIES=[]
+GUI_LIBEXEC_BINARIES=['gosty']
+BINARIES=['ldt', 'chemdict_tool', 'tmalign', 'tmscore']
+GUI_BINARIES=['gosty']
+GUI_COMPONENTS=['gfx', 'gui', 'info']
+COMPONENTS=['mol', 'geom', 'conop', 'seq_alg', 'seq',
+            'img', 'img_alg', 'io', 'db', 'base']
+GUI_SCRIPTS=['dng']
+SCRIPTS=['ost']
 CHANGE_ID_RPATH='install_name_tool -id @rpath/%s %s'   
 CHANGE_ID='install_name_tool -id @rpath/%s %s'
 CHANGE_LOAD_CMD_RPATH='install_name_tool -change %s @rpath/%s %s'
 CHANGE_LOAD_CMD='install_name_tool -change %s @executable_path/%s %s'
 ADD_RPATH='install_name_tool -add_rpath %s %s 2> /dev/null'
-SITE_PACKAGES=['sip.so', 'sipconfig.py', 'sipdistutils.py', 'PyQt4']
+SITE_PACKAGES=[]
+GUI_SITE_PACKAGES=['sip.so', 'sipconfig.py', 'sipdistutils.py', 'PyQt4']
 REMOVE_HEADERS='rm -rf `find %s/lib -type d -name Headers`'
 REMOVE_CURRENT='rm -rf `find %s/lib -type d -name Current`'
 # collect libs of non-standard libraries/frameworks we depend on
@@ -205,8 +209,8 @@ def get_python_home():
   return os.path.dirname(sys.modules['os'].__file__)
 
 def make_standalone(stage_dir, outdir, no_includes, force_no_rpath=False,
-                    macports_workaround=False):
-  site_packages=get_site_package_dir()                    
+                    macports_workaround=False, no_gui=False):
+  site_packages_dir=get_site_package_dir()
 
   if os.path.exists(outdir):
     shutil.rmtree(outdir)
@@ -217,17 +221,27 @@ def make_standalone(stage_dir, outdir, no_includes, force_no_rpath=False,
   print 'copying shared datafiles'
   shutil.copytree(os.path.join(stage_dir, 'share'), 
                   os.path.join(outdir, 'share'))
+  scripts=SCRIPTS
+  binaries=BINARIES
+  components=COMPONENTS
+  site_packages=SITE_PACKAGES
+  libexec_binaries=LIBEXEC_BINARIES
+  if not no_gui:
+    scripts+=GUI_SCRIPTS
+    binaries+=GUI_BINARIES
+    components+=GUI_COMPONENTS
+    libexec_binaries+=GUI_LIBEXEC_BINARIES
+    site_packages+=GUI_SITE_PACKAGES
   print 'collecting dependencies'
-  deps=collect_deps(stage_dir, COMPONENTS, BINARIES, LIBEXEC_BINARIES,
-                    SITE_PACKAGES,
-                    site_packages)
+  deps=collect_deps(stage_dir, components, binaries, libexec_binaries,
+                    site_packages, site_packages_dir)
   print 'copying dependencies'
   copy_deps(deps, outdir)
-  print 'copying binaries'
-  copy_binaries(stage_dir, outdir, BINARIES, SCRIPTS, 'bin')
   print 'copying libexec binaries'
   copy_binaries(stage_dir, outdir, LIBEXEC_BINARIES, LIBEXEC_SCRIPTS,
                 'libexec/openstructure')
+  print 'copying binaries'
+  copy_binaries(stage_dir, outdir, binaries, scripts, 'bin')
   print 'copying pymod'
   shutil.copytree(os.path.join(stage_dir, 'lib/openstructure'), 
                   os.path.join(outdir, 'lib/openstructure'))
-- 
GitLab