Add ci action to automate running autogen

This commit is contained in:
Charles Giessen 2022-02-15 21:29:05 -07:00 committed by Charles Giessen
parent d299f782e6
commit b87fcf2da2
5 changed files with 98 additions and 5 deletions

View File

@ -62,6 +62,7 @@ jobs:
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y xorg-dev
- name: CMake Configure

47
.github/workflows/run_autogen.yml vendored Normal file
View File

@ -0,0 +1,47 @@
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the “Software”), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Copyright © 2022 Charles Giessen (charles@lunarg.com)
#
# The purpose of this script is to automatically run the autogen code every week and submit a PR to include the changes
on:
schedule:
- cron: '0 0 * * 2'
workflow_dispatch:
jobs:
test_schedule:
name: Test schedule
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Run dispatch generator
run: echo "python script/generate_dispatch.py --auto"
python script/generate_dispatch.py --auto
- name: Diff source to see if anything changed
id: git-diff
run: echo "::set-output name=git-diff::$(git diff --quiet HEAD~1 HEAD -- apps/api/src || echo true)"
- name: pull-request
uses: repo-sync/pull-request@v2
if: ${{ steps.git-diff.outputs.git-diff == 'true' }}
with:
destination_branch: "develop"
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "[auto] Update repo to latest Vulkan-Headers"

View File

@ -8,6 +8,8 @@ add_library(vk-bootstrap-vulkan-headers INTERFACE)
set(VK_BOOTSTRAP_VULKAN_HEADER_DIR "" CACHE STRING "Specify the location of the Vulkan-Headers include directory.")
mark_as_advanced(VK_BOOTSTRAP_VULKAN_HEADER_DIR)
include(gen/CurrentBuildVulkanVersion.cmake)
if(NOT "${VK_BOOTSTRAP_VULKAN_HEADER_DIR}" STREQUAL "")
target_include_directories(vk-bootstrap-vulkan-headers INTERFACE $<BUILD_INTERFACE:${VK_BOOTSTRAP_VULKAN_HEADER_DIR}>)
else ()
@ -18,7 +20,7 @@ else ()
FetchContent_Declare(
VulkanHeaders
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers
GIT_TAG v1.3.204
GIT_TAG ${VK_BOOTSTRAP_SOURCE_HEADER_VERSION_GIT_TAG}
)
FetchContent_MakeAvailable(VulkanHeaders)
target_link_libraries(vk-bootstrap-vulkan-headers INTERFACE Vulkan::Headers)

View File

@ -0,0 +1,2 @@
set(VK_BOOTSTRAP_SOURCE_HEADER_VERSION 1.3.205)
set(VK_BOOTSTRAP_SOURCE_HEADER_VERSION_GIT_TAG v1.3.205)

View File

@ -28,6 +28,9 @@
# https://github.com/martinblech/xmltodict
# User will be prompted to install if not detected
# Command Line Arguments
# [--auto] Don't ask for input from the command line
# Exclusions
exclusions = [
'vkGetDeviceProcAddr',
@ -42,10 +45,12 @@ excluded_extension_authors = [
# Check for/install xmltodict
import sys
import os
import subprocess
import pkg_resources
import copy
import codecs
import re
from string import Template
installed = {pkg.key for pkg in pkg_resources.working_set}
@ -53,14 +58,18 @@ xmltodict_missing = {'xmltodict'} - installed
# Install xmltodict
if xmltodict_missing:
val = input("xmltodict is required to run this script. Would you like to install? (y/n): ")
if '--auto' not in sys.argv:
val = input("xmltodict is required to run this script. Would you like to install? (y/n): ")
else:
val = "y"
if(val.lower() == "y"):
try:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'xmltodict'])
except subprocess.CalledProcessError as error:
print("Failed to install xmltodict due to error:")
print(error)
input("Press Enter to continue...")
if '--auto' not in sys.argv:
input("Press Enter to continue...")
sys.exit()
else:
sys.exit()
@ -74,7 +83,8 @@ try:
except urllib.error.URLError as error:
print("Failed to download vk.xml due to error:")
print(error.reason)
input("Press Enter to continue...")
if '-q' not in sys.argv:
input("Press Enter to continue...")
sys.exit()
vk_xml_raw = response.read()
@ -308,10 +318,41 @@ body += '\t bool populated = false;\n'
body += '};\n\n'
body += '} // namespace vkb'
# find the version used to generate the code
for type_node in types_node:
if 'name' in type_node and type_node['name'] == 'VK_HEADER_VERSION_COMPLETE':
complete_header_version = type_node["#text"]
if 'name' in type_node and type_node['name'] == 'VK_HEADER_VERSION':
vk_header_version = type_node['#text']
find_number_fields = re.compile('[0-9]+')
version_fields = find_number_fields.findall(complete_header_version)
header_version_field = find_number_fields.findall(vk_header_version)[0]
version_tag = f'{version_fields[1]}.{version_fields[2]}.{header_version_field}'
header = license + info + body
header_file = codecs.open("../src/VkBootstrapDispatch.h", "w", "utf-8")
path_to_src = os.path.join('src')
if not os.path.exists(path_to_src):
path_to_src = os.path.join('..', 'src')
if not os.path.exists(path_to_src):
print("Couldn't find source folder. Is the current directory wrong?")
sys.exit()
header_file = codecs.open(os.path.join(path_to_src,"VkBootstrapDispatch.h"), "w", "utf-8")
header_file.write(header)
header_file.close()
path_to_gen = os.path.join('gen')
if not os.path.exists(path_to_gen):
path_to_gen = os.path.join('..', 'gen')
if not os.path.exists(path_to_gen):
print("Couldn't find gen folder. Is the current directory wrong?")
sys.exit()
# Generate a CMake file that contains the header version used.
cmake_version_file = codecs.open(os.path.join(path_to_gen,"CurrentBuildVulkanVersion.cmake"), "w", "utf-8")
cmake_version_file.write(f'set(VK_BOOTSTRAP_SOURCE_HEADER_VERSION {version_tag})\n')
cmake_version_file.write(f'set(VK_BOOTSTRAP_SOURCE_HEADER_VERSION_GIT_TAG v{version_tag})\n')
cmake_version_file.close()
print("Generation finished.")