Hi! There was something like this required sometime ago from the nokogiri package to build ruby-nokogumbo. You can have a look at commit a3939406c9a1b7ef2d07942ea01d693057f50f47 in nokogiri git repo, dating from 2021-10-22. I hope it helps at least a bit.
I don't know if the solution is optimal. Best wishes, Cédric