diff --git a/.gitignore b/.gitignore index 42c4a5cb5..29f6d0f19 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,8 @@ build-* bin-* mkqtdecl.tmp testtmp +*build.macos* +*bin.macos* # private data private @@ -54,3 +56,12 @@ src/klayout.pro.user *.egg-info/ build/ dist/ + + +# IDEs +.vscode + + +# Macos artifacts +*.dmg +*.dmg.md5 diff --git a/Makefile b/Makefile index a8e1d727b..b96f80895 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ GITCOMMIT := $(shell git rev-parse --short HEAD) KLAYOUT_VERSION := $(shell source version.sh && echo $$KLAYOUT_VERSION) ifndef PYTHON_VERSION - PYTHON_VERSION := B37 + PYTHON_VERSION := HB38 endif ifndef MACOS_VERSION - MACOS_VERSION := HighSierra + MACOS_VERSION := Catalina endif .ONESHELL: @@ -15,11 +15,11 @@ default: help help: @echo "For Mac OS only" - @echo "make build PYTHON_VERSION=B37" - @echo "make deploy PYTHON_VERSION=B37" + @echo "make build PYTHON_VERSION=HB38" + @echo "make deploy PYTHON_VERSION=HB38" @echo "make test MACOS_VERSION=HighSierra" - @echo "Valid Mac OS Versions: [Yosemite, ElCapitan, Sierra, HighSierra]" - @echo "Valid Python Version: [nil, Sys, B37]" + @echo "Valid Mac OS Versions: [Yosemite, ElCapitan, Sierra, HighSierra, Mojave, Catalina]" + @echo "Valid Python Version: [nil, Sys, HB38]" build: @echo "Building for Mac $(GITCOMMIT)" @@ -29,11 +29,11 @@ build: deploy: @echo "Deploying 4 Mac $(GITCOMMIT)" ./build4mac.py -p $(PYTHON_VERSION) -q Qt5Brew -y - + test: @echo "Testing 4 Mac $(GITCOMMIT)" - qt5.pkg.macos-$(MACOS_VERSION)-release/klayout.app/Contents/MacOS/klayout -b -r test-pylib-script.py; \ - cd qt5.build.macos-$(MACOS_VERSION)-release; \ + PIP_REQUIRE_VIRTUALENV="false" HW-qt5Brew.pkg.macos-$(MACOS_VERSION)-release-RsysPhb38/klayout.app/Contents/MacOS/klayout -b -r test-pylib-script.py; \ + cd qt5Brew.build.macos-$(MACOS_VERSION)-release-RsysPhb38; \ ln -s klayout.app/Contents/MacOS/klayout klayout; \ export TESTTMP=testtmp; \ export TESTSRC=..; \ @@ -41,18 +41,24 @@ test: ./ut_runner -h || true; \ cd .. +dmg-template: + mkdir -p testtemplate/klayout.app + ./makeDMG4mac.py -p testtemplate -m -z -t klayoutDMGTemplate.dmg + cp -a klayoutDMGTemplate.dmg* macbuild/Resources/ + rm -Rf testtemplate + dropbox-deploy: @echo "Preparing for dropbox deployment $(MACOS_VERSION) $(GITCOMMIT)" - mkdir -p deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION); \ - pwd; \ - ls -lah; \ - touch build.txt; \ - cp build.txt deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).log.txt; \ - hdiutil convert macbuild/Resources/klayoutDMGTemplate.dmg -format UDRW -o work-KLayout.dmg; \ - hdiutil resize -size 500m work-KLayout.dmg; \ - hdiutil attach work-KLayout.dmg -readwrite -noverify -quiet -mountpoint tempKLayout -noautoopen; \ - cp -a qt5.pkg.macos-$(MACOS_VERSION)-release/ tempKLayout/; \ - hdiutil detach tempKLayout; \ - hdiutil convert work-KLayout.dmg -format UDZO -imagekey zlib-level=9 -o deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg; \ - md5 -q deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg > deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg.md5; \ + mkdir -p deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION) + pwd + ls -lah + touch build.txt + cp build.txt deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).log.txt + hdiutil convert macbuild/Resources/klayoutDMGTemplate.dmg -ov -format UDRW -o work-KLayout.dmg + hdiutil resize -size 500m work-KLayout.dmg + hdiutil attach -readwrite -noverify -quiet -mountpoint tempKLayout -noautoopen work-KLayout.dmg + cp -a HW-qt5Brew.pkg.macos-$(MACOS_VERSION)-release-RsysPhb38/ tempKLayout/ + hdiutil detach tempKLayout + hdiutil convert work-KLayout.dmg -ov -format UDZO -imagekey zlib-level=9 -o deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg + md5 -q deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg > deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg.md5 rm work-KLayout.dmg diff --git a/build.sh b/build.sh index 6c6150e8f..676d8aa99 100755 --- a/build.sh +++ b/build.sh @@ -532,6 +532,11 @@ if [ "$BIN" = "" ]; then BIN=$CURR_DIR/bin-$CONFIG fi +if [ "$QMAKE_CCACHE" = 1 ]; then + echo " Compilation caching is activated." +else + echo " Compilation caching is deactivated!" +fi echo " Installation target: $BIN" echo " Build directory: $BUILD" diff --git a/macbuild/.gitignore b/macbuild/.gitignore index 0d20b6487..4081080e3 100644 --- a/macbuild/.gitignore +++ b/macbuild/.gitignore @@ -1 +1,2 @@ *.pyc +KLayoutDMG.applescript diff --git a/macbuild/Resources/klayoutDMGTemplate.dmg b/macbuild/Resources/klayoutDMGTemplate.dmg index 8ad28f4ad..65ca57755 100644 Binary files a/macbuild/Resources/klayoutDMGTemplate.dmg and b/macbuild/Resources/klayoutDMGTemplate.dmg differ diff --git a/macbuild/Resources/template-KLayoutDMG.applescript b/macbuild/Resources/template-KLayoutDMG.applescript index 78d5b00d7..c27b6c10c 100644 --- a/macbuild/Resources/template-KLayoutDMG.applescript +++ b/macbuild/Resources/template-KLayoutDMG.applescript @@ -26,6 +26,12 @@ ------------------------------------------------------------------------------------------------- on run (volumeName) -- most likely, the volume name is "KLayout" tell application "Finder" + repeat 20 times + if (exists (disk (volumeName as string))) then + exit repeat + end if + delay 1 + end repeat tell disk (volumeName as string) -- [1] Open the volume open diff --git a/macbuild/build4mac.py b/macbuild/build4mac.py index d9a99e74c..9657b9f94 100755 --- a/macbuild/build4mac.py +++ b/macbuild/build4mac.py @@ -27,550 +27,661 @@ 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 PackagePrefix # the package prefix: 'ST-', 'LW-', 'HW-', or 'EX-' - global DeployVerbose # -verbose=<0-3> level passed to 'macdeployqt' tool - global Version # KLayout's version - global ModuleSet # (Qt, Ruby, Python)-tuple - # 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 +def get_default_config(): + """ + Returns a dictionary containing the default configuration for the macOS build. + """ + # 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 PackagePrefix # the package prefix: 'ST-', 'LW-', 'HW-', or 'EX-' + # global DeployVerbose # -verbose=<0-3> level passed to 'macdeployqt' tool + # global Version # KLayout's version + # global ModuleSet # (Qt, Ruby, Python)-tuple + # # 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 - - Usage = "\n" - Usage += "---------------------------------------------------------------------------------------------------------\n" - Usage += "<< Usage of 'build4mac.py' >>\n" - Usage += " for building KLayout 0.26.1 or later on different Apple Mac OSX platforms.\n" - Usage += "\n" - Usage += "$ [python] ./build4mac.py \n" - Usage += " option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details)| default value\n" - Usage += " --------------------------------------------------------------------------------------+---------------\n" - Usage += " [-q|--qt ] : case-insensitive type=['Qt5MacPorts', 'Qt5Brew', 'Qt5Ana3'] | qt5macports \n" - Usage += " : Qt5MacPorts: use Qt5 from MacPorts | \n" - Usage += " : Qt5Brew: use Qt5 from Homebrew | \n" - Usage += " : Qt5Ana3: use Qt5 from Anaconda3 | \n" - Usage += " [-r|--ruby ] : case-insensitive type=['nil', 'Sys', 'MP26', 'HB27', 'Ana3'] | sys \n" - Usage += " : nil: don't bind Ruby | \n" - Usage += " : Sys: use OS-bundled Ruby [2.0 - 2.6] depending on OS | \n" - Usage += " : MP26: use Ruby 2.6 from MacPorts | \n" - Usage += " : HB27: use Ruby 2.7 from Homebrew | \n" - Usage += " : Ana3: use Ruby 2.5 from Anaconda3 | \n" - Usage += " [-p|--python ] : case-insensitive type=['nil', 'Sys', 'MP38', 'HB38', 'Ana3'] | sys \n" - Usage += " : nil: don't bind Python | \n" - Usage += " : Sys: use OS-bundled Python 2.7 [ElCapitan -- Catalina] | \n" - Usage += " : MP38: use Python 3.8 from MacPorts | \n" - Usage += " : HB38: use Python 3.8 from Homebrew | \n" - Usage += " : Ana3: use Python 3.7 from Anaconda3 | \n" - Usage += " [-n|--noqtbinding] : don't create Qt bindings for ruby scripts | disabled \n" - Usage += " [-m|--make