blob: 606845196caf783ca5b1f9646248da8134e3aea0 [file] [log] [blame]
#!/usr/bin/python3 -i
#
# Copyright (c) 2015-2017, 2019-2020 The Khronos Group Inc.
# Copyright (c) 2015-2017, 2019-2020 Valve Corporation
# Copyright (c) 2015-2017, 2019-2020 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Mark Lobodzinski <mark@lunarg.com>
import os
import sys
import subprocess
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], '..'))
if sys.version_info[0] != 3:
print("This script requires Python 3. Run script with [-h] option for more details.")
sys_exit(0)
# helper to define paths relative to the repo root
def repo_relative(path):
return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', path))
# Runs a command in a directory and returns its return code.
# Directory is project root by default, or a relative path from project root
def RunShellCmd(command, start_dir = PROJECT_ROOT):
if start_dir != PROJECT_ROOT:
start_dir = repo_relative(start_dir)
cmd_list = command.split(" ")
subprocess.check_call(cmd_list, cwd=start_dir)