scripts: Improve 'generate-orchestra' script
Align 'generate-orchestra' with 'generate-repository' and generate
both FIX Latest and FIXT 1.1 with a single command.
# 3.7 or newer.
#
# As this repository already contains the generated FIX protocol versions, you
-# only need to run this script if FIX Latest updates or you change Philadelphia
-# Code Generator.
+# only need to run this script if FIX Latest or FIXT 1.1 updates or you change
+# Philadelphia Code Generator.
#
set -e
@@ -48,21 +48,26 @@ generate() {
>> "../../$output_path")
}
-if [[ $# != 2 ]]; then
- echo "Usage: ${0##*/} <configuration-file> <input-file>" >&2
- exit 2
-fi
-
-config_file=$1
-input_file=$2
+generate_version() {
+ local input_file=$1
+ local output_prefix=$2
-class_name_prefix=$(grep class-name-prefix "$config_file")
+ local output_module=${output_prefix,,}
-output_prefix=${class_name_prefix#class-name-prefix=}
-output_module=${output_prefix,,}
-
-output_dir="libraries/$output_module/src/main/java/com/paritytrading/philadelphia/$output_module"
+ local config_file="scripts/config-$output_module.ini"
+ local output_dir="libraries/$output_module/src/main/java/com/paritytrading/philadelphia/$output_module"
generate enumerations "$config_file" "$input_file" "$output_dir/${output_prefix}Enumerations.java"
generate msg-types "$config_file" "$input_file" "$output_dir/${output_prefix}MsgTypes.java"
generate tags "$config_file" "$input_file" "$output_dir/${output_prefix}Tags.java"
+}
+
+if [[ $# != 1 ]]; then
+ echo "Usage: ${0##*/} <input-directory>" >&2
+ exit 2
+fi
+
+input_dir=$1
+
+generate_version "$input_dir/OrchestraFIXLatest.xml" "FIXLatest"
+generate_version "$input_dir/FIXTSession.xml" "FIXT11"
