From: Juan Ramos Date: Wed, 21 Jun 2023 18:04:34 +0000 (-0600) Subject: cmake: Update update_deps.py logic X-Git-Tag: upstream/1.3.268~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b02d69f3a1d54e9a1f9d957bd1a389a481aa1d25;p=platform%2Fupstream%2FVulkan-Loader.git cmake: Update update_deps.py logic --- diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index a1b5daa4..bf4d7c41 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -28,15 +28,9 @@ if (UPDATE_DEPS) list(APPEND update_dep_command "${CMAKE_GENERATOR}") if (CMAKE_GENERATOR_PLATFORM) - set(_target_arch ${CMAKE_GENERATOR_PLATFORM}) - else() - if (MSVC_IDE) - message(WARNING "CMAKE_GENERATOR_PLATFORM not set. Using x64 as target architecture.") - endif() - set(_target_arch x64) + list(APPEND update_dep_command "--arch") + list(APPEND update_dep_command "${CMAKE_GENERATOR_PLATFORM}") endif() - list(APPEND update_dep_command "--arch") - list(APPEND update_dep_command "${_target_arch}") if (NOT CMAKE_BUILD_TYPE) message(WARNING "CMAKE_BUILD_TYPE not set. Using Debug for dependency build type") @@ -88,12 +82,16 @@ if (UPDATE_DEPS) set(UPDATE_DEPS_HASH "0" CACHE STRING "Default value until we run update_deps.py") mark_as_advanced(UPDATE_DEPS_HASH) + if ("${UPDATE_DEPS_HASH}" STREQUAL "0") + list(APPEND update_dep_command "--clean-build") + list(APPEND update_dep_command "--clean-install") + endif() + if ("${md5_hash}" STREQUAL $CACHE{UPDATE_DEPS_HASH}) message(DEBUG "update_deps.py: no work to do.") else() execute_process( COMMAND ${Python3_EXECUTABLE} ${update_dep_command} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE _update_deps_result ) if (NOT (${_update_deps_result} EQUAL 0)) @@ -103,13 +101,12 @@ if (UPDATE_DEPS) include("${UPDATE_DEPS_DIR}/helper.cmake") endif() endif() - if (VULKAN_HEADERS_INSTALL_DIR) list(APPEND CMAKE_PREFIX_PATH ${VULKAN_HEADERS_INSTALL_DIR}) endif() if (CMAKE_CROSSCOMPILING) - set(CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CMAKE_PREFIX_PATH} PARENT_SCOPE) else() set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE) endif() diff --git a/scripts/update_deps.py b/scripts/update_deps.py index 7664a55f..937c7902 100755 --- a/scripts/update_deps.py +++ b/scripts/update_deps.py @@ -3,6 +3,7 @@ # Copyright 2017 The Glslang Authors. All rights reserved. # Copyright (c) 2018-2023 Valve Corporation # Copyright (c) 2018-2023 LunarG, Inc. +# Copyright (c) 2023-2023 RasterGrid Kft. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -31,11 +32,6 @@ this home repository depend on. It also checks out each dependent repository at a "known-good" commit in order to provide stability in the dependent repositories. -Python Compatibility --------------------- - -This program can be used with Python 2.7 and Python 3. - Known-Good JSON Database ------------------------ @@ -117,6 +113,10 @@ examples of all of these elements. The name of the dependent repository. This field can be referenced by the "deps.repo_name" structure to record a dependency. +- api + +The name of the API the dependency is specific to (e.g. "vulkan"). + - url Specifies the URL of the repository. @@ -233,8 +233,6 @@ option can be a relative or absolute path. """ -from __future__ import print_function - import argparse import json import os.path @@ -264,7 +262,7 @@ DEVNULL = open(os.devnull, 'wb') def on_rm_error( func, path, exc_info): """Error handler for recursively removing a directory. The shutil.rmtree function can fail on Windows due to read-only files. - This handler will change the permissions for tha file and continue. + This handler will change the permissions for the file and continue. """ os.chmod( path, stat.S_IWRITE ) os.unlink( path ) @@ -335,6 +333,7 @@ class GoodRepo(object): self.build_step = json['build_step'] if ('build_step' in json) else 'build' self.build_platforms = json['build_platforms'] if ('build_platforms' in json) else [] self.optional = set(json.get('optional', [])) + self.api = json['api'] if ('api' in json) else None # Absolute paths for a repo's directories dir_top = os.path.abspath(args.dir) self.repo_dir = os.path.join(dir_top, self.sub_dir) @@ -425,9 +424,11 @@ class GoodRepo(object): def CMakeConfig(self, repos): """Build CMake command for the configuration phase and execute it""" if self._args.do_clean_build: - shutil.rmtree(self.build_dir) + if os.path.isdir(self.build_dir): + shutil.rmtree(self.build_dir, onerror=on_rm_error) if self._args.do_clean_install: - shutil.rmtree(self.install_dir) + if os.path.isdir(self.install_dir): + shutil.rmtree(self.install_dir, onerror=on_rm_error) # Create and change to build directory make_or_exist_dirs(self.build_dir) @@ -579,6 +580,10 @@ def CreateHelper(args, repos, filename): install_names = GetInstallNames(args) with open(filename, 'w') as helper_file: for repo in repos: + # If the repo has an API tag and that does not match + # the target API then skip it + if repo.api is not None and repo.api != args.api: + continue if install_names and repo.name in install_names and repo.on_build_platform: helper_file.write('set({var} "{dir}" CACHE STRING "" FORCE)\n' .format( @@ -654,6 +659,12 @@ def main(): type=str.lower, help="Set build files configuration", default='debug') + parser.add_argument( + '--api', + dest='api', + default='vulkan', + choices=['vulkan'], + help="Target API") parser.add_argument( '--generator', dest='generator', @@ -685,6 +696,11 @@ def main(): print('Starting builds in {d}'.format(d=abs_top_dir)) for repo in repos: + # If the repo has an API tag and that does not match + # the target API then skip it + if repo.api is not None and repo.api != args.api: + continue + # If the repo has a platform whitelist, skip the repo # unless we are building on a whitelisted platform. if not repo.on_build_platform: