21
21
#endif
22
22
23
23
#include < floor/floor/floor.hpp>
24
+ #include < floor/floor/floor_version.hpp>
24
25
#include < floor/compute/llvm_compute.hpp>
25
26
#include < floor/compute/compute_device.hpp>
26
27
#include < floor/core/option_handler.hpp>
35
36
#include < floor/compute/metal/metal_compute.hpp>
36
37
#include < floor/compute/metal/metal_device.hpp>
37
38
39
+ #define FLOOR_OCC_VERSION_STR FLOOR_MAJOR_VERSION_STR " ." << FLOOR_MINOR_VERSION_STR " ." FLOOR_REVISION_VERSION_STR FLOOR_DEV_STAGE_VERSION_STR
40
+ #define FLOOR_OCC_FULL_VERSION_STR " offline compute compiler v" FLOOR_OCC_VERSION_STR
41
+
38
42
struct option_context {
39
43
string filename { " " };
40
44
string output_filename { " " };
@@ -59,6 +63,7 @@ typedef option_handler<option_context> occ_opt_handler;
59
63
// ! option -> function map
60
64
template <> vector<pair<string, occ_opt_handler::option_function>> occ_opt_handler::options {
61
65
{ " --help" , [](option_context& ctx, char **&) {
66
+ cout << FLOOR_OCC_FULL_VERSION_STR << endl;
62
67
cout << (" command line options:\n "
63
68
" \t --src <input-file>: the source file that should be compiled\n "
64
69
" \t --out <output-file>: the output file name (defaults to {spir.bc,cuda.ptx,metal.ll,applecl.bc})\n "
@@ -77,6 +82,7 @@ template<> vector<pair<string, occ_opt_handler::option_function>> occ_opt_handle
77
82
" \t --test-bin <input-file>: tests/compiles the specified binary on the target platform (if possible) - experimental!\n "
78
83
" \t -v: verbose output (DBG level)\n "
79
84
" \t -vv: very verbose output (MSG level)\n "
85
+ " \t --version: prints the occ/floor version\n "
80
86
" \t --config <path>: the path where config.json is located (defaults to \" ../../data/\" )\n "
81
87
" \t --: end of occ options, everything beyond this point is piped through to the compiler" ) << endl;
82
88
ctx.done = true ;
@@ -174,6 +180,10 @@ template<> vector<pair<string, occ_opt_handler::option_function>> occ_opt_handle
174
180
{ " -vv" , [](option_context& ctx, char **&) {
175
181
ctx.verbosity = (size_t )logger::LOG_TYPE::UNDECORATED;
176
182
}},
183
+ { " --version" , [](option_context& ctx, char **&) {
184
+ cout << FLOOR_OCC_FULL_VERSION_STR << endl;
185
+ ctx.done = true ;
186
+ }},
177
187
{ " --config" , [](option_context& ctx, char **& arg_ptr) {
178
188
++arg_ptr;
179
189
if (*arg_ptr == nullptr ) {
0 commit comments