Merge pull request #86 from lightwave-lab/master

Building KLayout on macOS High Sierra with python3 from brew and Qt 5.9.4
This commit is contained in:
Matthias Köfferlein 2018-03-11 22:20:41 +01:00 committed by GitHub
commit 4ef4635e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 228 additions and 26 deletions

1
macbuild/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.pyc

View File

@ -62,7 +62,7 @@ $ ./build4mac.py -r mp24 -p mp36
```
$ ./build4mac.py -r mp24 -p mp36 -Y
```
* [-Y|--DEPOLY] option deploys KLayout's dylibs and executables only.
* [-Y|--DEPLOY] option deploys KLayout's dylibs and executables only.
That is, paths to other modules (Ruby, Python, and Qt5 Frameworks) remain unchanged (absolute paths in your development environment).
5. Copy/move generated bundles ("klayout.app" and "klayout.scripts/") to your "/Applications" directory for installation.
@ -84,4 +84,25 @@ $ ./makeDMG4mac.py -p qt5.pkg.macos-HighSierra-release -m
```
By: Kazzz (January 16, 2018)
# 5. Alternative building options
### 5.1 Python 3.6 from brew, Qt 5.9.4 from offline installer
Homebrew's installation of python3 places a `Python.framework` in `/usr/local/opt/python/Frameworks/Python.framework/`, which you can use to build KLayout from. Qt can be downloaded for [offline installation](https://www1.qt.io/offline-installers/). You can place it in your home folder: e.g. `/home/username/Qt5.9.4/`. Given these two dependencies, you can successfully compile KLayout with the following commands:
```
# Build step
./build4mac.py -p B36 -q Qt5Custom
# Deploy step
./build4mac.py -p B36 -q Qt5Custom -y # normal deploy
./build4mac.py -p B36 -q Qt5Custom -y -v 3 2>&1 | tee qt5.pkg.macos-HighSierra-release.log # deploy with debug options
# Packaging step
./makeDMG4mac.py -p qt5.pkg.macos-HighSierra-release -m -q Qt594
```
PS: If you get a syntax error in one of ruby's libraries because it is not compatible with C++11, do not fret. You only have to change one offending file.
[End of File]

View File

@ -60,7 +60,7 @@ Relevant KLayout version: 0.25.1
to deploy executables and libraries under "klayout.app" bundle.
The buddy command line tools (strm*) will also be deployed.
$ ./build4mac.py -r mp24 -p mp36 -Y
* [-Y|--DEPOLY] option deploys KLayout's dylibs and executables only.
* [-Y|--DEPLOY] option deploys KLayout's dylibs and executables only.
That is, paths to other modules (Ruby, Python, and Qt5 Frameworks)
remain unchanged (absolute paths in your development environment).
(5) Copy/move generated bundles ("klayout.app" and "klayout.scripts/") to your

View File

@ -0,0 +1,116 @@
-------------------------------------------------------------------------------------------------
(*
* Template File:
* macbuild/Resources/template-KLayoutDMG.applescript
*
* Actual AppleScrip File to be generated:
* macbuild/Resources/KLayoutDMG.applescript
*
* Description:
* A template AppleScript to make a fancy DMG installer of KLayout
* (http://www.klayout.de/index.php) bundles.
* "makeDMG4mac.py" will read this template and generate the actual AppleScript to execute.
* Values to be found and replaced by "makeDMG4mac.py" are marked by ${KEYWORD}.
*
* The background image was designed using Logoist2 (http://www.syniumsoftware.com/en/logoist)
* and exported to a PNG file of 1000 x 700 pix size.
*-----------------------------------------------------------------------------------------------
* This is a derivative work of Ref. 2) below. Refer to "macbuild/LICENSE" file.
* Ref.
* 1) https://el-tramo.be/guides/fancy-dmg/
* 2) https://github.com/andreyvit/create-dmg.git
*)
-------------------------------------------------------------------------------------------------
on run (volumeName) -- most likely, the volume name is "KLayout"
tell application "Finder"
tell disk (volumeName as string)
-- [1] Open the volume
open
-- [2] Set the key coordinates and windows size
-- The size of given background PNG image is 1000 x 700 pix
-- ORGX = [50] pix
-- ORGY = [100] pix
-- WIN_WIDTH = [1000] pix
-- WIN_HEIGHT = [700] pix
set posMargin to 50
set negMargin to 10
set theTopLeftX to 50
set theTopLeftY to 100
set theWidth to 1000
set theHeight to 700
set theBottomRightX to (theTopLeftX + theWidth + posMargin)
set theBottomRightY to (theTopLeftY + theHeight + posMargin)
-- [3] Set the full path to .DS_Store file
set dotDSStore to "/Volumes/KLayout/.DS_Store"
-- [4] Set global view options
tell container window
set current view to icon view
set toolbar visible to false
set statusbar visible to false
set statusbar visible to false
set bounds to {theTopLeftX, theTopLeftY, theBottomRightX, theBottomRightY}
set position of every item to {theTopLeftX + 150, theTopLeftY + 350}
end tell
-- [5] Set icon view options
set opts to the icon view options of container window
tell opts
set icon size to 80
set text size to 16
set arrangement to not arranged
end tell
-- [6] Set the background PNG image (1000 x 700 pix) file name stored
set background picture of opts to file ".background:KLayoutDMG-Back.png"
-- [7] Set positions of each icon
-- ITEM_1 = klayout.app {960, 140}
-- ITEM_2 = klayout.scripts {610, 140}
-- ITEM_3 = Applications {790, 140}
set position of item "klayout.app" to {960, 140}
set position of item "klayout.scripts" to {610, 140}
set position of item "Applications" to {790, 140}
-- [8] Update the contents of container
close
open
update without registering applications
-- [9] Force save the negatively resized window size
delay 2
tell container window
set statusbar visible to false
set bounds to {theTopLeftX, theTopLeftY, theBottomRightX - negMargin, theBottomRightY - negMargin}
end tell
update without registering applications
end tell
-- [10] Restore back the original window size
delay 2
tell disk (volumeName as string)
tell container window
set statusbar visible to false
set bounds to {theTopLeftX, theTopLeftY, theBottomRightX, theBottomRightY}
end tell
update without registering applications
end tell
-- [11] Wait for some time so that "Finder" can complete writing to .DS_Store file
delay 3
set elapsedTime to 0
set ejected to false
repeat while ejected is false
delay 1
set elapsedTime to elapsedTime + 1
if (do shell script "[ -f " & dotDSStore & " ]; echo $?") = "0" then set ejected to true
end repeat
log "### Elapsed <" & elapsedTime & "> [sec] for writing .DS_Store file."
end tell
end run
--
-- End of file
--

View File

@ -0,0 +1,4 @@
[Paths]
Plugins = ../PlugIns
Imports = ../Resources/qml
Qml2Imports = ../Resources/qml

View File

@ -65,9 +65,9 @@ def SetGlobals():
Usage += " : 'nil' = not to support the script language | \n"
Usage += " : 'Sys' = using the OS standard script language | \n"
Usage += " : Refer to 'macbuild/build4mac_env.py' for details | \n"
Usage += " [-q|--qt <type>] : type=['Qt4MacPorts', 'Qt5MacPorts'] | qt5macports \n"
Usage += " [-r|--ruby <type>] : type=['nil', 'Sys', 'Src24', 'MP24'] | sys \n"
Usage += " [-p|--python <type>] : type=['nil', 'Sys', 'Ana27', 'Ana36', 'MP36'] | sys \n"
Usage += " [-q|--qt <type>] : type=['Qt4MacPorts', 'Qt5MacPorts', 'Qt5Custom'] | qt5macports \n"
Usage += " [-r|--ruby <type>] : type=['nil', 'Sys', 'Src24', 'MP24', 'B25'] | sys \n"
Usage += " [-p|--python <type>] : type=['nil', 'Sys', 'Ana27', 'Ana36', 'MP36', 'B36'] | sys \n"
Usage += " [-n|--noqtbinding] : don't create Qt bindings for ruby scripts | disabled \n"
Usage += " [-m|--make <option>] : option passed to 'make' | -j4 \n"
Usage += " [-d|--debug] : enable debug mode build | disabled \n"
@ -239,7 +239,7 @@ def ParseCommandLineArguments():
quit()
# Determine Qt type
candidates = [ i.upper() for i in ['Qt4MacPorts', 'Qt5MacPorts'] ]
candidates = [ i.upper() for i in ['Qt4MacPorts', 'Qt5MacPorts', 'Qt5Custom'] ]
ModuleQt = ""
index = 0
for item in candidates:
@ -250,6 +250,9 @@ def ParseCommandLineArguments():
elif index == 1:
ModuleQt = 'Qt5MacPorts'
break
elif index == 2:
ModuleQt = 'Qt5Custom'
break
else:
index += 1
if ModuleQt == "":
@ -262,7 +265,7 @@ def ParseCommandLineArguments():
NonOSStdLang = False
# Determine Ruby type
candidates = [ i.upper() for i in ['nil', 'Sys', 'Src24', 'MP24'] ]
candidates = [ i.upper() for i in ['nil', 'Sys', 'Src24', 'MP24', 'B25'] ]
ModuleRuby = ""
index = 0
for item in candidates:
@ -288,6 +291,9 @@ def ParseCommandLineArguments():
elif index == 3:
ModuleRuby = 'Ruby24MacPorts'
NonOSStdLang = True
elif index == 4:
ModuleRuby = 'Ruby25Brew'
NonOSStdLang = True
else:
index += 1
if ModuleRuby == "":
@ -297,7 +303,7 @@ def ParseCommandLineArguments():
quit()
# Determine Python type
candidates = [ i.upper() for i in ['nil', 'Sys', 'Ana27', 'Ana36', 'MP36'] ]
candidates = [ i.upper() for i in ['nil', 'Sys', 'Ana27', 'Ana36', 'MP36', 'B36'] ]
ModulePython = ""
index = 0
for item in candidates:
@ -326,6 +332,9 @@ def ParseCommandLineArguments():
elif index == 4:
ModulePython = 'Python36MacPorts'
NonOSStdLang = True
elif index == 5:
ModulePython = 'Python36Brew'
NonOSStdLang = True
else:
index += 1
if ModulePython == "":
@ -427,6 +436,20 @@ def RunMainBuildBash():
AbsMacBuildLog = "%s/qt5.build.macos-%s-%s.log" % (ProjectDir, Platform, mode)
parameters += " \\\n -bin %s" % MacBinDir
parameters += " \\\n -build %s" % MacBuildDir
elif ModuleQt == 'Qt5Custom':
parameters += " \\\n -qt5"
parameters += " \\\n -qmake %s" % Qt5Custom['qmake']
MacPkgDir = "./qt5.pkg.macos-%s-%s" % (Platform, mode)
MacBinDir = "./qt5.bin.macos-%s-%s" % (Platform, mode)
MacBuildDir = "./qt5.build.macos-%s-%s" % (Platform, mode)
MacBuildLog = "./qt5.build.macos-%s-%s.log" % (Platform, mode)
AbsMacPkgDir = "%s/qt5.pkg.macos-%s-%s" % (ProjectDir, Platform, mode)
AbsMacBinDir = "%s/qt5.bin.macos-%s-%s" % (ProjectDir, Platform, mode)
AbsMacBuildDir = "%s/qt5.build.macos-%s-%s" % (ProjectDir, Platform, mode)
AbsMacBuildLog = "%s/qt5.build.macos-%s-%s.log" % (ProjectDir, Platform, mode)
parameters += " \\\n -bin %s" % MacBinDir
parameters += " \\\n -build %s" % MacBuildDir
parameters += " \\\n -rpath %s" % "@executable_path/../Frameworks"
# (C) want Qt bindings with Ruby scripts?
if NoQtBindings:
@ -524,9 +547,9 @@ def DeployBinariesForBundle():
if not DeploymentF and not DeploymentP:
return 1
if DeploymentF and NonOSStdLang:
print( "!!! You chose <-y|--deploy> while using non-OS-standard script language.", file=sys.stderr )
print( "WARNING!!! You chose <-y|--deploy> while using non-OS-standard script language.", file=sys.stderr )
print( " Use <-Y|--DEPLOY> instead", file=sys.stderr )
return 1
#return 1
if not os.path.isfile(MacBuildLog):
print( "!!! Build log file <%s> does not present !!!" % MacBuildLog, file=sys.stderr )
return 1
@ -629,7 +652,7 @@ def DeployBinariesForBundle():
# e.g. [ 'libklayout_lay', '0', '25', '0', 'dylib' ]
nameStyle3 = fullName[0] + "." + fullName[1] + ".dylib"
shutil.copy2( item, nameStyle3 )
os.chmod( nameStyle3, 0755 )
os.chmod( nameStyle3, 0o0755 )
#-------------------------------------------------------------------
# (B) Then get inter-library dependencies
#-------------------------------------------------------------------
@ -676,17 +699,20 @@ def DeployBinariesForBundle():
shutil.copy2( sourceDir0 + "/PkgInfo", targetDir0 ) # this file is not mandatory
shutil.copy2( sourceDir1 + "/klayout", targetDirM )
shutil.copy2( sourceDir2 + "/klayout.icns", targetDirR )
shutil.copy2( sourceDir2 + "/qt.conf", targetDirM )
os.chmod( targetDir0 + "/PkgInfo", 0644 )
os.chmod( targetDir0 + "/Info.plist", 0644 )
os.chmod( targetDirM + "/klayout", 0755 )
os.chmod( targetDirR + "/klayout.icns", 0644 )
os.chmod( targetDir0 + "/PkgInfo", 0o0644 )
os.chmod( targetDir0 + "/Info.plist", 0o0644 )
os.chmod( targetDirM + "/klayout", 0o0755 )
os.chmod( targetDirM + "/qt.conf", 0o0644 )
os.chmod( targetDirR + "/klayout.icns", 0o0644 )
buddies = glob.glob( sourceDir3 + "/strm*" )
for item in buddies:
shutil.copy2( item, targetDirB )
buddy = os.path.basename(item)
os.chmod( targetDirB + "/" + buddy, 0755 )
os.chmod( targetDirB + "/" + buddy, 0o0755 )
print( " [7] Setting and changing the identification names of KLayout's libraries in each executable ..." )
@ -729,10 +755,15 @@ def DeployBinariesForBundle():
deploytool = Qt5MacPorts['deploy']
app_bundle = "klayout.app"
options = macdepQtOpt + verbose
elif ModuleQt == 'Qt5Custom':
deploytool = Qt5Custom['deploy']
app_bundle = "klayout.app"
options = macdepQtOpt + verbose
os.chdir(ProjectDir)
os.chdir(MacPkgDir)
command = "%s %s %s" % ( deploytool, app_bundle, options )
print(command)
if subprocess.call( command, shell=True ) != 0:
msg = "!!! Failed to deploy applications on OSX !!!"
print( msg, file=sys.stderr )
@ -834,10 +865,10 @@ def DeployScriptBundles():
shutil.copy2( resourceDir + "/klayout-red.icns", targetDirRE )
shutil.copy2( resourceDir + "/klayout-blue.icns", targetDirRV )
os.chmod( targetDirME + "/KLayoutEditor.sh", 0755 )
os.chmod( targetDirMV + "/KLayoutViewer.sh", 0755 )
os.chmod( targetDirRE + "/klayout-red.icns", 0644 )
os.chmod( targetDirRV + "/klayout-blue.icns", 0644 )
os.chmod( targetDirME + "/KLayoutEditor.sh", 0o0755 )
os.chmod( targetDirMV + "/KLayoutViewer.sh", 0o0755 )
os.chmod( targetDirRE + "/klayout-red.icns", 0o0644 )
os.chmod( targetDirRV + "/klayout-blue.icns", 0o0644 )
tmpfileE = ProjectDir + "/macbuild/Resources/Info.plist.template"
keydicE = { 'exe': 'KLayoutEditor.sh', 'icon': 'klayout-red.icns', 'bname': 'klayout', 'ver': Version }

View File

@ -21,7 +21,7 @@ XcodeToolChain = { 'nameID': '/usr/bin/install_name_tool -id ',
#-----------------------------------------------------
# [1] Qt
#-----------------------------------------------------
Qts = [ 'Qt4MacPorts', 'Qt5MacPorts' ]
Qts = [ 'Qt4MacPorts', 'Qt5MacPorts', 'Qt5Custom' ]
#-----------------------------------------------------
# Whereabout of different components of Qt4
@ -41,11 +41,23 @@ Qt5MacPorts = { 'qmake' : '/opt/local/libexec/qt5/bin/qmake',
'deploy': '/opt/local/libexec/qt5/bin/macdeployqt'
}
# # Qt5 from Brew
# # [Key Type Name] = 'Qt5Brew'
# Qt5Brew = { 'qmake' : '/usr/local/Cellar/qt5/5.10.0_1/bin/qmake',
# 'deploy': '/usr/local/Cellar/qt5/5.10.0_1/bin/macdeployqt'
# }
# Qt5 Custom (https://www1.qt.io/offline-installers/)
# [Key Type Name] = 'Qt5Custom'
Qt5Custom = { 'qmake' : '~/Qt5.9.4/5.9.4/clang_64/bin/qmake',
'deploy': '~/Qt5.9.4/5.9.4/clang_64/bin/macdeployqt'
}
#-----------------------------------------------------
# [2] Ruby
#-----------------------------------------------------
Rubies = [ 'nil', 'RubyYosemite', 'RubyElCapitan', 'RubySierra', 'RubyHighSierra' ]
Rubies += [ 'Ruby24SrcBuild', 'Ruby24MacPorts' ]
Rubies += [ 'Ruby24SrcBuild', 'Ruby24MacPorts', 'Ruby24Brew' ]
#-----------------------------------------------------
# Whereabout of different components of Ruby
@ -94,6 +106,13 @@ Ruby24MacPorts = { 'exe': '/opt/local/bin/ruby2.4',
'lib': '/opt/local/lib/libruby.2.4.dylib'
}
# Ruby 2.5 from Brew *+*+*+ EXPERIMENTAL *+*+*+
# [Key Type Name] = 'Brew25'
Ruby25Brew = { 'exe': '/usr/local/bin/ruby',
'inc': '/usr/local/include/ruby-2.5.0',
'lib': '/usr/local/lib/libruby.2.5.0.dylib'
}
# Consolidated dictionary kit for Ruby
RubyDictionary = { 'nil' : None,
'RubyYosemite' : RubyYosemite,
@ -101,14 +120,15 @@ RubyDictionary = { 'nil' : None,
'RubySierra' : RubySierra,
'RubyHighSierra': RubyHighSierra,
'Ruby24SrcBuild': Ruby24SrcBuild,
'Ruby24MacPorts': Ruby24MacPorts
'Ruby24MacPorts': Ruby24MacPorts,
'Ruby25Brew' : Ruby25Brew
}
#-----------------------------------------------------
# [3] Python
#-----------------------------------------------------
Pythons = [ 'nil', 'PythonYosemite', 'PythonElCapitan', 'PythonSierra', 'PythonHighSierra' ]
Pythons += [ 'Anaconda27', 'Anaconda36', 'Python36MacPorts' ]
Pythons += [ 'Anaconda27', 'Anaconda36', 'Python36MacPorts', 'Python36Brew' ]
#-----------------------------------------------------
# Whereabout of different components of Python
@ -170,6 +190,13 @@ Python36MacPorts= { 'exe': '/opt/local/Library/Frameworks/Python.framework/Versi
'lib': '/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib'
}
# Python 3.6 from Brew *+*+*+ EXPERIMENTAL *+*+*+
# [Key Type Name] = 'pybrew'
Python36Brew= { 'exe': '/usr/local/opt/python3/Frameworks/Python.framework/Versions/Current/bin/python3.6m' ,
'inc': '/usr/local/opt/python3/Frameworks/Python.framework/Versions/Current/include/python3.6m',
'lib': '/usr/local/opt/python3/Frameworks/Python.framework/Versions/Current/lib/libpython3.6m.dylib'
}
# Consolidated dictionary kit for Python
PythonDictionary= { 'nil' : None,
'PythonYosemite' : PythonYosemite,
@ -178,7 +205,8 @@ PythonDictionary= { 'nil' : None,
'PythonHighSierra': PythonHighSierra,
'Anaconda27' : Anaconda27,
'Anaconda36' : Anaconda36,
'Python36MacPorts': Python36MacPorts
'Python36MacPorts': Python36MacPorts,
'Python36Brew' : Python36Brew,
}
#-----------------------------------------------------

View File

@ -143,7 +143,7 @@ def SetChangeLibIdentificationName( executable, relativedir ):
otoolOut = os.popen( otoolCm ).read()
exedepdic = DecomposeLibraryDependency( executable + ":\n" + otoolOut )
keys = exedepdic.keys()
deplibs = exedepdic[ keys[0] ]
deplibs = exedepdic[ list(keys)[0] ]
for lib in deplibs:
#-----------------------------------------------------------

View File

@ -62,6 +62,7 @@ QMAKE_CXXFLAGS_WARN_ON += \
-Wno-long-long \
-Wno-strict-aliasing \
-Wno-deprecated-declarations \
-Wno-reserved-user-defined-literal \
QT += network xml sql