Port https://codereview.chromium.org/398163006 to gn.