flatbuffers
flatbuffers copied to clipboard
Reproducible paths in schemas
I have a test case which essentially confirms that the SHA1 of a flatbuffer schema doesn't change. I'd like the ability to make all the paths relative so they are reproducible and the same when built on different developer's machines. From debugging, Flatbuffers likes to resolve things to absolute paths.
From inside the compiled Schema table produced from parsing a .fbs file:
"fbs_files": [
{
"filename": "//../../../../../../../../../home/austin/local/971-Robot-Code/aos/configuration.fbs",
"included_filenames": [
"//../../../../../../../../../home/austin/local/971-Robot-Code/third_party/flatbuffers/reflection/reflection.fbs"
]
},
{
"filename": "//../../../../../../../../../home/austin/local/971-Robot-Code/aos/events/event_loop.fbs",
"included_filenames": [
"//../../../../../../../../../home/austin/local/971-Robot-Code/aos/configuration.fbs"
]
},
{
"filename": "//../../../../../../../../../home/austin/local/971-Robot-Code/third_party/flatbuffers/reflection/reflection.fbs",
"included_filenames": [
]
}
]
You can see here that user information and compilation paths are getting baked into the resulting schema.
We are using Flatbuffers with Bazel if that makes any difference.
I'd like to see instead something like:
"fbs_files": [
{
"filename": "aos/configuration.fbs",
"included_filenames": [
"reflection/reflection.fbs"
]
},
{
"filename": "aos/events/event_loop.fbs",
"included_filenames": [
"aos/configuration.fbs"
]
},
{
"filename": "reflection/reflection.fbs",
"included_filenames": [
]
}
]
While this doesn't report the resolved paths, it is reproducible and reports out what was included with enough information to go find it in the code base. Protobuf encodes paths relative to the search path to get around this.
Is there interest in a command line option to support this? I'm assuming the current behavior is on purpose. I'm happy to develop it.
Would this flag help?
https://github.com/google/flatbuffers/blob/cfe157ec5667ab2101a62889ac0f5260a0166116/src/flatc.cpp#L163
Oooh, thanks @CasperN ! That looks very helpful. It looks like it only supports 1 path, I might need to teach it to support multiple paths. But that's easier than making something new.
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale
, or this will be closed in 14 days.
This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.