1# Copyright © Microsoft Corporation 2 3# Permission is hereby granted, free of charge, to any person obtaining a 4# copy of this software and associated documentation files (the "Software"), 5# to deal in the Software without restriction, including without limitation 6# the rights to use, copy, modify, merge, publish, distribute, sublicense, 7# and/or sell copies of the Software, and to permit persons to whom the 8# Software is furnished to do so, subject to the following conditions: 9 10# The above copyright notice and this permission notice (including the next 11# paragraph) shall be included in all copies or substantial portions of the 12# Software. 13 14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20# IN THE SOFTWARE. 21 22clang_resource_dir = join_paths(llvm_libdir, 'clang', dep_llvm.version(), 'include') 23 24if dep_llvm.version().version_compare('< 15.0') 25 opencl_c_h = custom_target( 26 'opencl-c.h', 27 input : [files_xxd, join_paths(clang_resource_dir, 'opencl-c.h')], 28 output : 'opencl-c.h.h', 29 command : [prog_python, '@INPUT@', '@OUTPUT@', '-n', 'opencl_c_source'], 30 ) 31endif 32 33opencl_c_base_h = custom_target( 34 'opencl-c-base.h', 35 input : [files_xxd, join_paths(clang_resource_dir, 'opencl-c-base.h')], 36 output : 'opencl-c-base.h.h', 37 command : [prog_python, '@INPUT@', '@OUTPUT@', '-n', 'opencl_c_base_source'], 38) 39 40_libclc_sources = [opencl_c_base_h] 41if dep_llvm.version().version_compare('< 15.0') 42 _libclc_sources += [opencl_c_h] 43endif 44 45files_libclc = files( 46 'clc.c', 47 'clc_helpers.cpp', 48) 49 50_libclc_cpp_args = ['-DCLANG_RESOURCE_DIR="@0@"'.format(clang_resource_dir)] 51if with_microsoft_clc 52 _libclc_cpp_args += ['-DUSE_STATIC_OPENCL_C_H=1'] 53endif 54 55# Supported added for SPIRV 1.4 in a version that required LLVM 14. 56if dep_llvm.version().version_compare('>= 14.0') 57 _libclc_cpp_args += ['-DHAS_SPIRV_1_4=1'] 58endif 59 60_libclc = static_library( 61 'libclc', 62 files_libclc, 63 sources: _libclc_sources, 64 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_compiler, inc_spirv], 65 cpp_args : _libclc_cpp_args, 66 dependencies: [idep_nir_headers, dep_clang, dep_llvm, dep_llvmspirvlib, 67 idep_mesautil, idep_nir, dep_spirv_tools] 68) 69 70idep_clc = declare_dependency( 71 link_with : _libclc, 72 include_directories : include_directories('.'), 73) 74