Additional `SOURCE_FILENAME` variable in CppCompileVariables
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the feature request:
We currently define `__SHORT_FILENAME__=basename of source_file` in cmake using `COMPILE_DEFINITIONS` feature. Currently, I don't see any way to define that flag inside of bazel. I tried
```
# pseudo code
flag_group('-D__SHORT_FILENAME__=$(basename %{source_file})')
```
but that fails to work because it gets escaped during the shell expansion with single quotes to `'-D__SHORT_FILENAME=$(basename path_to_file/file.cpp)'`.
So, would it be okay for me to make a change to the `CompileBuildVariables.java` and add a enum `SOURCE_FILENAME` that just stores the name of the file.
Contributor guide
Research direction
Start by reading CompileBuildVariables.java and the existing CMake COMPILE_DEFINITIONS handling described in the issue. Trace how CppCompileVariables are exposed to Bazel flag expansion, then verify that the requested SOURCE_FILENAME value is available as the source file name without shell escaping; done means the variable can support the stated compile-definition use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, java
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100