Skip to content

Commit 3d5c13c

Browse files
committed
address comments
1 parent 0630438 commit 3d5c13c

6 files changed

Lines changed: 65 additions & 60 deletions

File tree

.github/actions/cpp-bazel/pre-merge/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ runs:
2929
- name: Setup Bazel with cache
3030
uses: ./.github/actions/utils/setup-cpp-with-cache
3131

32+
- name: Setup Rust with cache
33+
uses: ./.github/actions/utils/setup-rust-with-cache
34+
3235
- name: Install clang-format
3336
if: inputs.task == 'lint'
3437
shell: bash

foreign/cpp/BUILD.bazel

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,16 @@ genrule(
2424
"Cargo.lock",
2525
"build.rs",
2626
],
27-
tools = [
28-
"@rules_rust//tools/upstream_wrapper:cargo",
29-
],
3027
outs = [
3128
"libiggy_cpp.a",
3229
"include/lib.rs.h",
3330
"cxxbridge/rust/cxx.h",
3431
],
3532
cmd = """
36-
set -e
33+
set -euo pipefail
3734
38-
CARGO="$$(pwd)/$(execpath @rules_rust//tools/upstream_wrapper:cargo)"
35+
CARGO="$$(command -v cargo)"
36+
CARGO_TARGET_DIR="$(@D)/cargo_target"
3937
OUT_LIB="$$(pwd)/$(location libiggy_cpp.a)"
4038
OUT_RS="$$(pwd)/$(location include/lib.rs.h)"
4139
OUT_CXX="$$(pwd)/$(location cxxbridge/rust/cxx.h)"
@@ -50,11 +48,24 @@ genrule(
5048
FLAGS="--release"
5149
fi
5250
53-
env -u PWD CARGO_TARGET_DIR="target" "$$CARGO" build $$FLAGS --locked
51+
mkdir -p "$$CARGO_TARGET_DIR"
52+
env -u PWD CARGO_TARGET_DIR="$$CARGO_TARGET_DIR" "$$CARGO" build $$FLAGS --locked
53+
54+
cp "$$CARGO_TARGET_DIR/$$PROFILE/libiggy_cpp.a" "$$OUT_LIB"
5455
55-
cp "target/$$PROFILE/libiggy_cpp.a" "$$OUT_LIB"
56-
find "target/$$PROFILE/build" -name lib.rs.h | head -n 1 | xargs -I{} cp {} "$$OUT_RS"
57-
find "target/$$PROFILE/build" -name cxx.h | head -n 1 | xargs -I{} cp {} "$$OUT_CXX"
56+
RS_HDR="$$(find "$$CARGO_TARGET_DIR/$$PROFILE/build" -name lib.rs.h -print -quit)"
57+
if [ -z "$$RS_HDR" ]; then
58+
echo "ERROR: Failed to locate generated lib.rs.h under $$CARGO_TARGET_DIR/$$PROFILE/build" >&2
59+
exit 1
60+
fi
61+
cp "$$RS_HDR" "$$OUT_RS"
62+
63+
CXX_HDR="$$(find "$$CARGO_TARGET_DIR/$$PROFILE/build" -name cxx.h -print -quit)"
64+
if [ -z "$$CXX_HDR" ]; then
65+
echo "ERROR: Failed to locate generated cxx.h under $$CARGO_TARGET_DIR/$$PROFILE/build" >&2
66+
exit 1
67+
fi
68+
cp "$$CXX_HDR" "$$OUT_CXX"
5869
""",
5970
local = 1,
6071
)

foreign/cpp/MODULE.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,5 @@ module(
2020
)
2121

2222
bazel_dep(name = "rules_cc", version = "0.2.16")
23-
bazel_dep(name = "rules_rust", version = "0.68.1")
2423
bazel_dep(name = "platforms", version = "1.0.0")
2524
bazel_dep(name = "googletest", version = "1.17.0")
26-
27-
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
28-
rust.toolchain(
29-
edition = "2024",
30-
versions = ["1.93.0"],
31-
)
32-
use_repo(rust, "rust_toolchains")

foreign/cpp/MODULE.bazel.lock

Lines changed: 35 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

foreign/cpp/include/iggy.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class PollingStrategy final {
103103
std::uint64_t polling_strategy_value_;
104104
};
105105

106+
// TODO(slbotbm): Add rust bindings for Identifier that will use IdKind
106107
class IdKind final {
107108
public:
108109
static IdKind numeric() { return IdKind("numeric"); }

scripts/ci/sync-rust-version.sh

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ while [[ $# -gt 0 ]]; do
4141
--help|-h)
4242
echo "Usage: $0 [--check|--fix]"
4343
echo ""
44-
echo "Sync Rust version from rust-toolchain.toml to all Dockerfiles and Bazel MODULE files"
44+
echo "Sync Rust version from rust-toolchain.toml to all Dockerfiles"
4545
echo ""
4646
echo "Options:"
47-
echo " --check Check if all Dockerfiles and MODULE files have the correct Rust version"
48-
echo " --fix Update all Dockerfiles and MODULE files to use the correct Rust version"
47+
echo " --check Check if all Dockerfiles have the correct Rust version"
48+
echo " --fix Update all Dockerfiles to use the correct Rust version"
4949
echo " --help Show this help message"
5050
exit 0
5151
;;
@@ -84,7 +84,6 @@ echo ""
8484

8585
# Find all Dockerfiles
8686
DOCKERFILES=$(find . -name "Dockerfile*" -type f | grep -v node_modules | grep -v target | sort)
87-
MODULE_FILE="foreign/cpp/MODULE.bazel"
8887

8988
# Track misaligned files
9089
MISALIGNED_FILES=()
@@ -121,35 +120,12 @@ for dockerfile in $DOCKERFILES; do
121120
fi
122121
done
123122

124-
if [ -f "$MODULE_FILE" ] && grep -q 'versions = \["' "$MODULE_FILE" 2>/dev/null; then
125-
TOTAL_FILES=$((TOTAL_FILES + 1))
126-
127-
CURRENT_VERSION=$(grep 'versions = \["' "$MODULE_FILE" | head -1 | sed -E 's/.*versions = \["([^"]+)"\].*/\1/')
128-
129-
if [ "$MODE" = "check" ]; then
130-
if [ "$CURRENT_VERSION" != "$RUST_VERSION" ]; then
131-
MISALIGNED_FILES+=("$MODULE_FILE")
132-
echo -e "${RED}${NC} $MODULE_FILE: ${RED}$CURRENT_VERSION${NC} (expected: ${GREEN}$RUST_VERSION${NC})"
133-
else
134-
echo -e "${GREEN}${NC} $MODULE_FILE: $CURRENT_VERSION"
135-
fi
136-
elif [ "$MODE" = "fix" ]; then
137-
if [ "$CURRENT_VERSION" != "$RUST_VERSION" ]; then
138-
sed -i -E "s/(versions = \\[\")[^\"]+(\"\\])/\1$RUST_VERSION\2/" "$MODULE_FILE"
139-
FIXED_FILES=$((FIXED_FILES + 1))
140-
echo -e "${GREEN}Fixed${NC} $MODULE_FILE: ${RED}$CURRENT_VERSION${NC} -> ${GREEN}$RUST_VERSION${NC}"
141-
else
142-
echo -e "${GREEN}${NC} $MODULE_FILE: already correct ($RUST_VERSION)"
143-
fi
144-
fi
145-
fi
146-
147123
echo ""
148124
echo "────────────────────────────────────────────────"
149125

150126
if [ "$MODE" = "check" ]; then
151127
if [ ${#MISALIGNED_FILES[@]} -eq 0 ]; then
152-
echo -e "${GREEN}✓ All $TOTAL_FILES files are aligned with Rust versions (Dockerfiles: $RUST_VERSION_SHORT, MODULE files: $RUST_VERSION)${NC}"
128+
echo -e "${GREEN}✓ All $TOTAL_FILES files are aligned with Rust version (Dockerfiles: $RUST_VERSION_SHORT)${NC}"
153129
exit 0
154130
else
155131
echo -e "${RED}✗ Found ${#MISALIGNED_FILES[@]} misaligned file(s) out of $TOTAL_FILES:${NC}"
@@ -162,9 +138,9 @@ if [ "$MODE" = "check" ]; then
162138
fi
163139
elif [ "$MODE" = "fix" ]; then
164140
if [ $FIXED_FILES -eq 0 ]; then
165-
echo -e "${GREEN}✓ All $TOTAL_FILES files were already aligned with Rust versions (Dockerfiles: $RUST_VERSION_SHORT, MODULE files: $RUST_VERSION)${NC}"
141+
echo -e "${GREEN}✓ All $TOTAL_FILES files were already aligned with Rust version (Dockerfiles: $RUST_VERSION_SHORT)${NC}"
166142
else
167-
echo -e "${GREEN}✓ Fixed $FIXED_FILES out of $TOTAL_FILES files to use Rust versions (Dockerfiles: $RUST_VERSION_SHORT, MODULE files: $RUST_VERSION)${NC}"
143+
echo -e "${GREEN}✓ Fixed $FIXED_FILES out of $TOTAL_FILES files to use Rust version (Dockerfiles: $RUST_VERSION_SHORT)${NC}"
168144
fi
169145
exit 0
170146
fi

0 commit comments

Comments
 (0)