mirror of https://github.com/KLayout/klayout.git
commit
37f7645d77
File diff suppressed because it is too large
Load Diff
|
|
@ -1,322 +1,322 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# File: "macbuild/build4mac_env.py"
|
# File: "macbuild/build4mac_env.py"
|
||||||
#
|
#
|
||||||
# Here are dictionaries of ...
|
# Here are dictionaries of ...
|
||||||
# different modules for building KLayout (http://www.klayout.de/index.php)
|
# different modules for building KLayout (http://www.klayout.de/index.php)
|
||||||
# version 0.26.1 or later on different Apple Mac OSX platforms.
|
# version 0.26.1 or later on different Apple Mac OSX platforms.
|
||||||
#
|
#
|
||||||
# This file is imported by 'build4mac.py' script.
|
# This file is imported by 'build4mac.py' script.
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------
|
||||||
# [0] Xcode's tools
|
# [0] Xcode's tools
|
||||||
# and
|
# and
|
||||||
# Default Homebrew root
|
# Default Homebrew root
|
||||||
# Ref. https://github.com/Homebrew/brew/blob/master/docs/Installation.md#alternative-installs
|
# Ref. https://github.com/Homebrew/brew/blob/master/docs/Installation.md#alternative-installs
|
||||||
#---------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------
|
||||||
XcodeToolChain = { 'nameID': '/usr/bin/install_name_tool -id ',
|
XcodeToolChain = { 'nameID': '/usr/bin/install_name_tool -id ',
|
||||||
'nameCH': '/usr/bin/install_name_tool -change '
|
'nameCH': '/usr/bin/install_name_tool -change '
|
||||||
}
|
}
|
||||||
|
|
||||||
(System, Node, Release, MacVersion, Machine, Processor) = platform.uname()
|
(System, Node, Release, MacVersion, Machine, Processor) = platform.uname()
|
||||||
if Machine == "arm64": # Apple Silicon!
|
if Machine == "arm64": # Apple Silicon!
|
||||||
DefaultHomebrewRoot = '/opt/homebrew'
|
DefaultHomebrewRoot = '/opt/homebrew'
|
||||||
else:
|
else:
|
||||||
DefaultHomebrewRoot = '/usr/local'
|
DefaultHomebrewRoot = '/usr/local'
|
||||||
del System, Node, Release, MacVersion, Machine, Processor
|
del System, Node, Release, MacVersion, Machine, Processor
|
||||||
|
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# [1] Qt
|
# [1] Qt
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
Qts = [ 'Qt5MacPorts', 'Qt5Brew', 'Qt5Ana3' ]
|
Qts = [ 'Qt5MacPorts', 'Qt5Brew', 'Qt5Ana3' ]
|
||||||
|
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# Whereabout of different components of Qt5
|
# Whereabout of different components of Qt5
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# Qt5 from MacPorts (https://www.macports.org/)
|
# Qt5 from MacPorts (https://www.macports.org/)
|
||||||
# install with 'sudo port install qt5'
|
# install with 'sudo port install qt5'
|
||||||
# [Key Type Name] = 'Qt5MacPorts'
|
# [Key Type Name] = 'Qt5MacPorts'
|
||||||
Qt5MacPorts = { 'qmake' : '/opt/local/libexec/qt5/bin/qmake',
|
Qt5MacPorts = { 'qmake' : '/opt/local/libexec/qt5/bin/qmake',
|
||||||
'deploy': '/opt/local/libexec/qt5/bin/macdeployqt'
|
'deploy': '/opt/local/libexec/qt5/bin/macdeployqt'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Qt5 from Homebrew (https://brew.sh/)
|
# Qt5 from Homebrew (https://brew.sh/)
|
||||||
# install with 'brew install qt'
|
# install with 'brew install qt'
|
||||||
# [Key Type Name] = 'Qt5Brew'
|
# [Key Type Name] = 'Qt5Brew'
|
||||||
Qt5Brew = { 'qmake' : '%s/opt/qt@5/bin/qmake' % DefaultHomebrewRoot,
|
Qt5Brew = { 'qmake' : '%s/opt/qt@5/bin/qmake' % DefaultHomebrewRoot,
|
||||||
'deploy': '%s/opt/qt@5/bin/macdeployqt' % DefaultHomebrewRoot
|
'deploy': '%s/opt/qt@5/bin/macdeployqt' % DefaultHomebrewRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
# Qt5 bundled with anaconda3 installed under /Applications/anaconda3/
|
# Qt5 bundled with anaconda3 installed under /Applications/anaconda3/
|
||||||
# The standard installation deploys the tool under $HOME/opt/anaconda3/.
|
# The standard installation deploys the tool under $HOME/opt/anaconda3/.
|
||||||
# If so, you need to make a symbolic link: /Applications/anaconda3 ---> $HOME/opt/anaconda3/
|
# If so, you need to make a symbolic link: /Applications/anaconda3 ---> $HOME/opt/anaconda3/
|
||||||
# [Key Type Name] = 'Qt5Ana3'
|
# [Key Type Name] = 'Qt5Ana3'
|
||||||
Qt5Ana3 = { 'qmake' : '/Applications/anaconda3/bin/qmake',
|
Qt5Ana3 = { 'qmake' : '/Applications/anaconda3/bin/qmake',
|
||||||
'deploy': '/Applications/anaconda3/bin/macdeployqt'
|
'deploy': '/Applications/anaconda3/bin/macdeployqt'
|
||||||
}
|
}
|
||||||
|
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# [2] Ruby
|
# [2] Ruby
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
RubyNil = [ 'nil' ]
|
RubyNil = [ 'nil' ]
|
||||||
RubySys = [ 'RubyElCapitan', 'RubySierra', 'RubyHighSierra', 'RubyMojave', 'RubyCatalina', 'RubyBigSur' ]
|
RubySys = [ 'RubyElCapitan', 'RubySierra', 'RubyHighSierra', 'RubyMojave', 'RubyCatalina', 'RubyBigSur' ]
|
||||||
RubyExt = [ 'Ruby27MacPorts', 'Ruby27Brew', 'RubyAnaconda3' ]
|
RubyExt = [ 'Ruby27MacPorts', 'Ruby27Brew', 'RubyAnaconda3' ]
|
||||||
Rubies = RubyNil + RubySys + RubyExt
|
Rubies = RubyNil + RubySys + RubyExt
|
||||||
|
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# Whereabout of different components of Ruby
|
# Whereabout of different components of Ruby
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# Bundled with Yosemite (10.10)
|
# Bundled with Yosemite (10.10)
|
||||||
# !!! Yosemite is no longer supported (KLayout 0.26 ~) but remains here to keep the record of
|
# !!! Yosemite is no longer supported (KLayout 0.26 ~) but remains here to keep the record of
|
||||||
# the directory structure of earlier generations.
|
# the directory structure of earlier generations.
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
RubyYosemite = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby',
|
RubyYosemite = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby',
|
||||||
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
||||||
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.dylib'
|
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with El Capitan (10.11)
|
# Bundled with El Capitan (10.11)
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
RubyElCapitan = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby',
|
RubyElCapitan = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby',
|
||||||
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
||||||
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.dylib'
|
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with Sierra (10.12)
|
# Bundled with Sierra (10.12)
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
RubySierra = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby',
|
RubySierra = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby',
|
||||||
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
||||||
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.dylib'
|
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with High Sierra (10.13)
|
# Bundled with High Sierra (10.13)
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
RubyHighSierra = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby',
|
RubyHighSierra = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby',
|
||||||
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
||||||
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.dylib'
|
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with Mojave (10.14)
|
# Bundled with Mojave (10.14)
|
||||||
# The missing Ruby header files under "/System/Library/Frameworks/Ruby.framework/" were manually deployed there
|
# The missing Ruby header files under "/System/Library/Frameworks/Ruby.framework/" were manually deployed there
|
||||||
# from "Xcode-10.1-beta2" with the corresponding Ruby version.
|
# from "Xcode-10.1-beta2" with the corresponding Ruby version.
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
RubyMojave = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby',
|
RubyMojave = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby',
|
||||||
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
'inc': '/System/Library/Frameworks/Ruby.framework/Headers',
|
||||||
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.dylib'
|
'lib': '/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with Catalina (10.15)
|
# Bundled with Catalina (10.15)
|
||||||
# !!! Catalina does not allow to hack the "/System" directory; it's READ ONLY even for the super user!
|
# !!! Catalina does not allow to hack the "/System" directory; it's READ ONLY even for the super user!
|
||||||
# Hence, we need to refer to the Ruby header file in "Xcode.app" directly.
|
# Hence, we need to refer to the Ruby header file in "Xcode.app" directly.
|
||||||
#
|
#
|
||||||
# With the major release of "macOS Big Sur (11.0)" in November 2020, Xcode has been updated, too.
|
# With the major release of "macOS Big Sur (11.0)" in November 2020, Xcode has been updated, too.
|
||||||
# (base) MacBookPro2{kazzz-s}(1)$ pwd
|
# (base) MacBookPro2{kazzz-s}(1)$ pwd
|
||||||
# /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0
|
# /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0
|
||||||
#
|
#
|
||||||
# (base) MacBookPro2{kazzz-s}(2)$ ll
|
# (base) MacBookPro2{kazzz-s}(2)$ ll
|
||||||
# total 4
|
# total 4
|
||||||
# drwxr-xr-x 6 root wheel 192 11 15 20:57 .
|
# drwxr-xr-x 6 root wheel 192 11 15 20:57 .
|
||||||
# drwxr-xr-x 3 root wheel 96 10 20 05:33 ..
|
# drwxr-xr-x 3 root wheel 96 10 20 05:33 ..
|
||||||
# drwxr-xr-x 23 root wheel 736 10 24 11:57 ruby
|
# drwxr-xr-x 23 root wheel 736 10 24 11:57 ruby
|
||||||
# -rw-r--r-- 1 root wheel 868 10 19 19:32 ruby.h
|
# -rw-r--r-- 1 root wheel 868 10 19 19:32 ruby.h
|
||||||
# lrwxr-xr-x 1 root wheel 19 11 15 20:57 universal-darwin19 -> universal-darwin20/ <=== manually created this symbolic link
|
# lrwxr-xr-x 1 root wheel 19 11 15 20:57 universal-darwin19 -> universal-darwin20/ <=== manually created this symbolic link
|
||||||
# drwxr-xr-x 6 root wheel 192 10 20 05:33 universal-darwin20
|
# drwxr-xr-x 6 root wheel 192 10 20 05:33 universal-darwin20
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
CatalinaSDK = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
|
CatalinaSDK = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
|
||||||
RubyCatalina = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby',
|
RubyCatalina = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby',
|
||||||
'inc': '%s/System/Library/Frameworks/Ruby.framework/Headers' % CatalinaSDK,
|
'inc': '%s/System/Library/Frameworks/Ruby.framework/Headers' % CatalinaSDK,
|
||||||
'inc2': '%s/System/Library/Frameworks/Ruby.framework/Headers/ruby' % CatalinaSDK,
|
'inc2': '%s/System/Library/Frameworks/Ruby.framework/Headers/ruby' % CatalinaSDK,
|
||||||
'lib': '%s/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/libruby.tbd' % CatalinaSDK
|
'lib': '%s/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/libruby.tbd' % CatalinaSDK
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with Big Sur (11.0)
|
# Bundled with Big Sur (11.0)
|
||||||
# Refer to the "Catalina" section above
|
# Refer to the "Catalina" section above
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
BigSurSDK = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
|
BigSurSDK = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
|
||||||
RubyBigSur = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby',
|
RubyBigSur = { 'exe': '/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby',
|
||||||
'inc': '%s/System/Library/Frameworks/Ruby.framework/Headers' % BigSurSDK,
|
'inc': '%s/System/Library/Frameworks/Ruby.framework/Headers' % BigSurSDK,
|
||||||
'inc2': '%s/System/Library/Frameworks/Ruby.framework/Headers/ruby' % BigSurSDK,
|
'inc2': '%s/System/Library/Frameworks/Ruby.framework/Headers/ruby' % BigSurSDK,
|
||||||
'lib': '%s/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/libruby.tbd' % BigSurSDK
|
'lib': '%s/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/libruby.tbd' % BigSurSDK
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ruby 2.7 from MacPorts (https://www.macports.org/) *+*+*+ EXPERIMENTAL *+*+*+
|
# Ruby 2.7 from MacPorts (https://www.macports.org/) *+*+*+ EXPERIMENTAL *+*+*+
|
||||||
# install with 'sudo port install ruby27'
|
# install with 'sudo port install ruby27'
|
||||||
# [Key Type Name] = 'MP27'
|
# [Key Type Name] = 'MP27'
|
||||||
Ruby27MacPorts = { 'exe': '/opt/local/bin/ruby2.7',
|
Ruby27MacPorts = { 'exe': '/opt/local/bin/ruby2.7',
|
||||||
'inc': '/opt/local/include/ruby-2.7.0',
|
'inc': '/opt/local/include/ruby-2.7.0',
|
||||||
'lib': '/opt/local/lib/libruby.2.7.dylib'
|
'lib': '/opt/local/lib/libruby.2.7.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ruby 2.7 from Homebrew *+*+*+ EXPERIMENTAL *+*+*+
|
# Ruby 2.7 from Homebrew *+*+*+ EXPERIMENTAL *+*+*+
|
||||||
# install with 'brew install ruby'
|
# install with 'brew install ruby'
|
||||||
# [Key Type Name] = 'HB27'
|
# [Key Type Name] = 'HB27'
|
||||||
HBRuby27Path = '%s/opt/ruby@2.7' % DefaultHomebrewRoot
|
HBRuby27Path = '%s/opt/ruby@2.7' % DefaultHomebrewRoot
|
||||||
Ruby27Brew = { 'exe': '%s/bin/ruby' % HBRuby27Path,
|
Ruby27Brew = { 'exe': '%s/bin/ruby' % HBRuby27Path,
|
||||||
'inc': '%s/include/ruby-2.7.0' % HBRuby27Path,
|
'inc': '%s/include/ruby-2.7.0' % HBRuby27Path,
|
||||||
'lib': '%s/lib/libruby.2.7.dylib' % HBRuby27Path
|
'lib': '%s/lib/libruby.2.7.dylib' % HBRuby27Path
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ruby 2.5 bundled with anaconda3 installed under /Applications/anaconda3/ *+*+*+ EXPERIMENTAL *+*+*+
|
# Ruby 2.5 bundled with anaconda3 installed under /Applications/anaconda3/ *+*+*+ EXPERIMENTAL *+*+*+
|
||||||
# The standard installation deploys the tool under $HOME/opt/anaconda3/.
|
# The standard installation deploys the tool under $HOME/opt/anaconda3/.
|
||||||
# If so, you need to make a symbolic link: /Applications/anaconda3 ---> $HOME/opt/anaconda3/
|
# If so, you need to make a symbolic link: /Applications/anaconda3 ---> $HOME/opt/anaconda3/
|
||||||
# [Key Type Name] = 'Ana3'
|
# [Key Type Name] = 'Ana3'
|
||||||
RubyAnaconda3 = { 'exe': '/Applications/anaconda3/bin/ruby',
|
RubyAnaconda3 = { 'exe': '/Applications/anaconda3/bin/ruby',
|
||||||
'inc': '/Applications/anaconda3/include/ruby-2.5.0',
|
'inc': '/Applications/anaconda3/include/ruby-2.5.0',
|
||||||
'lib': '/Applications/anaconda3/lib/libruby.2.5.1.dylib'
|
'lib': '/Applications/anaconda3/lib/libruby.2.5.1.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Consolidated dictionary kit for Ruby
|
# Consolidated dictionary kit for Ruby
|
||||||
RubyDictionary = { 'nil' : None,
|
RubyDictionary = { 'nil' : None,
|
||||||
'RubyYosemite' : RubyYosemite,
|
'RubyYosemite' : RubyYosemite,
|
||||||
'RubyElCapitan' : RubyElCapitan,
|
'RubyElCapitan' : RubyElCapitan,
|
||||||
'RubySierra' : RubySierra,
|
'RubySierra' : RubySierra,
|
||||||
'RubyHighSierra': RubyHighSierra,
|
'RubyHighSierra': RubyHighSierra,
|
||||||
'RubyMojave' : RubyMojave,
|
'RubyMojave' : RubyMojave,
|
||||||
'RubyCatalina' : RubyCatalina,
|
'RubyCatalina' : RubyCatalina,
|
||||||
'RubyBigSur' : RubyBigSur,
|
'RubyBigSur' : RubyBigSur,
|
||||||
'Ruby27MacPorts': Ruby27MacPorts,
|
'Ruby27MacPorts': Ruby27MacPorts,
|
||||||
'Ruby27Brew' : Ruby27Brew,
|
'Ruby27Brew' : Ruby27Brew,
|
||||||
'RubyAnaconda3' : RubyAnaconda3
|
'RubyAnaconda3' : RubyAnaconda3
|
||||||
}
|
}
|
||||||
|
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# [3] Python
|
# [3] Python
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
PythonNil = [ 'nil' ]
|
PythonNil = [ 'nil' ]
|
||||||
PythonSys = [ 'PythonElCapitan', 'PythonSierra', 'PythonHighSierra', 'PythonMojave', 'PythonCatalina', 'PythonBigSur' ]
|
PythonSys = [ 'PythonElCapitan', 'PythonSierra', 'PythonHighSierra', 'PythonMojave', 'PythonCatalina', 'PythonBigSur' ]
|
||||||
PythonExt = [ 'Python38MacPorts', 'Python38Brew', 'PythonAnaconda3', 'PythonAutoBrew' ]
|
PythonExt = [ 'Python38MacPorts', 'Python38Brew', 'PythonAnaconda3', 'PythonAutoBrew' ]
|
||||||
Pythons = PythonNil + PythonSys + PythonExt
|
Pythons = PythonNil + PythonSys + PythonExt
|
||||||
|
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# Whereabout of different components of Python
|
# Whereabout of different components of Python
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# Bundled with Yosemite (10.10)
|
# Bundled with Yosemite (10.10)
|
||||||
# !!! Yosemite is no longer supported but remains here to keep the record of the directory structure
|
# !!! Yosemite is no longer supported but remains here to keep the record of the directory structure
|
||||||
# of earlier generations.
|
# of earlier generations.
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
PythonYosemite = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
PythonYosemite = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
||||||
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
||||||
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with El Capitan (10.11)
|
# Bundled with El Capitan (10.11)
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
PythonElCapitan = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
PythonElCapitan = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
||||||
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
||||||
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with Sierra (10.12)
|
# Bundled with Sierra (10.12)
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
PythonSierra = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
PythonSierra = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
||||||
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
||||||
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with High Sierra (10.13)
|
# Bundled with High Sierra (10.13)
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
PythonHighSierra= { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
PythonHighSierra= { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
||||||
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
||||||
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with Mojave (10.14)
|
# Bundled with Mojave (10.14)
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
PythonMojave = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
PythonMojave = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
||||||
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
||||||
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with Catalina (10.15)
|
# Bundled with Catalina (10.15)
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
PythonCatalina = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
PythonCatalina = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
||||||
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
||||||
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bundled with Big Sur (11.0)
|
# Bundled with Big Sur (11.0)
|
||||||
# [Key Type Name] = 'Sys'
|
# [Key Type Name] = 'Sys'
|
||||||
PythonBigSur = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
PythonBigSur = { 'exe': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python',
|
||||||
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
'inc': '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
|
||||||
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
'lib': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Python 3.8 from MacPorts (https://www.macports.org/) *+*+*+ EXPERIMENTAL *+*+*+
|
# Python 3.8 from MacPorts (https://www.macports.org/) *+*+*+ EXPERIMENTAL *+*+*+
|
||||||
# install with 'sudo port install python38'
|
# install with 'sudo port install python38'
|
||||||
# [Key Type Name] = 'MP38'
|
# [Key Type Name] = 'MP38'
|
||||||
Python38MacPorts= { 'exe': '/opt/local/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8',
|
Python38MacPorts= { 'exe': '/opt/local/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8',
|
||||||
'inc': '/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8',
|
'inc': '/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8',
|
||||||
'lib': '/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib'
|
'lib': '/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Python 3.8 from Homebrew *+*+*+ EXPERIMENTAL *+*+*+
|
# Python 3.8 from Homebrew *+*+*+ EXPERIMENTAL *+*+*+
|
||||||
# install with 'brew install python'
|
# install with 'brew install python'
|
||||||
# [Key Type Name] = 'HB38'
|
# [Key Type Name] = 'HB38'
|
||||||
HBPython38FrameworkPath = '%s/opt/python@3.8/Frameworks/Python.framework' % DefaultHomebrewRoot
|
HBPython38FrameworkPath = '%s/opt/python@3.8/Frameworks/Python.framework' % DefaultHomebrewRoot
|
||||||
Python38Brew = { 'exe': '%s/Versions/3.8/bin/python3.8' % HBPython38FrameworkPath,
|
Python38Brew = { 'exe': '%s/Versions/3.8/bin/python3.8' % HBPython38FrameworkPath,
|
||||||
'inc': '%s/Versions/3.8/include/python3.8' % HBPython38FrameworkPath,
|
'inc': '%s/Versions/3.8/include/python3.8' % HBPython38FrameworkPath,
|
||||||
'lib': '%s/Versions/3.8/lib/libpython3.8.dylib' % HBPython38FrameworkPath
|
'lib': '%s/Versions/3.8/lib/libpython3.8.dylib' % HBPython38FrameworkPath
|
||||||
}
|
}
|
||||||
|
|
||||||
# Python 3.8 bundled with anaconda3 installed under /Applications/anaconda3/ *+*+*+ EXPERIMENTAL *+*+*+
|
# Python 3.8 bundled with anaconda3 installed under /Applications/anaconda3/ *+*+*+ EXPERIMENTAL *+*+*+
|
||||||
# The standard installation deploys the tool under $HOME/opt/anaconda3/.
|
# The standard installation deploys the tool under $HOME/opt/anaconda3/.
|
||||||
# If so, you need to make a symbolic link: /Applications/anaconda3 ---> $HOME/opt/anaconda3/
|
# If so, you need to make a symbolic link: /Applications/anaconda3 ---> $HOME/opt/anaconda3/
|
||||||
# [Key Type Name] = 'Ana3'
|
# [Key Type Name] = 'Ana3'
|
||||||
PythonAnaconda3 = { 'exe': '/Applications/anaconda3/bin/python3.8',
|
PythonAnaconda3 = { 'exe': '/Applications/anaconda3/bin/python3.8',
|
||||||
'inc': '/Applications/anaconda3/include/python3.8',
|
'inc': '/Applications/anaconda3/include/python3.8',
|
||||||
'lib': '/Applications/anaconda3/lib/libpython3.8.dylib'
|
'lib': '/Applications/anaconda3/lib/libpython3.8.dylib'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Latest Python from Homebrew *+*+*+ EXPERIMENTAL *+*+*+
|
# Latest Python from Homebrew *+*+*+ EXPERIMENTAL *+*+*+
|
||||||
# install with 'brew install python'
|
# install with 'brew install python'
|
||||||
# There can be multiple candidates such as: (python, python3, python@3, python@3.8, python@3.9)
|
# There can be multiple candidates such as: (python, python3, python@3, python@3.8, python@3.9)
|
||||||
# Hard to tell which is going to be available to the user. Picking the last one.
|
# Hard to tell which is going to be available to the user. Picking the last one.
|
||||||
# [Key Type Name] = 'HBAuto'
|
# [Key Type Name] = 'HBAuto'
|
||||||
HBPythonAutoFrameworkPath = ""
|
HBPythonAutoFrameworkPath = ""
|
||||||
HBPythonAutoVersion = ""
|
HBPythonAutoVersion = ""
|
||||||
try:
|
try:
|
||||||
HBPythonAutoFrameworkPath = glob.glob( "%s/opt/python*/Frameworks/Python.framework" % DefaultHomebrewRoot )[-1]
|
HBPythonAutoFrameworkPath = glob.glob( "%s/opt/python*/Frameworks/Python.framework" % DefaultHomebrewRoot )[-1]
|
||||||
# expand 3* into HBPythonAutoVersion, there should be only one, but I am taking no chances.
|
# expand 3* into HBPythonAutoVersion, there should be only one, but I am taking no chances.
|
||||||
HBAutoFrameworkVersionPath, HBPythonAutoVersion = os.path.split( glob.glob( "%s/Versions/3*" % HBPythonAutoFrameworkPath )[0] )
|
HBAutoFrameworkVersionPath, HBPythonAutoVersion = os.path.split( glob.glob( "%s/Versions/3*" % HBPythonAutoFrameworkPath )[0] )
|
||||||
PythonAutoBrew = { 'exe': '%s/%s/bin/python%s' % ( HBAutoFrameworkVersionPath, HBPythonAutoVersion, HBPythonAutoVersion ),
|
PythonAutoBrew = { 'exe': '%s/%s/bin/python%s' % ( HBAutoFrameworkVersionPath, HBPythonAutoVersion, HBPythonAutoVersion ),
|
||||||
'inc': '%s/%s/include/python%s' % ( HBAutoFrameworkVersionPath, HBPythonAutoVersion, HBPythonAutoVersion ),
|
'inc': '%s/%s/include/python%s' % ( HBAutoFrameworkVersionPath, HBPythonAutoVersion, HBPythonAutoVersion ),
|
||||||
'lib': glob.glob( "%s/%s/lib/*.dylib" % ( HBAutoFrameworkVersionPath, HBPythonAutoVersion ) )[0]
|
'lib': glob.glob( "%s/%s/lib/*.dylib" % ( HBAutoFrameworkVersionPath, HBPythonAutoVersion ) )[0]
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_have_Homebrew_Python = False
|
_have_Homebrew_Python = False
|
||||||
print( " WARNING!!! Since you don't have the Homebrew Python Frameworks, you cannot use the '-p HBAuto' option. " )
|
print( " WARNING!!! Since you don't have the Homebrew Python Frameworks, you cannot use the '-p HBAuto' option. " )
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
_have_Homebrew_Python = True
|
_have_Homebrew_Python = True
|
||||||
|
|
||||||
# Consolidated dictionary kit for Python
|
# Consolidated dictionary kit for Python
|
||||||
PythonDictionary = { 'nil' : None,
|
PythonDictionary = { 'nil' : None,
|
||||||
'PythonElCapitan' : PythonElCapitan,
|
'PythonElCapitan' : PythonElCapitan,
|
||||||
'PythonSierra' : PythonSierra,
|
'PythonSierra' : PythonSierra,
|
||||||
'PythonHighSierra': PythonHighSierra,
|
'PythonHighSierra': PythonHighSierra,
|
||||||
'PythonMojave' : PythonMojave,
|
'PythonMojave' : PythonMojave,
|
||||||
'PythonCatalina' : PythonCatalina,
|
'PythonCatalina' : PythonCatalina,
|
||||||
'PythonBigSur' : PythonBigSur,
|
'PythonBigSur' : PythonBigSur,
|
||||||
'Python38MacPorts': Python38MacPorts,
|
'Python38MacPorts': Python38MacPorts,
|
||||||
'Python38Brew' : Python38Brew,
|
'Python38Brew' : Python38Brew,
|
||||||
'PythonAnaconda3' : PythonAnaconda3
|
'PythonAnaconda3' : PythonAnaconda3
|
||||||
}
|
}
|
||||||
if _have_Homebrew_Python:
|
if _have_Homebrew_Python:
|
||||||
PythonDictionary['PythonAutoBrew'] = PythonAutoBrew
|
PythonDictionary['PythonAutoBrew'] = PythonAutoBrew
|
||||||
|
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# [4] KLayout executables including buddy tools
|
# [4] KLayout executables including buddy tools
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
KLayoutExecs = [ 'klayout' ]
|
KLayoutExecs = [ 'klayout' ]
|
||||||
KLayoutExecs += [ 'strm2cif', 'strm2dxf', 'strm2gds', 'strm2gdstxt', 'strm2oas' ]
|
KLayoutExecs += [ 'strm2cif', 'strm2dxf', 'strm2gds', 'strm2gdstxt', 'strm2oas' ]
|
||||||
KLayoutExecs += [ 'strm2txt', 'strmclip', 'strmcmp', 'strmrun', 'strmxor' ]
|
KLayoutExecs += [ 'strm2txt', 'strmclip', 'strmcmp', 'strmrun', 'strmxor' ]
|
||||||
|
|
||||||
#----------------
|
#----------------
|
||||||
# End of File
|
# End of File
|
||||||
#----------------
|
#----------------
|
||||||
|
|
|
||||||
|
|
@ -1,467 +1,467 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
#========================================================================================
|
#========================================================================================
|
||||||
# File: "macbuild/build4mac_util.py"
|
# File: "macbuild/build4mac_util.py"
|
||||||
#
|
#
|
||||||
# Here are utility functions and classes ...
|
# Here are utility functions and classes ...
|
||||||
# for building KLayout (http://www.klayout.de/index.php)
|
# for building KLayout (http://www.klayout.de/index.php)
|
||||||
# version 0.26.1 or later on different Apple Mac OSX platforms.
|
# version 0.26.1 or later on different Apple Mac OSX platforms.
|
||||||
#
|
#
|
||||||
# This file is imported by 'build4mac.py' script.
|
# This file is imported by 'build4mac.py' script.
|
||||||
#========================================================================================
|
#========================================================================================
|
||||||
from __future__ import print_function # to use print() of Python 3 in Python >= 2.7
|
from __future__ import print_function # to use print() of Python 3 in Python >= 2.7
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To import global dictionaries of different modules
|
## To import global dictionaries of different modules
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
mydir = os.path.dirname(os.path.abspath(__file__))
|
mydir = os.path.dirname(os.path.abspath(__file__))
|
||||||
sys.path.append( mydir )
|
sys.path.append( mydir )
|
||||||
from build4mac_env import *
|
from build4mac_env import *
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To decompose strings obtained by 'otool -L <*.dylib>' command and to
|
## To decompose strings obtained by 'otool -L <*.dylib>' command and to
|
||||||
# generate a dictionary of KLayout's inter-library dependency.
|
# generate a dictionary of KLayout's inter-library dependency.
|
||||||
#
|
#
|
||||||
# @param[in] depstr strings that tell dependency such as:
|
# @param[in] depstr strings that tell dependency such as:
|
||||||
#
|
#
|
||||||
# libklayout_edt.0.dylib:
|
# libklayout_edt.0.dylib:
|
||||||
# libklayout_edt.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
# libklayout_edt.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
||||||
# libklayout_tl.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
# libklayout_tl.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
||||||
# libklayout_gsi.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
# libklayout_gsi.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
||||||
# libklayout_laybasic.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
# libklayout_laybasic.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
||||||
# libklayout_db.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
# libklayout_db.0.dylib (compatibility version 0.26.0, current version 0.26.1)
|
||||||
# :
|
# :
|
||||||
# :
|
# :
|
||||||
#
|
#
|
||||||
# @return a dictionary
|
# @return a dictionary
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def DecomposeLibraryDependency( depstr ):
|
def DecomposeLibraryDependency( depstr ):
|
||||||
alllines = depstr.split('\n')
|
alllines = depstr.split('\n')
|
||||||
numlines = len(alllines)
|
numlines = len(alllines)
|
||||||
dependent = alllines[0].split(':')[0].strip()
|
dependent = alllines[0].split(':')[0].strip()
|
||||||
supporters = []
|
supporters = []
|
||||||
for line in alllines[1:]:
|
for line in alllines[1:]:
|
||||||
supporter = line.strip().split(' ')[0].strip()
|
supporter = line.strip().split(' ')[0].strip()
|
||||||
if not supporter == '':
|
if not supporter == '':
|
||||||
supporters.append(supporter)
|
supporters.append(supporter)
|
||||||
return { dependent: supporters }
|
return { dependent: supporters }
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To print the contents of a library dependency dictionary
|
## To print the contents of a library dependency dictionary
|
||||||
#
|
#
|
||||||
# @param[in] depdic dictionary
|
# @param[in] depdic dictionary
|
||||||
# @param[in] pathdic path dictionary
|
# @param[in] pathdic path dictionary
|
||||||
# @param[in] namedic dictionary name
|
# @param[in] namedic dictionary name
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def PrintLibraryDependencyDictionary( depdic, pathdic, namedic ):
|
def PrintLibraryDependencyDictionary( depdic, pathdic, namedic ):
|
||||||
keys = depdic.keys()
|
keys = depdic.keys()
|
||||||
print("")
|
print("")
|
||||||
print("##### Contents of <%s> #####:" % namedic )
|
print("##### Contents of <%s> #####:" % namedic )
|
||||||
for key in keys:
|
for key in keys:
|
||||||
supporters = depdic[key]
|
supporters = depdic[key]
|
||||||
keyName = os.path.basename(key)
|
keyName = os.path.basename(key)
|
||||||
print( " %s: (%s)" % (key, pathdic[keyName]) )
|
print( " %s: (%s)" % (key, pathdic[keyName]) )
|
||||||
for item in supporters:
|
for item in supporters:
|
||||||
itemName = os.path.basename(item)
|
itemName = os.path.basename(item)
|
||||||
if itemName != keyName and (itemName in pathdic):
|
if itemName != keyName and (itemName in pathdic):
|
||||||
print( " %s (%s)" % (item, pathdic[itemName]) )
|
print( " %s (%s)" % (item, pathdic[itemName]) )
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To set and change identification name of KLayout's dylib
|
## To set and change identification name of KLayout's dylib
|
||||||
#
|
#
|
||||||
# @param[in] libdic inter-library dependency dictionary
|
# @param[in] libdic inter-library dependency dictionary
|
||||||
#
|
#
|
||||||
# @return 0 on success; non-zero on failure
|
# @return 0 on success; non-zero on failure
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def SetChangeIdentificationNameOfDyLib( libdic, pathDic ):
|
def SetChangeIdentificationNameOfDyLib( libdic, pathDic ):
|
||||||
cmdNameId = XcodeToolChain['nameID']
|
cmdNameId = XcodeToolChain['nameID']
|
||||||
cmdNameChg = XcodeToolChain['nameCH']
|
cmdNameChg = XcodeToolChain['nameCH']
|
||||||
dependentLibs = libdic.keys()
|
dependentLibs = libdic.keys()
|
||||||
|
|
||||||
for lib in dependentLibs:
|
for lib in dependentLibs:
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
# [1] Set the identification name of each dependent library
|
# [1] Set the identification name of each dependent library
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
nameOld = "%s" % lib
|
nameOld = "%s" % lib
|
||||||
libName = os.path.basename(lib)
|
libName = os.path.basename(lib)
|
||||||
nameNew = pathDic[libName]
|
nameNew = pathDic[libName]
|
||||||
command = "%s %s %s" % ( cmdNameId, nameNew, nameOld )
|
command = "%s %s %s" % ( cmdNameId, nameNew, nameOld )
|
||||||
if subprocess.call( command, shell=True ) != 0:
|
if subprocess.call( command, shell=True ) != 0:
|
||||||
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
||||||
print( msg % lib, file=sys.stderr )
|
print( msg % lib, file=sys.stderr )
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
# [2] Make the library aware of the new identifications of all supporters
|
# [2] Make the library aware of the new identifications of all supporters
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
supporters = libdic[lib]
|
supporters = libdic[lib]
|
||||||
for sup in supporters:
|
for sup in supporters:
|
||||||
supName = os.path.basename(sup)
|
supName = os.path.basename(sup)
|
||||||
if libName != supName and (supName in pathDic):
|
if libName != supName and (supName in pathDic):
|
||||||
nameOld = "%s" % sup
|
nameOld = "%s" % sup
|
||||||
nameNew = pathDic[supName]
|
nameNew = pathDic[supName]
|
||||||
command = "%s %s %s %s" % ( cmdNameChg, nameOld, nameNew, lib )
|
command = "%s %s %s %s" % ( cmdNameChg, nameOld, nameNew, lib )
|
||||||
if subprocess.call( command, shell=True ) != 0:
|
if subprocess.call( command, shell=True ) != 0:
|
||||||
msg = "!!! Failed to make the library aware of the new identification name <%s> of supporter <%s> !!!"
|
msg = "!!! Failed to make the library aware of the new identification name <%s> of supporter <%s> !!!"
|
||||||
print( msg % (nameNew, sup), file=sys.stderr )
|
print( msg % (nameNew, sup), file=sys.stderr )
|
||||||
return 1
|
return 1
|
||||||
# for-lib
|
# for-lib
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To set the identification names of KLayout's libraries to an executable
|
## To set the identification names of KLayout's libraries to an executable
|
||||||
# and make the application aware of the library locations
|
# and make the application aware of the library locations
|
||||||
#
|
#
|
||||||
# @param[in] executable path/to/executable -- (1)
|
# @param[in] executable path/to/executable -- (1)
|
||||||
# @param[in] relativedir directory of dylib relative to executable -- (2)
|
# @param[in] relativedir directory of dylib relative to executable -- (2)
|
||||||
#
|
#
|
||||||
# Example: (1) "klayout.app/Contents/MacOS/klayout"
|
# Example: (1) "klayout.app/Contents/MacOS/klayout"
|
||||||
# (2) "../Frameworks"
|
# (2) "../Frameworks"
|
||||||
#
|
#
|
||||||
# klayout.app/+
|
# klayout.app/+
|
||||||
# +-- Contents/+
|
# +-- Contents/+
|
||||||
# +-- Info.plist
|
# +-- Info.plist
|
||||||
# +-- PkgInfo
|
# +-- PkgInfo
|
||||||
# +-- Resources/+
|
# +-- Resources/+
|
||||||
# | +-- 'klayout.icns'
|
# | +-- 'klayout.icns'
|
||||||
# +-- Frameworks/+
|
# +-- Frameworks/+
|
||||||
# | +-- '*.framework'
|
# | +-- '*.framework'
|
||||||
# | +-- '*.dylib'
|
# | +-- '*.dylib'
|
||||||
# | +-- 'db_plugins' --slink--> ../MacOS/db_plugins/
|
# | +-- 'db_plugins' --slink--> ../MacOS/db_plugins/
|
||||||
# +-- MacOS/+
|
# +-- MacOS/+
|
||||||
# | +-- 'klayout'
|
# | +-- 'klayout'
|
||||||
# | +-- db_plugins/
|
# | +-- db_plugins/
|
||||||
# | +-- lay_plugins/
|
# | +-- lay_plugins/
|
||||||
# +-- Buddy/+
|
# +-- Buddy/+
|
||||||
# +-- 'strm2cif'
|
# +-- 'strm2cif'
|
||||||
# +-- 'strm2dxf'
|
# +-- 'strm2dxf'
|
||||||
# :
|
# :
|
||||||
# +-- 'strmxor'
|
# +-- 'strmxor'
|
||||||
#
|
#
|
||||||
# @return 0 on success; non-zero on failure
|
# @return 0 on success; non-zero on failure
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def SetChangeLibIdentificationName( executable, relativedir ):
|
def SetChangeLibIdentificationName( executable, relativedir ):
|
||||||
cmdNameId = XcodeToolChain['nameID']
|
cmdNameId = XcodeToolChain['nameID']
|
||||||
cmdNameChg = XcodeToolChain['nameCH']
|
cmdNameChg = XcodeToolChain['nameCH']
|
||||||
otoolCm = "otool -L %s | grep libklayout" % executable
|
otoolCm = "otool -L %s | grep libklayout" % executable
|
||||||
otoolOut = os.popen( otoolCm ).read()
|
otoolOut = os.popen( otoolCm ).read()
|
||||||
exedepdic = DecomposeLibraryDependency( executable + ":\n" + otoolOut )
|
exedepdic = DecomposeLibraryDependency( executable + ":\n" + otoolOut )
|
||||||
keys = exedepdic.keys()
|
keys = exedepdic.keys()
|
||||||
deplibs = exedepdic[ list(keys)[0] ]
|
deplibs = exedepdic[ list(keys)[0] ]
|
||||||
|
|
||||||
for lib in deplibs:
|
for lib in deplibs:
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
# [1] Set the identification names for the library
|
# [1] Set the identification names for the library
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
nameOld = "klayout.app/Contents/Frameworks/%s" % lib
|
nameOld = "klayout.app/Contents/Frameworks/%s" % lib
|
||||||
nameNew = "@executable_path/%s/%s" % ( relativedir, lib )
|
nameNew = "@executable_path/%s/%s" % ( relativedir, lib )
|
||||||
command = "%s %s %s" % ( cmdNameId, nameNew, nameOld )
|
command = "%s %s %s" % ( cmdNameId, nameNew, nameOld )
|
||||||
if subprocess.call( command, shell=True ) != 0:
|
if subprocess.call( command, shell=True ) != 0:
|
||||||
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
||||||
print( msg % lib, file=sys.stderr )
|
print( msg % lib, file=sys.stderr )
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
# [2] Make the application aware of the new identification
|
# [2] Make the application aware of the new identification
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
nameOld = "%s" % lib
|
nameOld = "%s" % lib
|
||||||
nameNew = "@executable_path/%s/%s" % ( relativedir, lib )
|
nameNew = "@executable_path/%s/%s" % ( relativedir, lib )
|
||||||
command = "%s %s %s %s" % ( cmdNameChg, nameOld, nameNew, executable )
|
command = "%s %s %s %s" % ( cmdNameChg, nameOld, nameNew, executable )
|
||||||
if subprocess.call( command, shell=True ) != 0:
|
if subprocess.call( command, shell=True ) != 0:
|
||||||
msg = "!!! Failed to make the application aware of the new identification name <%s> !!!"
|
msg = "!!! Failed to make the application aware of the new identification name <%s> !!!"
|
||||||
print( msg % nameNew, file=sys.stderr )
|
print( msg % nameNew, file=sys.stderr )
|
||||||
return 1
|
return 1
|
||||||
# for-lib
|
# for-lib
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To make a library dependency dictionary by recursively walk down the lib hierarchy
|
## To make a library dependency dictionary by recursively walk down the lib hierarchy
|
||||||
#
|
#
|
||||||
# @param[in] dylibPath: dylib path
|
# @param[in] dylibPath: dylib path
|
||||||
# @param[in] depth: hierarchy depth (< 5)
|
# @param[in] depth: hierarchy depth (< 5)
|
||||||
# @param[in] filter_regex: filter regular expression
|
# @param[in] filter_regex: filter regular expression
|
||||||
#
|
#
|
||||||
# @return a dictionary
|
# @return a dictionary
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def WalkLibDependencyTree( dylibPath, depth=0, filter_regex=r'\t+/usr/local/opt' ):
|
def WalkLibDependencyTree( dylibPath, depth=0, filter_regex=r'\t+/usr/local/opt' ):
|
||||||
otoolCm = 'otool -L %s | grep -E "%s"' % (dylibPath, filter_regex)
|
otoolCm = 'otool -L %s | grep -E "%s"' % (dylibPath, filter_regex)
|
||||||
otoolOut = os.popen( otoolCm ).read()
|
otoolOut = os.popen( otoolCm ).read()
|
||||||
exedepdic = DecomposeLibraryDependency( dylibPath + ":\n" + otoolOut )
|
exedepdic = DecomposeLibraryDependency( dylibPath + ":\n" + otoolOut )
|
||||||
keys = exedepdic.keys()
|
keys = exedepdic.keys()
|
||||||
deplibs = exedepdic[ list(keys)[0] ]
|
deplibs = exedepdic[ list(keys)[0] ]
|
||||||
|
|
||||||
if depth < 5:
|
if depth < 5:
|
||||||
if len(deplibs) > 0:
|
if len(deplibs) > 0:
|
||||||
for idx, lib in enumerate(deplibs):
|
for idx, lib in enumerate(deplibs):
|
||||||
lib = str(lib)
|
lib = str(lib)
|
||||||
if lib != list(keys)[0]:
|
if lib != list(keys)[0]:
|
||||||
deplibs[idx] = WalkLibDependencyTree(lib, depth+1, filter_regex)
|
deplibs[idx] = WalkLibDependencyTree(lib, depth+1, filter_regex)
|
||||||
if depth == 0:
|
if depth == 0:
|
||||||
return deplibs
|
return deplibs
|
||||||
return exedepdic
|
return exedepdic
|
||||||
else:
|
else:
|
||||||
raise RuntimeError( "Exceeded maximum recursion depth." )
|
raise RuntimeError( "Exceeded maximum recursion depth." )
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To make a library dependency dictionary by recursively walk down the Framework
|
## To make a library dependency dictionary by recursively walk down the Framework
|
||||||
#
|
#
|
||||||
# @param[in] frameworkPaths: Framework path
|
# @param[in] frameworkPaths: Framework path
|
||||||
# @param[in] filter_regex: filter regular expression
|
# @param[in] filter_regex: filter regular expression
|
||||||
# @param[in] search_path_filter: search path filter regular expression
|
# @param[in] search_path_filter: search path filter regular expression
|
||||||
#
|
#
|
||||||
# @return a dictionary
|
# @return a dictionary
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def WalkFrameworkPaths( frameworkPaths, filter_regex=r'\.(so|dylib)$',
|
def WalkFrameworkPaths( frameworkPaths, filter_regex=r'\.(so|dylib)$',
|
||||||
search_path_filter=r'\t+/usr/local/opt' ):
|
search_path_filter=r'\t+/usr/local/opt' ):
|
||||||
|
|
||||||
if isinstance(frameworkPaths, str):
|
if isinstance(frameworkPaths, str):
|
||||||
frameworkPathsIter = [frameworkPaths]
|
frameworkPathsIter = [frameworkPaths]
|
||||||
else:
|
else:
|
||||||
frameworkPathsIter = frameworkPaths
|
frameworkPathsIter = frameworkPaths
|
||||||
|
|
||||||
dependency_dict = dict()
|
dependency_dict = dict()
|
||||||
|
|
||||||
for frameworkPath in frameworkPathsIter:
|
for frameworkPath in frameworkPathsIter:
|
||||||
# print("Calling:", 'find %s -type f | grep -E "%s"' % (frameworkPath, filter_regex))
|
# print("Calling:", 'find %s -type f | grep -E "%s"' % (frameworkPath, filter_regex))
|
||||||
find_grep_results = os.popen('find %s -type f | grep -E "%s"' % (frameworkPath, filter_regex)).read().split('\n')
|
find_grep_results = os.popen('find %s -type f | grep -E "%s"' % (frameworkPath, filter_regex)).read().split('\n')
|
||||||
framework_files = filter(lambda x: x != '',
|
framework_files = filter(lambda x: x != '',
|
||||||
map(lambda x: x.strip(),
|
map(lambda x: x.strip(),
|
||||||
find_grep_results))
|
find_grep_results))
|
||||||
|
|
||||||
dependency_dict[frameworkPath] = list()
|
dependency_dict[frameworkPath] = list()
|
||||||
for idx, file in enumerate(framework_files):
|
for idx, file in enumerate(framework_files):
|
||||||
dict_file = {file: WalkLibDependencyTree(file, filter_regex=search_path_filter)}
|
dict_file = {file: WalkLibDependencyTree(file, filter_regex=search_path_filter)}
|
||||||
dependency_dict[frameworkPath].append(dict_file)
|
dependency_dict[frameworkPath].append(dict_file)
|
||||||
return dependency_dict
|
return dependency_dict
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To make a list of changed libraries
|
## To make a list of changed libraries
|
||||||
#
|
#
|
||||||
# @param[in] dependencyDict: library dependency dictionary
|
# @param[in] dependencyDict: library dependency dictionary
|
||||||
# @param[in] visited_files: list of visited files
|
# @param[in] visited_files: list of visited files
|
||||||
#
|
#
|
||||||
# @return a list
|
# @return a list
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def WalkDictTree( dependencyDict, visited_files ):
|
def WalkDictTree( dependencyDict, visited_files ):
|
||||||
libNameChanges = list()
|
libNameChanges = list()
|
||||||
for lib, dependencies in dependencyDict.items():
|
for lib, dependencies in dependencyDict.items():
|
||||||
if lib in visited_files:
|
if lib in visited_files:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
dependency_list = list()
|
dependency_list = list()
|
||||||
if isinstance(dependencies, list):
|
if isinstance(dependencies, list):
|
||||||
for deplib in dependencies:
|
for deplib in dependencies:
|
||||||
if isinstance(deplib, str):
|
if isinstance(deplib, str):
|
||||||
dependency_list.append(deplib)
|
dependency_list.append(deplib)
|
||||||
if deplib not in visited_files:
|
if deplib not in visited_files:
|
||||||
visited_files.append(deplib)
|
visited_files.append(deplib)
|
||||||
elif isinstance(deplib, dict):
|
elif isinstance(deplib, dict):
|
||||||
dependency_list.append(next(iter(deplib)))
|
dependency_list.append(next(iter(deplib)))
|
||||||
libNameChanges.extend(WalkDictTree(deplib, visited_files))
|
libNameChanges.extend(WalkDictTree(deplib, visited_files))
|
||||||
else:
|
else:
|
||||||
#raise RuntimeError("Unexpected value: %s" % deplib)
|
#raise RuntimeError("Unexpected value: %s" % deplib)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Unexpected value: %s" % dependencies)
|
raise RuntimeError("Unexpected value: %s" % dependencies)
|
||||||
if len(dependency_list) > 0:
|
if len(dependency_list) > 0:
|
||||||
libNameChanges.append((lib, dependency_list))
|
libNameChanges.append((lib, dependency_list))
|
||||||
else:
|
else:
|
||||||
libNameChanges.append((lib, ))
|
libNameChanges.append((lib, ))
|
||||||
visited_files.append(lib)
|
visited_files.append(lib)
|
||||||
return libNameChanges
|
return libNameChanges
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To find the Framework name from a library name
|
## To find the Framework name from a library name
|
||||||
#
|
#
|
||||||
# @param[in] path: path to a library
|
# @param[in] path: path to a library
|
||||||
# @param[in] root_path: root path
|
# @param[in] root_path: root path
|
||||||
#
|
#
|
||||||
# @return the path to a Framework
|
# @return the path to a Framework
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def FindFramework( path, root_path ):
|
def FindFramework( path, root_path ):
|
||||||
relPath = os.path.relpath(path, root_path)
|
relPath = os.path.relpath(path, root_path)
|
||||||
frmPath = os.path.join(root_path, relPath.split(os.sep)[0])
|
frmPath = os.path.join(root_path, relPath.split(os.sep)[0])
|
||||||
#print( "###", frmPath, path, root_path )
|
#print( "###", frmPath, path, root_path )
|
||||||
return frmPath
|
return frmPath
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To resolve an executable path
|
## To resolve an executable path
|
||||||
#
|
#
|
||||||
# @param[in] path: a path to resolve
|
# @param[in] path: a path to resolve
|
||||||
# @param[in] executable_path: an executable path
|
# @param[in] executable_path: an executable path
|
||||||
#
|
#
|
||||||
# @return the resolved path
|
# @return the resolved path
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def ResolveExecutablePath( path, executable_path ):
|
def ResolveExecutablePath( path, executable_path ):
|
||||||
""" Transforms @executable_path into executable_path"""
|
""" Transforms @executable_path into executable_path"""
|
||||||
p = path.replace("@executable_path", "/%s/" % executable_path)
|
p = path.replace("@executable_path", "/%s/" % executable_path)
|
||||||
return p
|
return p
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To detect the changed library names
|
## To detect the changed library names
|
||||||
#
|
#
|
||||||
# @param[in] frameworkDependencyDict: framework dependency dictionary
|
# @param[in] frameworkDependencyDict: framework dependency dictionary
|
||||||
#
|
#
|
||||||
# @return a list of changes, each of which is stored in the form of
|
# @return a list of changes, each of which is stored in the form of
|
||||||
# * ('lib.dylib', ['dep1.dylib', ...])
|
# * ('lib.dylib', ['dep1.dylib', ...])
|
||||||
# OR
|
# OR
|
||||||
# * ('lib.dylib',)
|
# * ('lib.dylib',)
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def DetectChanges(frameworkDependencyDict):
|
def DetectChanges(frameworkDependencyDict):
|
||||||
visited_files = list()
|
visited_files = list()
|
||||||
libNameChanges = list()
|
libNameChanges = list()
|
||||||
for framework, libraries in frameworkDependencyDict.items():
|
for framework, libraries in frameworkDependencyDict.items():
|
||||||
for libraryDict in libraries:
|
for libraryDict in libraries:
|
||||||
libNameChanges.extend(WalkDictTree(libraryDict, visited_files))
|
libNameChanges.extend(WalkDictTree(libraryDict, visited_files))
|
||||||
return libNameChanges
|
return libNameChanges
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To perform the required changes
|
## To perform the required changes
|
||||||
#
|
#
|
||||||
# @param[in] frameworkDependencyDict: framework dependency dictionary
|
# @param[in] frameworkDependencyDict: framework dependency dictionary
|
||||||
# @param[in] replaceFromToPairs: (from, to)-pair for replacement
|
# @param[in] replaceFromToPairs: (from, to)-pair for replacement
|
||||||
# @param[in] executable_path: executable path
|
# @param[in] executable_path: executable path
|
||||||
#
|
#
|
||||||
# @return 0 on success; > 0 on failure
|
# @return 0 on success; > 0 on failure
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def PerformChanges( frameworkDependencyDict, replaceFromToPairs=None, executable_path="/tmp/klayout" ):
|
def PerformChanges( frameworkDependencyDict, replaceFromToPairs=None, executable_path="/tmp/klayout" ):
|
||||||
libNameChanges = DetectChanges(frameworkDependencyDict)
|
libNameChanges = DetectChanges(frameworkDependencyDict)
|
||||||
#print(libNameChanges)
|
#print(libNameChanges)
|
||||||
cmdNameId = XcodeToolChain['nameID']
|
cmdNameId = XcodeToolChain['nameID']
|
||||||
cmdNameChg = XcodeToolChain['nameCH']
|
cmdNameChg = XcodeToolChain['nameCH']
|
||||||
|
|
||||||
if replaceFromToPairs is None:
|
if replaceFromToPairs is None:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
for libNameChange in libNameChanges:
|
for libNameChange in libNameChanges:
|
||||||
libNameChangeIterator = iter(libNameChange)
|
libNameChangeIterator = iter(libNameChange)
|
||||||
lib = next(libNameChangeIterator)
|
lib = next(libNameChangeIterator)
|
||||||
try:
|
try:
|
||||||
dependencies = next(libNameChangeIterator)
|
dependencies = next(libNameChangeIterator)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
dependencies = list()
|
dependencies = list()
|
||||||
for replaceFrom, replaceTo, libdir in replaceFromToPairs:
|
for replaceFrom, replaceTo, libdir in replaceFromToPairs:
|
||||||
fileName = ResolveExecutablePath(lib.replace(replaceFrom, replaceTo), executable_path)
|
fileName = ResolveExecutablePath(lib.replace(replaceFrom, replaceTo), executable_path)
|
||||||
if fileName.startswith('/usr'):
|
if fileName.startswith('/usr'):
|
||||||
# print(f'skipping fileName: {fileName}')
|
# print(f'skipping fileName: {fileName}')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if lib.find(replaceFrom) >= 0:
|
if lib.find(replaceFrom) >= 0:
|
||||||
if libdir:
|
if libdir:
|
||||||
frameworkPath = FindFramework(lib, replaceFrom)
|
frameworkPath = FindFramework(lib, replaceFrom)
|
||||||
else:
|
else:
|
||||||
frameworkPath = lib
|
frameworkPath = lib
|
||||||
destFrameworkPath = frameworkPath.replace(replaceFrom, replaceTo)
|
destFrameworkPath = frameworkPath.replace(replaceFrom, replaceTo)
|
||||||
destFrameworkPath = ResolveExecutablePath(destFrameworkPath, executable_path)
|
destFrameworkPath = ResolveExecutablePath(destFrameworkPath, executable_path)
|
||||||
|
|
||||||
if not os.path.exists(fileName):
|
if not os.path.exists(fileName):
|
||||||
print( " NOT FOUND:", lib.replace(replaceFrom, replaceTo) )
|
print( " NOT FOUND:", lib.replace(replaceFrom, replaceTo) )
|
||||||
print( " COPYING:", frameworkPath, " -> ", destFrameworkPath )
|
print( " COPYING:", frameworkPath, " -> ", destFrameworkPath )
|
||||||
shutil.copytree(frameworkPath, destFrameworkPath)
|
shutil.copytree(frameworkPath, destFrameworkPath)
|
||||||
|
|
||||||
nameId = lib.replace(replaceFrom, replaceTo)
|
nameId = lib.replace(replaceFrom, replaceTo)
|
||||||
command = "%s %s %s" % ( cmdNameId, nameId, fileName )
|
command = "%s %s %s" % ( cmdNameId, nameId, fileName )
|
||||||
if not os.access(fileName, os.W_OK):
|
if not os.access(fileName, os.W_OK):
|
||||||
command = "chmod u+w %s; %s; chmod u-w %s" % (fileName, command, fileName)
|
command = "chmod u+w %s; %s; chmod u-w %s" % (fileName, command, fileName)
|
||||||
# print("\t%s" % command)
|
# print("\t%s" % command)
|
||||||
if subprocess.call( command, shell=True ) != 0:
|
if subprocess.call( command, shell=True ) != 0:
|
||||||
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
||||||
print( msg % fileName, file=sys.stderr )
|
print( msg % fileName, file=sys.stderr )
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for dependency in dependencies:
|
for dependency in dependencies:
|
||||||
if dependency.find(replaceFrom) >= 0:
|
if dependency.find(replaceFrom) >= 0:
|
||||||
print( " IN:", fileName )
|
print( " IN:", fileName )
|
||||||
print( " RENAMING:", dependency, " -> ", dependency.replace(replaceFrom, replaceTo) )
|
print( " RENAMING:", dependency, " -> ", dependency.replace(replaceFrom, replaceTo) )
|
||||||
|
|
||||||
# Try changing id first
|
# Try changing id first
|
||||||
nameId = dependency.replace(replaceFrom, replaceTo)
|
nameId = dependency.replace(replaceFrom, replaceTo)
|
||||||
command = "%s %s %s" % ( cmdNameId, nameId, fileName)
|
command = "%s %s %s" % ( cmdNameId, nameId, fileName)
|
||||||
if not os.access(str(fileName), os.W_OK):
|
if not os.access(str(fileName), os.W_OK):
|
||||||
command = "chmod u+w %s; %s; chmod u-w %s" % (fileName, command, fileName)
|
command = "chmod u+w %s; %s; chmod u-w %s" % (fileName, command, fileName)
|
||||||
# print("\t%s" % command)
|
# print("\t%s" % command)
|
||||||
if subprocess.call( command, shell=True ) != 0:
|
if subprocess.call( command, shell=True ) != 0:
|
||||||
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
||||||
print( msg % fileName, file=sys.stderr )
|
print( msg % fileName, file=sys.stderr )
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# Rename dependencies
|
# Rename dependencies
|
||||||
nameOld = dependency
|
nameOld = dependency
|
||||||
nameNew = dependency.replace(replaceFrom, replaceTo)
|
nameNew = dependency.replace(replaceFrom, replaceTo)
|
||||||
command = "%s %s %s %s" % ( cmdNameChg, nameOld, nameNew, str(fileName) )
|
command = "%s %s %s %s" % ( cmdNameChg, nameOld, nameNew, str(fileName) )
|
||||||
if not os.access(str(fileName), os.W_OK):
|
if not os.access(str(fileName), os.W_OK):
|
||||||
command = "chmod u+w %s; %s; chmod u-w %s" % (fileName, command, fileName)
|
command = "chmod u+w %s; %s; chmod u-w %s" % (fileName, command, fileName)
|
||||||
|
|
||||||
# print("\t%s" % command)
|
# print("\t%s" % command)
|
||||||
if subprocess.call( command, shell=True ) != 0:
|
if subprocess.call( command, shell=True ) != 0:
|
||||||
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
msg = "!!! Failed to set the new identification name to <%s> !!!"
|
||||||
print( msg % fileName, file=sys.stderr )
|
print( msg % fileName, file=sys.stderr )
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To get KLayout's version from a file; most likely from 'version.sh'
|
## To get KLayout's version from a file; most likely from 'version.sh'
|
||||||
#
|
#
|
||||||
# @param[in] verfile version file from which version is retrieved
|
# @param[in] verfile version file from which version is retrieved
|
||||||
#
|
#
|
||||||
# @return version string
|
# @return version string
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def GetKLayoutVersionFrom( verfile='version.h' ):
|
def GetKLayoutVersionFrom( verfile='version.h' ):
|
||||||
version = "?.?.?"
|
version = "?.?.?"
|
||||||
try:
|
try:
|
||||||
fd = open( verfile, "r" )
|
fd = open( verfile, "r" )
|
||||||
contents = fd.readlines()
|
contents = fd.readlines()
|
||||||
fd.close()
|
fd.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return version
|
return version
|
||||||
|
|
||||||
verReg = re.compile( u'(KLAYOUT_VERSION=\")([0-9A-Z_a-z\.]+)(\")' )
|
verReg = re.compile( u'(KLAYOUT_VERSION=\")([0-9A-Z_a-z\.]+)(\")' )
|
||||||
for line in contents:
|
for line in contents:
|
||||||
m = verReg.match(line)
|
m = verReg.match(line)
|
||||||
if m:
|
if m:
|
||||||
# print(m.group(0)) # KLAYOUT_VERSION="0.26.1"
|
# print(m.group(0)) # KLAYOUT_VERSION="0.26.1"
|
||||||
# print(m.group(1)) # KLAYOUT_VERSION="
|
# print(m.group(1)) # KLAYOUT_VERSION="
|
||||||
# print(m.group(2)) # 0.26.1
|
# print(m.group(2)) # 0.26.1
|
||||||
# print(m.group(3)) # "
|
# print(m.group(3)) # "
|
||||||
version = m.group(2)
|
version = m.group(2)
|
||||||
return version
|
return version
|
||||||
return version
|
return version
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
## To generate the contents of "Info.plist" file from a template
|
## To generate the contents of "Info.plist" file from a template
|
||||||
#
|
#
|
||||||
# @param[in] keydic dictionary of four key words ['exe', 'icon', 'bname', 'ver']
|
# @param[in] keydic dictionary of four key words ['exe', 'icon', 'bname', 'ver']
|
||||||
# @param[in] templfile template file ("macbuild/Resources/Info.plist.template")
|
# @param[in] templfile template file ("macbuild/Resources/Info.plist.template")
|
||||||
#
|
#
|
||||||
# @return generated strings
|
# @return generated strings
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
def GenerateInfoPlist( keydic, templfile ):
|
def GenerateInfoPlist( keydic, templfile ):
|
||||||
val_exe = keydic['exe']
|
val_exe = keydic['exe']
|
||||||
val_icon = keydic['icon']
|
val_icon = keydic['icon']
|
||||||
val_bname = keydic['bname']
|
val_bname = keydic['bname']
|
||||||
val_ver = keydic['ver']
|
val_ver = keydic['ver']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fd = open( templfile, "r" )
|
fd = open( templfile, "r" )
|
||||||
template = fd.read()
|
template = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return "???"
|
return "???"
|
||||||
|
|
||||||
t = string.Template(template)
|
t = string.Template(template)
|
||||||
s = t.substitute( EXECUTABLE = val_exe,
|
s = t.substitute( EXECUTABLE = val_exe,
|
||||||
ICONFILE = val_icon,
|
ICONFILE = val_icon,
|
||||||
BUNDLENAME = val_bname,
|
BUNDLENAME = val_bname,
|
||||||
VERSION = val_ver)
|
VERSION = val_ver)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
#----------------
|
#----------------
|
||||||
# End of File
|
# End of File
|
||||||
#----------------
|
#----------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue