From f7c4aa0348cc2867ecef4e96e4d68d0df15668b1 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 2 Oct 2018 17:36:30 -0700 Subject: [PATCH] (Partial) attempt to fix the plugin detection issue on MacOS --- macbuild/build4mac.py | 22 +++++++++++++++++++++- src/db/db/dbInit.cc | 2 ++ src/lay/lay/layInit.cc | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/macbuild/build4mac.py b/macbuild/build4mac.py index 69bb4784a..cce1ac842 100755 --- a/macbuild/build4mac.py +++ b/macbuild/build4mac.py @@ -581,6 +581,10 @@ def DeployBinariesForBundle(): # | +-- '*.dylib' # +-- MacOS/+ # | +-- 'klayout' + # | +-- 'db_plugins'/+ + # | +-- '*.dylib' + # | +-- 'lay_plugins'/+ + # | +-- '*.dylib' # +-- Buddy/+ # +-- 'strm2cif' # +-- 'strm2dxf' @@ -631,7 +635,7 @@ def DeployBinariesForBundle(): # : #------------------------------------------------------------------------------- os.chdir( targetDirF ) - dynamicLinkLibs = glob.glob( AbsMacBinDir + "/*.dylib" ) + dynamicLinkLibs = glob.glob( os.path.join( AbsMacBinDir, "*.dylib" ) ) depDicOrdinary = {} # inter-library dependency dictionary for item in dynamicLinkLibs: if os.path.isfile(item) and not os.path.islink(item): @@ -691,6 +695,22 @@ def DeployBinariesForBundle(): shutil.copy2( sourceDir1 + "/klayout", targetDirM ) shutil.copy2( sourceDir2 + "/klayout.icns", targetDirR ) + # copy the contents of the plugin directories to a place next to the application + # binary + for piDir in [ "db_plugins", "lay_plugins" ]: + os.makedirs( os.path.join( targetDirM, piDir ), exist_ok = True ) + dynamicLinkLibs = glob.glob( os.path.join( sourceDir3, piDir, "*.dylib" ) ) + for item in dynamicLinkLibs: + if os.path.isfile(item) and not os.path.islink(item): + #------------------------------------------------------------------- + # (A) Copy an ordinary *.dylib file here by changing the name + # to style (3) and set its mode to 0755 (sanity check). + #------------------------------------------------------------------- + fullName = os.path.basename(item).split('.') + # e.g. [ 'libklayout_lay', '0', '25', '0', 'dylib' ] + nameStyle3 = os.path.join( targetDirM, piDir, fullName[0] + "." + fullName[1] + ".dylib" ) + shutil.copy2( item, nameStyle3 ) + os.chmod( nameStyle3, 0o0755 ) os.chmod( targetDir0 + "/PkgInfo", 0o0644 ) os.chmod( targetDir0 + "/Info.plist", 0o0644 ) diff --git a/src/db/db/dbInit.cc b/src/db/db/dbInit.cc index 273f9913c..935363a52 100644 --- a/src/db/db/dbInit.cc +++ b/src/db/db/dbInit.cc @@ -129,6 +129,8 @@ void init (const std::vector &_paths) #if defined(_WIN32) pattern.set_case_sensitive (false); pattern = std::string ("*.dll"); +#elif defined(__APPLE__) + pattern = std::string ("*.dylib"); #else pattern = std::string ("*.so"); #endif diff --git a/src/lay/lay/layInit.cc b/src/lay/lay/layInit.cc index b6c8facf4..4262cb1f3 100644 --- a/src/lay/lay/layInit.cc +++ b/src/lay/lay/layInit.cc @@ -130,6 +130,8 @@ void init (const std::vector &_paths) #if defined(_WIN32) pattern.set_case_sensitive (false); pattern = std::string ("*.dll"); +#elif defined(__APPLE__) + pattern = std::string ("*.dylib"); #else pattern = std::string ("*.so"); #endif