syntax_check.sh 3.11 KB
Newer Older
ritterth's avatar
ritterth committed
#!/bin/sh -e
# ----------------------------------------------------
# This script uses the Open Source asn1c to check all used ASN.1 modules
# are compile clean (no guarantee the generated code is valid).
#
# The used compile binary was built from here:
#   https://github.com/brchiu/asn1c/commits/velichkov_s1ap_plus_option_group_plus_adding_trailing_ull
#
# The referenced ISO ASN.1 modules are pulled from the ISO Standards Maintenance Portal
# Yet not all are compile clean, thus minor fixed need to be done.
# All these changes are irrelevant for the resulting encoding.
#  - Fixing duplicate DE tags
#  - Fixing OID typo
#  - Removing unused types (which bloat the IMPORTS)
# ----------------------------------------------------

# set -x
ASN_CACHE=".external"

mkdir -p ${ASN_CACHE}

if [ ! -f ${ASN_CACHE}/ISO19321IVIv2-patched.asn ]; then
  wget -P ${ASN_CACHE} 'https://standards.iso.org/iso/ts/19321/ed-2/en/ISO19321IVIv2.asn'
  sed -e 's/^FROM DSRC.*/FROM ETSI-ITS-DSRC { itu-t (0) identified-organization (4) etsi (0) itsDomain (5) wg1 (1) ts103301 (103301) dsrc (6) version2 (2) }/g' \
      -e 's/^FROM ITS-Container.*/FROM ETSI-ITS-CDD { itu-t (0) identified-organization (4) etsi (0) itsDomain (5) wg1 (1) 102894 cdd (2) major-version-3 (3) minor-version-1 (1) }/g' \
      ${ASN_CACHE}/ISO19321IVIv2.asn > ${ASN_CACHE}/ISO19321IVIv2-patched.asn
fi

ASN1_SRC="\
 DSRC-addgrp-C.asn \
 DSRC-region.asn \
 DSRC.asn \
 cdd/ETSI-ITS-CDD.asn"

ritterth's avatar
ritterth committed
asnimports.py --verbose -o ${ASN_CACHE} ${ASN1_SRC} > ${ASN_CACHE}/dsrc-ext-modules
ritterth's avatar
ritterth committed

ASN1C_OPTIONS="-E -F -fcompound-names -fknown-extern-type=DATE"

asn1c ${ASN1C_OPTIONS} -pdu=SPATEM \
	SPATEM-PDU-Descriptions.asn \
    DSRC-addgrp-C.asn \
    DSRC-region.asn \
    DSRC.asn \
	cdd/ETSI-ITS-CDD.asn \
    $(cat ${ASN_CACHE}/dsrc-ext-modules) \
    > /dev/null

asn1c ${ASN1C_OPTIONS} -pdu=MAPEM \
	MAPEM-PDU-Descriptions.asn \
    DSRC.asn \
    DSRC-region.asn \
    DSRC-addgrp-C.asn \
	cdd/ETSI-ITS-CDD.asn \
    $(cat ${ASN_CACHE}/dsrc-ext-modules) \
    > /dev/null

asn1c ${ASN1C_OPTIONS} -pdu=SREM \
	SREM-PDU-Descriptions.asn \
    DSRC.asn \
    DSRC-region.asn \
    DSRC-addgrp-C.asn \
	cdd/ETSI-ITS-CDD.asn \
    $(cat ${ASN_CACHE}/dsrc-ext-modules) \
    > /dev/null

asn1c ${ASN1C_OPTIONS} -pdu=SSEM \
	SSEM-PDU-Descriptions.asn \
    DSRC.asn \
    DSRC-region.asn \
    DSRC-addgrp-C.asn \
	cdd/ETSI-ITS-CDD.asn \
    $(cat ${ASN_CACHE}/dsrc-ext-modules) \
    > /dev/null

asn1c ${ASN1C_OPTIONS} -pdu=RTCMEM \
	RTCMEM-PDU-Descriptions.asn \
    DSRC.asn \
    DSRC-region.asn \
    DSRC-addgrp-C.asn \
	cdd/ETSI-ITS-CDD.asn \
    $(cat ${ASN_CACHE}/dsrc-ext-modules) \
    > /dev/null

asn1c ${ASN1C_OPTIONS} -pdu=IVIM \
	IVIM-PDU-Descriptions.asn \
    DSRC.asn \
    DSRC-region.asn \
    DSRC-addgrp-C.asn \
	cdd/ETSI-ITS-CDD.asn \
    ${ASN_CACHE}/ISO19321IVIv2-patched.asn \
	iso-patched/ISO14823-missing.asn \
	'iso-patched/ISO14906(2018)EfcDsrcGenericv7-patched.asn' \
	'iso-patched/ISO14906(2018)EfcDsrcApplicationv6-patched.asn' \
    $(cat ${ASN_CACHE}/dsrc-ext-modules) \
    > /dev/null

echo "++++++++++++++++++++++++"
echo "+++ SUCCESS"
echo "+++ All modules compiled"
echo "++++++++++++++++++++++++"