Skip to content

feat: added --version flag to CLI #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ build --enable_runfiles

build:windows --platforms=//bazel/platforms:windows
build:windows --host_platform=//bazel/platforms:windows
build:windows --workspace_status_command=bazel/tools/wsc.cmd

build:linux --platforms=//bazel/platforms:linux
build:linux --host_platform=//bazel/platforms:linux
build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux
build:linux --workspace_status_command=bazel/tools/wsc.sh

common:ci --announce_rc
common:ci --disk_cache=~/.cache/bazel-disk-cache
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ jobs:
key: ${{runner.os}}-bazel-cache
- uses: actions/checkout@v3
- run: bazel build --config=ci ...
build-windows:
runs-on: windows-latest
steps:
- uses: actions/cache@v3
with:
path: |
/Users/runneradmin/AppData/Local/bazelisk
/Users/runneradmin/.cache/bazel-disk-cache
key: ${{runner.os}}-bazel-cache
- uses: actions/checkout@v3
- run: bazel build --config=ci //...
check-dist:
runs-on: ubuntu-latest
steps:
Expand Down
13 changes: 10 additions & 3 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()

http_archive(
name = "rules_cc_stamp",
strip_prefix = "rules_cc_stamp-63d4861f4d420b574fa0f112599aae2b8aee785e",
urls = ["https://github.com/zaucy/rules_cc_stamp/archive/63d4861f4d420b574fa0f112599aae2b8aee785e.zip"],
sha256 = "f469a3b97eeabeb850c655f59ea17799ff40badd3a0b3e9de38534c89ad2f87d",
)

http_archive(
name = "ecsact_si_wasm",
sha256 = "4153154fd80e2cd48ddd8e0d0c208691f134b33d5c67dc6fc081b3f77149b2c2",
Expand Down Expand Up @@ -188,9 +195,9 @@ bazel_skylib_workspace()

http_archive(
name = "rules_blender",
sha256 = "1ae03c77c6e41b90904296f8d6269c3de9ffa12d0faef997a50e4edb225ef64c",
strip_prefix = "rules_blender-6f17aa27b6d76ecda9df0dab2be61adc2bc11c61",
urls = ["https://github.com/zaucy/rules_blender/archive/6f17aa27b6d76ecda9df0dab2be61adc2bc11c61.zip"],
sha256 = "734b08d1f0eb29a09f81509803cc324c2012a09f47e692a13c41af1370fcb648",
strip_prefix = "rules_blender-ef5c746f0ef3e9b8523175bed4ac8e8157fe0be3",
urls = ["https://github.com/zaucy/rules_blender/archive/ef5c746f0ef3e9b8523175bed4ac8e8157fe0be3.zip"],
)

load("@rules_blender//:repo.bzl", "blender_repository")
Expand Down
10 changes: 10 additions & 0 deletions bazel/tools/wsc.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off

if "%GITHUB_REF%"=="" (
for /f %%i in ('git describe --tags --abbrev^=0') do (
set GITHUB_REF=%%i
)
)

echo STABLE_ECSACT_SDK_VERSION %GITHUB_REF%

10 changes: 10 additions & 0 deletions bazel/tools/wsc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

if [[ -z "${GITHUB_REF}" ]]; then
echo "STABLE_ECSACT_SDK_VERSION $(git describe --tags --abbrev=0)"
else
echo "STABLE_ECSACT_SDK_VERSION ${GITHUB_REF}"
fi

9 changes: 8 additions & 1 deletion cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_cc_stamp//:index.bzl", "cc_stamp_header")
load("//bazel:copts.bzl", "copts")

package(default_visibility = ["//visibility:public"])

cc_stamp_header(
name = "bazel_stamp_header",
out = "bazel_stamp_header.hh",
)

cc_binary(
name = "ecsact",
srcs = ["cli.cc"],
srcs = ["cli.cc", "bazel_stamp_header.hh"],
copts = copts,
stamp = 1,
deps = [
"//cli/commands:codegen",
"//cli/commands:command",
Expand Down
6 changes: 5 additions & 1 deletion cli/cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <string_view>
#include <unordered_map>
#include "cli/bazel_stamp_header.hh"

#include "./commands/command.hh"
#include "./commands/codegen.hh"
Expand All @@ -25,9 +26,9 @@ constexpr auto USAGE = R"(Ecsact SDK Command Line

Usage:
ecsact (--help | -h)
ecsact (--version | -v)
ecsact config ([<options>...] | --help)
ecsact codegen ([<options>...] | --help)

)";

std::string colorize_logo() {
Expand Down Expand Up @@ -74,6 +75,9 @@ int main(int argc, char* argv[]) {
if(command == "-h" || command == "--help") {
print_usage();
return 0;
} else if(command == "-v" || command == "--version") {
std::cout << STABLE_ECSACT_SDK_VERSION << "\n";
return 0;
} else if(command.starts_with('-')) {
std::cerr << "Expected subcommand and instead got '" << command << "'\n";
print_usage();
Expand Down