Skip to content

Commit a87c82e

Browse files
uclarosnyalldawson
authored andcommitted
remove pyqt5 folder from sip-include
1 parent c03dd32 commit a87c82e

File tree

2 files changed

+53
-56
lines changed

2 files changed

+53
-56
lines changed

scripts/sip_include.sh

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,50 +37,49 @@ else
3737
modules=(core gui analysis server 3d)
3838
fi
3939
sources=(HDRS MOC_HDRS SRCS)
40+
root_dir=python/PyQt6
4041

41-
for root_dir in python python/PyQt6; do
42-
for module in "${modules[@]}"; do
43-
file=${DIR}/$root_dir/${module}/${module}_auto.sip
44-
echo "Creating $root_dir/${module}/${module}_auto.sip"
45-
echo "// Include auto-generated SIP files" > $file
42+
for module in "${modules[@]}"; do
43+
file=${DIR}/$root_dir/${module}/${module}_auto.sip
44+
echo "Creating $root_dir/${module}/${module}_auto.sip"
45+
echo "// Include auto-generated SIP files" > $file
4646

47-
headers=$(
48-
for source in "${sources[@]}"; do
49-
echo "QGIS_${module^^}_${source}"
50-
${GP}sed -r -n -e "/^\s*set\s*\(QGIS_${module^^}_${source}/,/\)\$/{ /^\s*set\s*\(QGIS_${module^^}_${source}/d; /\)\$/d; p; }" src/${module}/CMakeLists.txt | \
51-
${GP}sed -r -e '/\.cc?$/d' `# remove c and cc extensions` \
52-
-e 's/\.cpp$/.h/' `# rename cpp file as headers` \
53-
-e '/^\s*\$\{CMAKE_(CURRENT_)?BINARY_DIR\}/d' \
54-
-e '/^\s*#/d' `# remove commented lines` \
55-
-e 's/\$\{.*\}//g' `# remove CMake variable append` \
56-
-e 's/^\s+//' `# remove leading spaces` \
57-
-e '/^\s*$/d' `# remove blank lines`
58-
done | cat -n | sort -uk2 | sort -nk1 | cut -f2- # remove duplicated lines without sorting
59-
)
60-
for header in ${headers}; do
61-
if [ ! -f src/${module}/$header ]; then
62-
# if no header, no sip file!
63-
#echo "src/${module}/$header not found"
64-
continue
47+
headers=$(
48+
for source in "${sources[@]}"; do
49+
echo "QGIS_${module^^}_${source}"
50+
${GP}sed -r -n -e "/^\s*set\s*\(QGIS_${module^^}_${source}/,/\)\$/{ /^\s*set\s*\(QGIS_${module^^}_${source}/d; /\)\$/d; p; }" src/${module}/CMakeLists.txt | \
51+
${GP}sed -r -e '/\.cc?$/d' `# remove c and cc extensions` \
52+
-e 's/\.cpp$/.h/' `# rename cpp file as headers` \
53+
-e '/^\s*\$\{CMAKE_(CURRENT_)?BINARY_DIR\}/d' \
54+
-e '/^\s*#/d' `# remove commented lines` \
55+
-e 's/\$\{.*\}//g' `# remove CMake variable append` \
56+
-e 's/^\s+//' `# remove leading spaces` \
57+
-e '/^\s*$/d' `# remove blank lines`
58+
done | cat -n | sort -uk2 | sort -nk1 | cut -f2- # remove duplicated lines without sorting
59+
)
60+
for header in ${headers}; do
61+
if [ ! -f src/${module}/$header ]; then
62+
# if no header, no sip file!
63+
#echo "src/${module}/$header not found"
64+
continue
65+
fi
66+
if ! grep -xq -E '^(#define +)?SIP_NO_FILE' src/${module}/${header}; then
67+
sip=$(${GP}sed -r 's/(.*)\.h$/\1.sip/' <<< ${header})
68+
if_cond=$(grep -x -E '^(#define +)?SIP_IF_MODULE\((.*)\)$' src/${module}/${header} | \
69+
${GP}sed -r -e 's/(#define +)?SIP_IF_MODULE\((.*)\)/%If (\2)/')
70+
if [[ -n $if_cond ]]; then
71+
echo "$if_cond" >> $file
6572
fi
66-
if ! grep -xq -E '^(#define +)?SIP_NO_FILE' src/${module}/${header}; then
67-
sip=$(${GP}sed -r 's/(.*)\.h$/\1.sip/' <<< ${header})
68-
if_cond=$(grep -x -E '^(#define +)?SIP_IF_MODULE\((.*)\)$' src/${module}/${header} | \
69-
${GP}sed -r -e 's/(#define +)?SIP_IF_MODULE\((.*)\)/%If (\2)/')
70-
if [[ -n $if_cond ]]; then
71-
echo "$if_cond" >> $file
72-
fi
73-
if [[ "$sip" == [0-9]* ]]; then
74-
# unfortunately SIP parser does not accept relative paths starting with a number
75-
# so "%Include 3d/xxxx.sip" is a syntax error but everything works with "%Include ./3d/xxxx.sip"
76-
sip="./$sip"
77-
fi
78-
echo "%Include auto_generated/$sip" >> $file
79-
if [[ -n $if_cond ]]; then
80-
echo "%End" >> $file
81-
fi
73+
if [[ "$sip" == [0-9]* ]]; then
74+
# unfortunately SIP parser does not accept relative paths starting with a number
75+
# so "%Include 3d/xxxx.sip" is a syntax error but everything works with "%Include ./3d/xxxx.sip"
76+
sip="./$sip"
8277
fi
83-
done
78+
echo "%Include auto_generated/$sip" >> $file
79+
if [[ -n $if_cond ]]; then
80+
echo "%End" >> $file
81+
fi
82+
fi
8483
done
8584
done
8685

tests/code_layout/sipify/test_sip_include.sh

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,24 @@ pushd ${DIR} > /dev/null || exit
99

1010
code=0
1111
modules=(3d core gui analysis server)
12-
for root_dir in python python/PyQt6; do
13-
for module in "${modules[@]}"; do
14-
cp $root_dir/${module}/${module}_auto.sip $root_dir/${module}/${module}_auto.sip.$REV.bak
15-
done
12+
root_dir=python/PyQt6
13+
14+
for module in "${modules[@]}"; do
15+
cp $root_dir/${module}/${module}_auto.sip $root_dir/${module}/${module}_auto.sip.$REV.bak
1616
done
1717

1818
./scripts/sip_include.sh
1919

20-
for root_dir in python python/PyQt6; do
21-
for module in "${modules[@]}"; do
22-
outdiff=$(diff $root_dir/${module}/${module}_auto.sip $root_dir/${module}/${module}_auto.sip.$REV.bak)
23-
if [[ -n $outdiff ]]; then
24-
echo -e " *** SIP include file for \x1B[33m${module}\x1B[0m not up to date."
25-
echo "$outdiff"
26-
code=1
27-
mv $root_dir/${module}/${module}_auto.sip.$REV.bak $root_dir/${module}/${module}_auto.sip
28-
else
29-
rm $root_dir/${module}/${module}_auto.sip.$REV.bak
30-
fi
31-
done
20+
for module in "${modules[@]}"; do
21+
outdiff=$(diff $root_dir/${module}/${module}_auto.sip $root_dir/${module}/${module}_auto.sip.$REV.bak)
22+
if [[ -n $outdiff ]]; then
23+
echo -e " *** SIP include file for \x1B[33m${module}\x1B[0m not up to date."
24+
echo "$outdiff"
25+
code=1
26+
mv $root_dir/${module}/${module}_auto.sip.$REV.bak $root_dir/${module}/${module}_auto.sip
27+
else
28+
rm $root_dir/${module}/${module}_auto.sip.$REV.bak
29+
fi
3230
done
3331

3432
if [[ code -eq 1 ]]; then

0 commit comments

Comments
 (0)