[M3devel] Multiple executables from the same source

Rodney M. Bates rodney_bates at lcwb.coop
Mon Jul 8 20:13:16 CEST 2013



On 07/08/2013 11:25 AM, Hendrik Boom wrote:
> On Mon, Jul 08, 2013 at 10:51:41AM -0500, Rodney M. Bates wrote:
>>
>>
>> On 07/06/2013 09:11 PM, Hendrik Boom wrote:
>>> I'm writiing and debugging a bunch of interfaces and modules.
>>> They are all supposed to fit together into one happy executable.
>>>
>>> But of course, until I've finished debugging them
>>>    they fit together into one unhappy executable.
>>> To test them properly I'd like to write a series of unit tests.
>>> To run these tests I will need  to make further executables,
>>>    each consisting of a test modules and several of the modules under test.
>>>
>>> Now with the usual structure of a Modula 3 workspace,
>>>    there is one m3makefile and a src directory, and it makes one executable,
>>>    not many,
>>>    and it doesn't really give me a choice of which executable I want.
>>>
>>> In the old days of C code and Makefiles, I could have multiple targets
>>>    each one being built with its own cc command
>>>    with its own list of source files names.
>>>
>>> Is there anything comparable for Modula 3?
>>>
>>> The best I've come up sith so far is to have a number of directories,
>>>    one for each test case,
>>>    with its own m3makefile and its own symbolic link to a common src directory.
>>
>> I have one project with three executables and a majority of the code shared.  I
>> am using essentially this scheme, but instead of the symlinks in the directories,
>> I have 'include_dir("../common/src")' in the m3makefiles of the main programs.
>> common/src has its m3makefile for all the stuff in common.
>
> Is this a way of getting cm3 to search ../common/src as sell as the src
> it usually looks through?

Yes,, it uses ../common/src/m3makefile and whatever it refers to.  I
don't know the precise semantics, but I imagine it just interprets
the contents of the included m3makefile in place of the include_dir.

>
> That may be what I wanted ... but IF statements in m3makefiles suffice
> for now.
>
> It's useful to know that include_dir is available, though.
>
> Is there any advice how to make sure the variable names I use in an
> m3makefiles don't confllict with the ones that cm3 might be using to
> manage the compilation?
>

I don't think there is anything graceful here, other than try it and
see if things blow up.

>>
>> This means means every main program has to independently compile all the common
>> stuff and keep its own copies thereof.  But disk is cheap and plentiful,
>> and 200K..300K SLOC compiles from scratch fast enough.
>
> Independently compiling all that stuff is what I originally wanted --
> it would give me the option of trying independent and very different
> implementations for some interfaces so as to discover hidden logical
> dependencies.
>
> And the extra disk space is not that much space -- considering that
> it only needs to be tied up during testing,
>
> -- hendrik
>




More information about the M3devel mailing list