-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitOrigin-RevId: 223d3d429cdd2612b27118bafc4d9a59e490d65c
- Loading branch information
1 parent
3de4baa
commit 28a8f6c
Showing
7 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
SPDX-FileCopyrightText: Copyright 2024 Julian Amann <[email protected]> | ||
SPDX-License-Identifier: Apache-2.0 | ||
""" | ||
|
||
load("@rules_qt//:qt.bzl", "qt_cc_binary") | ||
|
||
cc_binary( | ||
name = "compiler_information", | ||
srcs = [ | ||
"main.cpp", | ||
], | ||
deps = [ | ||
"@boost.predef//:predef", | ||
"@fmt", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# How to run? | ||
|
||
## macOS | ||
|
||
```shell | ||
bazel run --config=macos //tools/compiler_information | ||
``` | ||
|
||
## Ubuntu | ||
|
||
```shell | ||
bazel run --config=gcc11 //tools/compiler_information | ||
``` | ||
|
||
```shell | ||
bazel run --config=clang16 //tools/compiler_information | ||
``` | ||
|
||
# Windows | ||
|
||
```shell | ||
bazel --output_base=G:/bazel_output_base run --config=vs2022 --compilation_mode=opt //tools/compiler_information | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright 2024 Julian Amann <[email protected]> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "boost/predef.h" | ||
|
||
#include "fmt/core.h" | ||
#include "fmt/format.h" | ||
|
||
#include <iostream> | ||
#include <map> | ||
#include <sstream> | ||
#include <string> | ||
|
||
std::string semantic_versioning_string(int major, int minor, int patch) { | ||
return fmt::format("{}.{}.{}", major, minor, patch); | ||
} | ||
|
||
// See https://dev.to/yumetodo/list-of-mscver-and-mscfullver-8nd | ||
std::string vs_product_name(int version) { | ||
std::map<int, std::string> versions { | ||
{1936, "Visual Studio 2022 17.6.2"}, | ||
{1937, "Visual Studio 2022 17.7.0"}, | ||
{1938, "Visual Studio 2022 17.8.3"}, | ||
{1939, "Visual Studio 2022 17.9.2"}, | ||
}; | ||
|
||
auto it = versions.find(version); | ||
|
||
if(it != std::end(versions)) { | ||
return it->second; | ||
} | ||
else { | ||
return fmt::format("Unknown Visual Studio version {}", version); | ||
} | ||
} | ||
|
||
int main() { | ||
#if __apple_build_version__ | ||
std::cout << "Apple clang version " << semantic_versioning_string(__clang_major__, __clang_minor__, __clang_patchlevel__); | ||
#elif BOOST_COMP_CLANG | ||
std::cout << "Clang " << semantic_versioning_string(__clang_major__, __clang_minor__, __clang_patchlevel__); | ||
#elif BOOST_COMP_GNUC | ||
std::cout << "GCC " << semantic_versioning_string(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); | ||
#elif BOOST_COMP_MSVC | ||
std::cout << vs_product_name(_MSC_VER); | ||
#else | ||
std::cout << "Unknown compiler"; | ||
#endif | ||
|
||
std::cout << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" | ||
SPDX-FileCopyrightText: Copyright 2022-2023 Julian Amann <[email protected]> | ||
SPDX-License-Identifier: Apache-2.0 | ||
""" | ||
|
||
py_binary( | ||
name = "file_header_generator", | ||
srcs = ["file_header_generator.py"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Header file generator | ||
|
||
A simple tool for generating include guards and header comments for header files | ||
|
||
Example call: | ||
|
||
```shell | ||
bazel run //tools/header_file_generator:file_header_generator Quaternion | ||
``` |
61 changes: 61 additions & 0 deletions
61
devertexwahn/tools/header_file_generator/file_header_generator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
""" | ||
SPDX-FileCopyrightText: Copyright 2022-2024 Julian Amann <[email protected]> | ||
SPDX-License-Identifier: Apache-2.0 | ||
""" | ||
|
||
import argparse | ||
import sys | ||
import uuid | ||
|
||
TEXT_HEADER = """/* | ||
* SPDX-FileCopyrightText: Copyright 2024 Julian Amann <[email protected]> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
""" | ||
|
||
|
||
def parseArguments(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("class_name") | ||
return parser.parse_args() | ||
|
||
|
||
def main(argv): | ||
args = parseArguments() | ||
|
||
class_name = args.class_name | ||
|
||
str_uuid = str(uuid.uuid4()) | ||
str_uuid = str_uuid.replace("-", "_") | ||
|
||
print(TEXT_HEADER) | ||
|
||
print("#pragma once") | ||
print("#ifndef De_Vertexwahn_Core_" + class_name + "_" + str_uuid + "_h") | ||
print("#define De_Vertexwahn_Core_" + class_name + "_" + str_uuid + "_h") | ||
print("") | ||
print("#include \"core/namespace.h\"") | ||
print("") | ||
print("DE_VERTEXWAHN_BEGIN_NAMESPACE") | ||
print("") | ||
|
||
print("class " + class_name + " {"); | ||
print("public:") | ||
|
||
print(class_name + "() {") | ||
print("}") | ||
|
||
print("virtual ~" + class_name + "() {") | ||
print("}") | ||
|
||
print("};") | ||
print("") | ||
|
||
print("DE_VERTEXWAHN_END_NAMESPACE") | ||
print("") | ||
|
||
print("#endif // end define De_Vertexwahn_Core_" + class_name + "_" + str_uuid + "_h") | ||
|
||
|
||
if __name__ == "__main__": | ||
main(sys.argv[1:]) |