There are two arguments for using make
(GNU make) on the target Linux system for builing projects in VCLinux : performance and flexibility.
On Windows, the VC++ build process is a sequence of steps where each source file is compiled to an object file and then object files combined into an application (or library) by executing the appropriate CL command for each step under the control of MSBuild. This works well and the ability to run pre- and post-build commands allows for customisation.
VCLinux build processing closely follows that of native Windows applications. However, pre- and post-build commands are missing (1.0.4) and, because it's building on a remote target, the build proceeds slowly.
The VCLinux build steps (1.0.4) are:
- validate ssh communication with, and architecture of, Linux system
- copy all project source files to be compiled via ssh to Linux
- execute g++ command to compile each source file in turn
- copy object file from each successful compilation back to Windows
- link objects into executable (or static or shared library)
- copy executable back to Windows
Personally, I'm quite happy with this process in principle. My applications consists exclusively of C++ source that is built into one or more static libraries, shared libraries and executables. But using make
seems to offer opportunities to offload some work, both development and execution, to an existing tool.
Performance
Because everything has to be done at arms length on a remote Linux system, building is much slower than on Windows; steps are executed sequentially and copying takes time.
It does seem that using make
on the Linux target and building as a batch process would offer performance improvements:
- single command via ssh for build
- parallel compilation capabilities in
make
(--jobs
option)
An additional perfomance improvement might be to not copy object files back to Windows. The executable is required for debugging with gdb and must be copied. Object files are only to satisfy MSBuild and a locally generated zero-length file with the appropriate name and time stamp would suffice.
Flexibility
In addition, basing VCLinux build on make
would allow users to supply their own makefiles. This would give complete control over the process and work-around issues such as pre- and post-build steps, non-g++ compilation, cross-compilation, etc. There are simply too many variations for VCLinux to cover all the options.
So how would it work?
I don't want to have to write a makefile for my projects and would want VCLinux to generate one from the project settings. This is what Eclipse CDT does. Eclipse will create / recreate a makefile on demand from the project settings and contents. Thereafter, Eclipse builds the project using this makefile as it would with a user-supplied one. It's rather clumsy in that the user must regenerate the makefile following any changes to the project, including the addition of new source files.
I'd like to see VCLinux automatically generate its makefile on every build; creating the makefile is quick and build-specific makefiles can be simpler and need only reference the source files affected. It does not need to be a makefile that can be used outside VCLinux.
At the same time it should be possible to give VCLinux the makefile to use. It would have to be part of the Visual Studio project and 'live' on the Windows host. But it would be opaque to VCLinux, i.e. I'm not suggesting it should be parsed by VCLinux. Rules would need to be established for the build targets, e.g. make debug, make clean and what and where the generated executable (or library) wiil be; it being the users responsibility to ensure that everything corresponds (with great power comes great responsibility, eh?).