@@ -11,12 +11,12 @@ if [[ -z "${TT_REPO}" ]]; then
11
11
TT_REPO=" https://github.com/tarantool/tarantool.git"
12
12
fi
13
13
14
- TT_DIR=tarantool
14
+ TT_DIR=tarantool- ${TT_TAG}
15
15
16
16
# Cleanup.
17
17
rm -rf ${TT_DIR}
18
18
19
- git clone --depth 1 --branch ${TT_TAG} ${TT_REPO} -o ${TT_DIR}
19
+ git clone --depth 1 --branch ${TT_TAG} ${TT_REPO} ${TT_DIR}
20
20
cd ${TT_DIR}
21
21
TT_COMMIT=$( git log -n 1 | head -n 1 | sed " s/commit //" )
22
22
cd ..
@@ -227,25 +227,30 @@ EOF
227
227
echo " ${FOOTER} " > ${DST_ERRORS}
228
228
cat << EOF >> ${DST_ERRORS}
229
229
// IPROTO error code constants, generated from
230
- // ${SRC_ERRORS}
230
+ // ${SRC_ERRORS// - ${TT_TAG} / }
231
231
type Error int
232
232
233
233
const (
234
234
EOF
235
235
236
- grep " (ER_" ${SRC_ERRORS} | \
237
- # Remove comments symbols.
238
- sed " s/\/\*//" | \
239
- sed " s/\*\/_(//" | \
240
- # Remove and of values.
241
- sed " s/) *\\ \//" | \
242
- # Remove comma at an end of a value.
243
- sed " s/,/ /" | \
244
- # Finally print parsed values in Golang format.
245
- awk ' {
246
- com="";
247
- for(i=3;i<=NF;i++){com=com" "$i};
248
- printf("\t//%s\n\t%s Error = %s\n", com, $2, $1)
236
+ # Extract body of define ERROR_CODES
237
+ ERROR_CODES=` sed -n ' /^#define ERROR_CODES(/,/This one should be last/{//!p;}' ${SRC_ERRORS} `
238
+
239
+ echo " ${ERROR_CODES} " | \
240
+ # Get line with ER_* description.
241
+ sed -nE ' s/^[^E]*(ER_.+)\s*\\\s*$/\1/p' | \
242
+ # Remove trailing parenthesis or comment's ending.
243
+ sed -E ' s/(.*)\s*(:?\)|\*\/)\s*$/\1/' | \
244
+ # Extract three fields: name, id and first comment string.
245
+ # Match string based on https://regex101.com/library/zI0yV6
246
+ sed -E ' s/^([^"]+)("([^"]|\\")*[^\\]"|"").*$/\1\2/' | \
247
+ # Format three fields comma separated for Go lang const declaration.
248
+ awk '
249
+ BEGIN{ FS=",[[:space:]]*" }
250
+ {
251
+ com=$3;
252
+ for(i=4;i<=NF;i++){com=com", "$i};
253
+ printf("\t// %s\n\t%s Error = %s\n", com, $1, $2)
249
254
}' >> ${DST_ERRORS}
250
255
251
256
echo " )" >> ${DST_ERRORS}
@@ -259,7 +264,7 @@ func TestError(t *testing.T) {
259
264
} {
260
265
EOF
261
266
262
- grep -o " ER_[A-Z0-9_]\+," ${SRC_ERRORS} | \
267
+ echo " ${ERROR_CODES} " | grep -o " ER_[A-Z0-9_]\+," | \
263
268
sed " s/,$//" | \
264
269
awk ' {printf("\t\t{iproto.%s, \"%s\"},\n", $1, $1)}' >> ${DST_ERRORS_TEST}
265
270
286
291
echo " ${FOOTER} " > ${DST_FEATURES}
287
292
cat << EOF >> ${DST_FEATURES}
288
293
// IPROTO feature constants, generated from
289
- // ${SRC_FEATURES}
294
+ // ${SRC_FEATURES// - ${TT_TAG} / }
290
295
EOF
291
296
292
297
read_define_with_prefix IPROTO_FEATURES iproto_feature_id ${SRC_FEATURES} | \
@@ -304,7 +309,7 @@ read_define_with_prefix IPROTO_FEATURES iproto_feature_id ${SRC_FEATURES} | \
304
309
echo " ${FOOTER} " > ${DST_FLAGS}
305
310
cat << EOF >> ${DST_FLAGS}
306
311
// IPROTO flag constants, generated from
307
- // ${SRC_CONST}
312
+ // ${SRC_CONST// - ${TT_TAG} / }
308
313
EOF
309
314
310
315
read_define_with_prefix IPROTO_FLAGS iproto_flag ${SRC_CONST} | \
@@ -322,7 +327,7 @@ read_define_with_prefix IPROTO_FLAGS iproto_flag ${SRC_CONST} | \
322
327
echo " ${FOOTER} " > ${DST_ITERATORS}
323
328
cat << EOF >> ${DST_ITERATORS}
324
329
// IPROTO iterators constants, generated from
325
- // ${SRC_ITERATORS}
330
+ // ${SRC_ITERATORS// - ${TT_TAG} / }
326
331
EOF
327
332
328
333
read_enum iterator_type ${SRC_ITERATORS} | \
@@ -340,7 +345,7 @@ read_enum iterator_type ${SRC_ITERATORS} | \
340
345
echo " ${FOOTER} " > ${DST_TYPES}
341
346
cat << EOF >> ${DST_TYPES}
342
347
// IPROTO type constants, generated from
343
- // ${SRC_CONST}
348
+ // ${SRC_CONST// - ${TT_TAG} / }
344
349
EOF
345
350
346
351
read_define_with_prefix IPROTO_TYPES iproto_type ${SRC_CONST} | \
@@ -358,7 +363,7 @@ read_define_with_prefix IPROTO_TYPES iproto_type ${SRC_CONST} | \
358
363
echo " ${FOOTER} " > ${DST_KEYS}
359
364
cat << EOF >> ${DST_KEYS}
360
365
// IPROTO key constants, generated from
361
- // ${SRC_CONST}
366
+ // ${SRC_CONST// - ${TT_TAG} / }
362
367
EOF
363
368
364
369
read_define_with_prefix IPROTO_KEYS iproto_key ${SRC_CONST} | \
@@ -367,7 +372,7 @@ read_define_with_prefix IPROTO_KEYS iproto_key ${SRC_CONST} | \
367
372
cat << EOF >> ${DST_KEYS}
368
373
369
374
// IPROTO metadata key constants, generated from
370
- // ${SRC_CONST}
375
+ // ${SRC_CONST// - ${TT_TAG} / }
371
376
EOF
372
377
373
378
read_define_with_prefix IPROTO_METADATA_KEYS iproto_metadata_key ${SRC_CONST} | \
@@ -376,7 +381,7 @@ read_define_with_prefix IPROTO_METADATA_KEYS iproto_metadata_key ${SRC_CONST} |
376
381
cat << EOF >> ${DST_KEYS}
377
382
378
383
// IPROTO ballot key constants, generated from
379
- // ${SRC_CONST}
384
+ // ${SRC_CONST// - ${TT_TAG} / }
380
385
EOF
381
386
382
387
read_define_with_prefix IPROTO_BALLOT_KEYS iproto_ballot_key ${SRC_CONST} | \
@@ -385,7 +390,7 @@ read_define_with_prefix IPROTO_BALLOT_KEYS iproto_ballot_key ${SRC_CONST} | \
385
390
cat << EOF >> ${DST_KEYS}
386
391
387
392
// IPROTO raft key constants, generated from
388
- // ${SRC_CONST}
393
+ // ${SRC_CONST// - ${TT_TAG} / }
389
394
EOF
390
395
391
396
read_define_with_prefix IPROTO_RAFT_KEYS iproto_raft_key ${SRC_CONST} | \
@@ -394,7 +399,7 @@ read_define_with_prefix IPROTO_RAFT_KEYS iproto_raft_key ${SRC_CONST} | \
394
399
cat << EOF >> ${DST_KEYS}
395
400
396
401
// IPROTO SQL info key constants, generated from
397
- // ${SRC_EXECUTE}
402
+ // ${SRC_EXECUTE// - ${TT_TAG} / }
398
403
EOF
399
404
400
405
read_enum sql_info_key ${SRC_EXECUTE} | \
0 commit comments