1#!/usr/bin/env bash 2 3set -euxo pipefail 4 5mkdir -p out/ 6OUT_DIR="$(pwd)/out" 7 8# move to `pdl-compiler` directory 9cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &> /dev/null 10 11sed -e 's/little_endian_packets/big_endian_packets/' \ 12 -e '/Start: little_endian_only/,/End: little_endian_only/d' \ 13 < tests/canonical/le_test_file.pdl > "$OUT_DIR"/be_test_file.pdl 14 15pdlc tests/canonical/le_test_file.pdl > "$OUT_DIR"/le_test_file.json 16pdlc "$OUT_DIR"/be_test_file.pdl > "$OUT_DIR"/be_test_file.json 17 18python3 scripts/generate_cxx_backend.py \ 19 --input "$OUT_DIR"/le_test_file.json \ 20 --output "$OUT_DIR"/le_backend.h \ 21 --exclude-declaration Packet_Custom_Field_ConstantSize \ 22 --exclude-declaration Packet_Custom_Field_VariableSize \ 23 --exclude-declaration Packet_Checksum_Field_FromStart \ 24 --exclude-declaration Packet_Checksum_Field_FromEnd \ 25 --exclude-declaration Packet_Array_Field_VariableElementSize_ConstantSize \ 26 --exclude-declaration Packet_Array_Field_VariableElementSize_VariableSize \ 27 --exclude-declaration Packet_Array_Field_VariableElementSize_VariableCount \ 28 --exclude-declaration Packet_Array_Field_VariableElementSize_UnknownSize \ 29 --exclude-declaration Struct_Custom_Field_ConstantSize \ 30 --exclude-declaration Struct_Custom_Field_VariableSize \ 31 --exclude-declaration Struct_Checksum_Field_FromStart \ 32 --exclude-declaration Struct_Checksum_Field_FromEnd \ 33 --exclude-declaration Struct_Custom_Field_ConstantSize_ \ 34 --exclude-declaration Struct_Custom_Field_VariableSize_ \ 35 --exclude-declaration Struct_Checksum_Field_FromStart_ \ 36 --exclude-declaration Struct_Checksum_Field_FromEnd_ \ 37 --exclude-declaration PartialParent5 \ 38 --exclude-declaration PartialChild5_A \ 39 --exclude-declaration PartialChild5_B \ 40 --exclude-declaration PartialParent12 \ 41 --exclude-declaration PartialChild12_A \ 42 --exclude-declaration PartialChild12_B \ 43 --namespace le_backend 44python3 scripts/generate_cxx_backend.py \ 45 --input "$OUT_DIR"/be_test_file.json \ 46 --output "$OUT_DIR"/be_backend.h \ 47 --exclude-declaration Packet_Custom_Field_ConstantSize \ 48 --exclude-declaration Packet_Custom_Field_VariableSize \ 49 --exclude-declaration Packet_Checksum_Field_FromStart \ 50 --exclude-declaration Packet_Checksum_Field_FromEnd \ 51 --exclude-declaration Packet_Array_Field_VariableElementSize_ConstantSize \ 52 --exclude-declaration Packet_Array_Field_VariableElementSize_VariableSize \ 53 --exclude-declaration Packet_Array_Field_VariableElementSize_VariableCount \ 54 --exclude-declaration Packet_Array_Field_VariableElementSize_UnknownSize \ 55 --exclude-declaration Struct_Custom_Field_ConstantSize \ 56 --exclude-declaration Struct_Custom_Field_VariableSize \ 57 --exclude-declaration Struct_Checksum_Field_FromStart \ 58 --exclude-declaration Struct_Checksum_Field_FromEnd \ 59 --exclude-declaration Struct_Custom_Field_ConstantSize_ \ 60 --exclude-declaration Struct_Custom_Field_VariableSize_ \ 61 --exclude-declaration Struct_Checksum_Field_FromStart_ \ 62 --exclude-declaration Struct_Checksum_Field_FromEnd_ \ 63 --exclude-declaration PartialParent5 \ 64 --exclude-declaration PartialChild5_A \ 65 --exclude-declaration PartialChild5_B \ 66 --exclude-declaration PartialParent12 \ 67 --exclude-declaration PartialChild12_A \ 68 --exclude-declaration PartialChild12_B \ 69 --namespace be_backend 70 71python3 scripts/generate_cxx_backend_tests.py \ 72 --input "$OUT_DIR"/le_test_file.json \ 73 --output "$OUT_DIR"/le_backend_tests.cc \ 74 --test-vectors tests/canonical/le_test_vectors.json \ 75 --namespace le_backend \ 76 --parser-test-suite le_backend_parser_test \ 77 --serializer-test-suite le_backend_serializer_test \ 78 --include-header le_backend.h 79python3 scripts/generate_cxx_backend_tests.py \ 80 --input "$OUT_DIR"/be_test_file.json \ 81 --output "$OUT_DIR"/be_backend_tests.cc \ 82 --test-vectors tests/canonical/be_test_vectors.json \ 83 --namespace be_backend \ 84 --parser-test-suite be_backend_parser_test \ 85 --serializer-test-suite be_backend_serializer_test \ 86 --include-header be_backend.h 87 88g++ -Iscripts -I"$OUT_DIR" \ 89 "$OUT_DIR"/le_backend_tests.cc \ 90 "$OUT_DIR"/be_backend_tests.cc \ 91 -lgtest -lgtest_main -o "$OUT_DIR"/cxx_backend_tests 92 93"$OUT_DIR"/cxx_backend_tests \ 94 --gtest_output="xml:$OUT_DIR/cxx_backend_tests_detail.xml" 95