1#!/usr/bin/env python3 2# 3# Copyright (c) 2016-2018 The Khronos Group Inc. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# Build Promoter submission package for a specified extension or extensions. 18# This consists of one spec with the extension(s) and all dependencies, 19# one with just the dependencies, and an htmldiff of them. 20# 21# This script lives in config/, but is executed from the parent directory. 22# 23# Usage: makeSubmit extension targets 24 25import argparse, copy, io, os, pdb, re, string, subprocess, sys 26 27# Ensure config/extDependency.py is up-to-date before we import it. 28subprocess.check_call(['make', 'config/extDependency.py']) 29 30from extDependency import * 31 32def enQuote(str): 33 return '"' + str + '"' 34 35# Make a single submission target. Several are needed per document. 36# 37# outDir - where to generate intermediate and final documents 38# extensionList - list of extensions to include 39# submitName - base name of final HTML file 40# title - document title 41# target - default 'html' 42def makeTarget(outDir, extensionList, submitName, title, target): 43 print('make clean_generated') 44 print('make OUTDIR=' + outDir, 45 'EXTENSIONS="' + ' '.join(extensionList) + '"', 46 'APITITLE="' + title + '"', target) 47 # Rename into submission directory 48 outFile = outDir + '/html/' + submitName + '.html' 49 print('mv', outDir + '/html/vkspec.html', enQuote(outFile)) 50 # No longer needed 51 # print('mv -n', outDir + '/katex', 'out/submit/') 52 53 return outFile 54 55# Make submission for a list of required extension names 56def makeSubmit(submitName, required, target='html'): 57 global extensions 58 59 deps = [] 60 for name in required: 61 if name in extensions.keys(): 62 for depname in extensions[name]: 63 if (depname not in required and depname not in deps): 64 deps.append(depname) 65 66 print('echo Required extensions:', ' '.join(required)) 67 print('echo Dependent extensions:', ' '.join(deps)) 68 print('') 69 70 # Generate shell commands to build the specs 71 outDir = 'submit' 72 print('mkdir -p', outDir) 73 74 # Generate spec with required extensions + dependencies 75 newSpec = makeTarget(outDir, required + deps, submitName, 76 submitName, target) 77 78 # Generate base spec with just dependencies 79 baseSpec = makeTarget(outDir, deps, 'deps-' + submitName, 80 '(with only dependencies of ' + submitName + ')', 81 target) 82 83 # # Reorganize and rename them, and generate the diff spec 84 print('') 85 print('cd scripts') 86 print('./htmldiff', 87 enQuote('../' + baseSpec), 88 enQuote('../' + newSpec), 89 '>', 90 enQuote('../submit/html/diff-' + submitName + '.html')) 91 print('cd ..') 92 93if __name__ == '__main__': 94 parser = argparse.ArgumentParser() 95 96 parser.add_argument('-title', action='store', 97 default='vkspec', 98 help='Set the document title') 99 parser.add_argument('-extension', action='append', 100 default=[], 101 help='Specify a required extension or extensions to add to targets') 102 103 results = parser.parse_args() 104 105 makeSubmit(results.title, results.extension) 106