2022-10-10 04:36:50 +02:00
|
|
|
#! /usr/bin/env python3
|
2020-07-16 22:57:28 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
import shutil
|
|
|
|
|
import glob
|
2021-02-08 22:06:38 +01:00
|
|
|
import platform
|
2020-07-16 22:57:28 +02:00
|
|
|
import optparse
|
|
|
|
|
import subprocess
|
|
|
|
|
|
2021-02-08 22:06:38 +01:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To test if the platform is a member of valid platforms
|
|
|
|
|
#
|
|
|
|
|
# @param[in] platforms valid platforms
|
|
|
|
|
#
|
|
|
|
|
# @return matching platform name on success; "" on failure
|
|
|
|
|
#------------------------------------------------------------------------------
|
2021-11-15 22:38:47 +01:00
|
|
|
def Test_My_Platform( platforms=['Catalina', 'BigSur', 'Monterey' ] ):
|
2021-02-08 22:06:38 +01:00
|
|
|
(System, Node, Release, MacVersion, Machine, Processor) = platform.uname()
|
|
|
|
|
|
|
|
|
|
if not System == "Darwin":
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
release = int( Release.split(".")[0] ) # take the first of ['19', '0', '0']
|
2021-11-15 22:38:47 +01:00
|
|
|
if release == 21:
|
|
|
|
|
Platform = "Monterey"
|
|
|
|
|
elif release == 20:
|
2021-02-08 22:06:38 +01:00
|
|
|
Platform = "BigSur"
|
|
|
|
|
elif release == 19:
|
|
|
|
|
Platform = "Catalina"
|
|
|
|
|
elif release == 18:
|
|
|
|
|
Platform = "Mojave"
|
|
|
|
|
elif release == 17:
|
|
|
|
|
Platform = "HighSierra"
|
|
|
|
|
elif release == 16:
|
|
|
|
|
Platform = "Sierra"
|
|
|
|
|
elif release == 15:
|
|
|
|
|
Platform = "ElCapitan"
|
|
|
|
|
else:
|
|
|
|
|
Platform = ""
|
|
|
|
|
|
|
|
|
|
if Platform in platforms:
|
|
|
|
|
return Platform
|
|
|
|
|
else:
|
|
|
|
|
return ""
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To populate the build target dictionary
|
|
|
|
|
#
|
|
|
|
|
# @return a dictionary; key=integer, value=mnemonic
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
def Get_Build_Target_Dict():
|
|
|
|
|
buildTargetDic = dict()
|
2022-12-24 03:08:57 +01:00
|
|
|
# buildTargetDic[0] = 'std' # has been abolished in 0.28
|
2020-11-26 23:00:12 +01:00
|
|
|
buildTargetDic[1] = 'ports'
|
|
|
|
|
buildTargetDic[2] = 'brew'
|
|
|
|
|
buildTargetDic[3] = 'brewHW'
|
|
|
|
|
buildTargetDic[4] = 'ana3'
|
|
|
|
|
|
|
|
|
|
buildTargetDic[5] = 'brewA'
|
|
|
|
|
buildTargetDic[6] = 'brewAHW'
|
|
|
|
|
return buildTargetDic
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To get the build option dictionary
|
|
|
|
|
#
|
|
|
|
|
# @param[in] targetDic build target dictionary
|
|
|
|
|
#
|
|
|
|
|
# @return a dictionary; key=mnemonic, value=build option list
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
def Get_Build_Options( targetDic ):
|
2022-10-10 04:36:50 +02:00
|
|
|
if QtType == 5:
|
|
|
|
|
qtType = "Qt5"
|
|
|
|
|
else:
|
|
|
|
|
qtType = "Qt6"
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
buildOp = dict()
|
|
|
|
|
for key in targetDic.keys():
|
|
|
|
|
target = targetDic[key]
|
2021-02-08 22:06:38 +01:00
|
|
|
if target == "std": # use 'Qt5MacPorts' that provides Qt 5.15.2~ to run on "Big Sur", too
|
2022-10-10 04:36:50 +02:00
|
|
|
buildOp["std"] = [ '-q', '%sMacPorts' % qtType, '-r', 'sys', '-p', 'sys' ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "ports":
|
2022-10-10 04:36:50 +02:00
|
|
|
buildOp["ports"] = [ '-q', '%sMacPorts' % qtType, '-r', 'MP31', '-p', 'MP38' ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brew":
|
2022-10-10 04:36:50 +02:00
|
|
|
buildOp["brew"] = [ '-q', '%sBrew' % qtType, '-r', 'HB31', '-p', 'HB38' ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brewHW":
|
2022-10-10 04:36:50 +02:00
|
|
|
buildOp["brewHW"] = [ '-q', '%sBrew' % qtType, '-r', 'sys', '-p', 'HB38' ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "ana3":
|
2022-10-10 04:36:50 +02:00
|
|
|
buildOp["ana3"] = [ '-q', '%sAna3' % qtType, '-r', 'Ana3', '-p', 'Ana3' ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brewA":
|
2022-10-10 04:36:50 +02:00
|
|
|
buildOp["brewA"] = [ '-q', '%sBrew' % qtType, '-r', 'HB31', '-p', 'HBAuto' ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brewAHW":
|
2022-10-10 04:36:50 +02:00
|
|
|
buildOp["brewAHW"] = [ '-q', '%sBrew' % qtType, '-r', 'sys', '-p', 'HBAuto' ]
|
2022-05-10 20:25:30 +02:00
|
|
|
|
|
|
|
|
if WithPymod:
|
|
|
|
|
buildOp["ports"] = buildOp["ports"] + ['--buildPymod']
|
|
|
|
|
buildOp["brew"] = buildOp["brew"] + ['--buildPymod']
|
|
|
|
|
buildOp["ana3"] = buildOp["ana3"] + ['--buildPymod']
|
2020-11-26 23:00:12 +01:00
|
|
|
return buildOp
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To get the ".macQAT" dictionary for QA Test
|
|
|
|
|
#
|
|
|
|
|
# @param[in] targetDic build target dictionary
|
2021-02-08 22:06:38 +01:00
|
|
|
# @param[in] platform platform name
|
2020-11-26 23:00:12 +01:00
|
|
|
#
|
|
|
|
|
# @return a dictionary; key=mnemonic, value=".macQAT" directory
|
|
|
|
|
#------------------------------------------------------------------------------
|
2021-02-08 22:06:38 +01:00
|
|
|
def Get_QAT_Directory( targetDic, platform ):
|
2022-10-10 04:36:50 +02:00
|
|
|
if QtType == 5:
|
|
|
|
|
qtType = "qt5"
|
|
|
|
|
else:
|
|
|
|
|
qtType = "qt6"
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
dirQAT = dict()
|
|
|
|
|
for key in targetDic.keys():
|
|
|
|
|
target = targetDic[key]
|
|
|
|
|
if target == "std":
|
2022-10-10 04:36:50 +02:00
|
|
|
dirQAT["std"] = '%sMP.build.macos-%s-release-RsysPsys.macQAT' % (qtType, platform)
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "ports":
|
2022-10-10 04:36:50 +02:00
|
|
|
dirQAT["ports"] = '%sMP.build.macos-%s-release-Rmp31Pmp38.macQAT' % (qtType, platform)
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brew":
|
2022-10-10 04:36:50 +02:00
|
|
|
dirQAT["brew"] = '%sBrew.build.macos-%s-release-Rhb31Phb38.macQAT' % (qtType, platform)
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brewHW":
|
2022-10-10 04:36:50 +02:00
|
|
|
dirQAT["brewHW"] = '%sBrew.build.macos-%s-release-RsysPhb38.macQAT' % (qtType, platform)
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "ana3":
|
2022-10-10 04:36:50 +02:00
|
|
|
dirQAT["ana3"] = '%sAna3.build.macos-%s-release-Rana3Pana3.macQAT' % (qtType, platform)
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brewA":
|
2022-10-10 04:36:50 +02:00
|
|
|
dirQAT["brewA"] = '%sBrew.build.macos-%s-release-Rhb31Phbauto.macQAT' % (qtType, platform)
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brewAHW":
|
2022-10-10 04:36:50 +02:00
|
|
|
dirQAT["brewAHW"] = '%sBrew.build.macos-%s-release-RsysPhbauto.macQAT' % (qtType, platform)
|
2020-11-26 23:00:12 +01:00
|
|
|
return dirQAT
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To get the build option dictionary for making/cleaning DMG
|
|
|
|
|
#
|
|
|
|
|
# @param[in] targetDic build target dictionary
|
2021-02-08 22:06:38 +01:00
|
|
|
# @param[in] platform platform name
|
2020-11-26 23:00:12 +01:00
|
|
|
# @param[in] srlDMG serial number of DMG
|
|
|
|
|
# @param[in] makeflag True to make; False to clean
|
|
|
|
|
#
|
|
|
|
|
# @return a dictionary; key=mnemonic, value=build option list
|
|
|
|
|
#------------------------------------------------------------------------------
|
2021-02-08 22:06:38 +01:00
|
|
|
def Get_Package_Options( targetDic, platform, srlDMG, makeflag ):
|
2022-10-10 04:36:50 +02:00
|
|
|
if QtType == 5:
|
|
|
|
|
qtType = "qt5"
|
|
|
|
|
else:
|
|
|
|
|
qtType = "qt6"
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
if makeflag:
|
|
|
|
|
flag = '-m'
|
2020-07-16 22:57:28 +02:00
|
|
|
else:
|
2020-11-26 23:00:12 +01:00
|
|
|
flag = '-c'
|
|
|
|
|
|
|
|
|
|
packOp = dict()
|
|
|
|
|
for key in targetDic.keys():
|
|
|
|
|
target = targetDic[key]
|
|
|
|
|
if target == "std":
|
2022-10-10 04:36:50 +02:00
|
|
|
packOp["std"] = [ '-p', 'ST-%sMP.pkg.macos-%s-release-RsysPsys' % (qtType, platform),
|
2021-02-08 22:06:38 +01:00
|
|
|
'-s', '%d' % srlDMG, '%s' % flag ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "ports":
|
2022-10-10 04:36:50 +02:00
|
|
|
packOp["ports"] = [ '-p', 'LW-%sMP.pkg.macos-%s-release-Rmp31Pmp38' % (qtType, platform),
|
2021-02-08 22:06:38 +01:00
|
|
|
'-s', '%d' % srlDMG, '%s' % flag ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brew":
|
2022-10-10 04:36:50 +02:00
|
|
|
packOp["brew"] = [ '-p', 'LW-%sBrew.pkg.macos-%s-release-Rhb31Phb38' % (qtType, platform),
|
2021-02-08 22:06:38 +01:00
|
|
|
'-s', '%d' % srlDMG, '%s' % flag ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brewHW":
|
2022-10-10 04:36:50 +02:00
|
|
|
packOp["brewHW"] = [ '-p', 'HW-%sBrew.pkg.macos-%s-release-RsysPhb38' % (qtType, platform),
|
2021-02-08 22:06:38 +01:00
|
|
|
'-s', '%d' % srlDMG, '%s' % flag ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "ana3":
|
2022-10-10 04:36:50 +02:00
|
|
|
packOp["ana3"] = [ '-p', 'LW-%sAna3.pkg.macos-%s-release-Rana3Pana3' % (qtType, platform),
|
2021-02-08 22:06:38 +01:00
|
|
|
'-s', '%d' % srlDMG, '%s' % flag ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brewA":
|
2022-10-10 04:36:50 +02:00
|
|
|
packOp["brewA"] = [ '-p', 'LW-%sBrew.pkg.macos-%s-release-Rhb31Phbauto' % (qtType, platform),
|
2021-02-08 22:06:38 +01:00
|
|
|
'-s', '%d' % srlDMG, '%s' % flag ]
|
2020-11-26 23:00:12 +01:00
|
|
|
elif target == "brewAHW":
|
2022-10-10 04:36:50 +02:00
|
|
|
packOp["brewAHW"] = [ '-p', 'HW-%sBrew.pkg.macos-%s-release-RsysPhbauto' % (qtType, platform),
|
2021-02-08 22:06:38 +01:00
|
|
|
'-s', '%d' % srlDMG, '%s' % flag ]
|
2020-11-26 23:00:12 +01:00
|
|
|
return packOp
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To parse the command line arguments
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
def Parse_CommandLine_Arguments():
|
|
|
|
|
global Usage # usage
|
2022-10-10 04:36:50 +02:00
|
|
|
global QtType # Qt type
|
2020-11-26 23:00:12 +01:00
|
|
|
global Target # target list
|
|
|
|
|
global Build # operation flag
|
2022-05-10 20:25:30 +02:00
|
|
|
global WithPymod # operation flag
|
2020-11-26 23:00:12 +01:00
|
|
|
global QATest # operation flag
|
|
|
|
|
global QACheck # operation flag
|
|
|
|
|
global MakeDMG # operation flag
|
|
|
|
|
global CleanDMG # operation flag
|
|
|
|
|
global Upload # operation flag
|
|
|
|
|
global SrlDMG # DMG serial number
|
|
|
|
|
global Dropbox # Dropbox directory
|
|
|
|
|
|
2021-11-15 22:38:47 +01:00
|
|
|
platform = Test_My_Platform()
|
|
|
|
|
if platform in [ "Monterey", "BigSur" ]:
|
|
|
|
|
targetopt = "1,2,3,4"
|
|
|
|
|
elif platform in ["Catalina"]:
|
2022-12-17 05:42:08 +01:00
|
|
|
targetopt = "1,2,3,4"
|
2021-11-15 22:38:47 +01:00
|
|
|
else:
|
|
|
|
|
targetopt = ""
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
Usage = "\n"
|
2021-11-15 22:38:47 +01:00
|
|
|
Usage += "--------------------------------------------------------------------------------------------------\n"
|
2021-02-08 22:06:38 +01:00
|
|
|
Usage += " nightlyBuild.py [EXPERIMENTAL] \n"
|
2021-11-15 22:38:47 +01:00
|
|
|
Usage += " << To execute the jobs for making KLayout's DMGs for macOS Catalina, Big Sur, or Monterey >>\n"
|
2020-11-26 23:00:12 +01:00
|
|
|
Usage += "\n"
|
2021-11-16 15:06:24 +01:00
|
|
|
Usage += "$ [python] nightlyBuild.py\n"
|
2020-11-26 23:00:12 +01:00
|
|
|
Usage += " option & argument : comment on option if any | default value\n"
|
|
|
|
|
Usage += " ------------------------------------------------------------------------+--------------\n"
|
2022-10-10 04:36:50 +02:00
|
|
|
Usage += " [--qt <type>] : 5='qt5', 6='qt6' (migration to Qt6 is ongoing) | 5\n"
|
2022-12-24 03:08:57 +01:00
|
|
|
Usage += " [--target <list>] : 1='ports', 2='brew', 3='brewHW', 4='ana3', | '%s'\n" % targetopt
|
2020-11-26 23:00:12 +01:00
|
|
|
Usage += " 5='brewA', 6='brewAHW' | \n"
|
2022-10-10 04:36:50 +02:00
|
|
|
Usage += " * with --qt=6, use --target='2,3' (4 is ignored) | \n"
|
2020-11-26 23:00:12 +01:00
|
|
|
Usage += " [--build] : build and deploy | disabled\n"
|
2022-05-10 20:25:30 +02:00
|
|
|
Usage += " [--pymod] : build and deploy Pymod, too | disabled\n"
|
2020-11-26 23:00:12 +01:00
|
|
|
Usage += " [--test] : run the QA Test | disabled\n"
|
|
|
|
|
Usage += " [--check] : check the QA Test results | disabled\n"
|
|
|
|
|
Usage += " [--makedmg|--cleandmg <srlno>] : make or clean DMGs | disabled\n"
|
|
|
|
|
Usage += " [--upload <dropbox>] : upload DMGs to $HOME/Dropbox/klayout/<dropbox> | disabled\n"
|
|
|
|
|
Usage += " [-?|--?] : print this usage and exit | disabled\n"
|
|
|
|
|
Usage += " | \n"
|
2021-02-08 22:06:38 +01:00
|
|
|
Usage += " To use this script, make a symbolic link in the project root by: | \n"
|
|
|
|
|
Usage += " $ ln -s ./macbuild/nightlyBuild.py . | \n"
|
|
|
|
|
Usage += " | \n"
|
|
|
|
|
Usage += " Regular sequence for using this script: | \n"
|
2022-05-10 20:25:30 +02:00
|
|
|
Usage += " (1) $ ./nightlyBuild.py --build --pymod | \n"
|
2020-11-26 23:00:12 +01:00
|
|
|
Usage += " (2) (confirm the build results) | \n"
|
2021-02-08 22:06:38 +01:00
|
|
|
Usage += " (3) $ ./nightlyBuild.py --test | \n"
|
|
|
|
|
Usage += " (4) $ ./nightlyBuild.py --check (confirm the QA Test results) | \n"
|
|
|
|
|
Usage += " (5) $ ./nightlyBuild.py --makedmg 1 | \n"
|
2022-12-24 03:08:57 +01:00
|
|
|
Usage += " (6) $ ./nightlyBuild.py --upload '0.28.2' | \n"
|
2021-02-08 22:06:38 +01:00
|
|
|
Usage += " (7) $ ./nightlyBuild.py --cleandmg 1 | \n"
|
2021-11-15 22:38:47 +01:00
|
|
|
Usage += "---------------------------------------------------------------------------+----------------------\n"
|
2020-11-26 23:00:12 +01:00
|
|
|
|
|
|
|
|
p = optparse.OptionParser( usage=Usage )
|
2022-10-10 04:36:50 +02:00
|
|
|
p.add_option( '--qt',
|
|
|
|
|
dest='qt_type',
|
|
|
|
|
help='Qt5 or Qt6 (5)' )
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
p.add_option( '--target',
|
|
|
|
|
dest='targets',
|
|
|
|
|
help='build target list' )
|
|
|
|
|
|
|
|
|
|
p.add_option( '--build',
|
|
|
|
|
action='store_true',
|
|
|
|
|
dest='build',
|
|
|
|
|
default=False,
|
|
|
|
|
help='build and deploy' )
|
|
|
|
|
|
2022-05-10 20:25:30 +02:00
|
|
|
p.add_option( '--pymod',
|
|
|
|
|
action='store_true',
|
|
|
|
|
dest='with_pymod',
|
|
|
|
|
default=False,
|
|
|
|
|
help='build and deploy Pymod, too ' )
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
p.add_option( '--test',
|
|
|
|
|
action='store_true',
|
|
|
|
|
dest='qa_test',
|
|
|
|
|
default=False,
|
|
|
|
|
help='run the QA Test' )
|
|
|
|
|
|
|
|
|
|
p.add_option( '--check',
|
|
|
|
|
action='store_true',
|
|
|
|
|
dest='qa_check',
|
|
|
|
|
default=False,
|
|
|
|
|
help='check the QA Test results' )
|
|
|
|
|
|
|
|
|
|
p.add_option( '--makedmg',
|
|
|
|
|
dest='makedmg',
|
|
|
|
|
help='make DMG' )
|
|
|
|
|
|
|
|
|
|
p.add_option( '--cleandmg',
|
|
|
|
|
dest='cleandmg',
|
|
|
|
|
help='clean DMG' )
|
|
|
|
|
|
|
|
|
|
p.add_option( '--upload',
|
|
|
|
|
dest='upload',
|
|
|
|
|
help='upload to Dropbox' )
|
|
|
|
|
|
|
|
|
|
p.add_option( '-?', '--??',
|
|
|
|
|
action='store_true',
|
|
|
|
|
dest='checkusage',
|
|
|
|
|
default=False,
|
|
|
|
|
help='check usage' )
|
|
|
|
|
|
2022-10-10 04:36:50 +02:00
|
|
|
p.set_defaults( qt_type = "5",
|
|
|
|
|
targets = "%s" % targetopt,
|
2020-11-26 23:00:12 +01:00
|
|
|
build = False,
|
2022-05-10 20:25:30 +02:00
|
|
|
with_pymod = False,
|
2020-11-26 23:00:12 +01:00
|
|
|
qa_test = False,
|
|
|
|
|
qa_check = False,
|
|
|
|
|
makedmg = "",
|
|
|
|
|
cleandmg = "",
|
|
|
|
|
upload = "",
|
|
|
|
|
checkusage = False )
|
|
|
|
|
|
|
|
|
|
opt, args = p.parse_args()
|
|
|
|
|
if opt.checkusage:
|
|
|
|
|
print(Usage)
|
|
|
|
|
quit()
|
|
|
|
|
|
2021-11-15 22:38:47 +01:00
|
|
|
myPlatform = Test_My_Platform( ['Catalina', 'BigSur', 'Monterey' ] )
|
2021-02-08 22:06:38 +01:00
|
|
|
if myPlatform == "":
|
2021-11-15 22:38:47 +01:00
|
|
|
print( "! Current platform is not ['Catalina', 'BigSur', 'Monterey' ]" )
|
2021-02-08 22:06:38 +01:00
|
|
|
print(Usage)
|
|
|
|
|
quit()
|
|
|
|
|
|
2022-10-10 04:36:50 +02:00
|
|
|
QtType = int(opt.qt_type)
|
|
|
|
|
if not QtType in [5, 6]:
|
|
|
|
|
print( "! Invalid Qt type <%d>" % QtType )
|
|
|
|
|
print(Usage)
|
|
|
|
|
quit()
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
targetDic = Get_Build_Target_Dict()
|
|
|
|
|
Target = list()
|
|
|
|
|
for idx in sorted( list( set( [ int(item) for item in opt.targets.split(",") ] ) ) ):
|
2022-12-24 03:08:57 +01:00
|
|
|
if idx in range(1, 7): # '0' has been abolished in 0.28
|
2020-11-26 23:00:12 +01:00
|
|
|
Target.append( targetDic[idx] )
|
|
|
|
|
|
2022-05-10 20:25:30 +02:00
|
|
|
Build = opt.build
|
|
|
|
|
WithPymod = opt.with_pymod
|
|
|
|
|
QATest = opt.qa_test
|
|
|
|
|
QACheck = opt.qa_check
|
|
|
|
|
MakeDMG = False
|
|
|
|
|
CleanDMG = False
|
|
|
|
|
Upload = False
|
2020-11-26 23:00:12 +01:00
|
|
|
|
|
|
|
|
if not opt.makedmg == "":
|
|
|
|
|
MakeDMG = True
|
|
|
|
|
SrlDMG = int(opt.makedmg)
|
|
|
|
|
|
|
|
|
|
if not opt.cleandmg == "":
|
|
|
|
|
CleanDMG = True
|
|
|
|
|
SrlDMG = int(opt.cleandmg)
|
|
|
|
|
|
|
|
|
|
if MakeDMG and CleanDMG:
|
|
|
|
|
print( "! --makedmg and --cleandmg cannot be used simultaneously" )
|
|
|
|
|
print(Usage)
|
|
|
|
|
quit()
|
|
|
|
|
|
|
|
|
|
if not opt.upload == "":
|
|
|
|
|
Upload = True
|
|
|
|
|
Dropbox = opt.upload
|
|
|
|
|
|
|
|
|
|
if not (Build or QATest or QACheck or MakeDMG or CleanDMG or Upload):
|
2021-11-16 15:06:24 +01:00
|
|
|
print( "! No action selected" )
|
2020-11-26 23:00:12 +01:00
|
|
|
print(Usage)
|
|
|
|
|
quit()
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To build and deploy
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
def Build_Deploy():
|
|
|
|
|
pyBuilder = "./build4mac.py"
|
|
|
|
|
buildOp = Get_Build_Options( Get_Build_Target_Dict() )
|
|
|
|
|
|
|
|
|
|
for key in Target:
|
2022-10-10 04:36:50 +02:00
|
|
|
if key == 4 and QtType == 6: # anaconda3 does not provide Qt6 so far
|
|
|
|
|
continue
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
command1 = [ pyBuilder ] + buildOp[key]
|
|
|
|
|
if key in [ "std", "brewHW", "brewAHW" ] :
|
|
|
|
|
command2 = [ pyBuilder ] + buildOp[key] + ['-y']
|
|
|
|
|
else:
|
|
|
|
|
command2 = [ pyBuilder ] + buildOp[key] + ['-Y']
|
|
|
|
|
print(command1)
|
|
|
|
|
print(command2)
|
|
|
|
|
#continue
|
|
|
|
|
|
|
|
|
|
if subprocess.call( command1, shell=False ) != 0:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "!!! <%s>: failed to build KLayout" % pyBuilder, file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "### <%s>: successfully built KLayout" % pyBuilder, file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
|
|
|
|
|
if subprocess.call( command2, shell=False ) != 0:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "!!! <%s>: failed to deploy KLayout" % pyBuilder, file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "### <%s>: successfully deployed KLayout" % pyBuilder, file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To run the QA tests
|
|
|
|
|
#
|
|
|
|
|
# @param[in] exclude test to exclude such as 'pymod,pya'
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
def Run_QATest( exclude ):
|
|
|
|
|
pyRunnerQAT = "./macQAT.py"
|
2021-02-08 22:06:38 +01:00
|
|
|
myPlatform = Test_My_Platform()
|
|
|
|
|
dirQAT = Get_QAT_Directory( Get_Build_Target_Dict(), myPlatform )
|
2020-11-26 23:00:12 +01:00
|
|
|
|
|
|
|
|
for key in Target:
|
2022-10-10 04:36:50 +02:00
|
|
|
if key == 4 and QtType == 6: # anaconda3 does not provide Qt6 so far
|
|
|
|
|
continue
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
command1 = [ pyRunnerQAT ] + [ '--run', '--exclude', '%s' % exclude ]
|
|
|
|
|
print( dirQAT[key], command1 )
|
|
|
|
|
#continue
|
|
|
|
|
os.chdir( dirQAT[key] )
|
|
|
|
|
|
|
|
|
|
if subprocess.call( command1, shell=False ) != 0:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "!!! <%s>: failed to run the QA Test" % pyRunnerQAT, file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "### <%s>: successfully ran the QA Test" % pyRunnerQAT, file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
|
|
|
|
|
os.chdir( "../" )
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To check the QA test results
|
|
|
|
|
#
|
|
|
|
|
# @param[in] lines number of lines to dump from the tail
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
def Check_QATest_Results( lines ):
|
|
|
|
|
tailCommand = "/usr/bin/tail"
|
2021-02-08 22:06:38 +01:00
|
|
|
myPlatform = Test_My_Platform()
|
|
|
|
|
dirQAT = Get_QAT_Directory( Get_Build_Target_Dict(), myPlatform )
|
2020-11-26 23:00:12 +01:00
|
|
|
|
|
|
|
|
for key in Target:
|
2022-10-10 04:36:50 +02:00
|
|
|
if key == 4 and QtType == 6: # anaconda3 does not provide Qt6 so far
|
|
|
|
|
continue
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
os.chdir( dirQAT[key] )
|
|
|
|
|
logfile = glob.glob( "*.log" )
|
|
|
|
|
command1 = [ tailCommand ] + [ '-n', '%d' % lines ] + logfile
|
|
|
|
|
print( dirQAT[key], command1 )
|
|
|
|
|
#continue
|
|
|
|
|
|
|
|
|
|
if subprocess.call( command1, shell=False ) != 0:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "!!! <%s>: failed to check the QA Test results" % tailCommand, file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "### <%s>: successfully checked the QA Test results" % tailCommand, file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
|
|
|
|
|
os.chdir( "../" )
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To make DMGs
|
|
|
|
|
#
|
|
|
|
|
# @param[in] srlDMG DMG's serial number
|
|
|
|
|
#------------------------------------------------------------------------------
|
2020-07-16 22:57:28 +02:00
|
|
|
def DMG_Make( srlDMG ):
|
2020-11-26 23:00:12 +01:00
|
|
|
pyDMGmaker = "./makeDMG4mac.py"
|
|
|
|
|
stashDMG = "./DMGStash"
|
2021-02-08 22:06:38 +01:00
|
|
|
myPlatform = Test_My_Platform()
|
|
|
|
|
packOp = Get_Package_Options( Get_Build_Target_Dict(), myPlatform, srlDMG, makeflag=True )
|
2020-11-26 23:00:12 +01:00
|
|
|
|
|
|
|
|
if os.path.isdir( stashDMG ):
|
|
|
|
|
shutil.rmtree( stashDMG )
|
|
|
|
|
os.mkdir( stashDMG )
|
|
|
|
|
|
|
|
|
|
for key in Target:
|
2022-10-10 04:36:50 +02:00
|
|
|
if key == 4 and QtType == 6: # anaconda3 does not provide Qt6 so far
|
|
|
|
|
continue
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
command1 = [ pyDMGmaker ] + packOp[key]
|
|
|
|
|
print(command1)
|
|
|
|
|
#continue
|
|
|
|
|
|
|
|
|
|
if subprocess.call( command1, shell=False ) != 0:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "!!! <%s>: failed to make KLayout DMG" % pyDMGmaker, file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "### <%s>: successfully made KLayout DMG" % pyDMGmaker, file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
|
|
|
|
|
dmgs = glob.glob( "*.dmg*" )
|
|
|
|
|
for item in dmgs:
|
|
|
|
|
shutil.move( item, stashDMG )
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To clean up DMGs
|
|
|
|
|
#
|
|
|
|
|
# @param[in] srlDMG DMG's serial number
|
|
|
|
|
#------------------------------------------------------------------------------
|
2020-07-16 22:57:28 +02:00
|
|
|
def DMG_Clean( srlDMG ):
|
2020-11-26 23:00:12 +01:00
|
|
|
pyDMGmaker = "./makeDMG4mac.py"
|
|
|
|
|
stashDMG = "./DMGStash"
|
2021-02-08 22:06:38 +01:00
|
|
|
myPlatform = Test_My_Platform()
|
|
|
|
|
packOp = Get_Package_Options( Get_Build_Target_Dict(), myPlatform, srlDMG, makeflag=False )
|
2020-11-26 23:00:12 +01:00
|
|
|
|
|
|
|
|
if os.path.isdir( stashDMG ):
|
|
|
|
|
shutil.rmtree( stashDMG )
|
|
|
|
|
|
|
|
|
|
for key in Target:
|
2022-10-10 04:36:50 +02:00
|
|
|
if key == 4 and QtType == 6: # anaconda3 does not provide Qt6 so far
|
|
|
|
|
continue
|
|
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
command1 = [ pyDMGmaker ] + packOp[key]
|
|
|
|
|
print(command1)
|
|
|
|
|
#continue
|
|
|
|
|
|
|
|
|
|
if subprocess.call( command1, shell=False ) != 0:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "!!! <%s>: failed to clean KLayout DMG" % pyDMGmaker, file=sys.stderr )
|
|
|
|
|
print( "-----------------------------------------------------------------", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "### <%s>: successfully cleaned KLayout DMG" % pyDMGmaker, file=sys.stderr )
|
|
|
|
|
print( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", file=sys.stderr )
|
|
|
|
|
print( "", file=sys.stderr )
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## To upload DMGs to Dropbox
|
|
|
|
|
#
|
|
|
|
|
# @param[in] targetdir existing target directory such as "0.26.9"
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
def Upload_To_Dropbox( targetdir ):
|
|
|
|
|
stashDMG = "./DMGStash"
|
|
|
|
|
|
|
|
|
|
distDir = os.environ["HOME"] + "/Dropbox/klayout/" + targetdir
|
|
|
|
|
if not os.path.isdir(distDir):
|
|
|
|
|
os.makedirs(distDir)
|
|
|
|
|
|
|
|
|
|
dmgs = glob.glob( "%s/*.dmg*" % stashDMG )
|
|
|
|
|
for item in dmgs:
|
|
|
|
|
shutil.copy2( item, distDir )
|
2020-07-16 22:57:28 +02:00
|
|
|
|
2020-11-26 23:00:12 +01:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
## The main function
|
|
|
|
|
#------------------------------------------------------------------------------
|
2020-07-16 22:57:28 +02:00
|
|
|
def Main():
|
2020-11-26 23:00:12 +01:00
|
|
|
Parse_CommandLine_Arguments()
|
|
|
|
|
|
|
|
|
|
if Build:
|
|
|
|
|
Build_Deploy()
|
|
|
|
|
if QATest:
|
|
|
|
|
Run_QATest( 'pymod,pya' )
|
|
|
|
|
if QACheck:
|
|
|
|
|
Check_QATest_Results( 20 )
|
|
|
|
|
elif MakeDMG:
|
|
|
|
|
DMG_Make( SrlDMG )
|
|
|
|
|
elif Upload:
|
|
|
|
|
Upload_To_Dropbox( Dropbox )
|
|
|
|
|
elif CleanDMG:
|
|
|
|
|
DMG_Clean( SrlDMG )
|
2020-07-16 22:57:28 +02:00
|
|
|
|
|
|
|
|
#===================================================================================
|
|
|
|
|
if __name__ == "__main__":
|
2020-11-26 23:00:12 +01:00
|
|
|
Main()
|
2020-07-16 22:57:28 +02:00
|
|
|
|
|
|
|
|
#---------------
|
|
|
|
|
# End of file
|
|
|
|
|
#---------------
|