Skip to content

Commit 5b4bcda

Browse files
committed
add scripts
1 parent aa7b555 commit 5b4bcda

File tree

5 files changed

+291
-5
lines changed

5 files changed

+291
-5
lines changed

scripts/manual.sh

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
#!/usr/bin/env bash
2+
3+
# ================================
4+
# stash for release
5+
# ================================
6+
git stash push --include-untracked
7+
8+
9+
# ================================
10+
# tidy
11+
# ================================
12+
node ../${ESLINT_CONFIG_PROJECT}/node_modules/eslint/bin/eslint.js --config=../${ESLINT_CONFIG_PROJECT}/.eslintrc --fix 'generator/**/*.js' 'scripts/*.js'
13+
14+
15+
# ================================
16+
# generate doctoc
17+
# ================================
18+
node node_modules/doctoc/doctoc.js README.md
19+
20+
21+
# ================================
22+
# git commit
23+
# ================================
24+
npm version patch && git push --all --follow-tags origin --force && git push --all --follow-tags github --force
25+
26+
27+
# ================================
28+
# build
29+
# ================================
30+
for version in luajit-2.1 5.{4,3,2,1}; do
31+
bash -c "cd out/prepublish/${version}/lua-opencv && git stash push --include-untracked --all -- samples"
32+
wsl -e bash -li -c 'source scripts/wsl_init.sh; cd out/prepublish/'${version}'/lua-opencv && git stash push --include-untracked --all -- samples'
33+
done
34+
35+
time DIST_VERSION=1 node scripts/prepublish.js --pack 2>&1 | tee prepublish_win.log && \
36+
time DIST_VERSION=1 WSLENV=DIST_VERSION/u wsl -e bash -li -c './scripts/wsl_prepublish.sh --pack' 2>&1 | tee prepublish_linux.log
37+
38+
for version in luajit-2.1 5.{4,3,2,1}; do
39+
bash -c "cd out/prepublish/${version}/lua-opencv && git stash pop"
40+
wsl -e bash -li -c 'source scripts/wsl_init.sh; cd out/prepublish/'${version}'/lua-opencv && git reset --hard HEAD && git stash pop'
41+
done
42+
43+
44+
# ================================
45+
# Windows prepublish check
46+
# ================================
47+
for version in luajit-2.1 5.{4,3,2,1}; do
48+
bash -c '
49+
source scripts/vcvars_restore_start.sh || exit $?
50+
cd out/prepublish/'${version}'/lua-opencv && ./luarocks/luarocks.bat install --deps-only samples/samples-scm-1.rockspec
51+
' && \
52+
WORKSPACE_ROOT="out/prepublish/${version}/lua-opencv" node scripts/test.js --Release
53+
done
54+
55+
# Windows README.md samples check
56+
for version in luajit-2.1 5.{4,3,2,1}; do
57+
bash -c '
58+
version='${version}'
59+
projectDir="$PWD"
60+
61+
[ "${version:0:6}" == luajit ] && target=luajit || target=lua
62+
[ "${version:0:6}" == luajit ] && binary=4.9.0luajit2.1
63+
64+
test -d out/test || mkdir out/test
65+
test -d out/test/opencv/.git || git clone --depth 1 --branch 4.9.0 https://github.com/opencv/opencv.git out/test/opencv || exit $?
66+
67+
test -d out/test/${version} || mkdir out/test/${version} || exit $?
68+
if [ -d out/test/${version}/lua-opencv ]; then
69+
PWD_BCK="$PWD" && \
70+
cd out/test/${version}/lua-opencv && \
71+
git remote set-url origin "file://${projectDir}" && \
72+
git reset --hard HEAD && \
73+
git clean -fd && \
74+
git branch tmp && \
75+
git pull && \
76+
git checkout v0.0.3 && \
77+
git branch -d tmp && \
78+
cd "${PWD_BCK}" || exit $?
79+
else
80+
git clone --depth 1 --branch v0.0.3 "file://${projectDir}" out/test/${version}/lua-opencv || exit $?
81+
fi
82+
83+
source scripts/vcvars_restore_start.sh || exit $?
84+
85+
cd out/test/${version}/lua-opencv || exit $?
86+
87+
./build.bat --target ${target} "-DLua_VERSION=${version}" --install && \
88+
./build.bat --target luarocks && \
89+
./luarocks/luarocks.bat install "--server=${projectDir}/out/prepublish/server" opencv_lua ${binary} && \
90+
./luarocks/luarocks.bat install --deps-only samples/samples-scm-1.rockspec || exit $?
91+
92+
source "${projectDir}/scripts/vcvars_restore_end.sh" || exit $?
93+
94+
npm ci && \
95+
node scripts/test.js --Release
96+
'
97+
done
98+
99+
100+
# ================================
101+
# Windows README.md install source rock
102+
# ================================
103+
for version in luajit-2.1; do
104+
bash -c '
105+
version='${version}'
106+
projectDir="$PWD"
107+
108+
[ "${version:0:6}" == luajit ] && target=luajit || target=lua
109+
110+
test -d out/test/${version} || mkdir out/test/${version} || exit $?
111+
test -d out/test/${version}/lua-project || mkdir out/test/${version}/lua-project || exit $?
112+
113+
if [ -d out/test/${version}/lua-opencv ]; then
114+
PWD_BCK="$PWD" && \
115+
cd out/test/${version}/lua-opencv && \
116+
git remote set-url origin "file://${projectDir}" && \
117+
git reset --hard HEAD && \
118+
git clean -fd && \
119+
git branch tmp && \
120+
git pull && \
121+
git checkout v0.0.3 && \
122+
git branch -d tmp && \
123+
cd "${PWD_BCK}" || exit $?
124+
else
125+
git clone --depth 1 --branch v0.0.3 "file://${projectDir}" out/test/${version}/lua-opencv || exit $?
126+
fi
127+
128+
PWD_BCK="$PWD" && \
129+
cd out/test/${version}/lua-opencv && \
130+
./build.bat --target ${target} "-DLua_VERSION=${version}" --install && \
131+
./build.bat --target luarocks && \
132+
cd "${PWD_BCK}" || exit $?
133+
134+
LUA_BINDIR="$PWD/out/test/${version}/lua-opencv/luarocks"
135+
cd out/test/${version}/lua-project && \
136+
"${LUA_BINDIR}/luarocks.bat" init --lua-versions "5.1,5.2,5.3,5.4" && \
137+
./luarocks.bat install "--server=${projectDir}/out/prepublish/server" opencv_lua 4.9.0
138+
'
139+
done
140+
141+
142+
# ================================
143+
# WSL prepublish check
144+
# ================================
145+
for version in luajit-2.1 5.{4,3,2,1}; do
146+
version=${version} WSLENV=version/u wsl -e bash -li -c '
147+
source scripts/wsl_init.sh || exit $?
148+
cd out/prepublish/${version}/lua-opencv && ./luarocks/luarocks install --deps-only samples/samples-scm-1.rockspec && \
149+
cd "${sources}" && \
150+
WORKSPACE_ROOT="out/prepublish/${version}/lua-opencv" node scripts/test.js --Release
151+
'
152+
done
153+
154+
155+
# ================================
156+
# WSL README.md samples check
157+
# ================================
158+
for version in 5.{4,3,2,1}; do
159+
version=${version} WSLENV=version/u wsl -e bash -li -c '
160+
source scripts/wsl_init.sh || exit $?
161+
162+
[ "${version:0:6}" == luajit ] && target=luajit || target=lua
163+
[ "${version:0:6}" == luajit ] && binary=4.9.0luajit2.1
164+
165+
test -d out/test || mkdir out/test
166+
test -d out/test/opencv/.git || git clone --depth 1 --branch 4.9.0 https://github.com/opencv/opencv.git out/test/opencv || exit $?
167+
168+
test -d out/test/${version} || mkdir out/test/${version} || exit $?
169+
if [ -d out/test/${version}/lua-opencv ]; then
170+
PWD_BCK="$PWD" && \
171+
cd out/test/${version}/lua-opencv && \
172+
git remote set-url origin "file://${projectDir}" && \
173+
git reset --hard HEAD && \
174+
git clean -fd && \
175+
git branch tmp && \
176+
git pull && \
177+
git checkout v0.0.3 && \
178+
git branch -d tmp && \
179+
cd "${PWD_BCK}" || exit $?
180+
else
181+
git clone --depth 1 --branch v0.0.3 "file://${projectDir}" out/test/${version}/lua-opencv || exit $?
182+
fi
183+
184+
cd out/test/${version}/lua-opencv || exit $?
185+
186+
./build.sh --target ${target} "-DLua_VERSION=${version}" --install && \
187+
./build.sh --target luarocks && \
188+
./luarocks/luarocks install "--server=${projectDir}/out/prepublish/server" opencv_lua ${binary} && \
189+
./luarocks/luarocks install --deps-only samples/samples-scm-1.rockspec || exit $?
190+
191+
npm ci && \
192+
node scripts/test.js --Release
193+
'
194+
done
195+
196+
197+
# ================================
198+
# WSL README.md install source rock
199+
# ================================
200+
for version in luajit-2.1; do
201+
version=${version} WSLENV=version/u wsl -e bash -li -c '
202+
source scripts/wsl_init.sh || exit $?
203+
204+
[ "${version:0:6}" == luajit ] && target=luajit || target=lua
205+
206+
test -d out/test/${version} || mkdir out/test/${version} || exit $?
207+
test -d out/test/${version}/lua-project || mkdir out/test/${version}/lua-project || exit $?
208+
209+
if [ -d out/test/${version}/lua-opencv ]; then
210+
PWD_BCK="$PWD" && \
211+
cd out/test/${version}/lua-opencv && \
212+
git remote set-url origin "file://${projectDir}" && \
213+
git reset --hard HEAD && \
214+
git clean -fd && \
215+
git branch tmp && \
216+
git pull && \
217+
git checkout v0.0.3 && \
218+
git branch -d tmp && \
219+
cd "${PWD_BCK}" || exit $?
220+
else
221+
git clone --depth 1 --branch v0.0.3 "file://${projectDir}" out/test/${version}/lua-opencv || exit $?
222+
fi
223+
224+
PWD_BCK="$PWD" && \
225+
cd out/test/${version}/lua-opencv && \
226+
./build.sh --target ${target} "-DLua_VERSION=${version}" --install && \
227+
./build.sh --target luarocks && \
228+
cd "${PWD_BCK}" || exit $?
229+
230+
LUA_BINDIR="$PWD/out/test/${version}/lua-opencv/luarocks"
231+
cd out/test/${version}/lua-project && \
232+
"${LUA_BINDIR}/luarocks" init --lua-versions "5.1,5.2,5.3,5.4" && \
233+
./luarocks config --scope project cmake_generator Ninja && \
234+
./luarocks config --scope project cmake_build_args -- -j$(( $(nproc) - 2 )) && \
235+
./luarocks install "--server=${projectDir}/out/prepublish/server" opencv_lua 4.9.0
236+
'
237+
done
238+
239+
240+
# ================================
241+
# publish
242+
# ================================
243+
bash -c 'DIST_VERSION=1; ./luarocks/luarocks.bat upload out/prepublish/server/opencv_lua-4.9.0-${DIST_VERSION}.rockspec --api-key=${LUA_ROCKS_API_KEY}'
244+
245+
246+
# ================================
247+
# restore stash
248+
# ================================
249+
git stash pop

scripts/vcvars_restore_end.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
export "PATH=${PATH_BCK}"
4+
unset PATH_BCK

scripts/vcvars_restore_start.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
PATH_BCK="${PATH}"
4+
5+
PATH="${PATH//$HOME\/.local\/bin:/}"
6+
PATH="${PATH//$HOME\/.local\/sbin:/}"
7+
PATH="${PATH//$HOME\/bin:/}"
8+
PATH="${PATH//$HOME\/sbin:/}"
9+
PATH="${PATH//\/usr\/local\/bin:/}"
10+
PATH="${PATH//\/usr\/local\/sbin:/}"
11+
PATH="${PATH//\/usr\/bin:/}"
12+
PATH="${PATH//\/usr\/sbin:/}"
13+
PATH="${PATH//\/mingw64\/local\/bin:/}"
14+
PATH="${PATH//\/mingw64\/local\/sbin:/}"
15+
PATH="${PATH//\/mingw64\/bin:/}"
16+
PATH="${PATH//\/mingw64\/sbin:/}"
17+
PATH="${PATH//\/mingw32\/local\/bin:/}"
18+
PATH="${PATH//\/mingw32\/local\/sbin:/}"
19+
PATH="${PATH//\/mingw32\/bin:/}"
20+
PATH="${PATH//\/mingw32\/sbin:/}"
21+
PATH="${PATH//\/bin:/}"
22+
PATH="${PATH//\/usr\/bin\/vendor_perl:/}"
23+
PATH="${PATH//\/usr\/bin\/core_perl:/}"
24+
25+
export PATH

wsl_prepublish.sh renamed to scripts/wsl_init.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
export PATH="${PATH//\/mnt\/*:/}"
44

5+
workspaceHash=53b58a2f-f3e5-480b-8803-dc266ac326de
56
projectDir="$PWD"
67
projectDirName=$(basename "$projectDir")
78
sources="$HOME/.vs/${projectDirName}/${workspaceHash}/src"
@@ -22,8 +23,8 @@ rsync -t --delete -v -r \
2223
--exclude=.idea \
2324
--exclude=.venv \
2425
--exclude=.vs \
25-
--exclude='*.rock' \
26-
--exclude='*.rockspec' \
26+
--exclude="*.rock" \
27+
--exclude="*.rockspec" \
2728
--exclude=build.luarocks \
2829
--exclude=.luarocks \
2930
--exclude=luarocks/lua.bat \
@@ -36,5 +37,3 @@ rsync -t --delete -v -r \
3637
--exclude=node_modules \
3738
--exclude=out \
3839
"${projectDir}/" "${sources}" || exit $?
39-
40-
LUAROCKS_SERVER="$projectDir/out/prepublish/server" node scripts/prepublish.js "$@"

scripts/wsl_prepublish.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
#Absolute path to this script
4+
SCRIPT=$(readlink -f "$0")
5+
#Absolute path this script is in
6+
SCRIPTPATH=$(dirname "$SCRIPT")
7+
8+
source "${SCRIPTPATH}/wsl_init.sh" || exit $?
9+
LUAROCKS_SERVER="$projectDir/out/prepublish/server" node scripts/prepublish.js "$@"

0 commit comments

Comments
 (0)