forked from InsightSoftwareConsortium/ITKPythonPackage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacpython-build-module-deps.sh
More file actions
75 lines (64 loc) · 2.91 KB
/
Copy pathmacpython-build-module-deps.sh
File metadata and controls
75 lines (64 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
########################################################################
# Run this script in an ITK external module directory to generate
# build artifacts for prerequisite ITK MacOS modules.
#
# Module dependencies are built in a flat directory structure regardless
# of recursive dependencies. Prerequisite sources are required to be passed
# in the order in which they should be built.
# For example, if ITKTargetModule depends on ITKTargetModuleDep2 which
# depends on ITKTargetModuleDep1, the output directory structure
# will look like this:
#
# / ITKTargetModule
# -- / ITKTargetModuleDep1
# -- / ITKTargetModuleDep2
# ..
#
# ===========================================
# ENVIRONMENT VARIABLES
#
# - `ITK_MODULE_PREQ`: Prerequisite ITK modules that must be built before the requested module.
# Format is `<org_name>/<module_name>@<module_tag>:<org_name>/<module_name>@<module_tag>:...`.
# For instance, `export ITK_MODULE_PREQ=InsightSoftwareConsortium/ITKMeshToPolyData@v0.10.0`
#
########################################################################
script_dir=$(cd $(dirname $0) || exit 1; pwd)
if [[ ! -f "${script_dir}/macpython-download-cache-and-build-module-wheels.sh" ]]; then
echo "Could not find download script to use for building module dependencies!"
exit 1
fi
# Temporarily update prerequisite environment variable to prevent infinite recursion.
ITK_MODULE_PREQ_TOPLEVEL=${ITK_MODULE_PREQ}
ITK_USE_LOCAL_PYTHON_TOPLEVEL=${ITK_USE_LOCAL_PYTHON}
export ITK_MODULE_PREQ=""
export ITK_USE_LOCAL_PYTHON="ON"
########################################################################
echo "Building ITK module dependencies: ${ITK_MODULE_PREQ_TOPLEVEL}"
for MODULE_INFO in ${ITK_MODULE_PREQ_TOPLEVEL//:/ }; do
MODULE_ORG=`(echo ${MODULE_INFO} | cut -d'/' -f 1)`
MODULE_NAME=`(echo ${MODULE_INFO} | cut -d'@' -f 1 | cut -d'/' -f 2)`
MODULE_TAG=`(echo ${MODULE_INFO} | cut -d'@' -f 2)`
MODULE_UPSTREAM=https://github.com/${MODULE_ORG}/${MODULE_NAME}.git
echo "Cloning from ${MODULE_UPSTREAM}"
git clone ${MODULE_UPSTREAM}
pushd ${MODULE_NAME}
git checkout ${MODULE_TAG}
cp ${script_dir}/macpython-download-cache-and-build-module-wheels.sh .
echo "Building dependency ${MODULE_NAME}"
./macpython-download-cache-and-build-module-wheels.sh $@
popd
cp ./${MODULE_NAME}/include/* include/
find ${MODULE_NAME}/wrapping -name '*.in' -print -exec cp {} wrapping \;
find ${MODULE_NAME}/wrapping -name '*.init' -print -exec cp {} wrapping \;
find ${MODULE_NAME}/*build/*/include -type f -print -exec cp {} include \;
rm -f ./${MODULE_NAME}/ITKPythonBuilds-macosx.tar.zst
done
# Restore environment variable
export ITK_MODULE_PREQ=${ITK_MODULE_PREQ_TOPLEVEL}
export ITK_USE_LOCAL_PYTHON=${ITK_USE_LOCAL_PYTHON_TOPLEVEL}
ITK_MODULE_PREQ_TOPLEVEL=""
ITK_USE_LOCAL_PYTHON_TOPLEVEL=""
# Summarize disk usage for debugging
du -sh ./* | sort -hr | head -n 20
echo "Done building ITK external module dependencies"