GN: extract optional() as a template and use for giflib-dependent code

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2270833003

Review-Url: https://codereview.chromium.org/2270833003
1 file changed