Skip to content

Commit 9ba602f

Browse files
committed
update to match mono
1 parent 599f35a commit 9ba602f

File tree

10 files changed

+211
-191
lines changed

10 files changed

+211
-191
lines changed

.bazelrc

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,26 @@
11
####################################
2-
# General Bazel Configuration
2+
# Load Preset Configuration
33
####################################
44

5-
common --color=yes
6-
common --curses=yes
5+
import %workspace%/tools/preset.bazelrc
76

87
####################################
9-
# Default Platform (macOS ARM64)
8+
# Project-Specific Configuration
109
####################################
1110

12-
build --platforms=//config/platforms:macos_arm64_platform
13-
14-
####################################
15-
# Compiler & Linker Warnings
16-
####################################
11+
common --color=yes
12+
common --curses=yes
1713

18-
build --copt=-Wall
19-
build --copt=-Wextra
20-
build --copt=-Wpedantic
21-
build --copt=-Wno-unused-parameter
22-
build --copt=-Werror=implicit-function-declaration
14+
# Default build platform for this project (macOS ARM64)
15+
build --platforms=//config/platforms:macos_arm64_platform
2316

2417
####################################
25-
# Cache Configuration
18+
# Cache & Build Metadata
2619
####################################
2720

2821
build --disk_cache=.cache/bazel_cache
2922
build --workspace_status_command=tools/scripts/workspace_status.sh
3023

31-
####################################
32-
# Test Configuration
33-
####################################
34-
35-
test --test_verbose_timeout_warnings
36-
test --verbose_failures
37-
test --keep_going
38-
test --test_output=all
39-
4024
####################################
4125
# Debug Build (with ASAN/UBSAN)
4226
####################################
@@ -63,8 +47,8 @@ test:debug --config=debug
6347
build:opt --compilation_mode=opt
6448
build:opt --strip=always
6549
build:opt --copt=-O3
66-
build:opt --define=NDEBUG=1
6750
build:opt --copt=-march=native
51+
build:opt --define=NDEBUG=1
6852

6953
####################################
7054
# Profile/Report Build
@@ -113,7 +97,7 @@ build:tidy --features=layering_check
11397
build:tidy --copt=-fdiagnostics-color=always
11498

11599
####################################
116-
# Linux with Homebrew LLVM
100+
# Cross-Compile: Linux with Homebrew LLVM
117101
####################################
118102

119103
build:linux_llvm --action_env=CC=/opt/homebrew/opt/llvm/bin/clang
@@ -125,22 +109,3 @@ build:linux_llvm --platforms=@platforms//os:linux
125109
build:linux_llvm --cpu=x86_64
126110

127111
test:linux_llvm --config=linux_llvm
128-
129-
####################################
130-
# Heap Dump on OOM
131-
####################################
132-
133-
build --heap_dump_on_oom
134-
135-
####################################
136-
# Query Output Format
137-
####################################
138-
139-
query --output=label_kind
140-
141-
####################################
142-
# Output Filter
143-
####################################
144-
145-
# Suppresses most of the build output, leaving just the summary line
146-
# build --output_filter=^$ # Uncomment for cleaner output

BUILD

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
11
"""Root build file for C Template project."""
2-
3-
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
4-
5-
# Refresh compile_commands.json for IDE integration
6-
# Usage: bazel run //:refresh_compile_commands
7-
refresh_compile_commands(
8-
name = "refresh_compile_commands",
9-
targets = {
10-
"//lib/...": "",
11-
"//app/...": "",
12-
"//tests/...": "",
13-
},
14-
)

MODULE.bazel

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,32 @@ module(
1616
version = "0.1.0",
1717
)
1818

19+
######################################################################
20+
# Registries (Central Bazel Package Registries)
21+
######################################################################
22+
23+
# common --registry=file:///Users/uwe/Documents/Programmierung/Bazel-Registry
24+
# common --registry=https://raw.githubusercontent.com/tragisch/bazel-registry/main
25+
# common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main
26+
# common --registry=https://bcr.bazel.build
27+
28+
######################################################################
29+
# Bazel Configuration Management
30+
######################################################################
31+
32+
# Auto-generate optimized bazelrc from best practices
33+
# To update: bazel run @@//tools:preset.update
34+
bazel_dep(name = "bazelrc-preset.bzl", version = "0.4.2")
35+
1936
######################################################################
2037
# Core Build Tools & Platforms
2138
######################################################################
2239

23-
bazel_dep(name = "platforms", version = "0.0.11")
24-
bazel_dep(name = "rules_cc", version = "0.1.2")
25-
bazel_dep(name = "bazel_skylib", version = "1.7.1")
40+
bazel_dep(name = "platforms", version = "1.0.0")
41+
bazel_dep(name = "rules_cc", version = "0.2.8")
42+
bazel_dep(name = "bazel_skylib", version = "1.8.2")
2643
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.25.0")
27-
bazel_dep(name = "rules_shell", version = "0.4.0")
44+
bazel_dep(name = "rules_shell", version = "0.6.1")
2845
bazel_dep(name = "depend_on_what_you_use", version = "0.8.0")
2946

3047
######################################################################
@@ -40,11 +57,20 @@ use_repo(llvm, "llvm_toolchain_llvm")
4057

4158
register_toolchains("@llvm_toolchain//:all")
4259

60+
######################################################################
61+
# Apple Support (for macOS system frameworks)
62+
######################################################################
63+
64+
apple_cc_configure = use_extension("@apple_support//crosstool:setup.bzl", "apple_cc_configure_extension")
65+
use_repo(apple_cc_configure, "local_config_apple_cc", "local_config_apple_cc_toolchains")
66+
67+
register_toolchains("@local_config_apple_cc_toolchains//:all")
68+
4369
######################################################################
4470
# Apple Support (for macOS/iOS)
4571
######################################################################
4672

47-
bazel_dep(name = "apple_support", version = "1.23.1")
73+
bazel_dep(name = "apple_support", version = "1.24.3")
4874

4975
######################################################################
5076
# Testing & Development Tools

MODULE.bazel.lock

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

tests/BUILD

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
load("//:tools/unity_test.bzl", "unity_test")
2-
3-
unity_test(
4-
name = "test_armstrong_numbers",
5-
srcs = ["test_armstrong_numbers.c"],
6-
my_config = ["my_config.yml"],
7-
deps = [
8-
"//src:armstrong_numbers",
9-
],
10-
)
1+
"""Tests for the project."""

tests/test_armstrong_numbers.c

Lines changed: 0 additions & 86 deletions
This file was deleted.

tools/build/c_copts.bzl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Common compiler options for C projects.
3+
Centralized flag management for consistency across the entire codebase.
4+
"""
5+
6+
# Base C compilation options for all builds
7+
C_COPTS = [
8+
"-Wall",
9+
"-Wextra",
10+
"-pedantic",
11+
"-Wno-unused-parameter",
12+
"-Werror=implicit-function-declaration",
13+
"-std=c11",
14+
]
15+
16+
# Debug-specific compiler options
17+
C_DEBUG_COPTS = C_COPTS + [
18+
"-g",
19+
"-O0",
20+
"-fno-omit-frame-pointer",
21+
"-DDEBUG",
22+
]
23+
24+
# Release/Optimized compiler options
25+
C_RELEASE_COPTS = C_COPTS + [
26+
"-O3",
27+
"-march=native",
28+
"-DNDEBUG",
29+
]
30+
31+
# Linker options
32+
C_LINKOPTS = [
33+
"-lm", # Link math library
34+
]
35+
36+
# Platform-specific options
37+
C_MACOS_COPTS = []
38+
C_LINUX_COPTS = []
39+
C_WINDOWS_COPTS = []

0 commit comments

Comments
 (0)