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 #58130

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/sipify-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Run sipify

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

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

- name: Get PR branch
uses: alessbell/[email protected]
if: ${{ github.event_name == 'issue_comment' }}
id: comment-branch

- uses: actions/checkout@v4
with:
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
run: |
sudo apt install -y \
cpanminus \
libyaml-tiny-perl \
libio-socket-ssl-perl \
libhttp-date-perl \
libgetopt-long-descriptive-perl \
libmoo-perl \
libnamespace-clean-perl \
libpath-tiny-perl \
libpod-constants-perl \
libscalar-list-utils-perl \
libsort-key-perl \
libstrictures-perl \
libstring-escape-perl \
libtry-tiny-perl

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

- name: commit
run: |
git config user.name qgis-bot
git config user.email [email protected]
git add .
git commit -m "auto sipify 🍺" || echo "nothing to commit"
git push
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 @@ -430,3 +430,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 @@ -30,10 +30,11 @@
my $debug = 0;
my $sip_output = '';
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] [-sip_output FILE] [-python_output FILE] headerfile\n")
unless GetOptions ("debug" => \$debug, "sip_output=s" => \$sip_output, "python_output=s" => \$python_output) && @ARGV == 1;
die("usage: $0 [-debug] [-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, "class_map=s" => \$class_map_file) && @ARGV == 1;
my $headerfile = $ARGV[0];

# read file
Expand Down Expand Up @@ -923,6 +924,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 @@ -1417,6 +1424,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
70 changes: 51 additions & 19 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 @@ -42,18 +46,30 @@ if [[ -n $1 ]]; then
else
modules=(core gui analysis server 3d)
fi
for module in "${modules[@]}"; do

# clean auto_additions and auto_generated folders
rm -rf python/${module}/auto_additions/*.py
rm -rf python/${module}/auto_generated/*.py
# put back __init__.py
echo '"""
# shellcheck disable=SC2043
for root_dir in python; do

if [[ $root_dir == "python/PyQt6" ]]; then
IS_QT6="--qt6"
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
# put back __init__.py
echo '"""
This folder is completed using sipify.pl script
It is not aimed to be manually edited
"""' > python/${module}/auto_additions/__init__.py
"""' > ${module_dir}/auto_additions/__init__.py

while read -r sipfile; do
while read -r sipfile; do
echo "$sipfile.in"
header=$(${GP}sed -E 's@(.*)\.sip@src/\1.h@; s@auto_generated/@@' <<< $sipfile)
pyfile=$(${GP}sed -E 's@([^\/]+\/)*([^\/]+)\.sip@\2.py@;' <<< $sipfile)
Expand All @@ -62,13 +78,29 @@ It is not aimed to be manually edited
else
path=$(${GP}sed -r 's@/[^/]+$@@' <<< $sipfile)
mkdir -p python/$path
./scripts/sipify.pl -s python/$sipfile.in -p python/${module}/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 < <( ${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
# shellcheck disable=SC2043
for root_dir in python; 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