generator: Move all library generation code together.