Graft each target's added declarations onto its own source bytes and write the result to tmp. Returns the number of classes written.