BLD: Move config.h creation to `setup` stagepull/4885/head
| @@ -49,7 +49,7 @@ foreach lvl : ['l1', 'l2', 'l3', 'l3_3m'] | |||||
| executable( | executable( | ||||
| op_name, | op_name, | ||||
| sources: mapped_sources + [config_h], | |||||
| sources: mapped_sources, | |||||
| link_with: [_openblas], | link_with: [_openblas], | ||||
| dependencies: [dependency('threads')], | dependencies: [dependency('threads')], | ||||
| include_directories: ctest_inc, | include_directories: ctest_inc, | ||||
| @@ -540,7 +540,7 @@ foreach conf : kernel_confs | |||||
| # message(conf) | # message(conf) | ||||
| _kern_libs += [static_library( | _kern_libs += [static_library( | ||||
| conf['name'], | conf['name'], | ||||
| [conf['src'], config_h], | |||||
| conf['src'], | |||||
| include_directories: _inc, | include_directories: _inc, | ||||
| c_args: conf['c_args'], | c_args: conf['c_args'], | ||||
| )] | )] | ||||
| @@ -465,7 +465,7 @@ foreach conf : kernel_confs | |||||
| # message(conf) | # message(conf) | ||||
| _kern_libs += [static_library( | _kern_libs += [static_library( | ||||
| conf['name'], | conf['name'], | ||||
| [conf['src'], config_h], | |||||
| conf['src'], | |||||
| include_directories: _inc, | include_directories: _inc, | ||||
| c_args: conf['c_args'], | c_args: conf['c_args'], | ||||
| )] | )] | ||||
| @@ -74,7 +74,7 @@ others_libs = [] | |||||
| foreach conf : others_confs | foreach conf : others_confs | ||||
| others_libs += [static_library( | others_libs += [static_library( | ||||
| conf['name'], | conf['name'], | ||||
| [conf['src'], config_h], | |||||
| conf['src'], | |||||
| include_directories: _inc, | include_directories: _inc, | ||||
| c_args: conf['c_args'] | c_args: conf['c_args'] | ||||
| )] | )] | ||||
| @@ -1,16 +1,9 @@ | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #ifndef BUILD_KERNEL | #ifndef BUILD_KERNEL | ||||
| #ifdef BUILD_WITH_MESON | |||||
| #include "_config_for_getarch_2nd.h" | |||||
| #else | |||||
| #include "config.h" | #include "config.h" | ||||
| #endif | |||||
| #else | #else | ||||
| #include "config_kernel.h" | #include "config_kernel.h" | ||||
| #endif | #endif | ||||
| #if (defined(__WIN32__) || defined(__WIN64__) || defined(__CYGWIN32__) || defined(__CYGWIN64__) || defined(_WIN32) || defined(_WIN64)) && defined(__64BIT__) | #if (defined(__WIN32__) || defined(__WIN64__) || defined(__CYGWIN32__) || defined(__CYGWIN64__) || defined(_WIN32) || defined(_WIN64)) && defined(__64BIT__) | ||||
| typedef long long BLASLONG; | typedef long long BLASLONG; | ||||
| typedef unsigned long long BLASULONG; | typedef unsigned long long BLASULONG; | ||||
| @@ -623,7 +623,7 @@ foreach conf : _blas_roots | |||||
| # Create the static library for each symbol | # Create the static library for each symbol | ||||
| lib = static_library( | lib = static_library( | ||||
| sym_name, | sym_name, | ||||
| sources: [conf['fname'], config_h], | |||||
| sources: conf['fname'], | |||||
| include_directories: _inc, | include_directories: _inc, | ||||
| c_args: compiler_args + [ | c_args: compiler_args + [ | ||||
| f'-DASMNAME=@asm_name_prefix@@sym_name@', | f'-DASMNAME=@asm_name_prefix@@sym_name@', | ||||
| @@ -645,7 +645,7 @@ foreach conf : _blas_roots | |||||
| endif | endif | ||||
| cblas_lib = static_library( | cblas_lib = static_library( | ||||
| cblas_sym_name, | cblas_sym_name, | ||||
| sources: [conf['fname'], config_h], | |||||
| sources: conf['fname'], | |||||
| include_directories: _inc, | include_directories: _inc, | ||||
| c_args: compiler_args + [ | c_args: compiler_args + [ | ||||
| '-DCBLAS', | '-DCBLAS', | ||||
| @@ -1,21 +0,0 @@ | |||||
| import argparse | |||||
| def merge_files(file1_path: str, file2_path: str) -> str: | |||||
| # Open files in read mode | |||||
| with open(file1_path, 'r') as file1, open(file2_path, 'r') as file2: | |||||
| content1 = file1.read() | |||||
| content2 = file2.read() | |||||
| merged_content = content1 + "\n" + content2 | |||||
| return merged_content | |||||
| if __name__ == "__main__": | |||||
| parser = argparse.ArgumentParser(description="Merge and print content from two text files.") | |||||
| parser.add_argument("file1", help="Path to the first text file.") | |||||
| parser.add_argument("file2", help="Path to the second text file.") | |||||
| args = parser.parse_args() | |||||
| output = merge_files(args.file1, args.file2) | |||||
| print(output) | |||||
| @@ -1509,7 +1509,7 @@ _is_asm = false | |||||
| foreach conf: kernel_confs | foreach conf: kernel_confs | ||||
| _kern_libs += static_library( | _kern_libs += static_library( | ||||
| conf['name'], | conf['name'], | ||||
| [conf['src'], config_h], | |||||
| conf['src'], | |||||
| include_directories: _inc, | include_directories: _inc, | ||||
| c_args: conf['c_args'], | c_args: conf['c_args'], | ||||
| # See gh discussion 13374 for why, basically .S are coded as fortran.. | # See gh discussion 13374 for why, basically .S are coded as fortran.. | ||||
| @@ -462,55 +462,31 @@ symb_defs = { | |||||
| # config.h file generation | # config.h file generation | ||||
| _config_1_path = meson.current_build_dir() / '_config_1.h' | |||||
| _join_files_py = '../join_files.py' | |||||
| run_command('./c_check', 'Makefile.conf', _config_1_path, cc_id, check: true) | |||||
| run_command('./f_check', 'Makefile.conf', _config_1_path, fc_id, check: true) | |||||
| getarch = executable('getarch', ['getarch.c', 'cpuid.S']) | |||||
| _config_2h = custom_target('_config_2h', | |||||
| output: '_config_2.h', | |||||
| command: [getarch, '1'], | |||||
| depends: [getarch], | |||||
| capture: true, | |||||
| ) | |||||
| _config_for_getarch_2nd_h = custom_target('_config_for_getarch_2nd_h', | |||||
| output: '_config_for_getarch_2nd.h', | |||||
| command: [ | |||||
| py3, | |||||
| _join_files_py, | |||||
| _config_1_path, | |||||
| _config_2h, | |||||
| ], | |||||
| depends: [_config_2h], | |||||
| capture: true, | |||||
| ) | |||||
| getarch_2nd = executable('getarch_2nd', | |||||
| ['getarch_2nd.c', _config_for_getarch_2nd_h], | |||||
| c_args: ['-DGEMM_MULTITHREAD_THRESHOLD=4', '-DBUILD_WITH_MESON'] | |||||
| ) | |||||
| _config_3h = custom_target('_config_3h', | |||||
| output: '_config_3.h', | |||||
| command: [getarch_2nd, '1'], | |||||
| depends: [getarch_2nd], | |||||
| capture: true, | |||||
| ) | |||||
| config_h = custom_target('config_h', | |||||
| output: 'config.h', | |||||
| command: [ | |||||
| py3, | |||||
| _join_files_py, | |||||
| _config_for_getarch_2nd_h, | |||||
| _config_3h, | |||||
| ], | |||||
| depends: [_config_3h], | |||||
| capture: true, | |||||
| ) | |||||
| _config_h = meson.current_build_dir() / 'config.h' | |||||
| run_command('./c_check', 'Makefile.conf', _config_h, cc_id, check: true) | |||||
| run_command('./f_check', 'Makefile.conf', _config_h, fc_id, check: true) | |||||
| run_command(cc_id, '-o', 'getarch', 'getarch.c', 'cpuid.S', check: true) | |||||
| _getarch_result = run_command('./getarch', '1', check: true, capture: true) | |||||
| run_command(py3, | |||||
| './write_to_file.py', | |||||
| _getarch_result.stdout(), | |||||
| _config_h, | |||||
| check: true) | |||||
| run_command(cc_id, | |||||
| '-DGEMM_MULTITHREAD_THRESHOLD=4', | |||||
| '-I.', | |||||
| f'-I@prj_bld_dir@', | |||||
| '-o', 'getarch_2nd', | |||||
| 'getarch_2nd.c', | |||||
| capture: true, check: true) | |||||
| _getarch_2nd_result = run_command('./getarch_2nd', '1', check: true, capture: true) | |||||
| run_command(py3, | |||||
| './write_to_file.py', | |||||
| _getarch_2nd_result.stdout(), | |||||
| _config_h, | |||||
| check: true) | |||||
| # Ignoring other hostarch checks and conflicts for arch in BSD for now | # Ignoring other hostarch checks and conflicts for arch in BSD for now | ||||
| _inc = [include_directories('.')] | _inc = [include_directories('.')] | ||||
| @@ -563,7 +539,6 @@ pcl = custom_target('prepare_config_last', | |||||
| exprecision ? '--exprecision' : [], | exprecision ? '--exprecision' : [], | ||||
| ], | ], | ||||
| build_by_default : true, | build_by_default : true, | ||||
| depends: config_h, | |||||
| ) | ) | ||||
| # Generate the headers | # Generate the headers | ||||
| @@ -1,5 +1,4 @@ | |||||
| sources_utest = [ | sources_utest = [ | ||||
| config_h, | |||||
| 'utest_main.c', | 'utest_main.c', | ||||
| 'test_min.c', | 'test_min.c', | ||||
| 'test_amax.c', | 'test_amax.c', | ||||
| @@ -18,7 +17,6 @@ sources_utest = [ | |||||
| dir_ext = 'test_extensions' | dir_ext = 'test_extensions' | ||||
| sources_utest_ext = [ | sources_utest_ext = [ | ||||
| config_h, | |||||
| 'utest_main.c', | 'utest_main.c', | ||||
| dir_ext / 'xerbla.c', | dir_ext / 'xerbla.c', | ||||
| dir_ext / 'common.c', | dir_ext / 'common.c', | ||||
| @@ -0,0 +1,13 @@ | |||||
| import argparse | |||||
| if __name__ == "__main__": | |||||
| parser = argparse.ArgumentParser(description="Write contents to file.") | |||||
| parser.add_argument("contents", help="Contents.") | |||||
| parser.add_argument("file_path", help="File path.") | |||||
| args = parser.parse_args() | |||||
| f = open(args.file_path, "a") | |||||
| f.write(args.contents) | |||||
| f.close() | |||||