Skip to content

Commit 4cb6bf6

Browse files
committed
faster loop between lua versions
1 parent 7361cdd commit 4cb6bf6

File tree

5 files changed

+160
-74
lines changed

5 files changed

+160
-74
lines changed

docs/hosting-you-own-binary-rocks-Linux.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ if retval then
163163
print("font", font)
164164
ft2:loadFontData(font, 0)
165165

166-
points = points:convertTo(cv.CV_32S)
166+
points = points:convertTo(cv.CV_32S):table()
167167
for i = 1, #points do
168-
local cnt = points[i - 1]
168+
local cnt = points[i]
169169
cv.drawContours(img_rgb, { cnt }, 0, { 0, 0, 255 }, 2)
170170

171-
local position = cnt:table()[1]
171+
local position = cnt[1]
172172

173173
ft2:putText(img_rgb, "中文", position, opencv_lua.kwargs({
174174
fontHeight = 12,

docs/hosting-you-own-binary-rocks-Windows.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ if retval then
165165
assert(#font ~= 0, "msjh.ttc was not fount")
166166
ft2:loadFontData(font, 0)
167167

168-
points = points:convertTo(cv.CV_32S)
168+
points = points:convertTo(cv.CV_32S):table()
169169
for i = 1, #points do
170-
local cnt = points[i - 1]
170+
local cnt = points[i]
171171
cv.drawContours(img_rgb, { cnt }, 0, { 0, 0, 255 }, 2)
172172

173-
local position = cnt:table()[1]
173+
local position = cnt[1]
174174

175175
ft2:putText(img_rgb, "中文", position, opencv_lua.kwargs({
176176
fontHeight = 12,

luajit/luajit_exe.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Include the manifest file that indicates we support all
1212
// current versions of Windows.
13-
1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ ICON DISCARDABLE "luajit.ico"
13+
1 ICON DISCARDABLE "luajit.ico"
1414

1515

1616
/////////////////////////////////////////////////////////////////////////////

scripts/manual.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ bash -c 'source scripts/tasks.sh && stash_push'
1212
bash -c 'source scripts/tasks.sh && tidy'
1313

1414

15-
# ================================
16-
# generate doctoc
17-
# ================================
18-
bash -c 'source scripts/tasks.sh && doctoc'
19-
20-
2115
# ================================
2216
# build
2317
# ================================
@@ -27,8 +21,6 @@ bash -c 'source scripts/tasks.sh && new_version_rollback && build_full'
2721

2822
bash -c 'source scripts/tasks.sh && prepublish_stash_pop'
2923

30-
cp -f out/prepublish/luajit-2.1/opencv_lua/docs/docs.md ./docs/
31-
cp -f out/prepublish/luajit-2.1/opencv_lua/generator/ids.json ./generator/
3224

3325
# ================================
3426
# Windows README.md samples check
@@ -67,6 +59,14 @@ bash -c 'source scripts/tasks.sh && test_prepublished_binary_debian test-source-
6759
bash -c 'source scripts/tasks.sh && test_prepublished_binary_fedora test-source-fedora-39 fedora:39 -- object_detection.lua'
6860

6961

62+
# ================================
63+
# generate doctoc
64+
# ================================
65+
cp -f out/prepublish/luajit-2.1/opencv_lua/docs/docs.md ./docs/
66+
cp -f out/prepublish/luajit-2.1/opencv_lua/generator/ids.json ./generator/
67+
bash -c 'source scripts/tasks.sh && doctoc'
68+
69+
7070
# ================================
7171
# prepublish the new version
7272
# ================================

scripts/tasks.sh

Lines changed: 145 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ export SCRIPT_SUFFIX='${SCRIPT_SUFFIX}'
186186
export LUAROCKS_SUFFIX='${LUAROCKS_SUFFIX}'
187187
export DIST_VERSION='${DIST_VERSION}'
188188
export projectDir='${projectDir}'
189-
export version='${version:-luajit-2.1}'
190-
export suffix='${suffix}'
191189
"
192190
}
193191

@@ -343,21 +341,53 @@ function push_all() {
343341
}
344342

345343
function prepublish_stash_push() {
346-
for version in luajit-2.1 5.{4,3,2,1}; do
347-
for suffix in '' '-contrib'; do
348-
bash -c "cd out/prepublish/${version}/opencv_lua${suffix} && git stash push --include-untracked --all -- samples"
349-
wsl -c "source scripts/wsl_init.sh && cd out/prepublish/${version}/opencv_lua${suffix} && git stash push --include-untracked --all -- samples"
350-
done
344+
local script='cd out/prepublish/${version}/opencv_lua${suffix} && git stash push --include-untracked --all -- samples'
345+
346+
bash -c "
347+
for version in luajit-2.1 5.{4,3,2,1}; do
348+
for suffix in '' '-contrib'; do
349+
_PATH=\$PATH; pushd \$PWD
350+
${script}
351+
popd; PATH=\$_PATH; unset _PATH
352+
done
353+
done
354+
"
355+
356+
wsl -c "
357+
source scripts/wsl_init.sh
358+
for version in luajit-2.1 5.{4,3,2,1}; do
359+
for suffix in '' '-contrib'; do
360+
_PATH=\$PATH; pushd \$PWD
361+
${script}
362+
popd; PATH=\$_PATH; unset _PATH
351363
done
364+
done
365+
"
352366
}
353367

354368
function prepublish_stash_pop() {
355-
for version in luajit-2.1 5.{4,3,2,1}; do
356-
for suffix in '' '-contrib'; do
357-
bash -c "cd out/prepublish/${version}/opencv_lua${suffix} && git reset --hard HEAD && git stash pop"
358-
wsl -c "source scripts/wsl_init.sh && cd out/prepublish/${version}/opencv_lua${suffix} && git reset --hard HEAD && git stash pop"
359-
done
369+
local script='cd ${CWD}/out/prepublish/${version}/opencv_lua${suffix} && git reset --hard HEAD && git stash pop'
370+
371+
bash -c "
372+
for version in luajit-2.1 5.{4,3,2,1}; do
373+
for suffix in '' '-contrib'; do
374+
_PATH=\$PATH; pushd \$PWD
375+
${script}
376+
popd; PATH=\$_PATH; unset _PATH
360377
done
378+
done
379+
"
380+
381+
wsl -c "
382+
source scripts/wsl_init.sh
383+
for version in luajit-2.1 5.{4,3,2,1}; do
384+
for suffix in '' '-contrib'; do
385+
_PATH=\$PATH; pushd \$PWD
386+
${script}
387+
popd; PATH=\$_PATH; unset _PATH
388+
done
389+
done
390+
"
361391
}
362392

363393
function prepublish_any() {
@@ -580,6 +610,7 @@ function build_custom_wsl() {
580610
new_version && \
581611
wsl -c "
582612
$(export_shared_env /mnt); source scripts/wsl_init.sh || exit \$?
613+
WORKING_DIRECTORY=\${sources}/../opencv-lua-custom
583614
[ -d \${WORKING_DIRECTORY} ] || mkdir \${WORKING_DIRECTORY} || exit \$?
584615
[ -d \${projectDir}/out/prepublish/server-${name} ] || mkdir \${projectDir}/out/prepublish/server-${name} || exit \$?
585616
[ -L \${WORKING_DIRECTORY}/server ] || ln -s \${projectDir}/out/prepublish/server-wsl \${WORKING_DIRECTORY}/server || exit \$?
@@ -622,6 +653,7 @@ function test_rock_script() {
622653
local script='
623654
624655
if command -v cygpath &>/dev/null; then
656+
unset -f ln
625657
function ln() {
626658
local opt="$1"; shift
627659
local dest="$1"; shift
@@ -706,10 +738,6 @@ else
706738
cd ..
707739
fi
708740
709-
function luarocks() {
710-
./luarocks/luarocks${LUAROCKS_SUFFIX} "$@"
711-
}
712-
713741
# ================================
714742
# Install the rock
715743
# ================================
@@ -722,10 +750,10 @@ else
722750
opencv_lua_version=
723751
fi
724752
725-
luarocks install --deps-only samples/samples-scm-1.rockspec || exit $?
726-
opencv_lua_installed="$(luarocks list --porcelain opencv_lua${suffix})"
727-
[ ${#opencv_lua_installed} -eq 0 ] || luarocks remove opencv_lua${suffix} || exit $?
728-
luarocks install "--server=${projectDir}/out/prepublish/server" opencv_lua${suffix} ${opencv_lua_version} || exit $?
753+
./luarocks/luarocks${LUAROCKS_SUFFIX} install --deps-only samples/samples-scm-1.rockspec || exit $?
754+
opencv_lua_installed="$(./luarocks/luarocks${LUAROCKS_SUFFIX} list --porcelain opencv_lua${suffix})"
755+
[ ${#opencv_lua_installed} -eq 0 ] || ./luarocks/luarocks${LUAROCKS_SUFFIX} remove opencv_lua${suffix} || exit $?
756+
./luarocks/luarocks${LUAROCKS_SUFFIX} install "--server=${projectDir}/out/prepublish/server" opencv_lua${suffix} ${opencv_lua_version} || exit $?
729757
730758
# ================================
731759
# Run the tests
@@ -749,63 +777,102 @@ PYTHON_VENV_PATH="${CWD}/out/test/.venv" MODELS_PATH="${projectDir}/out/test/.mo
749777
echo "rock_type=${rock_type}; $script"
750778
}
751779

752-
function test_prepublished_binary_windows() {
753-
local script="$(test_rock_script 0 binary "$@")"
780+
function test_prepublished_windows() {
781+
local exclude=$1; shift
782+
local rock_type=$1; shift
783+
local script="$(test_rock_script $exclude $rock_type "$@")"
784+
local versions
754785

755-
for version in luajit-2.1 5.{4,3,2,1}; do
756-
for suffix in '' '-contrib'; do
757-
bash -c "source scripts/vcvars_restore_start.sh; $(export_shared_env); ${script}" || return $?
758-
done
759-
done
760-
}
786+
if [ "$rock_type" == "source" ]; then
787+
versions='luajit-2.1'
788+
else
789+
versions='luajit-2.1 5.{4,3,2,1}'
790+
fi
761791

762-
function test_prepublished_binary_wsl() {
763-
local script="$(test_rock_script 1 binary "$@")"
792+
bash -c "
793+
$(export_shared_env)
794+
source scripts/vcvars_restore_start.sh
764795
765-
for version in luajit-2.1 5.{4,3,2,1}; do
766-
for suffix in '' '-contrib'; do
767-
wsl -c "$(export_shared_env /mnt); source \${projectDir}/scripts/wsl_init.sh || exit \$?; $script" || return $?
768-
done
796+
for version in ${versions}; do
797+
for suffix in '' '-contrib'; do
798+
_PATH=\$PATH; pushd \$PWD
799+
${script} || exit \$?
800+
popd; PATH=\$_PATH; unset _PATH
769801
done
802+
done
803+
"
804+
}
805+
806+
function test_prepublished_binary_windows() {
807+
test_prepublished_windows 0 binary "$@"
770808
}
771809

772810
function test_prepublished_source_windows() {
773-
local script="$(test_rock_script 0 source "$@")"
811+
test_prepublished_windows 0 source "$@"
812+
}
774813

775-
for version in luajit-2.1; do
776-
for suffix in '' '-contrib'; do
777-
bash -c "source scripts/vcvars_restore_start.sh; $(export_shared_env); ${script}" || return $?
778-
done
814+
function test_prepublished_wsl() {
815+
local exclude=$1; shift
816+
local rock_type=$1; shift
817+
local script="$(test_rock_script $exclude $rock_type "$@")"
818+
local versions
819+
820+
if [ "$rock_type" == "source" ]; then
821+
versions='luajit-2.1'
822+
else
823+
versions='luajit-2.1 5.{4,3,2,1}'
824+
fi
825+
826+
wsl -c "
827+
$(export_shared_env /mnt)
828+
source \${projectDir}/scripts/wsl_init.sh || exit \$?
829+
830+
for version in ${versions}; do
831+
for suffix in '' '-contrib'; do
832+
_PATH=\$PATH; pushd \$PWD
833+
${script} || exit \$?
834+
popd; PATH=\$_PATH; unset _PATH
779835
done
836+
done
837+
"
780838
}
781839

782-
function test_prepublished_source_wsl() {
783-
local script="$(test_rock_script 1 source "$@")"
840+
function test_prepublished_binary_wsl() {
841+
test_prepublished_wsl 1 binary "$@"
842+
}
784843

785-
for version in luajit-2.1; do
786-
for suffix in '' '-contrib'; do
787-
wsl -c "$(export_shared_env /mnt); source \${projectDir}/scripts/wsl_init.sh || exit \$?; $script" || return $?
788-
done
789-
done
844+
function test_prepublished_source_wsl() {
845+
test_prepublished_wsl 1 source "$@"
790846
}
791847

792848
function test_prepublished_docker() {
793849
local name=$1; shift
794850
local exclude=$1; shift
795851
local rock_type=$1; shift
796852
local script="$(test_rock_script $exclude $rock_type "$@")"
853+
local versions
797854

798-
for version in luajit-2.1 5.{4,3,2,1}; do
799-
for suffix in '' '-contrib'; do
800-
docker exec -u 1001 -it ${name} bash -c "
855+
if [ "$rock_type" == "source" ]; then
856+
versions='luajit-2.1'
857+
else
858+
versions='luajit-2.1 5.{4,3,2,1}'
859+
fi
860+
861+
docker exec -u 1001 -it ${name} bash -c "
801862
git config --global --add safe.directory /src/.git && \
802863
source /src/scripts/tasks.sh && \
803864
make_available_nvs && nvs add 16 && nvs use 16 && \
804865
cd /io || exit \$?
805866
$(export_shared_env '' /src)
806-
${script}" || return $?
807-
done
867+
868+
for version in ${versions}; do
869+
for suffix in '' '-contrib'; do
870+
_PATH=\$PATH; pushd \$PWD
871+
${script} || exit \$?
872+
popd; PATH=\$_PATH; unset _PATH
808873
done
874+
done
875+
"
809876
}
810877

811878
function install_test_essentials_debian() {
@@ -867,6 +934,11 @@ $(get_current_package_manager)
867934
\$cpm install -y curl gcc gcc-c++ git glib2 readline-devel libglvnd-glx libSM libXext make patch python3-pip unzip wget || \
868935
exit \$?
869936
937+
source /etc/os-release
938+
if [ \"\$NAME\" == \"AlmaLinux\" ]; then
939+
\$cpm install -y python3-devel # needed to install opencv-python || exit \$?
940+
fi
941+
870942
$(docker_init_script)"
871943
}
872944

@@ -989,19 +1061,33 @@ node scripts/test.js --Release'
9891061
function test_prepublished_build_windows() {
9901062
local script="$(test_build_script 0 "$@")"
9911063

992-
for version in luajit-2.1 5.{4,3,2,1}; do
993-
for suffix in '' '-contrib'; do
994-
bash -c "source scripts/vcvars_restore_start.sh; $(export_shared_env); $script" || return $?
995-
done
1064+
bash -c "
1065+
source scripts/vcvars_restore_start.sh
1066+
$(export_shared_env)
1067+
1068+
for version in luajit-2.1 5.{4,3,2,1}; do
1069+
for suffix in '' '-contrib'; do
1070+
_PATH=\$PATH; pushd \$PWD
1071+
${script} || exit \$?
1072+
popd; PATH=\$_PATH; unset _PATH
9961073
done
1074+
done
1075+
"
9971076
}
9981077

9991078
function test_prepublished_build_wsl() {
10001079
local script="$(test_build_script 1 "$@")"
10011080

1002-
for version in luajit-2.1 5.{4,3,2,1}; do
1003-
for suffix in '' '-contrib'; do
1004-
wsl -c "$(export_shared_env /mnt); source \${projectDir}/scripts/wsl_init.sh || exit \$?; $script" || return $?
1005-
done
1081+
wsl -c "
1082+
$(export_shared_env /mnt)
1083+
source \${projectDir}/scripts/wsl_init.sh || exit \$?
1084+
1085+
for version in luajit-2.1 5.{4,3,2,1}; do
1086+
for suffix in '' '-contrib'; do
1087+
_PATH=\$PATH; pushd \$PWD
1088+
${script} || exit \$?
1089+
popd; PATH=\$_PATH; unset _PATH
10061090
done
1091+
done
1092+
"
10071093
}

0 commit comments

Comments
 (0)