hs20: prepare server using uci-defaults and ship files
[feed/packages.git] / devel / meson / patches / 010-no-setuptools.patch
1 From 019ed04331695bb6f5c5fff70dfced34c4ba9012 Mon Sep 17 00:00:00 2001
2 From: Daniel Mensinger <daniel@mensinger-ka.de>
3 Date: Thu, 16 Jul 2020 20:29:34 +0200
4 Subject: [PATCH 1/3] mdata: Generate mesondata.py from */data folders
5
6 ---
7 mesonbuild/mesondata.py | 374 ++++++++++++++++++++++++++++++++++++++++
8 tools/gen_data.py | 139 +++++++++++++++
9 2 files changed, 513 insertions(+)
10 create mode 100644 mesonbuild/mesondata.py
11 create mode 100755 tools/gen_data.py
12
13 diff --git a/mesonbuild/mesondata.py b/mesonbuild/mesondata.py
14 new file mode 100644
15 index 0000000000..1f223c251b
16 --- /dev/null
17 +++ b/mesonbuild/mesondata.py
18 @@ -0,0 +1,374 @@
19 +# Copyright 2020 The Meson development team
20 +
21 +# Licensed under the Apache License, Version 2.0 (the "License");
22 +# you may not use this file except in compliance with the License.
23 +# You may obtain a copy of the License at
24 +
25 +# http://www.apache.org/licenses/LICENSE-2.0
26 +
27 +# Unless required by applicable law or agreed to in writing, software
28 +# distributed under the License is distributed on an "AS IS" BASIS,
29 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 +# See the License for the specific language governing permissions and
31 +# limitations under the License.
32 +
33 +
34 +####
35 +#### WARNING: This is an automatically generated file! Do not edit!
36 +#### Generated by tools/gen_data.py
37 +####
38 +
39 +
40 +from pathlib import Path
41 +import typing as T
42 +
43 +if T.TYPE_CHECKING:
44 + from .environment import Environment
45 +
46 +######################
47 +# BEGIN Data section #
48 +######################
49 +
50 +file_0_data_CMakeListsLLVM_txt = '''\
51 +cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} )
52 +
53 +set(PACKAGE_FOUND FALSE)
54 +
55 +while(TRUE)
56 + find_package(LLVM REQUIRED CONFIG QUIET)
57 +
58 + # ARCHS has to be set via the CMD interface
59 + if(LLVM_FOUND OR "${ARCHS}" STREQUAL "")
60 + break()
61 + endif()
62 +
63 + list(GET ARCHS 0 CMAKE_LIBRARY_ARCHITECTURE)
64 + list(REMOVE_AT ARCHS 0)
65 +endwhile()
66 +
67 +if(LLVM_FOUND)
68 + set(PACKAGE_FOUND TRUE)
69 +
70 + foreach(mod IN LISTS LLVM_MESON_MODULES)
71 + # Reset variables
72 + set(out_mods)
73 + set(real_mods)
74 +
75 + # Generate a lower and upper case version
76 + string(TOLOWER "${mod}" mod_L)
77 + string(TOUPPER "${mod}" mod_U)
78 +
79 + # Get the mapped components
80 + llvm_map_components_to_libnames(out_mods ${mod} ${mod_L} ${mod_U})
81 + list(SORT out_mods)
82 + list(REMOVE_DUPLICATES out_mods)
83 +
84 + # Make sure that the modules exist
85 + foreach(i IN LISTS out_mods)
86 + if(TARGET ${i})
87 + list(APPEND real_mods ${i})
88 + endif()
89 + endforeach()
90 +
91 + # Set the output variables
92 + set(MESON_LLVM_TARGETS_${mod} ${real_mods})
93 + foreach(i IN LISTS real_mods)
94 + set(MESON_TARGET_TO_LLVM_${i} ${mod})
95 + endforeach()
96 + endforeach()
97 +
98 + # Check the following variables:
99 + # LLVM_PACKAGE_VERSION
100 + # LLVM_VERSION
101 + # LLVM_VERSION_STRING
102 + if(NOT DEFINED PACKAGE_VERSION)
103 + if(DEFINED LLVM_PACKAGE_VERSION)
104 + set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
105 + elseif(DEFINED LLVM_VERSION)
106 + set(PACKAGE_VERSION "${LLVM_VERSION}")
107 + elseif(DEFINED LLVM_VERSION_STRING)
108 + set(PACKAGE_VERSION "${LLVM_VERSION_STRING}")
109 + endif()
110 + endif()
111 +
112 + # Check the following variables:
113 + # LLVM_LIBRARIES
114 + # LLVM_LIBS
115 + set(libs)
116 + if(DEFINED LLVM_LIBRARIES)
117 + set(libs LLVM_LIBRARIES)
118 + elseif(DEFINED LLVM_LIBS)
119 + set(libs LLVM_LIBS)
120 + endif()
121 +
122 + # Check the following variables:
123 + # LLVM_INCLUDE_DIRS
124 + # LLVM_INCLUDES
125 + # LLVM_INCLUDE_DIR
126 + set(includes)
127 + if(DEFINED LLVM_INCLUDE_DIRS)
128 + set(includes LLVM_INCLUDE_DIRS)
129 + elseif(DEFINED LLVM_INCLUDES)
130 + set(includes LLVM_INCLUDES)
131 + elseif(DEFINED LLVM_INCLUDE_DIR)
132 + set(includes LLVM_INCLUDE_DIR)
133 + endif()
134 +
135 + # Check the following variables:
136 + # LLVM_DEFINITIONS
137 + set(definitions)
138 + if(DEFINED LLVM_DEFINITIONS)
139 + set(definitions LLVM_DEFINITIONS)
140 + endif()
141 +
142 + set(PACKAGE_INCLUDE_DIRS "${${includes}}")
143 + set(PACKAGE_DEFINITIONS "${${definitions}}")
144 + set(PACKAGE_LIBRARIES "${${libs}}")
145 +endif()
146 +'''
147 +
148 +file_1_data_CMakePathInfo_txt = '''\
149 +cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})
150 +
151 +set(TMP_PATHS_LIST)
152 +list(APPEND TMP_PATHS_LIST ${CMAKE_PREFIX_PATH})
153 +list(APPEND TMP_PATHS_LIST ${CMAKE_FRAMEWORK_PATH})
154 +list(APPEND TMP_PATHS_LIST ${CMAKE_APPBUNDLE_PATH})
155 +list(APPEND TMP_PATHS_LIST $ENV{CMAKE_PREFIX_PATH})
156 +list(APPEND TMP_PATHS_LIST $ENV{CMAKE_FRAMEWORK_PATH})
157 +list(APPEND TMP_PATHS_LIST $ENV{CMAKE_APPBUNDLE_PATH})
158 +list(APPEND TMP_PATHS_LIST ${CMAKE_SYSTEM_PREFIX_PATH})
159 +list(APPEND TMP_PATHS_LIST ${CMAKE_SYSTEM_FRAMEWORK_PATH})
160 +list(APPEND TMP_PATHS_LIST ${CMAKE_SYSTEM_APPBUNDLE_PATH})
161 +
162 +set(LIB_ARCH_LIST)
163 +if(CMAKE_LIBRARY_ARCHITECTURE_REGEX)
164 + file(GLOB implicit_dirs RELATIVE /lib /lib/*-linux-gnu* )
165 + foreach(dir ${implicit_dirs})
166 + if("${dir}" MATCHES "${CMAKE_LIBRARY_ARCHITECTURE_REGEX}")
167 + list(APPEND LIB_ARCH_LIST "${dir}")
168 + endif()
169 + endforeach()
170 +endif()
171 +
172 +# "Export" these variables:
173 +set(MESON_ARCH_LIST ${LIB_ARCH_LIST})
174 +set(MESON_PATHS_LIST ${TMP_PATHS_LIST})
175 +set(MESON_CMAKE_ROOT ${CMAKE_ROOT})
176 +set(MESON_CMAKE_SYSROOT ${CMAKE_SYSROOT})
177 +set(MESON_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH})
178 +
179 +message(STATUS ${TMP_PATHS_LIST})
180 +'''
181 +
182 +file_2_data_CMakeLists_txt = '''\
183 +# fail noisily if attempt to use this file without setting:
184 +# cmake_minimum_required(VERSION ${CMAKE_VERSION})
185 +# project(... LANGUAGES ...)
186 +
187 +cmake_policy(SET CMP0000 NEW)
188 +
189 +set(PACKAGE_FOUND FALSE)
190 +set(_packageName "${NAME}")
191 +string(TOUPPER "${_packageName}" PACKAGE_NAME)
192 +
193 +while(TRUE)
194 + find_package("${NAME}" QUIET COMPONENTS ${COMPS})
195 +
196 + # ARCHS has to be set via the CMD interface
197 + if(${_packageName}_FOUND OR ${PACKAGE_NAME}_FOUND OR "${ARCHS}" STREQUAL "")
198 + break()
199 + endif()
200 +
201 + list(GET ARCHS 0 CMAKE_LIBRARY_ARCHITECTURE)
202 + list(REMOVE_AT ARCHS 0)
203 +endwhile()
204 +
205 +if(${_packageName}_FOUND OR ${PACKAGE_NAME}_FOUND)
206 + set(PACKAGE_FOUND TRUE)
207 +
208 + # Check the following variables:
209 + # FOO_VERSION
210 + # Foo_VERSION
211 + # FOO_VERSION_STRING
212 + # Foo_VERSION_STRING
213 + if(NOT DEFINED PACKAGE_VERSION)
214 + if(DEFINED ${_packageName}_VERSION)
215 + set(PACKAGE_VERSION "${${_packageName}_VERSION}")
216 + elseif(DEFINED ${PACKAGE_NAME}_VERSION)
217 + set(PACKAGE_VERSION "${${PACKAGE_NAME}_VERSION}")
218 + elseif(DEFINED ${_packageName}_VERSION_STRING)
219 + set(PACKAGE_VERSION "${${_packageName}_VERSION_STRING}")
220 + elseif(DEFINED ${PACKAGE_NAME}_VERSION_STRING)
221 + set(PACKAGE_VERSION "${${PACKAGE_NAME}_VERSION_STRING}")
222 + endif()
223 + endif()
224 +
225 + # Check the following variables:
226 + # FOO_LIBRARIES
227 + # Foo_LIBRARIES
228 + # FOO_LIBS
229 + # Foo_LIBS
230 + set(libs)
231 + if(DEFINED ${_packageName}_LIBRARIES)
232 + set(libs ${_packageName}_LIBRARIES)
233 + elseif(DEFINED ${PACKAGE_NAME}_LIBRARIES)
234 + set(libs ${PACKAGE_NAME}_LIBRARIES)
235 + elseif(DEFINED ${_packageName}_LIBS)
236 + set(libs ${_packageName}_LIBS)
237 + elseif(DEFINED ${PACKAGE_NAME}_LIBS)
238 + set(libs ${PACKAGE_NAME}_LIBS)
239 + endif()
240 +
241 + # Check the following variables:
242 + # FOO_INCLUDE_DIRS
243 + # Foo_INCLUDE_DIRS
244 + # FOO_INCLUDES
245 + # Foo_INCLUDES
246 + # FOO_INCLUDE_DIR
247 + # Foo_INCLUDE_DIR
248 + set(includes)
249 + if(DEFINED ${_packageName}_INCLUDE_DIRS)
250 + set(includes ${_packageName}_INCLUDE_DIRS)
251 + elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIRS)
252 + set(includes ${PACKAGE_NAME}_INCLUDE_DIRS)
253 + elseif(DEFINED ${_packageName}_INCLUDES)
254 + set(includes ${_packageName}_INCLUDES)
255 + elseif(DEFINED ${PACKAGE_NAME}_INCLUDES)
256 + set(includes ${PACKAGE_NAME}_INCLUDES)
257 + elseif(DEFINED ${_packageName}_INCLUDE_DIR)
258 + set(includes ${_packageName}_INCLUDE_DIR)
259 + elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIR)
260 + set(includes ${PACKAGE_NAME}_INCLUDE_DIR)
261 + endif()
262 +
263 + # Check the following variables:
264 + # FOO_DEFINITIONS
265 + # Foo_DEFINITIONS
266 + set(definitions)
267 + if(DEFINED ${_packageName}_DEFINITIONS)
268 + set(definitions ${_packageName}_DEFINITIONS)
269 + elseif(DEFINED ${PACKAGE_NAME}_DEFINITIONS)
270 + set(definitions ${PACKAGE_NAME}_DEFINITIONS)
271 + endif()
272 +
273 + set(PACKAGE_INCLUDE_DIRS "${${includes}}")
274 + set(PACKAGE_DEFINITIONS "${${definitions}}")
275 + set(PACKAGE_LIBRARIES "${${libs}}")
276 +endif()
277 +'''
278 +
279 +file_3_data_preload_cmake = '''\
280 +if(MESON_PS_LOADED)
281 + return()
282 +endif()
283 +
284 +set(MESON_PS_LOADED ON)
285 +
286 +# Dummy macros that have a special meaning in the meson code
287 +macro(meson_ps_execute_delayed_calls)
288 +endmacro()
289 +
290 +macro(meson_ps_reload_vars)
291 +endmacro()
292 +
293 +# Helper macro to inspect the current CMake state
294 +macro(meson_ps_inspect_vars)
295 + set(MESON_PS_CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
296 + set(MESON_PS_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
297 + meson_ps_execute_delayed_calls()
298 +endmacro()
299 +
300 +
301 +# Override some system functions with custom code and forward the args
302 +# to the original function
303 +macro(add_custom_command)
304 + meson_ps_inspect_vars()
305 + _add_custom_command(${ARGV})
306 +endmacro()
307 +
308 +macro(add_custom_target)
309 + meson_ps_inspect_vars()
310 + _add_custom_target(${ARGV})
311 +endmacro()
312 +
313 +macro(set_property)
314 + meson_ps_inspect_vars()
315 + _set_property(${ARGV})
316 +endmacro()
317 +
318 +function(set_source_files_properties)
319 + set(FILES)
320 + set(I 0)
321 + set(PROPERTIES OFF)
322 +
323 + while(I LESS ARGC)
324 + if(NOT PROPERTIES)
325 + if("${ARGV${I}}" STREQUAL "PROPERTIES")
326 + set(PROPERTIES ON)
327 + else()
328 + list(APPEND FILES "${ARGV${I}}")
329 + endif()
330 +
331 + math(EXPR I "${I} + 1")
332 + else()
333 + set(ID_IDX ${I})
334 + math(EXPR PROP_IDX "${ID_IDX} + 1")
335 +
336 + set(ID "${ARGV${ID_IDX}}")
337 + set(PROP "${ARGV${PROP_IDX}}")
338 +
339 + set_property(SOURCE ${FILES} PROPERTY "${ID}" "${PROP}")
340 + math(EXPR I "${I} + 2")
341 + endif()
342 + endwhile()
343 +endfunction()
344 +
345 +set(MESON_PS_DELAYED_CALLS add_custom_command;add_custom_target;set_property)
346 +meson_ps_reload_vars()
347 +'''
348 +
349 +
350 +####################
351 +# END Data section #
352 +####################
353 +
354 +class DataFile:
355 + def __init__(self, path: Path, sha256sum: str, data: str) -> None:
356 + self.path = path
357 + self.sha256sum = sha256sum
358 + self.data = data
359 +
360 + def write_once(self, path: Path) -> None:
361 + if not path.exists():
362 + path.write_text(self.data)
363 +
364 + def write_to_private(self, env: 'Environment') -> Path:
365 + out_file = Path(env.scratch_dir) / 'data' / self.path.name
366 + out_file.parent.mkdir(exist_ok=True)
367 + self.write_once(out_file)
368 + return out_file
369 +
370 +
371 +mesondata = {
372 + 'dependencies/data/CMakeListsLLVM.txt': DataFile(
373 + Path('dependencies/data/CMakeListsLLVM.txt'),
374 + '412cec3315597041a978d018cdaca282dcd47693793540da88ae2f80d0cbd7cd',
375 + file_0_data_CMakeListsLLVM_txt,
376 + ),
377 + 'dependencies/data/CMakePathInfo.txt': DataFile(
378 + Path('dependencies/data/CMakePathInfo.txt'),
379 + '90da8b443982d9c87139b7dc84228eb58cab4315764949637208f25e2bda7db2',
380 + file_1_data_CMakePathInfo_txt,
381 + ),
382 + 'dependencies/data/CMakeLists.txt': DataFile(
383 + Path('dependencies/data/CMakeLists.txt'),
384 + '71a2d58381f912bbfb1c8709884d34d721f682edf2fca001e1f582f0bffd0da7',
385 + file_2_data_CMakeLists_txt,
386 + ),
387 + 'cmake/data/preload.cmake': DataFile(
388 + Path('cmake/data/preload.cmake'),
389 + '064d047b18a5c919ad016b838bed50c5d40aebe9e53da0e70eff9d52a2c1ca1f',
390 + file_3_data_preload_cmake,
391 + ),
392 +}
393 diff --git a/tools/gen_data.py b/tools/gen_data.py
394 new file mode 100755
395 index 0000000000..2cc05a44e7
396 --- /dev/null
397 +++ b/tools/gen_data.py
398 @@ -0,0 +1,139 @@
399 +#!/usr/bin/env python3
400 +
401 +# Copyright 2020 Daniel Mensinger
402 +
403 +# Licensed under the Apache License, Version 2.0 (the "License");
404 +# you may not use this file except in compliance with the License.
405 +# You may obtain a copy of the License at
406 +
407 +# http://www.apache.org/licenses/LICENSE-2.0
408 +
409 +# Unless required by applicable law or agreed to in writing, software
410 +# distributed under the License is distributed on an "AS IS" BASIS,
411 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
412 +# See the License for the specific language governing permissions and
413 +# limitations under the License.
414 +
415 +import sys
416 +import hashlib
417 +import textwrap
418 +import re
419 +from pathlib import Path
420 +from datetime import datetime
421 +import typing as T
422 +
423 +class DataFile:
424 + file_counter = 0
425 +
426 + def __init__(self, path: Path, root: Path):
427 + self.path = path
428 + self.id = self.path.relative_to(root)
429 + self.data_str = f'file_{DataFile.file_counter}_data_' + re.sub('[^a-zA-Z0-9]', '_', self.path.name)
430 + DataFile.file_counter += 1
431 +
432 + b = self.path.read_bytes()
433 + self.data = b.decode()
434 + self.sha256sum = hashlib.sha256(b).hexdigest()
435 +
436 + def __repr__(self) -> str:
437 + return f'<{type(self).__name__}: [{self.sha256sum}] {self.id}>'
438 +
439 +def main() -> int:
440 + root_dir = Path(__file__).resolve().parents[1]
441 + mesonbuild_dir = root_dir / 'mesonbuild'
442 + out_file = mesonbuild_dir / 'mesondata.py'
443 +
444 + data_dirs = mesonbuild_dir.glob('**/data')
445 +
446 + data_files: T.List[DataFile] = []
447 +
448 + for d in data_dirs:
449 + for p in d.iterdir():
450 + data_files += [DataFile(p, mesonbuild_dir)]
451 +
452 + print(f'Found {len(data_files)} data files')
453 +
454 + # Generate the data script
455 + data = ''
456 +
457 + data += textwrap.dedent(f'''\
458 + # Copyright {datetime.today().year} The Meson development team
459 +
460 + # Licensed under the Apache License, Version 2.0 (the "License");
461 + # you may not use this file except in compliance with the License.
462 + # You may obtain a copy of the License at
463 +
464 + # http://www.apache.org/licenses/LICENSE-2.0
465 +
466 + # Unless required by applicable law or agreed to in writing, software
467 + # distributed under the License is distributed on an "AS IS" BASIS,
468 + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
469 + # See the License for the specific language governing permissions and
470 + # limitations under the License.
471 +
472 +
473 + ####
474 + #### WARNING: This is an automatically generated file! Do not edit!
475 + #### Generated by {Path(__file__).resolve().relative_to(root_dir)}
476 + ####
477 +
478 +
479 + from pathlib import Path
480 + import typing as T
481 +
482 + if T.TYPE_CHECKING:
483 + from .environment import Environment
484 +
485 + ######################
486 + # BEGIN Data section #
487 + ######################
488 +
489 + ''')
490 +
491 + for i in data_files:
492 + data += f"{i.data_str} = '''\\\n{i.data}'''\n\n"
493 +
494 + data += textwrap.dedent(f'''
495 + ####################
496 + # END Data section #
497 + ####################
498 +
499 + class DataFile:
500 + def __init__(self, path: Path, sha256sum: str, data: str) -> None:
501 + self.path = path
502 + self.sha256sum = sha256sum
503 + self.data = data
504 +
505 + def write_once(self, path: Path) -> None:
506 + if not path.exists():
507 + path.write_text(self.data)
508 +
509 + def write_to_private(self, env: 'Environment') -> Path:
510 + out_file = Path(env.scratch_dir) / 'data' / self.path.name
511 + out_file.parent.mkdir(exist_ok=True)
512 + self.write_once(out_file)
513 + return out_file
514 +
515 +
516 + mesondata = {{
517 + ''')
518 +
519 + for i in data_files:
520 + data += textwrap.indent(textwrap.dedent(f"""\
521 + '{i.id}': DataFile(
522 + Path('{i.id}'),
523 + '{i.sha256sum}',
524 + {i.data_str},
525 + ),
526 + """), ' ')
527 +
528 + data += textwrap.dedent('''\
529 + }
530 + ''')
531 +
532 + print(f'Updating {out_file}')
533 + out_file.write_text(data)
534 + return 0
535 +
536 +if __name__ == '__main__':
537 + sys.exit(main())
538
539 From 05ddd6543d4c4fc33b4c64f26291e73f49733f71 Mon Sep 17 00:00:00 2001
540 From: Daniel Mensinger <daniel@mensinger-ka.de>
541 Date: Thu, 16 Jul 2020 20:33:57 +0200
542 Subject: [PATCH 2/3] mdata: remove setuptools and use mesondata instead
543
544 ---
545 mesonbuild/cmake/interpreter.py | 5 ++---
546 mesonbuild/dependencies/base.py | 6 ++----
547 setup.py | 5 -----
548 4 files changed, 4 insertions(+), 16 deletions(-)
549
550 diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
551 index 05169478e8..f404109cf6 100644
552 --- a/mesonbuild/cmake/interpreter.py
553 +++ b/mesonbuild/cmake/interpreter.py
554 @@ -15,8 +15,6 @@
555 # This class contains the basic functionality needed to run any interpreter
556 # or an interpreter-based tool.
557
558 -import pkg_resources
559 -
560 from .common import CMakeException, CMakeTarget, TargetOptions
561 from .client import CMakeClient, RequestCMakeInputs, RequestConfigure, RequestCompute, RequestCodeModel
562 from .fileapi import CMakeFileAPI
563 @@ -25,6 +23,7 @@
564 from .. import mlog, mesonlib
565 from ..environment import Environment
566 from ..mesonlib import MachineChoice, OrderedSet, version_compare
567 +from ..mesondata import mesondata
568 from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes, lib_suffixes, is_header
569 from enum import Enum
570 from functools import lru_cache
571 @@ -814,7 +813,7 @@ def configure(self, extra_cmake_options: T.List[str]) -> None:
572 raise CMakeException('Unable to find CMake')
573 self.trace = CMakeTraceParser(cmake_exe.version(), self.build_dir, permissive=True)
574
575 - preload_file = pkg_resources.resource_filename('mesonbuild', 'cmake/data/preload.cmake')
576 + preload_file = mesondata['cmake/data/preload.cmake'].write_to_private(self.env)
577
578 # Prefere CMAKE_PROJECT_INCLUDE over CMAKE_TOOLCHAIN_FILE if possible,
579 # since CMAKE_PROJECT_INCLUDE was actually designed for code injection.
580 diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
581 index 23701da957..4c9c9fe18a 100644
582 --- a/mesonbuild/dependencies/base.py
583 +++ b/mesonbuild/dependencies/base.py
584 @@ -29,8 +29,6 @@
585 from enum import Enum
586 from pathlib import Path, PurePath
587
588 -import pkg_resources
589 -
590 from .. import mlog
591 from .. import mesonlib
592 from ..compilers import clib_langs
593 @@ -40,6 +38,7 @@
594 from ..mesonlib import MachineChoice, MesonException, OrderedSet, PerMachine
595 from ..mesonlib import Popen_safe, version_compare_many, version_compare, listify, stringlistify, extract_as_list, split_args
596 from ..mesonlib import Version, LibType
597 +from ..mesondata import mesondata
598
599 if T.TYPE_CHECKING:
600 from ..compilers.compilers import CompilerType # noqa: F401
601 @@ -1512,8 +1511,7 @@ def _setup_cmake_dir(self, cmake_file: str) -> str:
602 build_dir = self._get_build_dir()
603
604 # Insert language parameters into the CMakeLists.txt and write new CMakeLists.txt
605 - # Per the warning in pkg_resources, this is *not* a path and os.path and Pathlib are *not* safe to use here.
606 - cmake_txt = pkg_resources.resource_string('mesonbuild', 'dependencies/data/' + cmake_file).decode()
607 + cmake_txt = mesondata['dependencies/data/' + cmake_file].data
608
609 # In general, some Fortran CMake find_package() also require C language enabled,
610 # even if nothing from C is directly used. An easy Fortran example that fails
611 diff --git a/setup.py b/setup.py
612 index 1f95be70c8..145f19c522 100644
613 --- a/setup.py
614 +++ b/setup.py
615 @@ -37,10 +37,6 @@
616 'mesonbuild.scripts',
617 'mesonbuild.templates',
618 'mesonbuild.wrap']
619 -package_data = {
620 - 'mesonbuild.dependencies': ['data/CMakeLists.txt', 'data/CMakeListsLLVM.txt', 'data/CMakePathInfo.txt'],
621 - 'mesonbuild.cmake': ['data/run_ctgt.py', 'data/preload.cmake'],
622 -}
623 data_files = []
624 if sys.platform != 'win32':
625 # Only useful on UNIX-like systems
626 @@ -51,6 +47,5 @@
627 setup(name='meson',
628 version=version,
629 packages=packages,
630 - package_data=package_data,
631 entry_points=entries,
632 data_files=data_files,)
633
634 From 393d6e133d9abd584a2fc414971628e84ea48b7c Mon Sep 17 00:00:00 2001
635 From: Daniel Mensinger <daniel@mensinger-ka.de>
636 Date: Thu, 16 Jul 2020 20:34:15 +0200
637 Subject: [PATCH 3/3] mdata: Add test to ensure mesondata.py is up-to-date
638
639 ---
640 run_unittests.py | 32 ++++++++++++++++++++++++++++++++
641 1 file changed, 32 insertions(+)
642
643 diff --git a/run_unittests.py b/run_unittests.py
644 index 820b705b54..2c03a3e75c 100755
645 --- a/run_unittests.py
646 +++ b/run_unittests.py
647 @@ -1485,6 +1485,38 @@ def test_all_functions_defined_in_ast_interpreter(self):
648 astint = AstInterpreter('.', '', '')
649 self.assertEqual(set(interp.funcs.keys()), set(astint.funcs.keys()))
650
651 + def test_mesondata_is_up_to_date(self):
652 + from mesonbuild.mesondata import mesondata
653 + err_msg = textwrap.dedent('''
654 +
655 + ###########################################################
656 + ### mesonbuild.mesondata is not up-to-date ###
657 + ### Please regenerate it by running tools/gen_data.py ###
658 + ###########################################################
659 +
660 + ''')
661 +
662 + root_dir = Path(__file__).resolve().parent
663 + mesonbuild_dir = root_dir / 'mesonbuild'
664 +
665 + data_dirs = mesonbuild_dir.glob('**/data')
666 + data_files = [] # type: T.List[T.Tuple(str, str)]
667 +
668 + for i in data_dirs:
669 + for p in i.iterdir():
670 + data_files += [(p.relative_to(mesonbuild_dir).as_posix(), hashlib.sha256(p.read_bytes()).hexdigest())]
671 +
672 + from pprint import pprint
673 + current_files = set(mesondata.keys())
674 + scanned_files = set([x[0] for x in data_files])
675 +
676 + self.assertSetEqual(current_files, scanned_files, err_msg + 'Data files were added or removed\n')
677 + errors = []
678 + for i in data_files:
679 + if mesondata[i[0]].sha256sum != i[1]:
680 + errors += [i[0]]
681 +
682 + self.assertListEqual(errors, [], err_msg + 'Files were changed')
683
684 class BasePlatformTests(unittest.TestCase):
685 prefix = '/usr'