diff --git a/README.md b/README.md index b069f6401..32bcfbc1c 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,10 @@ For more details see http://www.klayout.org. ## Building requirements -* Qt 4.8 or later (4.6 with some restrictions) -* gcc 4.x or later +* Qt 4.7 or later (4.6 with some restrictions) or Qt 5 +* gcc 4.6 or later or clang 3.8 or later -Here is a list of packages required for various Linux flavors: - -* CentOS (6, 7): gcc gcc-c++ make qt qt-devel ruby ruby-devel python python-devel -* OpenSuSE: (13.2, 41.1): gcc gcc-c++ make libqt4 libqt4-devel ruby ruby-devel python3 python3-devel -* Ubuntu (14.04, 16.10): gcc g++ make libz-dev libqt4-dev-bin libqt4-dev ruby ruby-dev python3 python3-dev +For more build instructions see http://www.klayout.de/build.html. ## Build options diff --git a/build.sh b/build.sh index ece48ac1b..8dec34928 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ # # KLayout Layout Viewer -# Copyright (C) 2006-2017 Matthias Koefferlein +# Copyright (C) 2006-2018 Matthias Koefferlein # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/macbuild/LICENSE b/macbuild/LICENSE new file mode 100644 index 000000000..a47d294dd --- /dev/null +++ b/macbuild/LICENSE @@ -0,0 +1,30 @@ +The following two files are derivative works of: + https://github.com/andreyvit/create-dmg.git + + (1) makeDMG4mac.py + (2) Resources/template-KLayoutDMG.applescript + +The original "LICENSE" file is quoted below. +=============================================================================== +The MIT License (MIT) + +Copyright (c) 2008-2014 Andrey Tarantsov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +=============================================================================== diff --git a/macbuild/ReadMe.md b/macbuild/ReadMe.md new file mode 100644 index 000000000..7412de414 --- /dev/null +++ b/macbuild/ReadMe.md @@ -0,0 +1,87 @@ +Relevant KLayout version: 0.25.1 + +# 1. Introduction +This directory "macbuild" contains different files required for building KLayout (http://www.klayout.de/) version 0.25 or later for different Mac OSXs including: +* Yosemite (10.10) +* El Capitan (10.11) +* Sierra (10.12) +* High Sierra (10.13) + +By default, Qt framework is "Qt5" from Mac Ports (https://www.macports.org/) which is usually located under: +``` +/opt/local/libexec/qt5/ +``` + +### IMPORTANT +``` +* Please DO NOT USE "Qt 5.10.0" which is problematic in showing your design in the main canvas. +* Please USE "Qt 5.9.x" instead (5.9.3 is recommended). +* Building with Qt4 will lead to some compile errors. +``` +Also by default, supported script languages, i.e, Ruby and Python, are those standard ones bundled with the OS. + +# 2. Non-OS-standard script language support +You may want to use a non-OS-standard script language such as Python 3.6 from Anaconda2 (https://www.anaconda.com/download/#macos) in combination with KLayout. + +Since Anaconda2 is a popular Python development environment, this is worth trying. +Unfortunately, however, some dynamic linkage problems are observed as of today. +On the other hand, Python 3.6 provided by Mac Ports is usable. +Please try this (refer to 3B below) if you feel it's useful. + +# 3. Use-cases +### 3A. Debug build using the OS-standard script languages +1. Make a symbolic link from the parent directory (where 'build.sh' exists) to + 'build4mac.py', that is, +``` + build4mac.py -> macbuild/build4mac.py +``` +2. Invoke 'build4mac.py' with appropriate options ("-d" for debug build): +``` +$ cd /where/'build.sh'/exists +$ ./build4mac.py -d +``` +3. Confirm successful build. +4. Run 'build4mac.py' again with the same options used in 2. PLUS "-y" to deploy executables and libraries (including Qt's frameworks) under "klayout.app" bundle. The buddy command line tools (strm*) will also be deployed. +``` +$ ./build4mac.py -d -y +``` +5. Copy/move generated bundles ("klayout.app" and "klayout.scripts/") to your "/Applications" directory for installation. + +### 3B. Release build using the non-OS-standard Ruby 2.4 and Python 3.6 both from MacPorts +1. Make a symbolic link from the parent directory (where 'build.sh' exists) to 'build4mac.py', that is, +``` +build4mac.py -> macbuild/build4mac.py +``` +2. Invoke 'build4mac.py' with appropriate options: +``` +$ cd /where/'build.sh'/exists +$ ./build4mac.py -r mp24 -p mp36 +``` +3. Confirm successful build. +4. Run 'build4mac.py' again with the same options used in 2. PLUS "-Y" 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. +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. + +---- + +# 4. Making a DMG installer +You can make a DMG installer using another Python script 'makeDMG4mac.py'. +This script requires a directory generated by 'build4mac.py' with [-y|-Y] option (refer to 3A.4 & 3B.4) + +1. Make a symbolic link from the parent directory (where 'build.sh' exists) to 'makeDMG4mac.py', that is, +``` +makeDMG4mac.py -> macbuild/makeDMG4mac.py +``` +2. Invoke 'makeDMG4mac.py' with -p and -m options, for example, +``` +$ cd /where/'build.sh'/exists +$ ./makeDMG4mac.py -p qt5.pkg.macos-HighSierra-release -m +``` + +By: Kazzz (January 16, 2018) +[End of File] diff --git a/macbuild/ReadMe.txt b/macbuild/ReadMe.txt new file mode 100644 index 000000000..c8519bab3 --- /dev/null +++ b/macbuild/ReadMe.txt @@ -0,0 +1,80 @@ +<< Draft Version 0.004>> +Relevant KLayout version: 0.25.1 + +1. Introduction: + This directory "macbuild" contains different files required for building KLayout (http://www.klayout.de/) + version 0.25 or later for different Mac OSXs including: + * Yosemite (10.10) + * El Capitan (10.11) + * Sierra (10.12) + * High Sierra (10.13) + + By default, Qt framework is "Qt5" from Mac Ports (https://www.macports.org/) which is + usually located under: + /opt/local/libexec/qt5/ + + : + * Please DO NOT USE "5.10.0" which is problematic in showing your design in the main canvas. + * Please USE "5.9.x" instead (5.9.3 is recommended). + * Building with Qt4 will lead to some compile errors. + + Also by default, supported script languages, i.e, Ruby and Python, are those + standard ones bundled with the OS. + + +2. Non-OS-standard script language support: + You may want to use a non-OS-standard script language such as Python 3.6 from + Anaconda2 (https://www.anaconda.com/download/#macos) in combination with KLayout. + Since Anaconda2 is a popular Python development environment, this is worth trying. + Unfortunately, however, some dynamic linkage problems are observed as of today. + + On the other hand, Python 3.6 provided by Mac Ports is usable. + Please try this (refer to 3B below) if you feel it's useful. + +3. Use-cases: +3A. Debug build using the OS-standard script languages: + (1) Make a symbolic link from the parent directory (where 'build.sh' exists) to + 'build4mac.py', that is, + build4mac.py -> macbuild/build4mac.py + (2) Invoke 'build4mac.py' with appropriate options ("-d" for debug build): + $ cd /where/'build.sh'/exists + $ ./build4mac.py -d + (3) Confirm successful build. + (4) Run 'build4mac.py' again with the same options used in (2) PLUS "-y" + to deploy executables and libraries (including Qt's frameworks) under "klayout.app" bundle. + The buddy command line tools (strm*) will also be deployed. + $ ./build4mac.py -d -y + (5) Copy/move generated bundles ("klayout.app" and "klayout.scripts/") to your + "/Applications" directory for installation. + + +3B. Release build using the non-OS-standard Ruby 2.4 and Python 3.6 both from MacPorts: + (1) Make a symbolic link from the parent directory (where 'build.sh' exists) to + 'build4mac.py', that is, + build4mac.py -> macbuild/build4mac.py + (2) Invoke 'build4mac.py' with appropriate options: + $ cd /where/'build.sh'/exists + $ ./build4mac.py -r mp24 -p mp36 + (3) Confirm successful build. + (4) Run 'build4mac.py' again with the same options used in (2) PLUS "-Y" + 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. + 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. + +4. Making a DMG installer + You can make a DMG installer using another Python script 'makeDMG4mac.py'. + This script requires a directory generated by 'build4mac.py' with [-y|-Y] option (refer to 3A.4 & 3B.4) + + (1) Make a symbolic link from the parent directory (where 'build.sh' exists) to 'makeDMG4mac.py', that is, + makeDMG4mac.py -> macbuild/makeDMG4mac.py + (2) Invoke 'makeDMG4mac.py' with -p and -m options, for example, + $ cd /where/'build.sh'/exists + $ ./makeDMG4mac.py -p qt5.pkg.macos-HighSierra-release -m + +By: Kazzz (January 16, 2018) +[End of File] diff --git a/macbuild/Resources/Info.plist.template b/macbuild/Resources/Info.plist.template new file mode 100644 index 000000000..74090cbb3 --- /dev/null +++ b/macbuild/Resources/Info.plist.template @@ -0,0 +1,28 @@ + + + + + NOTE + This file was originally generated by Qt/QMake. + CFBundleGetInfoString + Created by Qt/QMake + CFBundleExecutable + ${EXECUTABLE} + CFBundleIconFile + ${ICONFILE} + CFBundleIdentifier + de.klayout + CFBundleName + ${BUNDLENAME} + CFBundlePackageType + APPL + CFBundleVersion + ${VERSION} + CFBundleSignature + ???? + NSPrincipalClass + NSApplication + NSSupportsAutomaticGraphicsSwitching + + + diff --git a/macbuild/Resources/KLayoutDMG-Back.logoist b/macbuild/Resources/KLayoutDMG-Back.logoist new file mode 100644 index 000000000..850b30229 Binary files /dev/null and b/macbuild/Resources/KLayoutDMG-Back.logoist differ diff --git a/macbuild/Resources/KLayoutDMG-Back.png b/macbuild/Resources/KLayoutDMG-Back.png new file mode 100644 index 000000000..a4090afad Binary files /dev/null and b/macbuild/Resources/KLayoutDMG-Back.png differ diff --git a/macbuild/Resources/KLayoutEditor.sh b/macbuild/Resources/KLayoutEditor.sh new file mode 100755 index 000000000..96f2c4c2d --- /dev/null +++ b/macbuild/Resources/KLayoutEditor.sh @@ -0,0 +1,36 @@ +#!/bin/bash +#------------------------------------------------------------------------------------- +# File: KLayoutEditor.sh +# +# Descriptions: +# This is to invoke "klayout" with Qt5 distributed as a binary package for Mac +# in "editor" mode. +# +# You may specify style and other options as you like by setting +# "opt_style" and "opt_others" variable in this script. +#------------------------------------------------------------------------------------- + +#--------------------------------------------------------- +# With "-n" option, multiple instances can be invoked +#--------------------------------------------------------- +myKLayout="open -n -a /Applications/klayout.app --args " + +#=================================================== +# Pass command line parameters to klayout +# vvvvvvvvvv You may edit the block below vvvvvvvvvv +opt_mode="-e" +opt_style="-style=fusion" +opt_others="" +# ^^^^^^^^^^ You may edit the block above ^^^^^^^^^^ +#=================================================== +options="$opt_mode $opt_style $opt_others" +targetfiles=$@ + +echo "### Starting KLayout in Editor mode..." +$myKLayout $options $targetfiles & + +exit 0 + +#------------------- +# End of file +#------------------- diff --git a/macbuild/Resources/KLayoutHDD.icns b/macbuild/Resources/KLayoutHDD.icns new file mode 100644 index 000000000..c0a933218 Binary files /dev/null and b/macbuild/Resources/KLayoutHDD.icns differ diff --git a/macbuild/Resources/KLayoutViewer.sh b/macbuild/Resources/KLayoutViewer.sh new file mode 100755 index 000000000..d0fa2c038 --- /dev/null +++ b/macbuild/Resources/KLayoutViewer.sh @@ -0,0 +1,36 @@ +#!/bin/bash +#------------------------------------------------------------------------------------- +# File: KLayoutViewer.sh +# +# Descriptions: +# This is to invoke "klayout" with Qt5 distributed as a binary package for Mac +# in "viewer" mode. +# +# You may specify style and other options as you like by setting +# "opt_style" and "opt_others" variable in this script. +#------------------------------------------------------------------------------------- + +#--------------------------------------------------------- +# With "-n" option, multiple instances can be invoked +#--------------------------------------------------------- +myKLayout="open -n -a /Applications/klayout.app --args " + +#=================================================== +# Pass command line parameters to klayout +# vvvvvvvvvv You may edit the block below vvvvvvvvvv +opt_mode="-ne" +opt_style="-style=windows" +opt_others="" +# ^^^^^^^^^^ You may edit the block above ^^^^^^^^^^ +#=================================================== +options="$opt_mode $opt_style $opt_others" +targetfiles=$@ + +echo "### Starting KLayout in Viewer mode..." +$myKLayout $options $targetfiles & + +exit 0 + +#------------------- +# End of file +#------------------- diff --git a/macbuild/Resources/klayout-blue.icns b/macbuild/Resources/klayout-blue.icns new file mode 100644 index 000000000..511940b8b Binary files /dev/null and b/macbuild/Resources/klayout-blue.icns differ diff --git a/macbuild/Resources/klayout-green.icns b/macbuild/Resources/klayout-green.icns new file mode 100644 index 000000000..00b48ee66 Binary files /dev/null and b/macbuild/Resources/klayout-green.icns differ diff --git a/macbuild/Resources/klayout-red.icns b/macbuild/Resources/klayout-red.icns new file mode 100644 index 000000000..381fc8906 Binary files /dev/null and b/macbuild/Resources/klayout-red.icns differ diff --git a/macbuild/Resources/klayout-yellow.icns b/macbuild/Resources/klayout-yellow.icns new file mode 100644 index 000000000..424217b6c Binary files /dev/null and b/macbuild/Resources/klayout-yellow.icns differ diff --git a/macbuild/Resources/klayout.icns b/macbuild/Resources/klayout.icns new file mode 100644 index 000000000..424217b6c Binary files /dev/null and b/macbuild/Resources/klayout.icns differ diff --git a/macbuild/Resources/template-KLayoutDMG.applescript b/macbuild/Resources/template-KLayoutDMG.applescript new file mode 100644 index 000000000..cb369eacb --- /dev/null +++ b/macbuild/Resources/template-KLayoutDMG.applescript @@ -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 ${ORGX} + set theTopLeftY to ${ORGY} + set theWidth to ${WIN_WIDTH} + set theHeight to ${WIN_HEIGHT} + set theBottomRightX to (theTopLeftX + theWidth + posMargin) + set theBottomRightY to (theTopLeftY + theHeight + posMargin) + + -- [3] Set the full path to .DS_Store file + set dotDSStore to "${FULL_PATH_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:${BACKGROUND_PNG_FILE}" + + -- [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 "${ITEM_1}" to {${X1}, ${Y1}} + set position of item "${ITEM_2}" to {${X2}, ${Y2}} + set position of item "${ITEM_3}" to {${X3}, ${Y3}} + + -- [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 "${CHECK_BASH}") = "0" then set ejected to true + end repeat + log "### Elapsed <" & elapsedTime & "> [sec] for writing .DS_Store file." + end tell +end run + +-- +-- End of file +-- diff --git a/macbuild/build4mac.py b/macbuild/build4mac.py new file mode 100755 index 000000000..9eaeaca8b --- /dev/null +++ b/macbuild/build4mac.py @@ -0,0 +1,901 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +#=============================================================================== +# File: "macbuild/build4mac.py" +# +# The top Python script for building KLayout (http://www.klayout.de/index.php) +# version 0.25 or later on different Apple Mac OSX platforms. +#=============================================================================== +from __future__ import print_function # to use print() of Python 3 in Python >= 2.7 +import sys +import os +import shutil +import glob +import platform +import optparse +import subprocess + +#------------------------------------------------------------------------------- +## To import global dictionaries of different modules and utility functions +#------------------------------------------------------------------------------- +mydir = os.path.dirname(os.path.abspath(__file__)) +sys.path.append( mydir + "/macbuild" ) +from build4mac_env import * +from build4mac_util import * + +#------------------------------------------------------------------------------- +## To set global variables including present directory and platform info. +#------------------------------------------------------------------------------- +def SetGlobals(): + global ProjectDir # project directory where "build.sh" exists + global Usage # string on usage + global BuildBash # the main build Bash script + global Platform # platform + global ModuleQt # Qt module to be used + global ModuleRuby # Ruby module to be used + global ModulePython # Python module to be used + global NonOSStdLang # True if non-OS-standard language is chosen + global NoQtBindings # True if not creating Qt bindings for Ruby scripts + global MakeOptions # options passed to `make` + global DebugMode # True if debug mode build + global CheckComOnly # True if only for checking the command line parameters to "build.sh" + global DeploymentF # True if fully (including Qt's Frameworks) deploy the binaries for bundles + global DeploymentP # True if partially deploy the binaries excluding Qt's Frameworks + global DeployVerbose # -verbose=<0-3> level passed to 'macdeployqt' tool + global Version # KLayout's version + # auxiliary variables on platform + global System # 6-tuple from platform.uname() + global Node # - do - + global Release # - do - + global Version # - do - + global Machine # - do - + global Processor # - do - + global Bit # machine bit-size + + Usage = "\n" + Usage += "--------------------------------------------------------------------------------------------------------\n" + Usage += "<< Usage of 'build4mac.py' >>\n" + Usage += " for building KLayout 0.25 or later on different Apple Mac OSX platforms.\n" + Usage += "\n" + Usage += "$ [python] ./build4mac.py \n" + Usage += " option & argument : descriptions | default value\n" + Usage += " ----------------------------------------------------------------------------------+---------------\n" + Usage += " : * key type names below are case insensitive * | \n" + 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=['Qt4MacPorts', 'Qt5MacPorts'] | qt5macports \n" + Usage += " [-r|--ruby ] : type=['nil', 'Sys', 'Src24', 'MP24'] | sys \n" + Usage += " [-p|--python ] : type=['nil', 'Sys', 'Ana27', 'Ana36', 'MP36'] | sys \n" + Usage += " [-n|--noqtbinding] : don't create Qt bindings for ruby scripts | disabled \n" + Usage += " [-m|--make