depot/third_party/nixpkgs/pkgs/build-support/make-hardcode-gsettings-patch/default.nix
Default email a3d4720129 Project import generated by Copybara.
GitOrigin-RevId: e182da8622a354d44c39b3d7a542dc12cd7baa5f
2022-12-28 22:21:41 +01:00

60 lines
1.4 KiB
Nix

{
runCommand,
git,
coccinelle,
python3,
}:
/*
Can be used as part of an update script to automatically create a patch
hardcoding the path of all GSettings schemas in C code.
For example:
passthru = {
hardcodeGsettingsPatch = makeHardcodeGsettingsPatch {
inherit src;
schemaIdToVariableMapping = {
...
};
};
updateScript =
let
updateSource = ...;
updatePatch = _experimental-update-script-combinators.copyAttrOutputToFile "evolution-ews.hardcodeGsettingsPatch" ./hardcode-gsettings.patch;
in
_experimental-update-script-combinators.sequence [
updateSource
updatePatch
];
};
}
takes as input a mapping from schema path to variable name.
For example `{ "org.gnome.evolution" = "EVOLUTION_SCHEMA_PATH"; }`
hardcodes looking for `org.gnome.evolution` into `@EVOLUTION_SCHEMA_PATH@`.
All schemas must be listed.
*/
{
src,
schemaIdToVariableMapping,
}:
runCommand
"hardcode-gsettings.patch"
{
inherit src;
nativeBuildInputs = [
git
coccinelle
python3 # For patch script
];
}
''
unpackPhase
cd "''${sourceRoot:-.}"
set -x
cp ${builtins.toFile "glib-schema-to-var.json" (builtins.toJSON schemaIdToVariableMapping)} ./glib-schema-to-var.json
git init
git add -A
spatch --sp-file "${./hardcode-gsettings.cocci}" --dir . --in-place
git diff > "$out"
''