13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 33d3250a0SJeremy L Thompson // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 53d3250a0SJeremy L Thompson // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 73d3250a0SJeremy L Thompson 83d3250a0SJeremy L Thompson #include <ceed/ceed.h> 93d3250a0SJeremy L Thompson #include <ceed/backend.h> 103d3250a0SJeremy L Thompson #include <ceed/jit-tools.h> 116eb0d8b4SJeremy L Thompson #include <ceed-impl.h> 123d3250a0SJeremy L Thompson #include <stdbool.h> 133d3250a0SJeremy L Thompson #include <stdio.h> 143d3250a0SJeremy L Thompson #include <string.h> 153d3250a0SJeremy L Thompson 163d3250a0SJeremy L Thompson /** 17ee5a26f2SJeremy L Thompson @brief Check if valid file exists at path given 18ee5a26f2SJeremy L Thompson 19ee5a26f2SJeremy L Thompson @param ceed A Ceed object for error handling 20ee5a26f2SJeremy L Thompson @param[in] source_file_path Absolute path to source file 21ee5a26f2SJeremy L Thompson @param[out] is_valid Boolean flag indicating if file can be opend 22ee5a26f2SJeremy L Thompson 23ee5a26f2SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 24ee5a26f2SJeremy L Thompson 25ee5a26f2SJeremy L Thompson @ref Backend 26ee5a26f2SJeremy L Thompson **/ 27ee5a26f2SJeremy L Thompson int CeedCheckFilePath(Ceed ceed, const char *source_file_path, bool *is_valid) { 28ee5a26f2SJeremy L Thompson int ierr; 29ee5a26f2SJeremy L Thompson 30ee5a26f2SJeremy L Thompson // Sometimes we have path/to/file.h:function_name 31ee5a26f2SJeremy L Thompson // Create tempory file path without name, if needed 32ee5a26f2SJeremy L Thompson char *source_file_path_only; 33ee5a26f2SJeremy L Thompson char *last_colon = strrchr(source_file_path, ':'); 34ee5a26f2SJeremy L Thompson if (last_colon) { 35ee5a26f2SJeremy L Thompson size_t source_file_path_length = (last_colon - source_file_path + 1); 36ee5a26f2SJeremy L Thompson 37ee5a26f2SJeremy L Thompson ierr = CeedCalloc(source_file_path_length, &source_file_path_only); 38ee5a26f2SJeremy L Thompson CeedChk(ierr); 39d602d780SJeremy L Thompson memcpy(source_file_path_only, source_file_path, source_file_path_length - 1); 40ee5a26f2SJeremy L Thompson } else { 41ee5a26f2SJeremy L Thompson source_file_path_only = (char *)source_file_path; 42ee5a26f2SJeremy L Thompson } 43ee5a26f2SJeremy L Thompson 44ee5a26f2SJeremy L Thompson // Debug 45ee5a26f2SJeremy L Thompson CeedDebug256(ceed, 1, "Checking for source file: "); 4613f886e9SJeremy L Thompson CeedDebug(ceed, "%s\n", source_file_path_only); 47ee5a26f2SJeremy L Thompson 48ee5a26f2SJeremy L Thompson // Check for valid file path 49ee5a26f2SJeremy L Thompson FILE *source_file; 50ee5a26f2SJeremy L Thompson source_file = fopen(source_file_path_only, "rb"); 51ee5a26f2SJeremy L Thompson *is_valid = !!source_file; 52ee5a26f2SJeremy L Thompson 53ee5a26f2SJeremy L Thompson if (*is_valid) { 54ee5a26f2SJeremy L Thompson // Debug 55ee5a26f2SJeremy L Thompson CeedDebug256(ceed, 1, "Found JiT source file: "); 5613f886e9SJeremy L Thompson CeedDebug(ceed, "%s\n", source_file_path_only); 57ee5a26f2SJeremy L Thompson 58ee5a26f2SJeremy L Thompson fclose(source_file); 59ee5a26f2SJeremy L Thompson } 60ee5a26f2SJeremy L Thompson 61ee5a26f2SJeremy L Thompson // Free temp file path, if used 62ee5a26f2SJeremy L Thompson if (last_colon) { 63ee5a26f2SJeremy L Thompson ierr = CeedFree(&source_file_path_only); CeedChk(ierr); 64ee5a26f2SJeremy L Thompson } 65ee5a26f2SJeremy L Thompson 66ee5a26f2SJeremy L Thompson return CEED_ERROR_SUCCESS; 67ee5a26f2SJeremy L Thompson } 68ee5a26f2SJeremy L Thompson 69ee5a26f2SJeremy L Thompson /** 70f6af633fSnbeams @brief Load source file into initialized string buffer, including full text 713d3250a0SJeremy L Thompson of local files in place of `#include "local.h"` 723d3250a0SJeremy L Thompson 733d3250a0SJeremy L Thompson @param ceed A Ceed object for error handling 743d3250a0SJeremy L Thompson @param[in] source_file_path Absolute path to source file 753d3250a0SJeremy L Thompson @param[out] buffer String buffer for source file contents 763d3250a0SJeremy L Thompson 773d3250a0SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 783d3250a0SJeremy L Thompson 793d3250a0SJeremy L Thompson @ref Backend 803d3250a0SJeremy L Thompson **/ 81f6af633fSnbeams int CeedLoadSourceToInitializedBuffer(Ceed ceed, 823d3250a0SJeremy L Thompson const char *source_file_path, char **buffer) { 833d3250a0SJeremy L Thompson int ierr; 843d3250a0SJeremy L Thompson FILE *source_file; 853d3250a0SJeremy L Thompson long file_size, file_offset = 0; 863d3250a0SJeremy L Thompson char *temp_buffer; 873d3250a0SJeremy L Thompson 883d3250a0SJeremy L Thompson // Debug 893d3250a0SJeremy L Thompson CeedDebug256(ceed, 1, "---------- Ceed JiT ----------\n"); 903d3250a0SJeremy L Thompson CeedDebug256(ceed, 1, "Current source file: "); 9113f886e9SJeremy L Thompson CeedDebug(ceed, "%s\n", source_file_path); 923d3250a0SJeremy L Thompson CeedDebug256(ceed, 1, "Current buffer:\n"); 9313f886e9SJeremy L Thompson CeedDebug(ceed, "%s\n", *buffer); 943d3250a0SJeremy L Thompson 953d3250a0SJeremy L Thompson // Read file to temporary buffer 963d3250a0SJeremy L Thompson source_file = fopen(source_file_path, "rb"); 973d3250a0SJeremy L Thompson if (!source_file) 983d3250a0SJeremy L Thompson // LCOV_EXCL_START 993d3250a0SJeremy L Thompson return CeedError(ceed, CEED_ERROR_MAJOR, "Couldn't open source file: %s", 1003d3250a0SJeremy L Thompson source_file_path); 1013d3250a0SJeremy L Thompson // LCOV_EXCL_STOP 1023d3250a0SJeremy L Thompson // -- Compute size of source 1033d3250a0SJeremy L Thompson fseek(source_file, 0L, SEEK_END); 1043d3250a0SJeremy L Thompson file_size = ftell(source_file); 1053d3250a0SJeremy L Thompson rewind(source_file); 1063d3250a0SJeremy L Thompson // -- Allocate memory for entire source file 1073d3250a0SJeremy L Thompson ierr = CeedCalloc(file_size + 1, &temp_buffer); CeedChk(ierr); 1083d3250a0SJeremy L Thompson // -- Copy the file into the buffer 1093d3250a0SJeremy L Thompson if (1 != fread(temp_buffer, file_size, 1, source_file)) { 1103d3250a0SJeremy L Thompson // LCOV_EXCL_START 1113d3250a0SJeremy L Thompson fclose(source_file); 1123d3250a0SJeremy L Thompson ierr = CeedFree(&temp_buffer); CeedChk(ierr); 1133d3250a0SJeremy L Thompson return CeedError(ceed, CEED_ERROR_MAJOR, "Couldn't read source file: %s", 1143d3250a0SJeremy L Thompson source_file_path); 1153d3250a0SJeremy L Thompson // LCOV_EXCL_STOP 1163d3250a0SJeremy L Thompson } 1173d3250a0SJeremy L Thompson fclose(source_file); 1183d3250a0SJeremy L Thompson 1193d3250a0SJeremy L Thompson // Search for headers to include 1203d3250a0SJeremy L Thompson const char *first_hash = strchr(temp_buffer, '#'); 1213d3250a0SJeremy L Thompson while (first_hash) { 1223d3250a0SJeremy L Thompson // -- Check for 'include' keyword 1233d3250a0SJeremy L Thompson const char *next_e = strchr(first_hash, 'e'); 1243d3250a0SJeremy L Thompson char keyword[8] = ""; 125*c9c2c079SJeremy L Thompson if (next_e && next_e - first_hash >= 7) memcpy(keyword, &next_e[-6], 7); 1263d3250a0SJeremy L Thompson bool is_hash_include = !strcmp(keyword, "include"); 1273d3250a0SJeremy L Thompson // ---- Spaces allowed in '# include <header.h>' 128*c9c2c079SJeremy L Thompson if (next_e) { 129*c9c2c079SJeremy L Thompson for (CeedInt i = 1; first_hash - next_e + i < -6; i++) { 1303d3250a0SJeremy L Thompson is_hash_include &= first_hash[i] == ' '; 131*c9c2c079SJeremy L Thompson } 132*c9c2c079SJeremy L Thompson } 1333d3250a0SJeremy L Thompson if (is_hash_include) { 1343d3250a0SJeremy L Thompson // -- Copy into buffer all preceding # 1353d3250a0SJeremy L Thompson long current_size = strlen(*buffer); 1363d3250a0SJeremy L Thompson long copy_size = first_hash - &temp_buffer[file_offset]; 1373d3250a0SJeremy L Thompson ierr = CeedRealloc(current_size + copy_size + 2, buffer); CeedChk(ierr); 138d602d780SJeremy L Thompson memcpy(&(*buffer)[current_size], "\n", 2); 139d602d780SJeremy L Thompson memcpy(&(*buffer)[current_size + 1], &temp_buffer[file_offset], copy_size); 140d602d780SJeremy L Thompson memcpy(&(*buffer)[current_size + copy_size], "", 1); 1413d3250a0SJeremy L Thompson // -- Load local "header.h" 1423d3250a0SJeremy L Thompson char *next_quote = strchr(first_hash, '"'); 1433d3250a0SJeremy L Thompson char *next_new_line = strchr(first_hash, '\n'); 144*c9c2c079SJeremy L Thompson bool is_local_header = is_hash_include && next_quote && 145*c9c2c079SJeremy L Thompson (next_new_line - next_quote > 0); 146*c9c2c079SJeremy L Thompson char *next_left_chevron = strchr(first_hash, '<'); 147*c9c2c079SJeremy L Thompson bool is_ceed_header = is_hash_include && next_left_chevron && 148*c9c2c079SJeremy L Thompson (next_new_line - next_left_chevron > 0) && 149*c9c2c079SJeremy L Thompson (!strncmp(next_left_chevron, "<ceed/jit-source/", 17) || 150*c9c2c079SJeremy L Thompson !strncmp(next_left_chevron, "<ceed/types.h>", 14) || 151*c9c2c079SJeremy L Thompson !strncmp(next_left_chevron, "<ceed/ceed-f32.h>", 17) || 152*c9c2c079SJeremy L Thompson !strncmp(next_left_chevron, "<ceed/ceed-f64.h>", 17)); 153*c9c2c079SJeremy L Thompson if (is_local_header || is_ceed_header) { 1543d3250a0SJeremy L Thompson // ---- Build source path 1553d3250a0SJeremy L Thompson char *include_source_path; 156*c9c2c079SJeremy L Thompson if (is_local_header) { 1573d3250a0SJeremy L Thompson long root_length = strrchr(source_file_path, '/') - source_file_path; 1583d3250a0SJeremy L Thompson long include_file_name_len = strchr(&next_quote[1], '"') - next_quote - 1; 1593d3250a0SJeremy L Thompson ierr = CeedCalloc(root_length + include_file_name_len + 2, 1603d3250a0SJeremy L Thompson &include_source_path); CeedChk(ierr); 161d602d780SJeremy L Thompson memcpy(include_source_path, source_file_path, root_length + 1); 162d602d780SJeremy L Thompson memcpy(&include_source_path[root_length + 1], &next_quote[1], 1633d3250a0SJeremy L Thompson include_file_name_len); 164d602d780SJeremy L Thompson memcpy(&include_source_path[root_length + include_file_name_len + 1], "", 1); 165*c9c2c079SJeremy L Thompson } else { 166*c9c2c079SJeremy L Thompson char *next_right_chevron = strchr(first_hash, '>'); 167*c9c2c079SJeremy L Thompson char *ceed_relative_path; 168*c9c2c079SJeremy L Thompson long ceed_relative_path_length = next_right_chevron - next_left_chevron - 1; 169*c9c2c079SJeremy L Thompson ierr = CeedCalloc(ceed_relative_path_length + 1, &ceed_relative_path); 170*c9c2c079SJeremy L Thompson CeedChk(ierr); 171*c9c2c079SJeremy L Thompson memcpy(ceed_relative_path, &next_left_chevron[1], ceed_relative_path_length); 172*c9c2c079SJeremy L Thompson ierr = CeedGetJitAbsolutePath(ceed, ceed_relative_path, &include_source_path); 173*c9c2c079SJeremy L Thompson CeedChk(ierr); 174*c9c2c079SJeremy L Thompson } 1753d3250a0SJeremy L Thompson // ---- Recursive call to load source to buffer 176a0154adeSJed Brown CeedDebug256(ceed, 2, "JiT Including: %s\n", include_source_path); 1773d3250a0SJeremy L Thompson CeedChk(ierr); 178*c9c2c079SJeremy L Thompson ierr = CeedLoadSourceToInitializedBuffer(ceed, include_source_path, buffer); 179*c9c2c079SJeremy L Thompson CeedChk(ierr); 1803d3250a0SJeremy L Thompson ierr = CeedFree(&include_source_path); CeedChk(ierr); 1813d3250a0SJeremy L Thompson } 1823d3250a0SJeremy L Thompson file_offset = strchr(first_hash, '\n') - temp_buffer + 1; 1833d3250a0SJeremy L Thompson } 1843d3250a0SJeremy L Thompson // -- Next hash 1853d3250a0SJeremy L Thompson first_hash = strchr(&first_hash[1], '#'); 1863d3250a0SJeremy L Thompson } 1873d3250a0SJeremy L Thompson // Copy rest of source file into buffer 1883d3250a0SJeremy L Thompson long current_size = strlen(*buffer); 1893d3250a0SJeremy L Thompson long copy_size = strlen(&temp_buffer[file_offset]); 1903d3250a0SJeremy L Thompson ierr = CeedRealloc(current_size + copy_size + 2, buffer); CeedChk(ierr); 191d602d780SJeremy L Thompson memcpy(&(*buffer)[current_size], "\n", 2); 192d602d780SJeremy L Thompson memcpy(&(*buffer)[current_size + 1], &temp_buffer[file_offset], copy_size); 193d602d780SJeremy L Thompson memcpy(&(*buffer)[current_size + copy_size + 1], "", 1); 1943d3250a0SJeremy L Thompson 1953d3250a0SJeremy L Thompson // Cleanup 1963d3250a0SJeremy L Thompson ierr = CeedFree(&temp_buffer); CeedChk(ierr); 1973d3250a0SJeremy L Thompson 1983d3250a0SJeremy L Thompson // Debug 1993d3250a0SJeremy L Thompson CeedDebug256(ceed, 1, "---------- Ceed JiT ----------\n"); 2003d3250a0SJeremy L Thompson CeedDebug256(ceed, 1, "Current source file: "); 20113f886e9SJeremy L Thompson CeedDebug(ceed, "%s\n", source_file_path); 2023d3250a0SJeremy L Thompson CeedDebug256(ceed, 1, "Final buffer:\n"); 20313f886e9SJeremy L Thompson CeedDebug(ceed, "%s\n", *buffer); 2043d3250a0SJeremy L Thompson 2053d3250a0SJeremy L Thompson return CEED_ERROR_SUCCESS; 2063d3250a0SJeremy L Thompson } 2073d3250a0SJeremy L Thompson 2083d3250a0SJeremy L Thompson /** 2093d3250a0SJeremy L Thompson @brief Initalize and load source file into string buffer, including full text 2103d3250a0SJeremy L Thompson of local files in place of `#include "local.h"`. 2113d3250a0SJeremy L Thompson Note: Caller is responsible for freeing the string buffer with `CeedFree()`. 2123d3250a0SJeremy L Thompson 2133d3250a0SJeremy L Thompson @param ceed A Ceed object for error handling 2143d3250a0SJeremy L Thompson @param[in] source_file_path Absolute path to source file 2153d3250a0SJeremy L Thompson @param[out] buffer String buffer for source file contents 2163d3250a0SJeremy L Thompson 2173d3250a0SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 2183d3250a0SJeremy L Thompson 2193d3250a0SJeremy L Thompson @ref Backend 2203d3250a0SJeremy L Thompson **/ 2213d3250a0SJeremy L Thompson int CeedLoadSourceToBuffer(Ceed ceed, const char *source_file_path, 2223d3250a0SJeremy L Thompson char **buffer) { 2233d3250a0SJeremy L Thompson int ierr; 2243d3250a0SJeremy L Thompson 2253d3250a0SJeremy L Thompson // Initalize buffer 2263d3250a0SJeremy L Thompson ierr = CeedCalloc(1, buffer); CeedChk(ierr); 2273d3250a0SJeremy L Thompson 2283d3250a0SJeremy L Thompson // Load to initalized buffer 229f6af633fSnbeams ierr = CeedLoadSourceToInitializedBuffer(ceed, source_file_path, buffer); 2303d3250a0SJeremy L Thompson CeedChk(ierr); 2313d3250a0SJeremy L Thompson 2323d3250a0SJeremy L Thompson return CEED_ERROR_SUCCESS; 2333d3250a0SJeremy L Thompson } 234437930d1SJeremy L Thompson 235437930d1SJeremy L Thompson /** 236437930d1SJeremy L Thompson @brief Build an absolute filepath from a base filepath and an absolute filepath. 237437930d1SJeremy L Thompson This helps construct source file paths for `CeedLoadSourceToBuffer()`. 238437930d1SJeremy L Thompson Note: Caller is responsible for freeing the string buffer with `CeedFree()`. 239437930d1SJeremy L Thompson 240437930d1SJeremy L Thompson @param ceed A Ceed object for error handling 241437930d1SJeremy L Thompson @param[in] base_file_path Absolute path to current file 242437930d1SJeremy L Thompson @param[in] relative_file_path Relative path to target file 243437930d1SJeremy L Thompson @param[out] new_file_path String buffer for absolute path to target file 244437930d1SJeremy L Thompson 245437930d1SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 246437930d1SJeremy L Thompson 247437930d1SJeremy L Thompson @ref Backend 248437930d1SJeremy L Thompson **/ 249437930d1SJeremy L Thompson int CeedPathConcatenate(Ceed ceed, const char *base_file_path, 250437930d1SJeremy L Thompson const char *relative_file_path, char **new_file_path) { 251437930d1SJeremy L Thompson int ierr; 252437930d1SJeremy L Thompson char *last_slash = strrchr(base_file_path, '/'); 253437930d1SJeremy L Thompson size_t base_length = (last_slash - base_file_path + 1), 254437930d1SJeremy L Thompson relative_length = strlen(relative_file_path), 255437930d1SJeremy L Thompson new_file_path_length = base_length + relative_length + 1; 256437930d1SJeremy L Thompson 257437930d1SJeremy L Thompson ierr = CeedCalloc(new_file_path_length, new_file_path); CeedChk(ierr); 258d602d780SJeremy L Thompson memcpy(*new_file_path, base_file_path, base_length); 259d602d780SJeremy L Thompson memcpy(&((*new_file_path)[base_length]), relative_file_path, relative_length); 260437930d1SJeremy L Thompson 261437930d1SJeremy L Thompson return CEED_ERROR_SUCCESS; 262437930d1SJeremy L Thompson } 2636eb0d8b4SJeremy L Thompson 2646eb0d8b4SJeremy L Thompson /** 265032e71eaSJeremy L Thompson @brief Find the relative filepath to an installed JiT file 2666eb0d8b4SJeremy L Thompson 267032e71eaSJeremy L Thompson @param[in] absolute_file_path Absolute path to installed JiT file 268032e71eaSJeremy L Thompson @param[out] relative_file_path Relative path to installed JiT file 2696eb0d8b4SJeremy L Thompson 2706eb0d8b4SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 2716eb0d8b4SJeremy L Thompson 2726eb0d8b4SJeremy L Thompson @ref Backend 2736eb0d8b4SJeremy L Thompson **/ 274032e71eaSJeremy L Thompson int CeedGetJitRelativePath(const char *absolute_file_path, 275032e71eaSJeremy L Thompson const char **relative_file_path) { 276032e71eaSJeremy L Thompson *(relative_file_path) = strstr(absolute_file_path, "ceed/jit-source"); 2776eb0d8b4SJeremy L Thompson 278032e71eaSJeremy L Thompson if (!*relative_file_path) 279032e71eaSJeremy L Thompson // LCOV_EXCL_START 280032e71eaSJeremy L Thompson return CeedError(NULL, CEED_ERROR_MAJOR, 281032e71eaSJeremy L Thompson "Couldn't find relative path including " 282032e71eaSJeremy L Thompson "'ceed/jit-source' for: %s", absolute_file_path); 283032e71eaSJeremy L Thompson // LCOV_EXCL_STOP 2846eb0d8b4SJeremy L Thompson 2856eb0d8b4SJeremy L Thompson return CEED_ERROR_SUCCESS; 2866eb0d8b4SJeremy L Thompson } 287032e71eaSJeremy L Thompson 288032e71eaSJeremy L Thompson /** 289032e71eaSJeremy L Thompson @brief Build an absolute filepath to a JiT file 290032e71eaSJeremy L Thompson 291032e71eaSJeremy L Thompson @param ceed A Ceed object for error handling 292032e71eaSJeremy L Thompson @param[in] relative_file_path Relative path to installed JiT file 293032e71eaSJeremy L Thompson @param[out] absolute_file_path String buffer for absolute path to target file 294032e71eaSJeremy L Thompson 295032e71eaSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 296032e71eaSJeremy L Thompson 297032e71eaSJeremy L Thompson @ref Backend 298032e71eaSJeremy L Thompson **/ 299032e71eaSJeremy L Thompson int CeedGetJitAbsolutePath(Ceed ceed, const char *relative_file_path, 300032e71eaSJeremy L Thompson char **absolute_file_path) { 301032e71eaSJeremy L Thompson int ierr; 3026155f12fSJeremy L Thompson Ceed ceed_parent; 303032e71eaSJeremy L Thompson 304032e71eaSJeremy L Thompson // Debug 305032e71eaSJeremy L Thompson CeedDebug256(ceed, 1, "---------- Ceed JiT ----------\n"); 306032e71eaSJeremy L Thompson CeedDebug256(ceed, 1, "Relative JiT source file: "); 30713f886e9SJeremy L Thompson CeedDebug(ceed, "%s\n", relative_file_path); 308032e71eaSJeremy L Thompson 309032e71eaSJeremy L Thompson 3106155f12fSJeremy L Thompson ierr = CeedGetParent(ceed, &ceed_parent); CeedChk(ierr); 3116155f12fSJeremy L Thompson for (CeedInt i = 0; i < ceed_parent->num_jit_source_roots; i++) { 312ee5a26f2SJeremy L Thompson bool is_valid; 313ee5a26f2SJeremy L Thompson 314032e71eaSJeremy L Thompson // Debug 315032e71eaSJeremy L Thompson CeedDebug256(ceed, 1, "Checking JiT root: "); 31613f886e9SJeremy L Thompson CeedDebug(ceed, "%s\n", ceed_parent->jit_source_roots[i]); 317032e71eaSJeremy L Thompson 318ee5a26f2SJeremy L Thompson // Build and check absolute path with current root 3196155f12fSJeremy L Thompson ierr = CeedPathConcatenate(ceed, ceed_parent->jit_source_roots[i], 320032e71eaSJeremy L Thompson relative_file_path, absolute_file_path); 321032e71eaSJeremy L Thompson CeedChk(ierr); 322ee5a26f2SJeremy L Thompson ierr = CeedCheckFilePath(ceed, *absolute_file_path, &is_valid); CeedChk(ierr); 323032e71eaSJeremy L Thompson 324ee5a26f2SJeremy L Thompson if (is_valid) { 325032e71eaSJeremy L Thompson return CEED_ERROR_SUCCESS; 326032e71eaSJeremy L Thompson } else { 327032e71eaSJeremy L Thompson ierr = CeedFree(absolute_file_path); CeedChk(ierr); 328032e71eaSJeremy L Thompson } 329032e71eaSJeremy L Thompson } 330032e71eaSJeremy L Thompson 331032e71eaSJeremy L Thompson // LCOV_EXCL_START 332032e71eaSJeremy L Thompson return CeedError(ceed, CEED_ERROR_MAJOR, 333032e71eaSJeremy L Thompson "Couldn't find matching JiT source file: %s", 334032e71eaSJeremy L Thompson relative_file_path); 335032e71eaSJeremy L Thompson // LCOV_EXCL_STOP 336032e71eaSJeremy L Thompson } 337