xref: /libCEED/rust/libceed-sys/c-src/interface/ceed-config.c (revision 9ba83ac0e4b1fca39d6fa6737a318a9f0cbc172d)
1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2944f002eSJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3944f002eSJeremy L Thompson //
4944f002eSJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
5944f002eSJeremy L Thompson //
6944f002eSJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
7944f002eSJeremy L Thompson 
8944f002eSJeremy L Thompson #include <ceed-impl.h>
9944f002eSJeremy L Thompson 
10944f002eSJeremy L Thompson const char *CeedGitVersion         = CEED_GIT_VERSION;
11944f002eSJeremy L Thompson const char *CeedBuildConfiguration = CEED_BUILD_CONFIGURATION;
12944f002eSJeremy L Thompson 
13944f002eSJeremy L Thompson /// @addtogroup CeedUser
14944f002eSJeremy L Thompson /// @{
15944f002eSJeremy L Thompson 
16944f002eSJeremy L Thompson /**
173b9caef5SJeremy L Thompson   @brief Get output of `git describe --dirty` from build time.
18944f002eSJeremy L Thompson 
193b9caef5SJeremy L Thompson   While @ref CeedGetVersion() uniquely identifies the source code for release
20944f002eSJeremy L Thompson   builds, it does not identify builds from other commits.
21944f002eSJeremy L Thompson 
22944f002eSJeremy L Thompson   @param[out] git_version A static string containing the Git commit description.
23944f002eSJeremy L Thompson 
24944f002eSJeremy L Thompson   If `git describe --always --dirty` fails, the string `"unknown"` will be provided.
25944f002eSJeremy L Thompson   This could occur if Git is not installed or if libCEED is not being built from a repository, for example.`
26944f002eSJeremy L Thompson 
27944f002eSJeremy L Thompson   @ref Developer
28944f002eSJeremy L Thompson 
29944f002eSJeremy L Thompson   @sa CeedGetVersion() CeedGetBuildConfiguration()
303b9caef5SJeremy L Thompson 
313b9caef5SJeremy L Thompson   @return An error code: 0 - success, otherwise - failure
32944f002eSJeremy L Thompson */
33944f002eSJeremy L Thompson int CeedGetGitVersion(const char **git_version) {
34944f002eSJeremy L Thompson   *git_version = CeedGitVersion;
35944f002eSJeremy L Thompson   return CEED_ERROR_SUCCESS;
36944f002eSJeremy L Thompson }
37944f002eSJeremy L Thompson 
38944f002eSJeremy L Thompson /**
392027fb9dSSirAlienTheGreat   @brief Set whether or not to use clang when compiling for GPU (instead of nvrtc)
402027fb9dSSirAlienTheGreat 
412027fb9dSSirAlienTheGreat   @param[in] is_clang Whether or not to use clang on GPU
422027fb9dSSirAlienTheGreat 
432027fb9dSSirAlienTheGreat   @ref Developer
442027fb9dSSirAlienTheGreat 
452027fb9dSSirAlienTheGreat   @sa CeedGetIsClang()
462027fb9dSSirAlienTheGreat 
472027fb9dSSirAlienTheGreat   @return An error code: 0 - success, otherwise - failure
482027fb9dSSirAlienTheGreat  */
492027fb9dSSirAlienTheGreat int CeedSetIsClang(Ceed ceed, bool is_clang) {
502027fb9dSSirAlienTheGreat   ceed->cuda_compile_with_clang = is_clang;
512027fb9dSSirAlienTheGreat   return CEED_ERROR_SUCCESS;
522027fb9dSSirAlienTheGreat }
532027fb9dSSirAlienTheGreat 
542027fb9dSSirAlienTheGreat /**
552027fb9dSSirAlienTheGreat   @brief Determine if the current ceed is set to compile with clang when on GPU
562027fb9dSSirAlienTheGreat 
572027fb9dSSirAlienTheGreat   @param[out] is_clang The location to write the current GPU clang status to
582027fb9dSSirAlienTheGreat 
592027fb9dSSirAlienTheGreat   @ref Developer
602027fb9dSSirAlienTheGreat 
612027fb9dSSirAlienTheGreat   @sa CeedSetIsClang()
622027fb9dSSirAlienTheGreat 
632027fb9dSSirAlienTheGreat   @return An error code: 0 - success, otherwise - failure
642027fb9dSSirAlienTheGreat  */
652027fb9dSSirAlienTheGreat int CeedGetIsClang(Ceed ceed, bool *is_clang) {
662027fb9dSSirAlienTheGreat   *is_clang = ceed->cuda_compile_with_clang;
672027fb9dSSirAlienTheGreat   return CEED_ERROR_SUCCESS;
682027fb9dSSirAlienTheGreat }
692027fb9dSSirAlienTheGreat 
702027fb9dSSirAlienTheGreat /**
713b9caef5SJeremy L Thompson   @brief Get build variables as a multi-line string.
72944f002eSJeremy L Thompson 
73944f002eSJeremy L Thompson   Each line of the string has the format `VARNAME = value`.
74944f002eSJeremy L Thompson 
75944f002eSJeremy L Thompson   @param[out] build_config A static string containing build variables
76944f002eSJeremy L Thompson 
77944f002eSJeremy L Thompson   @ref Developer
78944f002eSJeremy L Thompson 
79944f002eSJeremy L Thompson   @sa CeedGetVersion() CeedGetGitVersion()
803b9caef5SJeremy L Thompson 
813b9caef5SJeremy L Thompson   @return An error code: 0 - success, otherwise - failure
82944f002eSJeremy L Thompson */
83944f002eSJeremy L Thompson int CeedGetBuildConfiguration(const char **build_config) {
84944f002eSJeremy L Thompson   *build_config = CeedBuildConfiguration;
85944f002eSJeremy L Thompson   return CEED_ERROR_SUCCESS;
86944f002eSJeremy L Thompson }
87944f002eSJeremy L Thompson 
88944f002eSJeremy L Thompson /// @}
89