Skip to content

Comments

Add option for listeners to filter compilation units#59

Open
jglrxavpok wants to merge 1 commit intoddovod:masterfrom
jglrxavpok:upstream-master
Open

Add option for listeners to filter compilation units#59
jglrxavpok wants to merge 1 commit intoddovod:masterfrom
jglrxavpok:upstream-master

Conversation

@jglrxavpok
Copy link

Description

Allows applications to select which compilation units are monitored by jet-live.
If an application rejects a given compilation unit, this file will not be watched nor the object will be recompiled when changed. By default, all files are monitored (as it is before this PR)

Motivation

My project has different CMake targets when enabling AddressSanitizer, so my source files are the same between the ASAN and non-ASAN targets.
However, jet-live maps compilation arguments to the source filename. This creates an issue when trying to reload my source files because the ASAN compilation command is last inside my compile_commands.json file. Jet-live will override the non-ASAN version with the ASAN version of my compilation unit (in CompileCommandsCompilationUnitsParser.cpp), making jet-live compile the ASAN version, and failing to link it into the running non-ASAN executable.

Extract from my compile_commands.json file:

{
  "directory": "/mnt/StockageSSD/Programming/Games/Carrot/cmake-build-debug-ninja",
  "command": "/usr/bin/c++ [...] -o engine/CMakeFiles/Engine-Base.dir/engine/render/RenderGraph.cpp.o -c /mnt/StockageSSD/Programming/Games/Carrot/engine/engine/render/RenderGraph.cpp",
  "file": "/mnt/StockageSSD/Programming/Games/Carrot/engine/engine/render/RenderGraph.cpp",
  "output": "engine/CMakeFiles/Engine-Base.dir/engine/render/RenderGraph.cpp.o"
},
[...]
{
  "directory": "/mnt/StockageSSD/Programming/Games/Carrot/cmake-build-debug-ninja",
  "command": "/usr/bin/c++ [...] -fsanitize=address [...] -o engine/CMakeFiles/Engine-ASAN.dir/engine/render/RenderGraph.cpp.o -c /mnt/StockageSSD/Programming/Games/Carrot/engine/engine/render/RenderGraph.cpp",
  "file": "/mnt/StockageSSD/Programming/Games/Carrot/engine/engine/render/RenderGraph.cpp",
  "output": "engine/CMakeFiles/Engine-ASAN.dir/engine/render/RenderGraph.cpp.o"
},

From what I have seen, it is not possible to know which .o files are used to build a given executable (without modifications to the toolchain). Therefore, to minimize required changes to the toolchain of applications using jet-live, I have decided to create a hook to let the application reject some files if need be.

Example usage here: https://codeberg.org/jglrxavpok/Carrot/commit/582e5c701f78bff4150113a6ad32cacb5734b43e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant