#! /usr/bin/env python3

# SPDX-FileCopyrightText: 2024 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

# Script to validate a context.json against the json schema
#
# The default behavior takes a context.json file as a mandatory argument
# and it validates it agains the context_schema file in the Glass repo.
#
# If used from the default location, the relative path to the Glass repo
# is automatically configured. Otherwise, please add the corresponding
# directory to PYTHONPATH
#
import os, sys
from jsonvalidator import JSONValidator

MYPATH = os.path.dirname(os.path.realpath(__file__))
GEN_SCHEMA_PATH=os.path.join(MYPATH, "../compiler_interfaces")
sys.path.append(GEN_SCHEMA_PATH)

from schemas.context_schema import ContextJSONSchema, get_schema_version

v = JSONValidator()
rc = v.validate('context.json', ContextJSONSchema, get_schema_version())
if not rc:
    sys.exit(1)
