Merge pull request #65 from Kazzz-S/macos-build

DMG installer
This commit is contained in:
Matthias Köfferlein 2018-01-23 22:40:47 +01:00 committed by GitHub
commit 0402977424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 1024 additions and 177 deletions

30
macbuild/LICENSE Normal file
View File

@ -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.
===============================================================================

View File

@ -1,4 +1,4 @@
<< Draft Version 0.003>> Relevant KLayout version: 0.25.1
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:
@ -15,7 +15,7 @@ By default, Qt framework is "Qt5" from Mac Ports (https://www.macports.org/) whi
### 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.
* 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.
@ -41,7 +41,7 @@ $ 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.
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
```
@ -58,7 +58,7 @@ $ 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.
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
```
@ -67,6 +67,21 @@ That is, paths to other modules (Ruby, Python, and Qt5 Frameworks) remain unchan
5. Copy/move generated bundles ("klayout.app" and "klayout.scripts/") to your "/Applications" directory for installation.
By: Kazzz (January 08, 2018)
----
# 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]

View File

@ -1,4 +1,4 @@
<< Draft Version 0.003>>
<< Draft Version 0.004>>
Relevant KLayout version: 0.25.1
1. Introduction:
@ -15,7 +15,7 @@ Relevant KLayout version: 0.25.1
<IMPORTANT>:
* Please DO NOT USE "5.10.0" which is problematic in showing your design in the main canvas.
* Please USE "5.9.x" instead.
* 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
@ -42,6 +42,7 @@ Relevant KLayout version: 0.25.1
(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.
@ -57,6 +58,7 @@ Relevant KLayout version: 0.25.1
(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)
@ -64,6 +66,15 @@ Relevant KLayout version: 0.25.1
(5) Copy/move generated bundles ("klayout.app" and "klayout.scripts/") to your
"/Applications" directory for installation.
By: Kazzz (January 08, 2018)
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]

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB

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 ${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
--

540
macbuild/makeDMG4mac.py Executable file
View File

@ -0,0 +1,540 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#=============================================================================================
# File: "macbuild/makeDMG4mac.py"
#
# Python script for making a DMG file of KLayout (http://www.klayout.de/index.php) bundles.
#
# 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
#=============================================================================================
from __future__ import print_function # to use print() of Python 3 in Python >= 2.7
from time import sleep
import sys
import os
import shutil
import glob
import platform
import optparse
import subprocess
import hashlib
#-------------------------------------------------------------------------------
## 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_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 GenOSName # generic OS name
global Platform # platform
global PkgDir # the package directory where "klayout.app" and "klayout.scripts" exist
global OpClean # 'clean' operation
global OpMake # 'make' operation
global DMGSerialNum # the DMG serial number
global QtIdentification # Qt identification
global Version # KLayout's version
global OccupiedDS # approx. occupied disc space
global BackgroundPNG # the background PNG image file
global VolumeIcons # the volume icon file
global AppleScriptDMG # the AppleScript for KLayout DMG
global WorkDMG # work DMG file created under ProjectDir/
global VolumeDMG # the volume name of DMG
global TargetDMG # the name of target DMG file
global RootApplications # reserved directory name for applications
# 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 'makeDMG4mac.py' >>\n"
Usage += " for making a DMG file of KLayout 0.25 or later on different Apple Mac OSX platforms.\n"
Usage += "\n"
Usage += "$ [python] ./makeDMG4mac.py \n"
Usage += " option & argument : descriptions | default value\n"
Usage += " ----------------------------------------------------------------------------------+---------------\n"
Usage += " <-p|--pkg <dir>> : package directory created by `build4mac.py` with [-y|-Y] | `` \n"
Usage += " : like 'qt5.pkg.macos-HighSierra-release' | \n"
Usage += " <-c|--clean> : clean the work directory | disabled \n"
Usage += " <-m|--make> : make a compressed DMG file | disabled \n"
Usage += " : <-c|--clean> and <-m|--make> are mutually exclusive | \n"
Usage += " [-q|--qt <ID>] : ID name of deployed Qt | Qt593mp \n"
Usage += " [-s|--serial <num>] : DMG serial number | 1 \n"
Usage += " [-?|--?] : print this usage and exit | disabled \n"
Usage += "--------------------------------------------------------------------------------------------------------\n"
ProjectDir = os.getcwd()
(System, Node, Release, Version, Machine, Processor) = platform.uname()
if not System == "Darwin":
print("")
print( "!!! Sorry. Your system <%s> looks like non-Mac" % System, file=sys.stderr )
print(Usage)
quit()
release = int( Release.split(".")[0] ) # take the first of ['14', '5', '0']
if release == 14:
GenOSName = "MacOSX"
Platform = "Yosemite"
elif release == 15:
GenOSName = "MacOSX"
Platform = "ElCapitan"
elif release == 16:
GenOSName = "macOS"
Platform = "Sierra"
elif release == 17:
GenOSName = "macOS"
Platform = "HighSierra"
else:
Platform = ""
print("")
print( "!!! Sorry. Unsupported major OS release <%d>" % release, file=sys.stderr )
print(Usage)
quit()
if not Machine == "x86_64":
print("")
print( "!!! Sorry. Only x86_64 architecture machine is supported but found <%s>" % Machine, file=sys.stderr )
print(Usage)
quit()
PkgDir = ""
OpClean = False
OpMake = False
DMGSerialNum = 1
QtIdentification = "Qt593mp"
Version = GetKLayoutVersionFrom( "./version.sh" )
OccupiedDS = -1
BackgroundPNG = "KLayoutDMG-Back.png"
VolumeIcons = "KLayoutHDD.icns"
AppleScriptDMG = "macbuild/Resources/KLayoutDMG.applescript"
WorkDMG = "work-KLayout.dmg"
VolumeDMG = "KLayout"
TargetDMG = ""
RootApplications = "/Applications"
#------------------------------------------------------------------------------
## To check the contents of the package directory
#
# @return on success, positive integer in [MB] that tells approx. occupied disc space;
# on failure, -1
#------------------------------------------------------------------------------
def CheckPkgDirectory():
if PkgDir == "":
print( "! Package directory is not specified", file=sys.stderr )
print(Usage)
return -1
if not os.path.isdir(PkgDir):
print( "! Specified package directory <%s> does not exist" % PkgDir, file=sys.stderr )
print( "" )
return -1
os.chdir(PkgDir)
items = glob.glob( "*" ) # must be ['klayout.app', 'klayout.scripts']
if not len(items) == 2:
print( "! The package directory <%s> must have just <2> directories ['klayout.app', 'klayout.scripts']" % PkgDir, file=sys.stderr )
print( "" )
os.chdir(ProjectDir)
return -1
if not os.path.isdir( "klayout.app" ):
print( "! The package directory <%s> does not hold <klayout.app> bundle" % PkgDir, file=sys.stderr )
print( "" )
os.chdir(ProjectDir)
return -1
if not os.path.isdir( "klayout.scripts" ):
print( "! The package directory <%s> does not hold <klayout.scripts> subdirectory" % PkgDir, file=sys.stderr )
print( "" )
os.chdir(ProjectDir)
return -1
os.chdir( "klayout.scripts" )
if not os.path.isdir( "KLayoutEditor.app" ):
print( "! The package directory <%s> does not hold <KLayoutEditor.app> bundle under 'klayout.scripts/'" % PkgDir, file=sys.stderr )
print( "" )
os.chdir(ProjectDir)
return -1
if not os.path.isdir( "KLayoutViewer.app" ):
print( "! The package directory <%s> does not hold <KLayoutViewer.app> bundle under 'klayout.scripts/'" % PkgDir, file=sys.stderr )
print( "" )
os.chdir(ProjectDir)
return -1
os.chdir(ProjectDir)
os.chdir(PkgDir)
size1 = int( os.popen( "\du -sm klayout.app" ) .read().strip("\n").split("\t")[0] )
size2 = int( os.popen( "\du -sm klayout.scripts" ).read().strip("\n").split("\t")[0] )
os.chdir(ProjectDir)
return size1+size2
#------------------------------------------------------------------------------
## To get command line parameters
#------------------------------------------------------------------------------
def ParseCommandLineArguments():
global ProjectDir
global Usage
global GenOSName
global Platform
global PkgDir
global OpClean
global OpMake
global DMGSerialNum
global QtIdentification
global Version
global OccupiedDS
global TargetDMG
p = optparse.OptionParser( usage=Usage )
p.add_option( '-p', '--pkg',
dest='pkg_dir',
help="the pkg directory" )
p.add_option( '-c', '--clean',
action='store_true',
dest='operation_clean',
default=False,
help="clean operation" )
p.add_option( '-m', '--make',
action='store_true',
dest='operation_make',
default=False,
help="make operation" )
p.add_option( '-q', '--qt',
dest='qt_identification',
help="Qt's ID" )
p.add_option( '-s', '--serial',
dest='dmg_serial',
help="DMG serial number" )
p.add_option( '-?', '--??',
action='store_true',
dest='checkusage',
default=False,
help='check usage' )
p.set_defaults( pkg_dir = "",
operation_clean = False,
operation_make = False,
qt_identification = "Qt593mp",
dmg_serial = "1",
checkusage = False )
opt, args = p.parse_args()
if (opt.checkusage):
print(Usage)
quit()
PkgDir = opt.pkg_dir
OpClean = opt.operation_clean
OpMake = opt.operation_make
QtIdentification = opt.qt_identification
DMGSerialNum = int(opt.dmg_serial)
TargetDMG = "klayout-%s-%s-%s-%d-%s.dmg" % (Version, GenOSName, Platform, DMGSerialNum, QtIdentification)
OccupiedDS = CheckPkgDirectory()
if not OccupiedDS > 0:
quit()
if (OpClean and OpMake) or (not OpClean and not OpMake):
print( "! Specify <-c|--clean> OR <-m|--make>", file=sys.stderr )
print(Usage)
quit()
#------------------------------------------------------------------------------
## Make the target DMG file
#
# @param[in] msg message to print
#
# @return True on success; False on failure
#------------------------------------------------------------------------------
def MakeTargetDMGFile(msg=""):
#-----------------------------------------------------------------------
# The work DMG is mounted like:
# /dev/disk6s1 248Mi 228Mi 20Mi 93% 58449 5027 92% /Volumes/KLayout
#-----------------------------------------------------------------------
global MountDir # the mount directory: eg. /Volumes/KLayout
global FileSys # the file system : eg. /dev/disk6s1
#-------------------------------------------------------------
# [1] Print message
#-------------------------------------------------------------
if not msg == "":
print(msg)
#-------------------------------------------------------------
# [2] Do the following jobs (0) through (14) sequentially
#-------------------------------------------------------------
#--------------------------------------------------------
# (0) Cleanup ProjectDir/
#--------------------------------------------------------
CleanUp()
#--------------------------------------------------------
# (1) Read the AppleScript template file and generate
# the actual one to execute later
#--------------------------------------------------------
os.chdir(ProjectDir)
print( ">>> (1) Preparing AppleScript to execute later..." )
tempScr = "macbuild/Resources/template-KLayoutDMG.applescript"
try:
fd = open( tempScr, "r" )
tmpl = fd.read()
fd.close()
except Exception as e:
print( " ! Failed to read <%s>" % tempScr, file=sys.stderr )
return False
else:
t = string.Template(tmpl)
# Figures below were determined by experiments for best fit
applescript = t.safe_substitute(
ORGX='50', ORGY='100',
WIN_WIDTH='1000', WIN_HEIGHT='700',
FULL_PATH_DS_STORE='/Volumes/%s/.DS_Store' % VolumeDMG,
BACKGROUND_PNG_FILE=BackgroundPNG,
ITEM_1='klayout.app', X1='960', Y1='140',
ITEM_2='klayout.scripts', X2='610', Y2='140',
ITEM_3='Applications', X3='790', Y3='140',
CHECK_BASH='[ -f " & dotDSStore & " ]; echo $?'
)
try:
# print(applescript)
fd = open( AppleScriptDMG, "w" )
fd.write(applescript)
fd.close()
except Exception as e:
print( "! Failed to write <%s>" % AppleScriptDMG, file=sys.stderr )
return False
else:
print( " saved <%s>" % AppleScriptDMG )
#----------------------------------------------------
# (2) Create a work disk image under ProjectDir/
#----------------------------------------------------
if os.path.exists(WorkDMG):
os.remove(WorkDMG)
dmgsize = OccupiedDS + 20 # approx. occupied size plus 20[MB]
cmdline = 'hdiutil create -srcfolder %s -volname %s -fs HFS+ -fsargs "-c c=64,a=16,e=16" '
cmdline += '-format UDRW -size %dm %s'
command = cmdline % (PkgDir, VolumeDMG, dmgsize, WorkDMG)
print( ">>> (2) Creating a work DMG file <%s> of <%d> [MB] with the volume name of <%s>..." % (WorkDMG, dmgsize, VolumeDMG) )
os.system(command)
MountDir = "/Volumes/%s" % VolumeDMG
#--------------------------------------------------------
# (3) Check if the mount point 'MountDir' already exists.
# If so, unmount it first.
#--------------------------------------------------------
command1 = "hdiutil info | grep %s | grep \"/dev/\" | awk '{print $1}'" % VolumeDMG
print ( ">>> (3) Checking if the mount point <%s> already exists..." % MountDir)
FileSys = os.popen(command1).read().strip('\n')
if os.path.isdir(MountDir) and not FileSys == "":
command2 = "hdiutil detach %s" % FileSys
os.system(command2)
print( " Mount directory <%s> was detached" % MountDir )
else:
print( " Mount directory <%s> does not exist; nothing to do" % MountDir )
#--------------------------------------------------------
# (4) Mount the DMG
#--------------------------------------------------------
print( ">>> (4) Mounting <%s> to <%s>" % (WorkDMG, MountDir ) )
command1 = "hdiutil attach %s -readwrite -noverify -noautoopen -quiet" % WorkDMG
os.system(command1)
command2 = "hdiutil info | grep %s | grep \"/dev/\" | awk '{print $1}'" % VolumeDMG
FileSys = os.popen(command2).read().strip('\n')
if FileSys == "":
print( "! Failed to identify the file system on which <%s> is mounted" % VolumeDMG )
return False
else:
print( " File System = %s" % FileSys )
#--------------------------------------------------------
# (5) Copy the background image
#--------------------------------------------------------
print( ">>> (5) Copying the background image..." )
imageSrc = "macbuild/Resources/%s" % BackgroundPNG
imageDest = "%s/.background" % MountDir
if not os.path.isdir(imageDest):
os.mkdir(imageDest)
command = "\cp -p %s %s/%s" % (imageSrc, imageDest, BackgroundPNG)
os.system(command)
#--------------------------------------------------------
# (6) Create a symbolic link to /Applications
#--------------------------------------------------------
print( ">>> (6) Creating a symbolic link to /Applications..." )
command = "\ln -s %s %s/%s" % (RootApplications, MountDir, RootApplications)
os.system(command)
#--------------------------------------------------------
# (7) Run the AppleScript
#--------------------------------------------------------
print( ">>> (7) Running the AppleScript..." )
command = "/usr/bin/osascript %s %s" % (AppleScriptDMG, VolumeDMG)
process = subprocess.Popen( command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True )
output, error = process.communicate()
if not output == "":
print( " STDOUT: %s" % output )
if not error == "":
print( " STDERR: %s" % error )
#--------------------------------------------------------
# (8) Copy the custom volume icon
#--------------------------------------------------------
sleep(4)
print( ">>> (8) Copying the volume icon..." )
iconsSrc = "macbuild/Resources/%s" % VolumeIcons
iconsDest = "%s/.VolumeIcon.icns" % MountDir
command1 = "\cp -p %s %s" % (iconsSrc, iconsDest)
command2 = "SetFile -c icnC %s" % iconsDest
os.system(command1)
sleep(2)
os.system(command2)
sleep(2)
#--------------------------------------------------------
# (9) Change the permission
#--------------------------------------------------------
print( ">>> (9) Changing permission to 755..." )
command = "\chmod -Rf 755 %s &> /dev/null" % MountDir
os.system(command)
#--------------------------------------------------------
# (10) Set volume bootability and startup disk options.
# The folder will open on mount.
#--------------------------------------------------------
print( ">>> (10) Setting volume bootability and startup disk options..." )
command = "bless --folder %s --openfolder %s" % (MountDir, MountDir)
os.system(command)
sleep(2)
#--------------------------------------------------------
# (11) Set attributes of files and directories
#--------------------------------------------------------
print( ">>> (11) Setting attributes of files and directories..." )
command = "SetFile -a C %s" % MountDir # Custom icon (allowed on folders)
os.system(command)
sleep(2)
#--------------------------------------------------------
# (12) Unmount the disk image
#--------------------------------------------------------
print( ">>> (12) Unmounting the disk image..." )
command = "hdiutil detach %s" % FileSys
os.system(command)
#--------------------------------------------------------
# (13) Compress the disk image
#--------------------------------------------------------
print( "" )
print( ">>> (13) Compressing the disk image..." )
command = "hdiutil convert %s -format UDZO -imagekey zlib-level=9 -o %s" % (WorkDMG, TargetDMG)
os.system(command)
os.remove(WorkDMG)
print( "" )
print( " generated compressed target DMG <%s>" % TargetDMG )
#--------------------------------------------------------
# (14) Compute MD5 checksum
#--------------------------------------------------------
print( "" )
print( ">>> (14) Computing MD5 checksum..." )
with open( TargetDMG, "rb" ) as f:
data = f.read()
md5 = hashlib.md5(data).hexdigest()
md5 += " *%s\n" % TargetDMG
f.close()
path, ext = os.path.splitext( os.path.basename(TargetDMG) )
md5TargetDMG = path + ".dmg.md5"
with open( md5TargetDMG, "w" ) as f:
f.write(md5)
f.close()
print( " generated MD5 checksum file <%s>" % md5TargetDMG )
print( "" )
return True
#------------------------------------------------------------------------------
## Clean up
#
# @param[in] msg message to print
#
#------------------------------------------------------------------------------
def CleanUp(msg=""):
#----------------------------------------------------
# [1] Print message
#----------------------------------------------------
if not msg == "":
print(msg)
#----------------------------------------------------
# [2] Clean up *.dmg*
#----------------------------------------------------
os.chdir(ProjectDir)
dmgs = glob.glob( "*.dmg*" )
for item in dmgs:
os.system( "rm -Rf %s" % item )
#----------------------------------------------------
# [3] Clean up AppleScript if any
#----------------------------------------------------
if os.path.exists(AppleScriptDMG) and os.path.isfile(AppleScriptDMG):
os.remove(AppleScriptDMG)
#------------------------------------------------------------------------------
## The main function
#------------------------------------------------------------------------------
def Main():
SetGlobals()
ParseCommandLineArguments()
if OpMake:
print( "" )
print( " ### You are going to make <%s> from <%s>" % (TargetDMG, PkgDir) )
print( " KLayout bundles occupy about <%d> [MB] of disc space." % OccupiedDS )
print( "" )
ok = MakeTargetDMGFile()
if not ok:
print( " !!! Failed to make the target DMG <%s> ..." % TargetDMG, file=sys.stderr )
print( "", file=sys.stderr )
else:
print( " ### Done making the target DMG" )
print( "" )
else:
print( "" )
print( " ### You are going to clean up <%s> directory" % ProjectDir )
CleanUp()
print( " ### Done cleaning up" )
print( "" )
#===================================================================================
if __name__ == "__main__":
Main()
#---------------
# End of file
#---------------

View File

@ -1361,6 +1361,7 @@ drop_method "QXmlAttributes", /QXmlAttributes::index\(\s*const\s+QLatin1String/
drop_method "QXmlInputSource", /QXmlInputSource::setData\(.*QByteArray/ # clashes with QString version
drop_method "QXmlEntityResolver", /QXmlEntityResolver::resolveEntity/ # requires pointer return value
drop_method "QXmlDefaultHandler", /QXmlDefaultHandler::resolveEntity/ # requires pointer return value
drop_method "QXmlSimpleReader", /QXmlSimpleReader::parse\(.*QXmlInputSource\s*&/ # clashes with QXmlInputSource * version
rename "QDomElement", /QDomElement::setAttribute\(.*qulonglong/, "setAttribute_ull|attribute_ull="
rename "QDomElement", /QDomElement::setAttribute\(.*qlonglong/, "setAttribute_ll|attribute_ll="
rename "QDomElement", /QDomElement::setAttribute\(.*unsigned int/, "setAttribute_ui|attribute_ui="

View File

@ -1499,6 +1499,7 @@ no_imports "QXmlStreamAttributes" # base class is a template.
drop_method "QXmlStreamAttributes", /QXmlStreamAttributes::append\(const\s+QVector/ # QVector is a template
drop_method "QXmlStreamAttributes", /QXmlStreamAttributes::hasAttribute\(\s*QLatin1String/ # QLatin1String is not available
drop_method "QXmlStreamAttributes", /QXmlStreamAttributes::value\(.*QLatin1String/ # QLatin1String is not available
drop_method "QXmlSimpleReader", /QXmlSimpleReader::parse\(.*QXmlInputSource\s*&/ # clashes with QXmlInputSource * version
drop_method "QAbstractXmlNodeModel", /QAbstractXmlNodeModel::sequencedTypedValue/ # QExplicitlySharedDataPointer template not available
drop_method "QAbstractXmlNodeModel", /QAbstractXmlNodeModel::type/ # QExplicitlySharedDataPointer template not available
drop_method "QAbstractXmlNodeModel", /QAbstractXmlNodeModel::iterate/ # QExplicitlySharedDataPointer template not available

View File

@ -113,7 +113,7 @@ bool euclidian_near_part_of_edge (bool include_zero, db::Coord d, const db::Edge
// handle the parallel case
if (e.parallel (g)) {
if (abs (e.distance (g.p1 ())) >= d) {
if (std::abs (e.distance (g.p1 ())) >= d) {
return false;
}
} else {
@ -243,7 +243,7 @@ static bool var_near_part_of_edge (bool include_zero, db::Coord d, db::Coord dd,
// handle the parallel case
if (e.parallel (g)) {
if (abs (e.distance (g.p1 ())) >= d) {
if (std::abs (e.distance (g.p1 ())) >= d) {
return false;
}
} else {

View File

@ -26,6 +26,7 @@
#include "dbPolygonTools.h"
#include "dbPolygonGenerators.h"
#include "tlLog.h"
#include "tlInt128Support.h"
#include <algorithm>
#include <cmath>
@ -706,7 +707,7 @@ smooth_contour (db::Polygon::polygon_contour_iterator from, db::Polygon::polygon
}
for (size_t j = pi0; can_drop; ) {
if (abs (db::Edge (p0, p2).distance (org_points [j])) > d) {
if (std::abs (db::Edge (p0, p2).distance (org_points [j])) > d) {
can_drop = false;
}
if (j == pi2) {

View File

@ -828,8 +828,13 @@ Region::selected_interacting_generic (const Region &other, int mode, bool touchi
db::EdgeProcessor ep (m_report_progress, m_progress_desc);
// shortcut
if (empty () || other.empty ()) {
if (mode <= 0) {
if (empty ()) {
return *this;
} else if (other.empty ()) {
// clear, if b is empty and
// * mode is inside or interacting and inverse is false ("inside" or "interacting")
// * mode is outside and inverse is true ("not outside")
if ((mode <= 0) != inverse) {
return Region ();
} else {
return *this;
@ -879,8 +884,13 @@ void
Region::select_interacting_generic (const Region &other, int mode, bool touching, bool inverse)
{
// shortcut
if (empty () || other.empty ()) {
if (mode <= 0) {
if (empty ()) {
return;
} else if (other.empty ()) {
// clear, if b is empty and
// * mode is inside or interacting and inverse is false ("inside" or "interacting")
// * mode is outside and inverse is true ("not outside")
if ((mode <= 0) != inverse) {
clear ();
}
return;

View File

@ -176,7 +176,7 @@ TEST(3)
layout_read, top_read, j,
top_org.shapes (xor_layer), db::BooleanOp::Xor, true, false);
EXPECT_EQ (top_org.shapes (xor_layer).size () > 210, true);
sp.size (layout_org, top_org, xor_layer, top_org.shapes (xor_layer), -1, -1);
sp.size (layout_org, top_org, xor_layer, top_org.shapes (xor_layer), db::Coord (-1), db::Coord (-1));
EXPECT_EQ (top_org.shapes (xor_layer).size () == 0, true);
}
}
@ -236,7 +236,7 @@ TEST(4)
sp.boolean (layout_org, top_org, i,
layout_read, top_read, j,
top_org.shapes (xor_layer), db::BooleanOp::Xor, true, false);
sp.size (layout_org, top_org, xor_layer, top_org.shapes (xor_layer), -1, -1);
sp.size (layout_org, top_org, xor_layer, top_org.shapes (xor_layer), db::Coord (-1), db::Coord (-1));
EXPECT_EQ (top_org.shapes (xor_layer).size () == 0, true);
}
}

View File

@ -81,7 +81,7 @@ TEST(1)
sp.boolean (layout_org, top_org, i,
layout_read, top_read, j,
top_org.shapes (xor_layer), db::BooleanOp::Xor, true, false);
sp.size (layout_org, top_org, xor_layer, top_org.shapes (xor_layer), -1, -1);
sp.size (layout_org, top_org, xor_layer, top_org.shapes (xor_layer), db::Coord (-1), db::Coord (-1));
EXPECT_EQ (top_org.shapes (xor_layer).size () == 0, true);
}
}

View File

@ -1026,19 +1026,19 @@ TEST(20)
EXPECT_EQ (poly.to_string (), "(100,100;200,100;200,400;100,400;100,300;400,300;400,400;300,400;300,100;400,100;400,200;100,200)");
poly.assign_hull (pts, pts + sizeof (pts) / sizeof (pts[0]));
poly.size (100, 0);
poly.size (db::Coord (100), db::Coord (0));
EXPECT_EQ (poly.to_string (), "(0,100;0,400;500,400;500,100)");
poly.assign_hull (pts, pts + sizeof (pts) / sizeof (pts[0]));
poly.size (0, 100);
poly.size (db::Coord (0), db::Coord (100));
EXPECT_EQ (poly.to_string (), "(100,0;100,500;400,500;400,0)");
poly.assign_hull (pts, pts + sizeof (pts) / sizeof (pts[0]));
poly.size (-100, 0);
poly.size (db::Coord (-100), db::Coord (0));
EXPECT_EQ (poly.to_string (), "(100,100;200,100;200,400;100,400;400,400;300,400;300,100;400,100)");
poly.assign_hull (pts, pts + sizeof (pts) / sizeof (pts[0]));
poly.size (0, -100);
poly.size (db::Coord (0), db::Coord (-100));
EXPECT_EQ (poly.to_string (), "(100,100;100,400;100,300;400,300;400,400;400,100;400,200;100,200)");
poly.assign_hull (pts, pts + sizeof (pts) / sizeof (pts[0]));

View File

@ -122,7 +122,7 @@ TEST(1)
r.set_merged_semantics (false);
EXPECT_EQ (r.sized (10).to_string (), "(-10,-10;-10,60;60,60;60,-10);(40,40;40,110;110,110;110,40)");
EXPECT_EQ (r.sized (10, 20).to_string (), "(-10,-20;-10,70;60,70;60,-20);(40,30;40,120;110,120;110,30)");
EXPECT_EQ (r.sized (db::Coord (10), db::Coord (20)).to_string (), "(-10,-20;-10,70;60,70;60,-20);(40,30;40,120;110,120;110,30)");
EXPECT_EQ (r.sized (10, 20, 0).to_string (), "(0,-20;-10,0;-10,50;0,70;50,70;60,50;60,0;50,-20);(50,30;40,50;40,100;50,120;100,120;110,100;110,50;100,30)");
r.size (10, 20, 2);
EXPECT_EQ (r.to_string (), "(-10,-20;-10,70;60,70;60,-20);(40,30;40,120;110,120;110,30)");
@ -289,13 +289,13 @@ TEST(8)
EXPECT_EQ (r.sized (10).to_string (), "(-10,-10;-10,210;110,210;110,-10)");
EXPECT_EQ (r.sized (10).is_box (), true);
EXPECT_EQ (r.sized (10).is_merged (), true);
EXPECT_EQ (r.sized (10, 20).to_string (), "(-10,-20;-10,220;110,220;110,-20)");
EXPECT_EQ (r.sized (10, 20).is_box (), true);
EXPECT_EQ (r.sized (10, 20).is_merged (), true);
EXPECT_EQ (r.sized (db::Coord (10), db::Coord (20)).to_string (), "(-10,-20;-10,220;110,220;110,-20)");
EXPECT_EQ (r.sized (db::Coord (10), db::Coord (20)).is_box (), true);
EXPECT_EQ (r.sized (db::Coord (10), db::Coord (20)).is_merged (), true);
r.size (10);
EXPECT_EQ (r.to_string (), "(-10,-10;-10,210;110,210;110,-10)");
r.size (10, 20);
r.size (db::Coord (10), db::Coord (20));
EXPECT_EQ (r.to_string (), "(-20,-30;-20,230;120,230;120,-30)");
}
@ -307,9 +307,9 @@ TEST(9)
EXPECT_EQ (r.sized (10).to_string (), "(-110,-110;-110,410;210,410;210,-110)");
EXPECT_EQ (r.sized (10).is_box (), true);
EXPECT_EQ (r.sized (10).is_merged (), false);
EXPECT_EQ (r.sized (10, 20).to_string (), "(-110,-120;-110,420;210,420;210,-120)");
EXPECT_EQ (r.sized (10, 20).is_box (), true);
EXPECT_EQ (r.sized (10, 20).is_merged (), false);
EXPECT_EQ (r.sized (db::Coord (10), db::Coord (20)).to_string (), "(-110,-120;-110,420;210,420;210,-120)");
EXPECT_EQ (r.sized (db::Coord (10), db::Coord (20)).is_box (), true);
EXPECT_EQ (r.sized (db::Coord (10), db::Coord (20)).is_merged (), false);
}
TEST(10a)
@ -1141,12 +1141,12 @@ TEST(27)
db::Region r;
r.insert (db::Box (db::Point (0, 0), db::Point (100, 200)));
EXPECT_EQ (r.sized (-10, -20).to_string (), "(10,20;10,180;90,180;90,20)");
EXPECT_EQ (r.sized (-50, -20).to_string (), "");
EXPECT_EQ (r.sized (-50, -100).to_string (), "");
EXPECT_EQ (r.sized (-55, -20).to_string (), "");
EXPECT_EQ (r.sized (-10, -105).to_string (), "");
EXPECT_EQ (r.sized (-55, -105).to_string (), "");
EXPECT_EQ (r.sized (db::Coord (-10), db::Coord (-20)).to_string (), "(10,20;10,180;90,180;90,20)");
EXPECT_EQ (r.sized (db::Coord (-50), db::Coord (-20)).to_string (), "");
EXPECT_EQ (r.sized (db::Coord (-50), db::Coord (-100)).to_string (), "");
EXPECT_EQ (r.sized (db::Coord (-55), db::Coord (-20)).to_string (), "");
EXPECT_EQ (r.sized (db::Coord (-10), db::Coord (-105)).to_string (), "");
EXPECT_EQ (r.sized (db::Coord (-55), db::Coord (-105)).to_string (), "");
}
TEST(28)
@ -1159,7 +1159,7 @@ TEST(28)
r2.insert (db::Box (db::Point (100, 100), db::Point (200, 300)));
EXPECT_EQ ((r1 & r2).to_string (), "");
EXPECT_EQ ((r1 & r2.sized (5, 5)).to_string (), "(95,95;95,200;100,200;100,95)");
EXPECT_EQ ((r1 & r2.sized (db::Coord (5), db::Coord (5))).to_string (), "(95,95;95,200;100,200;100,95)");
}
TEST(29)

View File

@ -184,7 +184,7 @@ TEST(10)
EXPECT_EQ (t.is_ortho (), true);
EXPECT_EQ (t.to_string (), recomposed (t).to_string ());
t = db::DCplxTrans (db::ICplxTrans (db::disp_trans<int> (db::Vector (100, -256))));
t = db::DCplxTrans (db::ICplxTrans (db::disp_trans<db::Coord> (db::Vector (100, -256))));
EXPECT_EQ (t.is_unity (), false);
EXPECT_EQ (t.to_string (), "r0 *1 100,-256");
EXPECT_EQ (t.is_ortho (), true);
@ -202,7 +202,7 @@ TEST(10)
EXPECT_EQ (t.to_string (), "r0 *1 -0.5,1.25");
EXPECT_EQ (t.to_string (), recomposed (t).to_string ());
t = db::DCplxTrans (db::DTrans (db::simple_trans<int> (db::FTrans::m135, db::Vector (128, -256))));
t = db::DCplxTrans (db::DTrans (db::simple_trans<db::Coord> (db::FTrans::m135, db::Vector (128, -256))));
EXPECT_EQ (t.is_unity (), false);
EXPECT_EQ (t.to_string (), "m135 *1 128,-256");
EXPECT_EQ (t.to_string (), recomposed (t).to_string ());

View File

@ -30,7 +30,7 @@ TEST(1)
std::string input = tl::testsrc ();
input += "/testdata/drc/drctest.gds";
std::string au = tl::testsrc ();
au += "/testdata/drc/drcBasicTests_au.gds";
au += "/testdata/drc/drcBasicTests_au.oas";
std::string output = this->tmp_file ("tmp.gds");

View File

@ -31,7 +31,7 @@ TEST(1)
rs += "/testdata/drc/drcSimpleTests_1.drc";
std::string au = tl::testsrc ();
au += "/testdata/drc/drcSimpleTests_au1.gds";
au += "/testdata/drc/drcSimpleTests_au1.oas";
std::string output = this->tmp_file ("tmp.gds");
@ -71,7 +71,7 @@ TEST(2)
input += "/testdata/drc/drctest.gds";
std::string au = tl::testsrc ();
au += "/testdata/drc/drcSimpleTests_au2.gds";
au += "/testdata/drc/drcSimpleTests_au2.oas";
std::string output = this->tmp_file ("tmp.gds");
@ -111,7 +111,7 @@ TEST(3)
input += "/testdata/drc/drctest.gds";
std::string au = tl::testsrc ();
au += "/testdata/drc/drcSimpleTests_au3.gds";
au += "/testdata/drc/drcSimpleTests_au3.oas";
std::string output = this->tmp_file ("tmp.gds");

View File

@ -36,7 +36,7 @@ void runtest (tl::TestBase *_this, int mode)
std::string au = tl::testsrc ();
au += "/testdata/drc/drcSuiteTests_au";
au += tl::to_string (mode);
au += ".gds";
au += ".oas";
std::string output = _this->tmp_file ("tmp.gds");

View File

@ -66,6 +66,10 @@ ArgType::to_string () const
s += "long long"; break;
case T_ulonglong:
s += "unsigned long long"; break;
#if defined(HAVE_64BIT_COORD)
case T_int128:
s += "int128"; break;
#endif
case T_double:
s += "double"; break;
case T_float:

View File

@ -193,25 +193,6 @@ static void _call_f_lexicalHandler_c0 (const qt_gsi::GenericMethod * /*decl*/, v
}
// (const QXmlInputSource &)
static void _init_f_parse_2852 (qt_gsi::GenericMethod *decl)
{
static gsi::ArgSpecBase argspec_0 ("input");
decl->add_arg<const QXmlInputSource & > (argspec_0);
decl->set_return<bool > ();
}
static void _call_f_parse_2852 (const qt_gsi::GenericMethod * /*decl*/, void *cls, gsi::SerialArgs &args, gsi::SerialArgs &ret)
{
__SUPPRESS_UNUSED_WARNING(args);
tl::Heap heap;
const QXmlInputSource &arg1 = args.read<const QXmlInputSource & > (heap);
ret.write<bool > ((bool)((QXmlSimpleReader *)cls)->parse (arg1));
}
// (const QXmlInputSource *)
@ -470,7 +451,6 @@ static gsi::Methods methods_QXmlSimpleReader () {
methods += new qt_gsi::GenericMethod ("hasFeature", "@brief Method (const QString &) const\nThis is a reimplementation of QXmlReader::hasFeature", true, &_init_f_hasFeature_c2025, &_call_f_hasFeature_c2025);
methods += new qt_gsi::GenericMethod ("hasProperty", "@brief Method (const QString &) const\nThis is a reimplementation of QXmlReader::hasProperty", true, &_init_f_hasProperty_c2025, &_call_f_hasProperty_c2025);
methods += new qt_gsi::GenericMethod (":lexicalHandler", "@brief Method () const\nThis is a reimplementation of QXmlReader::lexicalHandler", true, &_init_f_lexicalHandler_c0, &_call_f_lexicalHandler_c0);
methods += new qt_gsi::GenericMethod ("parse", "@brief Method (const QXmlInputSource &)\nThis is a reimplementation of QXmlReader::parse", false, &_init_f_parse_2852, &_call_f_parse_2852);
methods += new qt_gsi::GenericMethod ("parse", "@brief Method (const QXmlInputSource *)\nThis is a reimplementation of QXmlReader::parse", false, &_init_f_parse_2856, &_call_f_parse_2856);
methods += new qt_gsi::GenericMethod ("parse", "@brief Method (const QXmlInputSource *, bool)\n", false, &_init_f_parse_3612, &_call_f_parse_3612);
methods += new qt_gsi::GenericMethod ("parseContinue", "@brief Method bool QXmlSimpleReader::parseContinue()\n", false, &_init_f_parseContinue_0, &_call_f_parseContinue_0);
@ -644,21 +624,6 @@ public:
}
}
// [adaptor impl] bool QXmlSimpleReader::parse(const QXmlInputSource &input)
bool cbs_parse_2852_0(const QXmlInputSource &input)
{
return QXmlSimpleReader::parse(input);
}
virtual bool parse(const QXmlInputSource &input)
{
if (cb_parse_2852_0.can_issue()) {
return cb_parse_2852_0.issue<QXmlSimpleReader_Adaptor, bool, const QXmlInputSource &>(&QXmlSimpleReader_Adaptor::cbs_parse_2852_0, input);
} else {
return QXmlSimpleReader::parse(input);
}
}
// [adaptor impl] bool QXmlSimpleReader::parse(const QXmlInputSource *input)
bool cbs_parse_2856_0(const QXmlInputSource *input)
{
@ -848,7 +813,6 @@ public:
gsi::Callback cb_hasFeature_c2025_0;
gsi::Callback cb_hasProperty_c2025_0;
gsi::Callback cb_lexicalHandler_c0_0;
gsi::Callback cb_parse_2852_0;
gsi::Callback cb_parse_2856_0;
gsi::Callback cb_parse_3612_0;
gsi::Callback cb_parseContinue_0_0;
@ -1065,29 +1029,6 @@ static void _set_callback_cbs_lexicalHandler_c0_0 (void *cls, const gsi::Callbac
}
// bool QXmlSimpleReader::parse(const QXmlInputSource &input)
static void _init_cbs_parse_2852_0 (qt_gsi::GenericMethod *decl)
{
static gsi::ArgSpecBase argspec_0 ("input");
decl->add_arg<const QXmlInputSource & > (argspec_0);
decl->set_return<bool > ();
}
static void _call_cbs_parse_2852_0 (const qt_gsi::GenericMethod * /*decl*/, void *cls, gsi::SerialArgs &args, gsi::SerialArgs &ret)
{
__SUPPRESS_UNUSED_WARNING(args);
tl::Heap heap;
const QXmlInputSource &arg1 = args.read<const QXmlInputSource & > (heap);
ret.write<bool > ((bool)((QXmlSimpleReader_Adaptor *)cls)->cbs_parse_2852_0 (arg1));
}
static void _set_callback_cbs_parse_2852_0 (void *cls, const gsi::Callback &cb)
{
((QXmlSimpleReader_Adaptor *)cls)->cb_parse_2852_0 = cb;
}
// bool QXmlSimpleReader::parse(const QXmlInputSource *input)
static void _init_cbs_parse_2856_0 (qt_gsi::GenericMethod *decl)
@ -1406,8 +1347,6 @@ static gsi::Methods methods_QXmlSimpleReader_Adaptor () {
methods += new qt_gsi::GenericMethod ("hasProperty", "@brief Virtual method bool QXmlSimpleReader::hasProperty(const QString &name)\nThis method can be reimplemented in a derived class.", true, &_init_cbs_hasProperty_c2025_0, &_call_cbs_hasProperty_c2025_0, &_set_callback_cbs_hasProperty_c2025_0);
methods += new qt_gsi::GenericMethod ("lexicalHandler", "@hide", true, &_init_cbs_lexicalHandler_c0_0, &_call_cbs_lexicalHandler_c0_0);
methods += new qt_gsi::GenericMethod ("lexicalHandler", "@brief Virtual method QXmlLexicalHandler *QXmlSimpleReader::lexicalHandler()\nThis method can be reimplemented in a derived class.", true, &_init_cbs_lexicalHandler_c0_0, &_call_cbs_lexicalHandler_c0_0, &_set_callback_cbs_lexicalHandler_c0_0);
methods += new qt_gsi::GenericMethod ("parse", "@hide", false, &_init_cbs_parse_2852_0, &_call_cbs_parse_2852_0);
methods += new qt_gsi::GenericMethod ("parse", "@brief Virtual method bool QXmlSimpleReader::parse(const QXmlInputSource &input)\nThis method can be reimplemented in a derived class.", false, &_init_cbs_parse_2852_0, &_call_cbs_parse_2852_0, &_set_callback_cbs_parse_2852_0);
methods += new qt_gsi::GenericMethod ("parse", "@hide", false, &_init_cbs_parse_2856_0, &_call_cbs_parse_2856_0);
methods += new qt_gsi::GenericMethod ("parse", "@brief Virtual method bool QXmlSimpleReader::parse(const QXmlInputSource *input)\nThis method can be reimplemented in a derived class.", false, &_init_cbs_parse_2856_0, &_call_cbs_parse_2856_0, &_set_callback_cbs_parse_2856_0);
methods += new qt_gsi::GenericMethod ("parse", "@hide", false, &_init_cbs_parse_3612_0, &_call_cbs_parse_3612_0);

View File

@ -193,25 +193,6 @@ static void _call_f_lexicalHandler_c0 (const qt_gsi::GenericMethod * /*decl*/, v
}
// (const QXmlInputSource &)
static void _init_f_parse_2852 (qt_gsi::GenericMethod *decl)
{
static gsi::ArgSpecBase argspec_0 ("input");
decl->add_arg<const QXmlInputSource & > (argspec_0);
decl->set_return<bool > ();
}
static void _call_f_parse_2852 (const qt_gsi::GenericMethod * /*decl*/, void *cls, gsi::SerialArgs &args, gsi::SerialArgs &ret)
{
__SUPPRESS_UNUSED_WARNING(args);
tl::Heap heap;
const QXmlInputSource &arg1 = args.read<const QXmlInputSource & > (heap);
ret.write<bool > ((bool)((QXmlSimpleReader *)cls)->parse (arg1));
}
// (const QXmlInputSource *)
@ -470,7 +451,6 @@ static gsi::Methods methods_QXmlSimpleReader () {
methods += new qt_gsi::GenericMethod ("hasFeature", "@brief Method (const QString &) const\nThis is a reimplementation of QXmlReader::hasFeature", true, &_init_f_hasFeature_c2025, &_call_f_hasFeature_c2025);
methods += new qt_gsi::GenericMethod ("hasProperty", "@brief Method (const QString &) const\nThis is a reimplementation of QXmlReader::hasProperty", true, &_init_f_hasProperty_c2025, &_call_f_hasProperty_c2025);
methods += new qt_gsi::GenericMethod (":lexicalHandler", "@brief Method () const\nThis is a reimplementation of QXmlReader::lexicalHandler", true, &_init_f_lexicalHandler_c0, &_call_f_lexicalHandler_c0);
methods += new qt_gsi::GenericMethod ("parse", "@brief Method (const QXmlInputSource &)\nThis is a reimplementation of QXmlReader::parse", false, &_init_f_parse_2852, &_call_f_parse_2852);
methods += new qt_gsi::GenericMethod ("parse", "@brief Method (const QXmlInputSource *)\nThis is a reimplementation of QXmlReader::parse", false, &_init_f_parse_2856, &_call_f_parse_2856);
methods += new qt_gsi::GenericMethod ("parse", "@brief Method (const QXmlInputSource *, bool)\n", false, &_init_f_parse_3612, &_call_f_parse_3612);
methods += new qt_gsi::GenericMethod ("parseContinue", "@brief Method bool QXmlSimpleReader::parseContinue()\n", false, &_init_f_parseContinue_0, &_call_f_parseContinue_0);
@ -644,21 +624,6 @@ public:
}
}
// [adaptor impl] bool QXmlSimpleReader::parse(const QXmlInputSource &input)
bool cbs_parse_2852_0(const QXmlInputSource &input)
{
return QXmlSimpleReader::parse(input);
}
virtual bool parse(const QXmlInputSource &input)
{
if (cb_parse_2852_0.can_issue()) {
return cb_parse_2852_0.issue<QXmlSimpleReader_Adaptor, bool, const QXmlInputSource &>(&QXmlSimpleReader_Adaptor::cbs_parse_2852_0, input);
} else {
return QXmlSimpleReader::parse(input);
}
}
// [adaptor impl] bool QXmlSimpleReader::parse(const QXmlInputSource *input)
bool cbs_parse_2856_0(const QXmlInputSource *input)
{
@ -848,7 +813,6 @@ public:
gsi::Callback cb_hasFeature_c2025_0;
gsi::Callback cb_hasProperty_c2025_0;
gsi::Callback cb_lexicalHandler_c0_0;
gsi::Callback cb_parse_2852_0;
gsi::Callback cb_parse_2856_0;
gsi::Callback cb_parse_3612_0;
gsi::Callback cb_parseContinue_0_0;
@ -1065,29 +1029,6 @@ static void _set_callback_cbs_lexicalHandler_c0_0 (void *cls, const gsi::Callbac
}
// bool QXmlSimpleReader::parse(const QXmlInputSource &input)
static void _init_cbs_parse_2852_0 (qt_gsi::GenericMethod *decl)
{
static gsi::ArgSpecBase argspec_0 ("input");
decl->add_arg<const QXmlInputSource & > (argspec_0);
decl->set_return<bool > ();
}
static void _call_cbs_parse_2852_0 (const qt_gsi::GenericMethod * /*decl*/, void *cls, gsi::SerialArgs &args, gsi::SerialArgs &ret)
{
__SUPPRESS_UNUSED_WARNING(args);
tl::Heap heap;
const QXmlInputSource &arg1 = args.read<const QXmlInputSource & > (heap);
ret.write<bool > ((bool)((QXmlSimpleReader_Adaptor *)cls)->cbs_parse_2852_0 (arg1));
}
static void _set_callback_cbs_parse_2852_0 (void *cls, const gsi::Callback &cb)
{
((QXmlSimpleReader_Adaptor *)cls)->cb_parse_2852_0 = cb;
}
// bool QXmlSimpleReader::parse(const QXmlInputSource *input)
static void _init_cbs_parse_2856_0 (qt_gsi::GenericMethod *decl)
@ -1406,8 +1347,6 @@ static gsi::Methods methods_QXmlSimpleReader_Adaptor () {
methods += new qt_gsi::GenericMethod ("hasProperty", "@brief Virtual method bool QXmlSimpleReader::hasProperty(const QString &name)\nThis method can be reimplemented in a derived class.", true, &_init_cbs_hasProperty_c2025_0, &_call_cbs_hasProperty_c2025_0, &_set_callback_cbs_hasProperty_c2025_0);
methods += new qt_gsi::GenericMethod ("lexicalHandler", "@hide", true, &_init_cbs_lexicalHandler_c0_0, &_call_cbs_lexicalHandler_c0_0);
methods += new qt_gsi::GenericMethod ("lexicalHandler", "@brief Virtual method QXmlLexicalHandler *QXmlSimpleReader::lexicalHandler()\nThis method can be reimplemented in a derived class.", true, &_init_cbs_lexicalHandler_c0_0, &_call_cbs_lexicalHandler_c0_0, &_set_callback_cbs_lexicalHandler_c0_0);
methods += new qt_gsi::GenericMethod ("parse", "@hide", false, &_init_cbs_parse_2852_0, &_call_cbs_parse_2852_0);
methods += new qt_gsi::GenericMethod ("parse", "@brief Virtual method bool QXmlSimpleReader::parse(const QXmlInputSource &input)\nThis method can be reimplemented in a derived class.", false, &_init_cbs_parse_2852_0, &_call_cbs_parse_2852_0, &_set_callback_cbs_parse_2852_0);
methods += new qt_gsi::GenericMethod ("parse", "@hide", false, &_init_cbs_parse_2856_0, &_call_cbs_parse_2856_0);
methods += new qt_gsi::GenericMethod ("parse", "@brief Virtual method bool QXmlSimpleReader::parse(const QXmlInputSource *input)\nThis method can be reimplemented in a derived class.", false, &_init_cbs_parse_2856_0, &_call_cbs_parse_2856_0, &_set_callback_cbs_parse_2856_0);
methods += new qt_gsi::GenericMethod ("parse", "@hide", false, &_init_cbs_parse_3612_0, &_call_cbs_parse_3612_0);

View File

@ -577,6 +577,10 @@ type_to_s (const gsi::ArgType &a, bool linked, bool for_return)
s += "unsigned short"; break;
case gsi::T_int:
s += "int"; break;
#if defined(HAVE_64BIT_COORD)
case gsi::T_int128:
s += "int128"; break;
#endif
case gsi::T_uint:
s += "unsigned int"; break;
case gsi::T_long:

View File

@ -145,6 +145,10 @@ LayoutHandle::rename (const std::string &name, bool force) throw (tl::Exception)
tl::info << "Renamed layout from " << m_name << " to " << n;
}
if (find (m_name) == this) {
ms_dict.erase (m_name);
}
m_name = n;
ms_dict.insert (std::make_pair (n, this));
return;

View File

@ -42,7 +42,8 @@ SOURCES = \
tlWebDAV.cc \
tlArch.cc \
tlCommandLineParser.cc \
tlUnitTest.cc
tlUnitTest.cc \
tlInt128Support.cc
HEADERS = \
tlAlgorithm.h \
@ -90,7 +91,8 @@ HEADERS = \
tlWebDAV.h \
tlArch.h \
tlCommandLineParser.h \
tlUnitTest.h
tlUnitTest.h \
tlInt128Support.h
INCLUDEPATH =
DEPENDPATH =

View File

@ -0,0 +1,29 @@
/*
KLayout Layout Viewer
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if defined(HAVE_64BIT_COORD)
#include "tlInt128Support.h"
// .. nothing yet ..
#endif

View File

@ -0,0 +1,58 @@
/*
KLayout Layout Viewer
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_tlInt128Support
#define HDR_tlInt128Support
#if defined(HAVE_64BIT_COORD)
#include "tlCommon.h"
#include "tlString.h"
#include <inttypes.h>
#include <ostream>
namespace std
{
#if !defined(__GLIBCXX_BITSIZE_INT_N_0) || __GLIBCXX_BITSIZE_INT_N_0 != 128
// Provide an implementation for abs(__int128_t) if there isn't one
inline __int128 abs (__int128 x)
{
return x < 0 ? -x : x;
}
#endif
// Provide ostream serialization for 128bit values
inline std::ostream &operator<< (std::ostream &os, __int128 x)
{
os << tl::to_string (x);
return os;
}
}
#endif
#endif

View File

@ -232,29 +232,52 @@ tl::to_string (const unsigned long long &d)
}
#if defined(HAVE_64BIT_COORD)
template <>
std::string
tl::to_string (const __int128 &d)
{
if (d < 0 ) {
return "-" + tl::to_string(static_cast<unsigned __int128>(-d));
return "-" + tl::to_string(static_cast<unsigned __int128> (-d));
} else {
return tl::to_string(static_cast<unsigned __int128>(d));
return tl::to_string(static_cast<unsigned __int128> (d));
}
}
template <>
std::string
tl::to_string (const unsigned __int128 &d)
tl::to_string (const unsigned __int128 &_x)
{
if (static_cast<uint64_t>(d) == d) {
return tl::to_string(static_cast<uint64_t>(d));
std::string r;
unsigned __int128 x = _x;
// this is the max. power of 10 that can be represented with __int128
unsigned __int128 m = (unsigned long long) 0x4b3b4ca85a86c47a;
m <<= 64;
m |= (unsigned long long) 0x98a224000000000;
if (x == 0) {
return "0";
}
std::ostringstream os;
os.imbue (c_locale);
os << "0x" << std::hex << static_cast<uint64_t> (d>>64) << static_cast<uint64_t> (d);
return os.str ();
bool first = true;
while (m > 1) {
int d = 0;
while (x >= m) {
d += 1;
x -= m;
}
if (d > 0 || !first) {
r += char ('0' + d);
first = false;
}
m /= 10;
}
r += char('0' + int(x));
return r;
}
#endif
template <>

View File

@ -27,6 +27,7 @@
#include "tlLog.h"
#include "tlException.h"
#include "tlString.h"
#include "tlInt128Support.h"
#include <string>
#include <vector>

View File

@ -0,0 +1,62 @@
/*
KLayout Layout Viewer
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if defined(HAVE_64BIT_COORD)
#include "tlInt128Support.h"
#include "tlUnitTest.h"
#include <cstdio>
TEST(1)
{
EXPECT_EQ (tl::to_string (__int128 (0)), "0");
EXPECT_EQ (tl::to_string (__int128 (42)), "42");
EXPECT_EQ (tl::to_string (__int128 (-42)), "-42");
__int128 x = 1;
for (int i = 0; i < 30; ++i) {
x *= 10;
}
EXPECT_EQ (tl::to_string (x), "1000000000000000000000000000000");
EXPECT_EQ (tl::to_string (-x), "-1000000000000000000000000000000");
EXPECT_EQ (tl::to_string (x + 1), "1000000000000000000000000000001");
EXPECT_EQ (tl::to_string (x - 1), "999999999999999999999999999999");
}
TEST(2)
{
EXPECT_EQ (tl::to_string ((unsigned __int128) 0), "0");
EXPECT_EQ (tl::to_string ((unsigned __int128) 42), "42");
unsigned __int128 x = 1;
for (int i = 0; i < 30; ++i) {
x *= 10;
}
EXPECT_EQ (tl::to_string (x), "1000000000000000000000000000000");
EXPECT_EQ (tl::to_string (x + 1), "1000000000000000000000000000001");
EXPECT_EQ (tl::to_string (x - 1), "999999999999999999999999999999");
}
#endif

View File

@ -32,6 +32,7 @@ SOURCES = \
tlVariant.cc \
tlWebDAV.cc \
tlXMLParser.cc \
tlInt128Support.cc
INCLUDEPATH += $$TL_INC
DEPENDPATH += $$TL_INC

View File

@ -13,6 +13,7 @@ def run_testsuite(dm, ic, tiled = false)
c = input(3)
x = input(10)
y = input(11)
empty = input(1000)
h = {}
layers.each { |l| h[l] = true }
@ -123,6 +124,9 @@ def run_testsuite(dm, ic, tiled = false)
message "--- interacting, in, not_in #{lb}"
b.interacting(a).output(lb, dm)
b.not_interacting(a).output(lb, dm + 1)
b.interacting(empty).output(lb, dm + 2)
b.not_interacting(empty).output(lb, dm + 3)
b.interacting(a).in(b).output(lb + 1, dm)
(b|a).not_in(b).output(lb + 2, dm)
x.in(b).output(lb + 3, dm)
@ -132,21 +136,73 @@ def run_testsuite(dm, ic, tiled = false)
message "--- inside, outside, overlapping, interacting #{lb}"
b.inside(c).output(lb, dm)
b.not_inside(c).output(lb, dm + 1)
b.inside(empty).output(lb, dm + 2)
b.not_inside(empty).output(lb, dm + 3)
b.outside(c).output(lb + 1, dm)
b.not_outside(c).output(lb + 1, dm + 1)
b.outside(empty).output(lb + 1, dm + 2)
b.not_outside(empty).output(lb + 1, dm + 3)
b.overlapping(c).output(lb + 2, dm)
b.not_overlapping(c).output(lb + 2, dm + 1)
b.overlapping(empty).output(lb + 2, dm + 2)
b.not_overlapping(empty).output(lb + 2, dm + 3)
b.interacting(c).output(lb + 3, dm)
b.not_interacting(c).output(lb + 3, dm + 1)
b.interacting(empty).output(lb + 3, dm + 2)
b.not_interacting(empty).output(lb + 3, dm + 3)
bdup = b.dup
bdup.select_inside(c)
bdup.xor(b.inside(c)).output(lb + 4, dm)
bdup = b.dup
bdup.select_not_inside(c)
bdup.output(lb + 4, dm + 1)
bdup = b.dup
bdup.select_inside(empty)
bdup.output(lb + 4, dm + 2)
bdup = b.dup
bdup.select_not_inside(empty)
bdup.output(lb + 4, dm + 3)
bdup = b.dup
bdup.select_outside(c)
bdup.xor(b.outside(c)).output(lb + 5, dm)
bdup = b.dup
bdup.select_not_outside(c)
bdup.output(lb + 5, dm + 1)
bdup = b.dup
bdup.select_outside(empty)
bdup.output(lb + 5, dm + 2)
bdup = b.dup
bdup.select_not_outside(empty)
bdup.output(lb + 5, dm + 3)
bdup = b.dup
bdup.select_overlapping(c)
bdup.xor(b.overlapping(c)).output(lb + 6, dm)
bdup = b.dup
bdup.select_not_overlapping(c)
bdup.output(lb + 6, dm + 1)
bdup = b.dup
bdup.select_overlapping(empty)
bdup.output(lb + 6, dm + 2)
bdup = b.dup
bdup.select_not_overlapping(empty)
bdup.output(lb + 6, dm + 3)
bdup = b.dup
bdup.select_interacting(c)
bdup.xor(b.interacting(c)).output(lb + 7, dm)
bdup = b.dup
bdup.select_not_interacting(c)
bdup.output(lb + 7, dm + 1)
bdup = b.dup
bdup.select_interacting(empty)
bdup.output(lb + 7, dm + 2)
bdup = b.dup
bdup.select_not_interacting(empty)
bdup.output(lb + 7, dm + 3)
b.inside(empty).output(lb + 8, dm)
b.not_inside(empty).output(lb + 8, dm + 1)
b.outside(empty).output(lb + 9, dm)
b.not_outside(empty).output(lb + 9, dm + 1)
lb += 10
message "--- merge #{lb}"