Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a file to hold a map from class/method to headerfile #58054

Merged
merged 14 commits into from
Jul 16, 2024
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
name: Run sipify on PR
name: Run sipify

on:
issue_comment:
types: [created]
push:
branches:
- master
- release-*

jobs:
sipify:
if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/sipify')
if: github.event_name == 'push' || (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/sipify'))
runs-on: [ubuntu-latest]
steps:

- name: Get PR branch
uses: alessbell/pull-request-comment-branch@v2.1.0
if: ${{ github.event_name == 'issue_comment' }}
id: comment-branch

- uses: actions/checkout@v4
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
repository: ${{ steps.comment-branch.outputs.head_owner }}/${{ steps.comment-branch.outputs.head_repo }}
ref: ${{ steps.comment-branch.outputs.head_ref || github.ref_name }}
repository: ${{ steps.comment-branch.outputs.head_owner || 'qgis' }}/${{ steps.comment-branch.outputs.head_repo || 'QGIS' }}
token: ${{ secrets.GH_TOKEN_BOT }}

- name: Install Requirements
Expand All @@ -39,7 +44,7 @@ jobs:
libtry-tiny-perl

- name: run sipify
run: ./scripts/sipify_all.sh
run: ./scripts/sipify_all.sh -m

- name: commit
run: |
Expand Down
625 changes: 625 additions & 0 deletions python/3d/class_map.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,6 @@ foreach(module ${PY_MODULES})
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${module}/auto_generated DESTINATION ${SIP_DEFAULT_SIP_DIR}/qgis/${module})
endif()
endforeach(module)

# install sipify config
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sipify.yaml DESTINATION "${QGIS_PYTHON_DIR}")
625 changes: 625 additions & 0 deletions python/PyQt6/3d/class_map.yaml

Large diffs are not rendered by default.

373 changes: 373 additions & 0 deletions python/PyQt6/analysis/class_map.yaml

Large diffs are not rendered by default.

18,796 changes: 18,796 additions & 0 deletions python/PyQt6/core/class_map.yaml

Large diffs are not rendered by default.

7,452 changes: 7,452 additions & 0 deletions python/PyQt6/gui/class_map.yaml

Large diffs are not rendered by default.

361 changes: 361 additions & 0 deletions python/PyQt6/server/class_map.yaml

Large diffs are not rendered by default.

373 changes: 373 additions & 0 deletions python/analysis/class_map.yaml

Large diffs are not rendered by default.

18,797 changes: 18,797 additions & 0 deletions python/core/class_map.yaml

Large diffs are not rendered by default.

7,452 changes: 7,452 additions & 0 deletions python/gui/class_map.yaml

Large diffs are not rendered by default.

361 changes: 361 additions & 0 deletions python/server/class_map.yaml

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions scripts/sipify.pl
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
my $sip_output = '';
my $is_qt6 = 0;
my $python_output = '';
my $class_map_file = '';
#my $SUPPORT_TEMPLATE_DOCSTRING = 0;
#die("usage: $0 [-debug] [-template-doc] headerfile\n") unless GetOptions ("debug" => \$debug, "template-doc" => \$SUPPORT_TEMPLATE_DOCSTRING) && @ARGV == 1;
die("usage: $0 [-debug] [-qt6] [-sip_output FILE] [-python_output FILE] headerfile\n")
unless GetOptions ("debug" => \$debug, "sip_output=s" => \$sip_output, "python_output=s" => \$python_output, "qt6" => \$is_qt6) && @ARGV == 1;
die("usage: $0 [-debug] [-qt6] [-sip_output FILE] [-python_output FILE] [-class_map FILE] headerfile\n")
unless GetOptions ("debug" => \$debug, "sip_output=s" => \$sip_output, "python_output=s" => \$python_output, "qt6" => \$is_qt6, "class_map=s" => \$class_map_file) && @ARGV == 1;
my $headerfile = $ARGV[0];

# read file
Expand Down Expand Up @@ -1400,6 +1401,12 @@ sub detect_non_method_member{
}
};
$LINE = "$1 $+{classname}";
# append to class map file
if ( $class_map_file ne '' ){
open(FH3, '>>', $class_map_file) or die $!;
print FH3 join(".", @CLASSNAME) . ": $headerfile#L".$LINE_IDX."\n";
close(FH3);
}
# Inheritance
if (defined $+{domain}){
my $m = $+{domain};
Expand Down Expand Up @@ -2001,6 +2008,15 @@ sub detect_non_method_member{

write_output("NOR", "$LINE\n");

# append to class map file
if ( $class_map_file ne '' && defined $ACTUAL_CLASS && $ACTUAL_CLASS ne '' ){
if ($LINE =~ m/^ *(const |virtual |static )* *[\w:]+ +\*?(?<method>\w+)\(.*$/){
open(FH3, '>>', $class_map_file) or die $!;
print FH3 join(".", @CLASSNAME) . "." . $+{method} .": $headerfile#L".$LINE_IDX."\n";
close(FH3);
}
}

if ($PYTHON_SIGNATURE ne '') {
write_output("PSI", "$PYTHON_SIGNATURE\n");
}
Expand Down
42 changes: 31 additions & 11 deletions scripts/sipify_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
###########################################################################
set -e

# TEMPLATE_DOC=""
# while :; do
# case $1 in
# -t|--template-doc) TEMPLATE_DOC="-template-doc"
# ;;
# *) break
# esac
# shift
# done
CLASS_MAP=0
while getopts "m" opt; do
case $opt in
m)
CLASS_MAP=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
shift $((OPTIND-1))

DIR=$(git rev-parse --show-toplevel)

Expand All @@ -50,9 +54,11 @@ for root_dir in python python/PyQt6; do
fi

for module in "${modules[@]}"; do

module_dir=${root_dir}/${module}

rm ${module_dir}/class_map.yaml || true
touch ${module_dir}/class_map.yaml

# clean auto_additions and auto_generated folders
rm -rf ${module_dir}/auto_additions/*.py
rm -rf ${module_dir}/auto_generated/*.py
Expand All @@ -71,14 +77,28 @@ It is not aimed to be manually edited
else
path=$(${GP}sed -r 's@/[^/]+$@@' <<< $sipfile)
mkdir -p python/$path
./scripts/sipify.pl $IS_QT6 -s ${root_dir}/$sipfile.in -p ${module_dir}/auto_additions/${pyfile} $header &
CLASS_MAP_CALL=
if [[ ${CLASS_MAP} -eq 1 ]]; then
CLASS_MAP_CALL="-c ${module_dir}/class_map.yaml"
fi
./scripts/sipify.pl $IS_QT6 -s ${root_dir}/${sipfile}.in -p ${module_dir}/auto_additions/${pyfile} ${CLASS_MAP_CALL} ${header} &
fi
count=$((count+1))
done < <( ${GP}sed -n -r "s@^%Include auto_generated/(.*\.sip)@${module}/auto_generated/\1@p" python/${module}/${module}_auto.sip )
done
done
wait # wait for sipify processes to finish

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

echo " => $count files sipified! 🍺"

popd > /dev/null
2 changes: 1 addition & 1 deletion scripts/spell_check/check_spelling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
EXCLUDE_SCRIPT_LIST='(\.(xml|sip|pl|sh|badquote|cmake(\.in)?)|^(debian/copyright|cmake_templates/.*|tests/testdata/labeling/README.rst|tests/testdata/font/QGIS-Vera/COPYRIGHT.TXT|doc/debian/build/))$'

# always exclude these files
EXCLUDE_EXTERNAL_LIST='((\.(svg|qgs|laz|las|png|lock|sip\.in))|resources/cpt-city-qgis-min/.*|resources/server/src/.*|resources/server/api/ogc/static/landingpage/js/.*|tests/testdata/.*|doc/api_break.dox|NEWS.md)$'
EXCLUDE_EXTERNAL_LIST='((\.(svg|qgs|laz|las|png|lock|sip\.in))|resources/cpt-city-qgis-min/.*|resources/server/src/.*|resources/server/api/ogc/static/landingpage/js/.*|tests/testdata/.*|doc/api_break.dox|NEWS.md|python/.*/class_map.yaml)$'

DIR=$(git rev-parse --show-toplevel)/scripts/spell_check

Expand Down
Loading