mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 05:29:34 +02:00
* bash scripts for testing and running googleapiconv (ref #40094)
This commit is contained in:
parent
ab3aae149b
commit
731fd94b8c
21
packages/googleapi/generator/fetch_google_json.sh
Executable file
21
packages/googleapi/generator/fetch_google_json.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ** NOTICE **
|
||||
# This script deletes the "./_google_api_json_tmp" directory
|
||||
# (if it exists) before attempting to download new definitions.
|
||||
|
||||
SCRIPT_DIR="$(dirname "$0")"
|
||||
JSON_DIR="$SCRIPT_DIR/_google_api_json_tmp"
|
||||
TIMESTAMP=$(date +%F@%H%M) #format: 2006-09-15@1228
|
||||
LOG_FILE="$JSON_DIR/${TIMESTAMP}-$(basename "$0").txt" #log file with same name as script
|
||||
|
||||
rm -r "$JSON_DIR" &> /dev/null
|
||||
mkdir "$JSON_DIR" &> /dev/null
|
||||
|
||||
{
|
||||
|
||||
echo "# googleapiconv --verbose --all --onlydownload --keepjson --output=$JSON_DIR/"
|
||||
echo ""
|
||||
"$SCRIPT_DIR/googleapiconv" --verbose --all --onlydownload --keepjson --output="$JSON_DIR/"
|
||||
|
||||
} |& tee "$LOG_FILE" #output both stdout and stderr to logfile and terminal
|
32
packages/googleapi/generator/nomalize_json_files.sh
Executable file
32
packages/googleapi/generator/nomalize_json_files.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script sorts the JSON files to make it easy to diff
|
||||
# which also makes the generated units to be easy to diff. :-)
|
||||
#
|
||||
# ** NOTICE **
|
||||
# This script requires jq to be installed. jq is
|
||||
# included in most distros package repos.
|
||||
# https://github.com/stedolan/jq/
|
||||
|
||||
shopt -s nocaseglob #ignore case for filename matches
|
||||
shopt -s nullglob #if no matches return a null string
|
||||
|
||||
SCRIPT_DIR="$(dirname "$0")"
|
||||
JSON_DIR="$SCRIPT_DIR/_google_api_json_tmp"
|
||||
TIMESTAMP=$(date +%F@%H%M) #format: 2006-09-15@1228
|
||||
LOG_FILE="$JSON_DIR/${TIMESTAMP}-$(basename "$0").txt" #log file with same name as script
|
||||
|
||||
{
|
||||
|
||||
TMP_FILE=$(mktemp --tmpdir="$JSON_DIR")
|
||||
((COUNT=0))
|
||||
for FILE in "$JSON_DIR/"*.json; do
|
||||
echo "# running jq --sortkeys on: $FILE"
|
||||
jq --sort-keys '.' "$FILE" > "$TMP_FILE"
|
||||
mv -f "$TMP_FILE" "$FILE"
|
||||
((COUNT++))
|
||||
done
|
||||
echo ""
|
||||
echo "Processed File Count = $COUNT"
|
||||
|
||||
} |& tee "$LOG_FILE" #output both stdout and stderr to logfile and terminal
|
63
packages/googleapi/generator/run_google_api_bindings_gen.sh
Executable file
63
packages/googleapi/generator/run_google_api_bindings_gen.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ** NOTICE **
|
||||
# If they exist, this script deletes the "./_google_api_bindings_tmp"
|
||||
# and "./_google_api_icons_tmp" directories before attempting
|
||||
# to convert new files. It does not download any JSON, but works on
|
||||
# files which must already be present in "./_google_api_bindings_tmp"
|
||||
# (use "./fetch_google_json.sh" to download the JSON files)
|
||||
|
||||
shopt -s nocaseglob #ignore case for filename matches
|
||||
shopt -s nullglob #if no matches return a null string
|
||||
|
||||
SCRIPT_DIR="$(dirname "$0")"
|
||||
JSON_DIR="$SCRIPT_DIR/_google_api_json_tmp"
|
||||
ICONS_DIR="$SCRIPT_DIR/_google_api_icons_tmp"
|
||||
BINDINGS_DIR="$SCRIPT_DIR/_google_api_bindings_tmp"
|
||||
|
||||
TIMESTAMP=$(date +%F@%H%M) #Example format: 2006-09-15@1228
|
||||
LOG_FILE="$BINDINGS_DIR/${TIMESTAMP}-$(basename "$0").txt" #log file with same name as script
|
||||
|
||||
if [ ! -d "$JSON_DIR" ]; then
|
||||
echo "** Nothing to do: $JSON_DIR directory does not exist **"
|
||||
echo ' 1) First run "fetch_google_json.sh" to download JSON files'
|
||||
echo ' 2) Then it is recommended to run "nomalize_json_files.sh"'
|
||||
echo ' (if you have "jq" installed on your system)'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -r "$BINDINGS_DIR" &> /dev/null
|
||||
mkdir "$BINDINGS_DIR" &> /dev/null
|
||||
rm -r "$ICONS_DIR" &> /dev/null
|
||||
mkdir "$ICONS_DIR" &> /dev/null
|
||||
|
||||
{
|
||||
|
||||
# Test convert a single JSON file
|
||||
# echo "googleapiconv --verbose --input=$JSON_DIR/googlegmail.json --output=$BINDINGS_DIR/googlegmail.pp"
|
||||
# "$SCRIPT_DIR/googleapiconv" --verbose --input="$JSON_DIR/googlegmail.json" --output="$BINDINGS_DIR/googlegmail.pp"
|
||||
|
||||
for FILE in "$JSON_DIR/"*.json; do
|
||||
OUT_NAME="${FILE##*/}"; OUT_NAME="${OUT_NAME%.*}.pp"
|
||||
#--verbose
|
||||
echo "googleapiconv --icon --timestamp --input=$FILE --output=$BINDINGS_DIR/$OUT_NAME"
|
||||
"$SCRIPT_DIR/googleapiconv" --icon --input="$FILE" --output="$BINDINGS_DIR/$OUT_NAME"
|
||||
done
|
||||
|
||||
mv "$BINDINGS_DIR/"*.png "$ICONS_DIR"
|
||||
mv "$BINDINGS_DIR/"*.gif "$ICONS_DIR"
|
||||
|
||||
# Check to see if we have any missing generated .pp files
|
||||
echo ""
|
||||
((COUNT=0))
|
||||
for FILE in "$JSON_DIR/"*.json; do
|
||||
JSON_NAME="${FILE##*/}"
|
||||
PASCAL_NAME="${JSON_NAME%.*}.pp"
|
||||
if [ ! -s "$BINDINGS_DIR/$PASCAL_NAME" ]; then
|
||||
echo "** Missing or empty file: JSON file $JSON_NAME did not generate $PASCAL_NAME"
|
||||
((COUNT++))
|
||||
fi
|
||||
done
|
||||
echo "Missing File Count = $COUNT"
|
||||
|
||||
} |& tee "$LOG_FILE" #output both stdout and stderr to logfile and terminal
|
37
packages/googleapi/generator/test_bindings_gen_all.sh
Executable file
37
packages/googleapi/generator/test_bindings_gen_all.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ** NOTICE **
|
||||
# If it exists, this script deletes the "./_gen_all_test"
|
||||
# directory before attempting to download and convert new files.
|
||||
|
||||
shopt -s nocaseglob #ignore case for filename matches
|
||||
shopt -s nullglob #if no matches return a null string
|
||||
|
||||
SCRIPT_DIR="$(dirname "$0")"
|
||||
DEST_DIR="$SCRIPT_DIR/_gen_all_test"
|
||||
|
||||
TIMESTAMP=$(date +%F@%H%M) #Example format: 2006-09-15@1228
|
||||
LOG_FILE="$DEST_DIR/${TIMESTAMP}-$(basename "$0").txt" #log file with same name as script
|
||||
|
||||
rm -r "$DEST_DIR" &> /dev/null
|
||||
mkdir "$DEST_DIR" &> /dev/null
|
||||
|
||||
{
|
||||
# Use option --verbose for more messages
|
||||
echo "googleapiconv --all --icon --keepjson --timestamp --output=$DEST_DIR/"
|
||||
"$SCRIPT_DIR/googleapiconv" --all --icon --keepjson --timestamp --output="$DEST_DIR/"
|
||||
|
||||
# Check to see if we have any missing generated .pp files
|
||||
echo ""
|
||||
((COUNT=0))
|
||||
for FILE in "$DEST_DIR/"*.json; do
|
||||
JSON_NAME="${FILE##*/}"
|
||||
PASCAL_NAME="${JSON_NAME%.*}.pp"
|
||||
if [ ! -s "$DEST_DIR/$PASCAL_NAME" ]; then
|
||||
echo "** Missing or empty file: JSON file $JSON_NAME did not generate $PASCAL_NAME"
|
||||
((COUNT++))
|
||||
fi
|
||||
done
|
||||
echo "Missing File Count = $COUNT"
|
||||
|
||||
} |& tee "$LOG_FILE" #output both stdout and stderr to logfile and terminal
|
Loading…
Reference in New Issue
Block a user