2017-03-27 09:27:12 +02:00
|
|
|
#!/usr/bin/env bash
|
2017-03-29 10:06:41 +02:00
|
|
|
###########################################################################
|
|
|
|
# sipify_all.sh
|
|
|
|
# ---------------------
|
|
|
|
# Date : 25.03.2017
|
|
|
|
# Copyright : (C) 2017 by Denis Rouzaud
|
|
|
|
# Email : denis.rouzaud@gmail.com
|
|
|
|
###########################################################################
|
|
|
|
# #
|
|
|
|
# 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. #
|
|
|
|
# #
|
|
|
|
###########################################################################
|
2017-03-27 15:36:48 +02:00
|
|
|
set -e
|
2017-03-27 09:27:12 +02:00
|
|
|
|
2024-07-16 11:40:25 +02:00
|
|
|
CLASS_MAP=0
|
2024-12-16 16:42:25 +01:00
|
|
|
while getopts "m" opt; do
|
2024-07-16 11:40:25 +02:00
|
|
|
case $opt in
|
|
|
|
m)
|
|
|
|
CLASS_MAP=1
|
|
|
|
;;
|
|
|
|
\?)
|
|
|
|
echo "Invalid option: -$OPTARG" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $((OPTIND-1))
|
2018-01-15 21:09:07 -04:00
|
|
|
|
2017-03-27 09:27:12 +02:00
|
|
|
DIR=$(git rev-parse --show-toplevel)
|
|
|
|
|
2022-03-16 17:51:07 +01:00
|
|
|
# GNU prefix command for bsd/mac os support (gsed, gsplit)
|
2017-03-27 15:36:48 +02:00
|
|
|
GP=
|
2022-03-16 17:51:07 +01:00
|
|
|
if [[ "$OSTYPE" == *bsd* ]] || [[ "$OSTYPE" =~ darwin* ]]; then
|
2017-03-27 15:36:48 +02:00
|
|
|
GP=g
|
|
|
|
fi
|
|
|
|
|
|
|
|
pushd ${DIR} > /dev/null
|
2017-03-27 09:27:12 +02:00
|
|
|
|
2017-04-24 15:52:13 +02:00
|
|
|
count=0
|
|
|
|
|
2023-12-13 09:14:43 +01:00
|
|
|
if [[ -n $1 ]]; then
|
|
|
|
modules=("$1")
|
|
|
|
else
|
2021-01-06 16:22:44 +01:00
|
|
|
modules=(core gui analysis server 3d)
|
|
|
|
fi
|
2023-12-06 18:54:21 +01:00
|
|
|
|
2024-12-11 17:34:24 +01:00
|
|
|
pids=()
|
|
|
|
iPid=0
|
|
|
|
|
2023-12-13 09:14:43 +01:00
|
|
|
for root_dir in python python/PyQt6; do
|
2018-06-05 08:54:45 -04:00
|
|
|
|
2023-12-13 09:14:43 +01:00
|
|
|
if [[ $root_dir == "python/PyQt6" ]]; then
|
2024-08-09 11:55:21 +10:00
|
|
|
IS_QT6="-qt6"
|
2023-12-06 18:54:21 +01:00
|
|
|
fi
|
|
|
|
|
2023-12-13 09:14:43 +01:00
|
|
|
for module in "${modules[@]}"; do
|
|
|
|
module_dir=${root_dir}/${module}
|
|
|
|
|
2024-08-13 13:47:46 +10:00
|
|
|
if [[ ${CLASS_MAP} -eq 1 ]]; then
|
|
|
|
rm ${module_dir}/class_map.yaml || true
|
|
|
|
touch ${module_dir}/class_map.yaml
|
|
|
|
fi
|
2024-07-16 11:40:25 +02:00
|
|
|
|
2023-12-13 09:14:43 +01:00
|
|
|
# clean auto_additions and auto_generated folders
|
|
|
|
rm -rf ${module_dir}/auto_additions/*.py
|
|
|
|
rm -rf ${module_dir}/auto_generated/*.py
|
|
|
|
# put back __init__.py
|
|
|
|
echo '"""
|
2024-08-10 18:14:10 +10:00
|
|
|
This folder is completed using sipify.py script
|
2018-06-05 08:54:45 -04:00
|
|
|
It is not aimed to be manually edited
|
2023-12-06 18:54:21 +01:00
|
|
|
"""' > ${module_dir}/auto_additions/__init__.py
|
2018-06-05 08:54:45 -04:00
|
|
|
|
2023-12-13 09:14:43 +01:00
|
|
|
while read -r sipfile; do
|
2018-01-16 11:21:13 -04:00
|
|
|
echo "$sipfile.in"
|
2018-05-14 10:43:24 -04:00
|
|
|
header=$(${GP}sed -E 's@(.*)\.sip@src/\1.h@; s@auto_generated/@@' <<< $sipfile)
|
2018-05-31 10:40:07 -04:00
|
|
|
pyfile=$(${GP}sed -E 's@([^\/]+\/)*([^\/]+)\.sip@\2.py@;' <<< $sipfile)
|
2017-06-26 09:57:09 +02:00
|
|
|
if [ ! -f $header ]; then
|
|
|
|
echo "*** Missing header: $header for sipfile $sipfile"
|
|
|
|
else
|
2017-07-27 23:17:33 +07:00
|
|
|
path=$(${GP}sed -r 's@/[^/]+$@@' <<< $sipfile)
|
2017-06-26 09:57:09 +02:00
|
|
|
mkdir -p python/$path
|
2024-07-16 11:40:25 +02:00
|
|
|
CLASS_MAP_CALL=
|
|
|
|
if [[ ${CLASS_MAP} -eq 1 ]]; then
|
|
|
|
CLASS_MAP_CALL="-c ${module_dir}/class_map.yaml"
|
|
|
|
fi
|
2024-12-16 16:42:25 +01:00
|
|
|
./scripts/sipify.py $IS_QT6 -s ${root_dir}/${sipfile}.in -p ${module_dir}/auto_additions/${pyfile} ${CLASS_MAP_CALL} ${header} &
|
2024-12-11 17:34:24 +01:00
|
|
|
pids[iPid]=$!
|
|
|
|
iPid=$((iPid+1))
|
|
|
|
|
2017-06-26 09:57:09 +02:00
|
|
|
fi
|
|
|
|
count=$((count+1))
|
2023-12-13 09:14:43 +01:00
|
|
|
done < <( ${GP}sed -n -r "s@^%Include auto_generated/(.*\.sip)@${module}/auto_generated/\1@p" python/${module}/${module}_auto.sip )
|
|
|
|
done
|
2017-06-26 09:57:09 +02:00
|
|
|
done
|
2024-12-11 17:34:24 +01:00
|
|
|
|
|
|
|
for pid in "${pids[@]}"; do
|
|
|
|
wait $pid || ( echo "Errors while calling sipify!!!" && exit 1 )
|
|
|
|
done
|
2017-03-27 15:36:48 +02:00
|
|
|
|
2024-07-16 11:40:25 +02:00
|
|
|
if [[ ${CLASS_MAP} -eq 1 ]]; then
|
|
|
|
for root_dir in python python/PyQt6; do
|
|
|
|
for module in "${modules[@]}"; do
|
|
|
|
module_dir=${root_dir}/${module}
|
|
|
|
echo "sorting ${module_dir}/class_map.yaml"
|
|
|
|
sort -n -o ${module_dir}/class_map.yaml ${module_dir}/class_map.yaml
|
|
|
|
done
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2017-04-30 14:12:05 +02:00
|
|
|
echo " => $count files sipified! 🍺"
|
2017-04-24 15:52:13 +02:00
|
|
|
|
2017-03-27 15:36:48 +02:00
|
|
|
popd > /dev/null
|