rez
rez.hpp
Go to the documentation of this file.
1 #pragma once
2 
10 #include <filesystem>
11 #include <optional>
12 #include <string>
13 
17 namespace rez {
21 constexpr char Version[]{ "0.0.11" };
22 
26 constexpr char TaskDefinitionCpp[]{ "rez.cpp" };
27 
31 constexpr char TaskDefinitionC[]{ "rez.c" };
32 
36 constexpr char CacheDir[]{ ".rez" };
37 
41 constexpr char CacheFileBasename[]{ "rez-env.txt" };
42 
46 constexpr char ArtifactDirBasename[]{ "bin" };
47 
51 constexpr char ArtifactFileBasenameUnix[]{ "delegate-rez" };
52 
62 constexpr char DefaultCompilerWindows[]{ "cl" };
63 
71 constexpr char DefaultCompilerUnixCpp[]{ "c++" };
72 
80 constexpr char DefaultCompilerUnixC[]{ "cc" };
81 
87 constexpr char DefaultMSVCToolchainQueryScript[]{ R"(C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat)" };
88 
92 constexpr char ArchitectureMsvcAmd64[]{ "x64" };
93 
97 enum class Lang {
101  Cpp,
102 
106  C
107 };
108 
116 std::ostream &operator<<(std::ostream &os, const Lang &o);
117 
125 std::filesystem::path ApplyBinaryExtension(const std::filesystem::path &basename, bool windows);
126 
133 std::optional<std::string> GetEnvironmentVariable(const std::string &key);
134 
145 
149 struct Config {
150  std::filesystem::path cache_file_path{ std::filesystem::path(CacheDir) / CacheFileBasename };
151 
160  bool debug{ false };
161 
170  bool windows{ false };
171 
182  std::filesystem::path task_definition_path{ std::filesystem::path(TaskDefinitionCpp) };
183 
193 
207  std::string compiler{ std::string(DefaultCompilerUnixCpp) };
208 
216  std::filesystem::path artifact_dir_path{ std::filesystem::path(CacheDir) / ArtifactDirBasename };
217 
226  std::filesystem::path artifact_file_path{ std::filesystem::path("") };
227 
236  std::string build_command{};
237 
245  void ApplyMSVCToolchain() const;
246 
252  void Load();
253 };
254 
262 std::ostream &operator<<(std::ostream &os, const Config &o);
263 }
rez::TaskDefinitionC
constexpr char TaskDefinitionC[]
TaskDefinitionC denotes the path to a C task definition source file.
Definition: rez.hpp:31
rez::Lang::C
@ C
C denotes C, the successor to BCPL.
rez::Version
constexpr char Version[]
Version is semver.
Definition: rez.hpp:21
rez::DefaultMSVCToolchainQueryScript
constexpr char DefaultMSVCToolchainQueryScript[]
DefaultMSVCToolchainQueryScript denotes the standard script which prepares environment variables for ...
Definition: rez.hpp:87
rez::Config::task_definition_lang
Lang task_definition_lang
task_definition_lang denotes the programming language for the user's task definition source file....
Definition: rez.hpp:192
rez::Config::Load
void Load()
Load populates build parameters according to the documented defaults and override mechanisms.
Definition: rez.cpp:180
rez::Config::debug
bool debug
debug controls whether additional logging is performed. (Default: false)
Definition: rez.hpp:160
rez::operator<<
std::ostream & operator<<(std::ostream &os, const Lang &o)
<< formats a Lang to an ostream.
Definition: rez.cpp:25
rez::ArchitectureMsvcAmd64
constexpr char ArchitectureMsvcAmd64[]
ArchitectureMsvcAmd64 denotes the amd64 architecture in MSVC nomenclature.
Definition: rez.hpp:92
rez::Config::task_definition_path
std::filesystem::path task_definition_path
task_definition_path denotes the user's task definition source file. (Default: rez....
Definition: rez.hpp:182
rez::Lang
Lang
Lang denotes a programming language.
Definition: rez.hpp:97
rez::Config::build_command
std::string build_command
build_command denotes the compilation step for the user task source file (Default: Determined at runt...
Definition: rez.hpp:236
rez::DefaultCompilerWindows
constexpr char DefaultCompilerWindows[]
DefaultCompilerWindows denotes the standard Microsoft Visual C++ (MSVC) compiler executable basename.
Definition: rez.hpp:62
rez::Config::ApplyMSVCToolchain
void ApplyMSVCToolchain() const
ApplyMSVCToolchain loads MSVC environment variables for cl into the current process.
Definition: rez.cpp:81
rez::Config::cache_file_path
std::filesystem::path cache_file_path
Definition: rez.hpp:150
rez::DefaultCompilerUnixCpp
constexpr char DefaultCompilerUnixCpp[]
DefaultCompilerUnixCpp denotes the standard UNIX C++ compiler executable basename.
Definition: rez.hpp:71
rez::Lang::Cpp
@ Cpp
Cpp denotes C++, object oriented C.
rez::CacheDir
constexpr char CacheDir[]
CacheDir denotes the path to the rez internal cache directory.
Definition: rez.hpp:36
rez::ApplyBinaryExtension
std::filesystem::path ApplyBinaryExtension(const std::filesystem::path &basename, bool windows)
ApplyBinaryExtension applies OS-appropriate file extensions to binaries.
Definition: rez.cpp:34
rez::Config::compiler
std::string compiler
compiler denotes the executable used to build the user task tree. (Default: Determined at runtime by ...
Definition: rez.hpp:207
rez::ArtifactDirBasename
constexpr char ArtifactDirBasename[]
ArtifactDirBaename denotes the path insode of CacheDir where artifacts are housed.
Definition: rez.hpp:46
rez::TaskDefinitionCpp
constexpr char TaskDefinitionCpp[]
TaskDefinitionCpp denotes the path to a C++ task definition source file.
Definition: rez.hpp:26
rez::Config
Config parameterizes rez builds.
Definition: rez.hpp:149
rez::CacheFileBasename
constexpr char CacheFileBasename[]
CacheFileBasename denotes the basename of the internal rez cache file.
Definition: rez.hpp:41
rez::Config::windows
bool windows
windows denotes whether the runtime environment is (COMSPEC) Windows. (Default: Determined at runtime...
Definition: rez.hpp:170
rez::Config::artifact_dir_path
std::filesystem::path artifact_dir_path
artifact_dir_path denotes the path where rez binaries are housed (Default: std::filesystem::path(Cach...
Definition: rez.hpp:216
rez
rez manages C++ tasks.
Definition: rez.hpp:17
rez::DetectWindowsEnvironment
bool DetectWindowsEnvironment()
DetectWindowsEnvironment determines whether the runtime environment is (COMSPEC) Windows.
Definition: rez.cpp:77
rez::DefaultCompilerUnixC
constexpr char DefaultCompilerUnixC[]
DefaultCompilerUnixC denotes the standard UNIX C compiler executable basename.
Definition: rez.hpp:80
rez::ArtifactFileBasenameUnix
constexpr char ArtifactFileBasenameUnix[]
ArtifactFileBasenameUnix denotes the basename of user task binaries generated by UNIX compilers.
Definition: rez.hpp:51
rez::Config::artifact_file_path
std::filesystem::path artifact_file_path
artifact_file_path denotes the binary path where user task executable shall be generated (Default: De...
Definition: rez.hpp:226
rez::GetEnvironmentVariable
std::optional< std::string > GetEnvironmentVariable(const std::string &key)
GetEnvironmentVariable retrieves environment variables.
Definition: rez.cpp:44