Create Makefile

Create phony targets in Makefile
This commit is contained in:
Daniel Wang 2018-08-02 18:04:24 -04:00 committed by Thomas Ferreira de Lima
parent 908be96bb9
commit 403efbd090
No known key found for this signature in database
GPG Key ID: 43E98870EAA0A86E
3 changed files with 59 additions and 43 deletions

View File

@ -1,16 +1,23 @@
matrix:
include:
- os: osx
osx_image: xcode9.3beta
env:
- MATRIX_EVAL=""
- os: osx
osx_image: xcode9.4 # macOS 10.13
env:
- MATRIX_EVAL="export PYTHON_VERSION=B37; export MACOS_VERSION=HighSierra;"
- os: osx
osx_image: xcode8.3 # macOS 10.12
env:
- MATRIX_EVAL="export PYTHON_VERSION=B37; export MACOS_VERSION=Sierra;"
- os: osx
osx_image: xcode8 # macOS 10.11
env:
- MATRIX_EVAL="export PYTHON_VERSION=B37; export MACOS_VERSION=ElCapitan;"
before_install:
- eval "${MATRIX_EVAL}"
- brew update
- brew bundle
- env
- pip install pathlib2
install:
- gem install dropbox-deployment
@ -18,20 +25,10 @@ install:
- cd osx-config-check ; python2.7 app.py --report-only --skip-sudo-checks ; cd ..
script:
- ./build4mac.py -p B37 -q Qt5Brew -c
- source filter-clang.sh; ./build4mac.py -p B37 -q Qt5Brew | filter
- ./build4mac.py -p B37 -q Qt5Brew -y
- qt5.pkg.macos-HighSierra-release/klayout.app/Contents/MacOS/klayout -b -r test-pylib-script.py
- cd qt5.build.macos-HighSierra-release
- ln -s klayout.app/Contents/MacOS/klayout klayout
- export TESTTMP=testtmp # path to a directory that will hold temporary data (will be created)
- export TESTSRC=.. # path to the source directory
- ./ut_runner -h
- ./ut_runner -s || true
- cd ..
- export gitcommit=$(git rev-parse --short HEAD)
- mkdir deploy
- tar czf "deploy/qt5.pkg.macos-HighSierra-release-$gitcommit.tar.gz" qt5.pkg.macos-HighSierra-release
- make build
- make deploy
- make test
- make dropbox-deploy
after_success:
- dropbox-deployment

33
Makefile Normal file
View File

@ -0,0 +1,33 @@
.PHONY: help build deploy test dropbox-deploy
default: help
help:
@echo "For Mac OS only"
@echo "make build PYTHON_VERSION=B37"
@echo "make deploy PYTHON_VERSION=B37"
@echo "make test MACOS_VERSION=HighSierra"
@echo "Valid Mac OS Versions: [Yosemite, ElCapitan, Sierra, HighSierra]"
@echo "Valid Python Version: [nil, Sys, B37]"
build:
./build4mac.py -p $(PYTHON_VERSION) -q Qt5Brew -c
./build4mac.py -p $(PYTHON_VERSION) -q Qt5Brew
deploy: build
./build4mac.py -p $(PYTHON_VERSION) -q Qt5Brew -y
test: deploy
qt5.pkg.macos--release/klayout.app/Contents/MacOS/klayout -b -r test-pylib-script.py
cd qt5.build.macos-$(MACOS_VERSION)-release
ln -s klayout.app/Contents/MacOS/klayout klayout
export TESTTMP=testtmp
export TESTSRC=..
./ut_runner -h
./ut_runner -s
dropbox-deploy: test
cd ..
export gitcommit=$(git rev-parse --short HEAD)
mkdir deploy
tar czf "deploy/qt5.pkg.macos-$(MACOS_VERSION)-release-$gitcommit.tar.gz" qt5.pkg.macos-$(MACOS_VERSION)-release

View File

@ -18,12 +18,6 @@ import string
import subprocess
import shutil
try:
from pathlib import Path
Path('~').expanduser()
except (ImportError,AttributeError): # python2
from pathlib2 import Path
#-------------------------------------------------------------------------------
## To import global dictionaries of different modules
#-------------------------------------------------------------------------------
@ -181,7 +175,6 @@ def SetChangeLibIdentificationName( executable, relativedir ):
def WalkLibDependencyTree( dylibPath, depth=0, filter_regex=r'\t+/usr/local/opt'):
NOTHINGTODO = [] # return empty list if nothing to do.
dylibPath = str(Path(dylibPath))
cmdNameId = XcodeToolChain['nameID']
cmdNameChg = XcodeToolChain['nameCH']
otoolCm = 'otool -L %s | grep -E "%s"' % (dylibPath, filter_regex)
@ -193,7 +186,7 @@ def WalkLibDependencyTree( dylibPath, depth=0, filter_regex=r'\t+/usr/local/opt'
if depth < 5:
if len(deplibs) > 0:
for idx, lib in enumerate(deplibs):
lib = str(Path(lib))
lib = str(lib)
if lib != list(keys)[0]:
deplibs[idx] = WalkLibDependencyTree(lib, depth+1, filter_regex)
if depth == 0:
@ -212,7 +205,6 @@ def WalkFrameworkPaths(frameworkPaths, filter_regex=r'\.(so|dylib)$', search_pat
dependency_dict = dict()
for frameworkPath in frameworkPathsIter:
frameworkPath = str(Path(frameworkPath))
# print("Calling:", 'find %s -type f | grep -E "%s"' % (frameworkPath, filter_regex))
find_grep_results = os.popen('find %s -type f | grep -E "%s"' % (frameworkPath, filter_regex)).read().split('\n')
framework_files = filter(lambda x: x != '',
@ -239,7 +231,7 @@ def WalkDictTree(dependencyDict, visited_files):
if deplib not in visited_files:
visited_files.append(deplib)
elif isinstance(deplib, dict):
dependency_list.append(str(next(iter(deplib))))
dependency_list.append(next(iter(deplib)))
libNameChanges.extend(WalkDictTree(deplib, visited_files))
else:
#raise RuntimeError("Unexpected value: %s" % deplib)
@ -253,16 +245,13 @@ def WalkDictTree(dependencyDict, visited_files):
visited_files.append(lib)
return libNameChanges
def FindFramework(path, root_path):
path = Path(path)
root_path = Path(root_path)
relPath = path.relative_to(root_path)
return str(root_path / relPath.parts[0])
def FindFramework(path, root_path):
relPath = os.path.relpath(path, root_path)
return os.path.join(root_path, relPath.split(os.sep)[0])
def ResolveExecutablePath(path, executable_path):
""" Transforms @executable_path into executable_path"""
executable_path = str(executable_path)
p = Path(str(path).replace("@executable_path", "/%s/" % executable_path))
p = path.replace("@executable_path", "/%s/" % executable_path)
return p
def DetectChanges(frameworkDependencyDict):
@ -289,11 +278,8 @@ def PerformChanges(frameworkDependencyDict, replaceFromToPairs=None, executable_
except StopIteration:
dependencies = list()
for replaceFrom, replaceTo, libdir in replaceFromToPairs:
replaceFrom = str(Path(replaceFrom))
replaceTo = str(Path(replaceTo))
fileName = ResolveExecutablePath(lib.replace(replaceFrom, replaceTo), executable_path)
if str(fileName).startswith('/usr'):
if fileName.startswith('/usr'):
# print(f'skipping fileName: {fileName}')
continue
@ -305,14 +291,14 @@ def PerformChanges(frameworkDependencyDict, replaceFromToPairs=None, executable_
destFrameworkPath = frameworkPath.replace(replaceFrom, replaceTo)
destFrameworkPath = ResolveExecutablePath(destFrameworkPath, executable_path)
if not fileName.exists():
if not os.path.exists(fileName):
print (lib.replace(replaceFrom, replaceTo), "DOES NOT EXIST")
print ("COPY", frameworkPath, " -> ", destFrameworkPath)
shutil.copytree(frameworkPath, str(destFrameworkPath))
shutil.copytree(frameworkPath, destFrameworkPath)
nameId = lib.replace(replaceFrom, replaceTo)
command = "%s %s %s" % ( cmdNameId, nameId, fileName )
if not os.access(str(fileName), os.W_OK):
if not os.access(fileName, os.W_OK):
command = "chmod u+w %s; %s; chmod u-w %s" % (fileName, command, fileName)
# print("\t%s" % command)
if subprocess.call( command, shell=True ) != 0: