Can I recompute fs.hash() when the file changes? #12876
-
I have a project where I generate an archive of files for deployment, based in part on some templates (using My problem is that one of these variables is a file's SHA256 hash computed via project(
'meson-test',
meson_version: '>=1.3.2',
)
fs = import('fs')
magic = files('magic')
magic_hash = fs.hash(magic, 'sha256')
message(f'Hash: @magic_hash@')
target_env = {
'HASH': magic_hash,
}
forcing_target = custom_target(
build_by_default : true,
depend_files : [magic],
output : 'more-magic',
command : ['sh', '-c', 'echo $HASH'],
env : target_env
) Create the
The first time this is set up and built, you get the hash:
But if the file is updated:
I think I understand what the problem is: meson's variables are computed at setup/configuration time. At build time, the configuration variables do not get recomputed except when However, even knowing that, I'm at a loss as to how to work around this. I don't think there's a way to "promote" a variable to a target or source, is there? Or to defer something like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Yes.
One approach would be to run the sha256sum tool in your custom_target command. Another approach is to do |
Beta Was this translation helpful? Give feedback.
Yes.
One approach would be to run the sha256sum tool in your custom_target command.
Another approach is to do