| ceed-jit-tools.c (76e570b879b329e479addbab569cc13ecfa673ca) | ceed-jit-tools.c (ca94c3ddc8f82b7d93a79f9e4812e99b8be840ff) |
|---|---|
| 1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3// 4// SPDX-License-Identifier: BSD-2-Clause 5// 6// This file is part of CEED: http://github.com/ceed 7 8#include <ceed-impl.h> 9#include <ceed.h> 10#include <ceed/backend.h> 11#include <ceed/jit-tools.h> 12#include <stdbool.h> 13#include <stdio.h> 14#include <string.h> 15 16/** 17 @brief Check if valid file exists at path given 18 | 1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3// 4// SPDX-License-Identifier: BSD-2-Clause 5// 6// This file is part of CEED: http://github.com/ceed 7 8#include <ceed-impl.h> 9#include <ceed.h> 10#include <ceed/backend.h> 11#include <ceed/jit-tools.h> 12#include <stdbool.h> 13#include <stdio.h> 14#include <string.h> 15 16/** 17 @brief Check if valid file exists at path given 18 |
| 19 @param[in] ceed Ceed object for error handling | 19 @param[in] ceed `Ceed` object for error handling |
| 20 @param[in] source_file_path Absolute path to source file 21 @param[out] is_valid Boolean flag indicating if file can be opened 22 23 @return An error code: 0 - success, otherwise - failure 24 25 @ref Backend 26**/ 27int CeedCheckFilePath(Ceed ceed, const char *source_file_path, bool *is_valid) { --- 30 unchanged lines hidden (view full) --- 58 // Free temp file path, if used 59 if (last_colon) CeedCall(CeedFree(&source_file_path_only)); 60 return CEED_ERROR_SUCCESS; 61} 62 63/** 64 @brief Load source file into initialized string buffer, including full text of local files in place of `#include "local.h"` 65 | 20 @param[in] source_file_path Absolute path to source file 21 @param[out] is_valid Boolean flag indicating if file can be opened 22 23 @return An error code: 0 - success, otherwise - failure 24 25 @ref Backend 26**/ 27int CeedCheckFilePath(Ceed ceed, const char *source_file_path, bool *is_valid) { --- 30 unchanged lines hidden (view full) --- 58 // Free temp file path, if used 59 if (last_colon) CeedCall(CeedFree(&source_file_path_only)); 60 return CEED_ERROR_SUCCESS; 61} 62 63/** 64 @brief Load source file into initialized string buffer, including full text of local files in place of `#include "local.h"` 65 |
| 66 @param[in] ceed Ceed object for error handling | 66 @param[in] ceed `Ceed` object for error handling |
| 67 @param[in] source_file_path Absolute path to source file 68 @param[out] buffer String buffer for source file contents 69 70 @return An error code: 0 - success, otherwise - failure 71 72 @ref Backend 73**/ 74int CeedLoadSourceToInitializedBuffer(Ceed ceed, const char *source_file_path, char **buffer) { --- 113 unchanged lines hidden (view full) --- 188 CeedDebug256(ceed, CEED_DEBUG_COLOR_SUCCESS, "Final buffer:\n"); 189 CeedDebug(ceed, "%s\n", *buffer); 190 return CEED_ERROR_SUCCESS; 191} 192 193/** 194 @brief Initialize and load source file into string buffer, including full text of local files in place of `#include "local.h"`. 195 | 67 @param[in] source_file_path Absolute path to source file 68 @param[out] buffer String buffer for source file contents 69 70 @return An error code: 0 - success, otherwise - failure 71 72 @ref Backend 73**/ 74int CeedLoadSourceToInitializedBuffer(Ceed ceed, const char *source_file_path, char **buffer) { --- 113 unchanged lines hidden (view full) --- 188 CeedDebug256(ceed, CEED_DEBUG_COLOR_SUCCESS, "Final buffer:\n"); 189 CeedDebug(ceed, "%s\n", *buffer); 190 return CEED_ERROR_SUCCESS; 191} 192 193/** 194 @brief Initialize and load source file into string buffer, including full text of local files in place of `#include "local.h"`. 195 |
| 196 Note: Caller is responsible for freeing the string buffer with `CeedFree()`. | 196 Note: Caller is responsible for freeing the string buffer with @ref CeedFree(). |
| 197 | 197 |
| 198 @param[in] ceed Ceed object for error handling | 198 @param[in] ceed `Ceed` object for error handling |
| 199 @param[in] source_file_path Absolute path to source file 200 @param[out] buffer String buffer for source file contents 201 202 @return An error code: 0 - success, otherwise - failure 203 204 @ref Backend 205**/ 206int CeedLoadSourceToBuffer(Ceed ceed, const char *source_file_path, char **buffer) { 207 // Initialize buffer 208 CeedCall(CeedCalloc(1, buffer)); 209 210 // Load to initalized buffer 211 CeedCall(CeedLoadSourceToInitializedBuffer(ceed, source_file_path, buffer)); 212 return CEED_ERROR_SUCCESS; 213} 214 215/** 216 @brief Build an absolute filepath from a base filepath and an absolute filepath. 217 | 199 @param[in] source_file_path Absolute path to source file 200 @param[out] buffer String buffer for source file contents 201 202 @return An error code: 0 - success, otherwise - failure 203 204 @ref Backend 205**/ 206int CeedLoadSourceToBuffer(Ceed ceed, const char *source_file_path, char **buffer) { 207 // Initialize buffer 208 CeedCall(CeedCalloc(1, buffer)); 209 210 // Load to initalized buffer 211 CeedCall(CeedLoadSourceToInitializedBuffer(ceed, source_file_path, buffer)); 212 return CEED_ERROR_SUCCESS; 213} 214 215/** 216 @brief Build an absolute filepath from a base filepath and an absolute filepath. 217 |
| 218 This helps construct source file paths for `CeedLoadSourceToBuffer()`. | 218 This helps construct source file paths for @ref CeedLoadSourceToBuffer(). |
| 219 | 219 |
| 220 Note: Caller is responsible for freeing the string buffer with `CeedFree()`. | 220 Note: Caller is responsible for freeing the string buffer with @ref CeedFree(). |
| 221 | 221 |
| 222 @param[in] ceed Ceed object for error handling | 222 @param[in] ceed `Ceed` object for error handling |
| 223 @param[in] base_file_path Absolute path to current file 224 @param[in] relative_file_path Relative path to target file 225 @param[out] new_file_path String buffer for absolute path to target file 226 227 @return An error code: 0 - success, otherwise - failure 228 229 @ref Backend 230**/ --- 22 unchanged lines hidden (view full) --- 253 *(relative_file_path) = strstr(absolute_file_path, "ceed/jit-source"); 254 CeedCheck(*relative_file_path, NULL, CEED_ERROR_MAJOR, "Couldn't find relative path including 'ceed/jit-source' for: %s", absolute_file_path); 255 return CEED_ERROR_SUCCESS; 256} 257 258/** 259 @brief Build an absolute filepath to a JiT file 260 | 223 @param[in] base_file_path Absolute path to current file 224 @param[in] relative_file_path Relative path to target file 225 @param[out] new_file_path String buffer for absolute path to target file 226 227 @return An error code: 0 - success, otherwise - failure 228 229 @ref Backend 230**/ --- 22 unchanged lines hidden (view full) --- 253 *(relative_file_path) = strstr(absolute_file_path, "ceed/jit-source"); 254 CeedCheck(*relative_file_path, NULL, CEED_ERROR_MAJOR, "Couldn't find relative path including 'ceed/jit-source' for: %s", absolute_file_path); 255 return CEED_ERROR_SUCCESS; 256} 257 258/** 259 @brief Build an absolute filepath to a JiT file 260 |
| 261 @param[in] ceed Ceed object for error handling | 261 @param[in] ceed `Ceed` object for error handling |
| 262 @param[in] relative_file_path Relative path to installed JiT file 263 @param[out] absolute_file_path String buffer for absolute path to target file, to be freed by caller 264 265 @return An error code: 0 - success, otherwise - failure 266 267 @ref Backend 268**/ 269int CeedGetJitAbsolutePath(Ceed ceed, const char *relative_file_path, char **absolute_file_path) { --- 28 unchanged lines hidden --- | 262 @param[in] relative_file_path Relative path to installed JiT file 263 @param[out] absolute_file_path String buffer for absolute path to target file, to be freed by caller 264 265 @return An error code: 0 - success, otherwise - failure 266 267 @ref Backend 268**/ 269int CeedGetJitAbsolutePath(Ceed ceed, const char *relative_file_path, char **absolute_file_path) { --- 28 unchanged lines hidden --- |