Skip to content

Commit 666d2fc

Browse files
committed
* occ: added a version number (same as floor) + --version flag
1 parent d79a1f3 commit 666d2fc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

offline_compiler/src/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#endif
2222

2323
#include <floor/floor/floor.hpp>
24+
#include <floor/floor/floor_version.hpp>
2425
#include <floor/compute/llvm_compute.hpp>
2526
#include <floor/compute/compute_device.hpp>
2627
#include <floor/core/option_handler.hpp>
@@ -35,6 +36,9 @@
3536
#include <floor/compute/metal/metal_compute.hpp>
3637
#include <floor/compute/metal/metal_device.hpp>
3738

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+
3842
struct option_context {
3943
string filename { "" };
4044
string output_filename { "" };
@@ -59,6 +63,7 @@ typedef option_handler<option_context> occ_opt_handler;
5963
//! option -> function map
6064
template<> vector<pair<string, occ_opt_handler::option_function>> occ_opt_handler::options {
6165
{ "--help", [](option_context& ctx, char**&) {
66+
cout << FLOOR_OCC_FULL_VERSION_STR << endl;
6267
cout << ("command line options:\n"
6368
"\t--src <input-file>: the source file that should be compiled\n"
6469
"\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
7782
"\t--test-bin <input-file>: tests/compiles the specified binary on the target platform (if possible) - experimental!\n"
7883
"\t-v: verbose output (DBG level)\n"
7984
"\t-vv: very verbose output (MSG level)\n"
85+
"\t--version: prints the occ/floor version\n"
8086
"\t--config <path>: the path where config.json is located (defaults to \"../../data/\")\n"
8187
"\t--: end of occ options, everything beyond this point is piped through to the compiler") << endl;
8288
ctx.done = true;
@@ -174,6 +180,10 @@ template<> vector<pair<string, occ_opt_handler::option_function>> occ_opt_handle
174180
{ "-vv", [](option_context& ctx, char**&) {
175181
ctx.verbosity = (size_t)logger::LOG_TYPE::UNDECORATED;
176182
}},
183+
{ "--version", [](option_context& ctx, char**&) {
184+
cout << FLOOR_OCC_FULL_VERSION_STR << endl;
185+
ctx.done = true;
186+
}},
177187
{ "--config", [](option_context& ctx, char**& arg_ptr) {
178188
++arg_ptr;
179189
if(*arg_ptr == nullptr) {

0 commit comments

Comments
 (0)