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 24opencl_c_h = custom_target( 25 'opencl-c.h', 26 input : [files_xxd, join_paths(clang_resource_dir, 'opencl-c.h')], 27 output : 'opencl-c.h.h', 28 command : [prog_python, '@INPUT@', '@OUTPUT@', '-n', 'opencl_c_source'], 29) 30opencl_c_base_h = custom_target( 31 'opencl-c-base.h', 32 input : [files_xxd, join_paths(clang_resource_dir, 'opencl-c-base.h')], 33 output : 'opencl-c-base.h.h', 34 command : [prog_python, '@INPUT@', '@OUTPUT@', '-n', 'opencl_c_base_source'], 35) 36 37files_libclc = files( 38 'clc.c', 39 'clc_helpers.cpp', 40) 41 42_libclc_cpp_args = ['-DCLANG_RESOURCE_DIR="@0@"'.format(clang_resource_dir)] 43if with_microsoft_clc 44 _libclc_cpp_args += ['-DUSE_STATIC_OPENCL_C_H=1'] 45endif 46 47# Supported added for SPIRV 1.4 in a version that required LLVM 14. 48if dep_llvm.version().version_compare('>= 14.0') 49 _libclc_cpp_args += ['-DHAS_SPIRV_1_4=1'] 50endif 51 52_libclc = static_library( 53 'libclc', 54 files_libclc, 55 opencl_c_h, 56 opencl_c_base_h, 57 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_compiler, inc_spirv], 58 cpp_args : _libclc_cpp_args, 59 dependencies: [idep_nir_headers, dep_clang, dep_llvm, dep_llvmspirvlib, 60 idep_mesautil, idep_nir, dep_spirv_tools] 61) 62 63idep_clc = declare_dependency( 64 link_with : _libclc, 65 include_directories : include_directories('.'), 66) 67