gen_data.py: sort files when generating mesondata

The current way this works is chaos since the tool might return files in
any order and thus shuffle around the order of embedded files. This
results in big diffs that cannot be easily reviewed.

Also regenerate the data according to the, going forward, canonical
ordering algorithm.
pull/8195/head
Eli Schwartz 4 years ago
parent e6a167ce09
commit 0063bd35d7
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 222
      mesonbuild/mesondata.py
  2. 2
      tools/gen_data.py

@ -1,4 +1,4 @@
# Copyright 2020 The Meson development team # Copyright 2021 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -30,7 +30,108 @@ if T.TYPE_CHECKING:
# BEGIN Data section # # BEGIN Data section #
###################### ######################
file_0_data_CMakeListsLLVM_txt = '''\ file_0_data_CMakeLists_txt = '''\
# fail noisily if attempt to use this file without setting:
# cmake_minimum_required(VERSION ${CMAKE_VERSION})
# project(... LANGUAGES ...)
cmake_policy(SET CMP0000 NEW)
set(PACKAGE_FOUND FALSE)
set(_packageName "${NAME}")
string(TOUPPER "${_packageName}" PACKAGE_NAME)
while(TRUE)
if ("${VERSION}" STREQUAL "")
find_package("${NAME}" QUIET COMPONENTS ${COMPS})
else()
find_package("${NAME}" "${VERSION}" QUIET COMPONENTS ${COMPS})
endif()
# ARCHS has to be set via the CMD interface
if(${_packageName}_FOUND OR ${PACKAGE_NAME}_FOUND OR "${ARCHS}" STREQUAL "")
break()
endif()
list(GET ARCHS 0 CMAKE_LIBRARY_ARCHITECTURE)
list(REMOVE_AT ARCHS 0)
endwhile()
if(${_packageName}_FOUND OR ${PACKAGE_NAME}_FOUND)
set(PACKAGE_FOUND TRUE)
# Check the following variables:
# FOO_VERSION
# Foo_VERSION
# FOO_VERSION_STRING
# Foo_VERSION_STRING
if(NOT DEFINED PACKAGE_VERSION)
if(DEFINED ${_packageName}_VERSION)
set(PACKAGE_VERSION "${${_packageName}_VERSION}")
elseif(DEFINED ${PACKAGE_NAME}_VERSION)
set(PACKAGE_VERSION "${${PACKAGE_NAME}_VERSION}")
elseif(DEFINED ${_packageName}_VERSION_STRING)
set(PACKAGE_VERSION "${${_packageName}_VERSION_STRING}")
elseif(DEFINED ${PACKAGE_NAME}_VERSION_STRING)
set(PACKAGE_VERSION "${${PACKAGE_NAME}_VERSION_STRING}")
endif()
endif()
# Check the following variables:
# FOO_LIBRARIES
# Foo_LIBRARIES
# FOO_LIBS
# Foo_LIBS
set(libs)
if(DEFINED ${_packageName}_LIBRARIES)
set(libs ${_packageName}_LIBRARIES)
elseif(DEFINED ${PACKAGE_NAME}_LIBRARIES)
set(libs ${PACKAGE_NAME}_LIBRARIES)
elseif(DEFINED ${_packageName}_LIBS)
set(libs ${_packageName}_LIBS)
elseif(DEFINED ${PACKAGE_NAME}_LIBS)
set(libs ${PACKAGE_NAME}_LIBS)
endif()
# Check the following variables:
# FOO_INCLUDE_DIRS
# Foo_INCLUDE_DIRS
# FOO_INCLUDES
# Foo_INCLUDES
# FOO_INCLUDE_DIR
# Foo_INCLUDE_DIR
set(includes)
if(DEFINED ${_packageName}_INCLUDE_DIRS)
set(includes ${_packageName}_INCLUDE_DIRS)
elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIRS)
set(includes ${PACKAGE_NAME}_INCLUDE_DIRS)
elseif(DEFINED ${_packageName}_INCLUDES)
set(includes ${_packageName}_INCLUDES)
elseif(DEFINED ${PACKAGE_NAME}_INCLUDES)
set(includes ${PACKAGE_NAME}_INCLUDES)
elseif(DEFINED ${_packageName}_INCLUDE_DIR)
set(includes ${_packageName}_INCLUDE_DIR)
elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIR)
set(includes ${PACKAGE_NAME}_INCLUDE_DIR)
endif()
# Check the following variables:
# FOO_DEFINITIONS
# Foo_DEFINITIONS
set(definitions)
if(DEFINED ${_packageName}_DEFINITIONS)
set(definitions ${_packageName}_DEFINITIONS)
elseif(DEFINED ${PACKAGE_NAME}_DEFINITIONS)
set(definitions ${PACKAGE_NAME}_DEFINITIONS)
endif()
set(PACKAGE_INCLUDE_DIRS "${${includes}}")
set(PACKAGE_DEFINITIONS "${${definitions}}")
set(PACKAGE_LIBRARIES "${${libs}}")
endif()
'''
file_1_data_CMakeListsLLVM_txt = '''\
cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} ) cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} )
set(PACKAGE_FOUND FALSE) set(PACKAGE_FOUND FALSE)
@ -128,7 +229,7 @@ if(LLVM_FOUND)
endif() endif()
''' '''
file_1_data_CMakePathInfo_txt = '''\ file_2_data_CMakePathInfo_txt = '''\
cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}) cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})
set(TMP_PATHS_LIST) set(TMP_PATHS_LIST)
@ -162,107 +263,6 @@ set(MESON_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH})
message(STATUS ${TMP_PATHS_LIST}) message(STATUS ${TMP_PATHS_LIST})
''' '''
file_2_data_CMakeLists_txt = '''\
# fail noisily if attempt to use this file without setting:
# cmake_minimum_required(VERSION ${CMAKE_VERSION})
# project(... LANGUAGES ...)
cmake_policy(SET CMP0000 NEW)
set(PACKAGE_FOUND FALSE)
set(_packageName "${NAME}")
string(TOUPPER "${_packageName}" PACKAGE_NAME)
while(TRUE)
if ("${VERSION}" STREQUAL "")
find_package("${NAME}" QUIET COMPONENTS ${COMPS})
else()
find_package("${NAME}" "${VERSION}" QUIET COMPONENTS ${COMPS})
endif()
# ARCHS has to be set via the CMD interface
if(${_packageName}_FOUND OR ${PACKAGE_NAME}_FOUND OR "${ARCHS}" STREQUAL "")
break()
endif()
list(GET ARCHS 0 CMAKE_LIBRARY_ARCHITECTURE)
list(REMOVE_AT ARCHS 0)
endwhile()
if(${_packageName}_FOUND OR ${PACKAGE_NAME}_FOUND)
set(PACKAGE_FOUND TRUE)
# Check the following variables:
# FOO_VERSION
# Foo_VERSION
# FOO_VERSION_STRING
# Foo_VERSION_STRING
if(NOT DEFINED PACKAGE_VERSION)
if(DEFINED ${_packageName}_VERSION)
set(PACKAGE_VERSION "${${_packageName}_VERSION}")
elseif(DEFINED ${PACKAGE_NAME}_VERSION)
set(PACKAGE_VERSION "${${PACKAGE_NAME}_VERSION}")
elseif(DEFINED ${_packageName}_VERSION_STRING)
set(PACKAGE_VERSION "${${_packageName}_VERSION_STRING}")
elseif(DEFINED ${PACKAGE_NAME}_VERSION_STRING)
set(PACKAGE_VERSION "${${PACKAGE_NAME}_VERSION_STRING}")
endif()
endif()
# Check the following variables:
# FOO_LIBRARIES
# Foo_LIBRARIES
# FOO_LIBS
# Foo_LIBS
set(libs)
if(DEFINED ${_packageName}_LIBRARIES)
set(libs ${_packageName}_LIBRARIES)
elseif(DEFINED ${PACKAGE_NAME}_LIBRARIES)
set(libs ${PACKAGE_NAME}_LIBRARIES)
elseif(DEFINED ${_packageName}_LIBS)
set(libs ${_packageName}_LIBS)
elseif(DEFINED ${PACKAGE_NAME}_LIBS)
set(libs ${PACKAGE_NAME}_LIBS)
endif()
# Check the following variables:
# FOO_INCLUDE_DIRS
# Foo_INCLUDE_DIRS
# FOO_INCLUDES
# Foo_INCLUDES
# FOO_INCLUDE_DIR
# Foo_INCLUDE_DIR
set(includes)
if(DEFINED ${_packageName}_INCLUDE_DIRS)
set(includes ${_packageName}_INCLUDE_DIRS)
elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIRS)
set(includes ${PACKAGE_NAME}_INCLUDE_DIRS)
elseif(DEFINED ${_packageName}_INCLUDES)
set(includes ${_packageName}_INCLUDES)
elseif(DEFINED ${PACKAGE_NAME}_INCLUDES)
set(includes ${PACKAGE_NAME}_INCLUDES)
elseif(DEFINED ${_packageName}_INCLUDE_DIR)
set(includes ${_packageName}_INCLUDE_DIR)
elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIR)
set(includes ${PACKAGE_NAME}_INCLUDE_DIR)
endif()
# Check the following variables:
# FOO_DEFINITIONS
# Foo_DEFINITIONS
set(definitions)
if(DEFINED ${_packageName}_DEFINITIONS)
set(definitions ${_packageName}_DEFINITIONS)
elseif(DEFINED ${PACKAGE_NAME}_DEFINITIONS)
set(definitions ${PACKAGE_NAME}_DEFINITIONS)
endif()
set(PACKAGE_INCLUDE_DIRS "${${includes}}")
set(PACKAGE_DEFINITIONS "${${definitions}}")
set(PACKAGE_LIBRARIES "${${libs}}")
endif()
'''
file_3_data_preload_cmake = '''\ file_3_data_preload_cmake = '''\
if(MESON_PS_LOADED) if(MESON_PS_LOADED)
return() return()
@ -371,20 +371,20 @@ class DataFile:
mesondata = { mesondata = {
'dependencies/data/CMakeLists.txt': DataFile(
Path('dependencies/data/CMakeLists.txt'),
'4dca24afa13e9311f0598a6ac29690490819bd7d82cfdaa0a2fe5eea3c0fa0d5',
file_0_data_CMakeLists_txt,
),
'dependencies/data/CMakeListsLLVM.txt': DataFile( 'dependencies/data/CMakeListsLLVM.txt': DataFile(
Path('dependencies/data/CMakeListsLLVM.txt'), Path('dependencies/data/CMakeListsLLVM.txt'),
'412cec3315597041a978d018cdaca282dcd47693793540da88ae2f80d0cbd7cd', '412cec3315597041a978d018cdaca282dcd47693793540da88ae2f80d0cbd7cd',
file_0_data_CMakeListsLLVM_txt, file_1_data_CMakeListsLLVM_txt,
), ),
'dependencies/data/CMakePathInfo.txt': DataFile( 'dependencies/data/CMakePathInfo.txt': DataFile(
Path('dependencies/data/CMakePathInfo.txt'), Path('dependencies/data/CMakePathInfo.txt'),
'90da8b443982d9c87139b7dc84228eb58cab4315764949637208f25e2bda7db2', '90da8b443982d9c87139b7dc84228eb58cab4315764949637208f25e2bda7db2',
file_1_data_CMakePathInfo_txt, file_2_data_CMakePathInfo_txt,
),
'dependencies/data/CMakeLists.txt': DataFile(
Path('dependencies/data/CMakeLists.txt'),
'4dca24afa13e9311f0598a6ac29690490819bd7d82cfdaa0a2fe5eea3c0fa0d5',
file_2_data_CMakeLists_txt,
), ),
'cmake/data/preload.cmake': DataFile( 'cmake/data/preload.cmake': DataFile(
Path('cmake/data/preload.cmake'), Path('cmake/data/preload.cmake'),

@ -48,7 +48,7 @@ def main() -> int:
data_files: T.List[DataFile] = [] data_files: T.List[DataFile] = []
for d in data_dirs: for d in data_dirs:
for p in d.iterdir(): for p in sorted(d.iterdir()):
data_files += [DataFile(p, mesonbuild_dir)] data_files += [DataFile(p, mesonbuild_dir)]
print(f'Found {len(data_files)} data files') print(f'Found {len(data_files)} data files')

Loading…
Cancel
Save