scons/swig: refactor some of the scons/SWIG code