xref: /libCEED/rust/libceed-sys/c-src/interface/ceed-config.c (revision 2027fb9d13fe34211738d8539f90542a9801ae2c)
1944f002eSJeremy L Thompson // Copyright (c) 2017-2025, 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 /**
39*2027fb9dSSirAlienTheGreat   @brief Set whether or not to use clang when compiling for GPU (instead of nvrtc)
40*2027fb9dSSirAlienTheGreat 
41*2027fb9dSSirAlienTheGreat   @param[in] is_clang Whether or not to use clang on GPU
42*2027fb9dSSirAlienTheGreat 
43*2027fb9dSSirAlienTheGreat   @ref Developer
44*2027fb9dSSirAlienTheGreat 
45*2027fb9dSSirAlienTheGreat   @sa CeedGetIsClang()
46*2027fb9dSSirAlienTheGreat 
47*2027fb9dSSirAlienTheGreat   @return An error code: 0 - success, otherwise - failure
48*2027fb9dSSirAlienTheGreat  */
49*2027fb9dSSirAlienTheGreat int CeedSetIsClang(Ceed ceed, bool is_clang) {
50*2027fb9dSSirAlienTheGreat   ceed->cuda_compile_with_clang = is_clang;
51*2027fb9dSSirAlienTheGreat   return CEED_ERROR_SUCCESS;
52*2027fb9dSSirAlienTheGreat }
53*2027fb9dSSirAlienTheGreat 
54*2027fb9dSSirAlienTheGreat /**
55*2027fb9dSSirAlienTheGreat   @brief Determine if the current ceed is set to compile with clang when on GPU
56*2027fb9dSSirAlienTheGreat 
57*2027fb9dSSirAlienTheGreat   @param[out] is_clang The location to write the current GPU clang status to
58*2027fb9dSSirAlienTheGreat 
59*2027fb9dSSirAlienTheGreat   @ref Developer
60*2027fb9dSSirAlienTheGreat 
61*2027fb9dSSirAlienTheGreat   @sa CeedSetIsClang()
62*2027fb9dSSirAlienTheGreat 
63*2027fb9dSSirAlienTheGreat   @return An error code: 0 - success, otherwise - failure
64*2027fb9dSSirAlienTheGreat  */
65*2027fb9dSSirAlienTheGreat int CeedGetIsClang(Ceed ceed, bool *is_clang) {
66*2027fb9dSSirAlienTheGreat   *is_clang = ceed->cuda_compile_with_clang;
67*2027fb9dSSirAlienTheGreat   return CEED_ERROR_SUCCESS;
68*2027fb9dSSirAlienTheGreat }
69*2027fb9dSSirAlienTheGreat 
70*2027fb9dSSirAlienTheGreat /**
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