Skip to content

Commit

Permalink
Add tools
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 223d3d429cdd2612b27118bafc4d9a59e490d65c
  • Loading branch information
Vertexwahn committed Apr 22, 2024
1 parent 3de4baa commit 28a8f6c
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- uses: codespell-project/actions-codespell@v2
with:
path: devertexwahn
exclude_file: devertexwahn/MODULE.bazel.lock
exclude_file: MODULE.bazel.lock
17 changes: 17 additions & 0 deletions devertexwahn/tools/compiler_information/BUILD.bazel
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",
],
)
23 changes: 23 additions & 0 deletions devertexwahn/tools/compiler_information/README.md
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
```
55 changes: 55 additions & 0 deletions devertexwahn/tools/compiler_information/main.cpp
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;
}
9 changes: 9 additions & 0 deletions devertexwahn/tools/header_file_generator/BUILD.bazel
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"],
)
9 changes: 9 additions & 0 deletions devertexwahn/tools/header_file_generator/README.md
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 devertexwahn/tools/header_file_generator/file_header_generator.py
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:])

0 comments on commit 28a8f6c

Please sign in to comment.