1cb93a386Sopenharmony_ci#!/usr/bin/env python 2cb93a386Sopenharmony_ci# 3cb93a386Sopenharmony_ci# Copyright 2016 Google Inc. 4cb93a386Sopenharmony_ci# 5cb93a386Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 6cb93a386Sopenharmony_ci# found in the LICENSE file. 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci 9cb93a386Sopenharmony_ci"""Create the asset.""" 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_ciimport argparse 13cb93a386Sopenharmony_ciimport os 14cb93a386Sopenharmony_ciimport subprocess 15cb93a386Sopenharmony_ciimport sys 16cb93a386Sopenharmony_ci 17cb93a386Sopenharmony_ciFILE_DIR = os.path.dirname(os.path.abspath(__file__)) 18cb93a386Sopenharmony_ciINFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir)) 19cb93a386Sopenharmony_cisys.path.insert(0, INFRA_BOTS_DIR) 20cb93a386Sopenharmony_ciimport utils 21cb93a386Sopenharmony_ci 22cb93a386Sopenharmony_ci 23cb93a386Sopenharmony_ciSDK_VERSION='1.2.141.0' 24cb93a386Sopenharmony_ciSDK_URL=('https://sdk.lunarg.com/sdk/download/%s/linux/' 25cb93a386Sopenharmony_ci 'vulkansdk-linux-x86_64-%s.tar.gz' % (SDK_VERSION, SDK_VERSION)) 26cb93a386Sopenharmony_ci 27cb93a386Sopenharmony_ci 28cb93a386Sopenharmony_cidef create_asset(target_dir): 29cb93a386Sopenharmony_ci """Create the asset.""" 30cb93a386Sopenharmony_ci with utils.tmp_dir(): 31cb93a386Sopenharmony_ci tarball = 'vulkansdk-linux.tar.gz' 32cb93a386Sopenharmony_ci subprocess.check_call(['curl', SDK_URL, '--output', tarball]) 33cb93a386Sopenharmony_ci subprocess.check_call(['tar', '--extract', '--verbose', 34cb93a386Sopenharmony_ci '--file=%s' % tarball, '--gunzip', 35cb93a386Sopenharmony_ci '--directory=%s' % target_dir, 36cb93a386Sopenharmony_ci '--strip-components=2', 37cb93a386Sopenharmony_ci '%s/x86_64' % SDK_VERSION]) 38cb93a386Sopenharmony_ci 39cb93a386Sopenharmony_ci 40cb93a386Sopenharmony_cidef main(): 41cb93a386Sopenharmony_ci if 'linux' not in sys.platform: 42cb93a386Sopenharmony_ci print('This script only runs on Linux.', file=sys.stderr) 43cb93a386Sopenharmony_ci sys.exit(1) 44cb93a386Sopenharmony_ci parser = argparse.ArgumentParser() 45cb93a386Sopenharmony_ci parser.add_argument('--target_dir', '-t', required=True) 46cb93a386Sopenharmony_ci args = parser.parse_args() 47cb93a386Sopenharmony_ci create_asset(args.target_dir) 48cb93a386Sopenharmony_ci 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ciif __name__ == '__main__': 51cb93a386Sopenharmony_ci main() 52