Just to update this thread, in case anyone is in a similar situation and
wondering: Oliver's suggestion of setting the environment variables works
beautifully. I use the Python line:

os.environ["CILLY_DONT_COMPILE_AFTER_**MERGE"] = 1

to set the environment variable (temporarily).

Thanks, Oliver!


On 30 September 2012 23:03, Jonathan Kotker <advancedvers...@gmail.com>wrote:

> Hi Oliver.
>
> Thanks for the quick replies!
>
> On 27 September 2012 02:14, Oliver Schwahn <
> schw...@rbg.informatik.tu-darmstadt.de> wrote:
>
>> Hi,
>>
>>
>>  So, what I'm currently using CIL for in my tool is to preprocess the
>>> source file under analysis to make it easier to analyze -- or at least,
>>> that's the hope.
>>>
>>
>> Ok, so you just want the merged C source as output? No compilation or
>> linking?
>>
>>
> Ideally, yes.
>
>
>>
>>  I'm interfacing with Cilly through Python. This is the command that I am
>>> constructing:
>>>
>>> "cilly --merge --extrafiles=tmp foo.c -o foo.out"
>>>
>>> where "tmp" is the file that contains the names of the files to be
>>> merged with "foo.c". Currently, it links the file that is produced as a
>>> result of the merge. Adding the "-c" flag (and removing "-o foo.out")
>>> prevents Cilly from linking, but for some reason, Cilly stops and only
>>> produces the *.i file, so I'm not sure what exactly I'm doing wrong.
>>>
>>
>> Well, the problem is that the "-c" flag is interpreted by the cilly
>> script which mimics gcc behavior and "compiles" the input file. Compiling
>> means here that the input file is preprocessed and the resulting code is
>> written to an *.o file. The actual merger (i.e. the CIL executable) is
>> never invoked! In order to merge files using cilly, you must tell it to
>> "link" them.
>>
>
> Ah okay, thanks for the clarification! That is an interesting way to do
> things. Hm...
>
>
>> I think the only way to prevent cilly from invoking gcc for actual
>> compilation and linking is to use the environment variables:
>> CILLY_DONT_COMPILE_AFTER_MERGE which prevents invoking gcc for compilation
>> and linking or CILLY_DONT_LINK_AFTER_MERGE which prevents invoking gcc for
>> linking.
>>
>> I'd construct a shell command that looks like this:
>> "CILLY_DONT_COMPILE_AFTER_**MERGE=1 cilly --merge --extrafiles=tmp
>> --merged_out=foo_merged.c foo.c"
>>
>> It merges all files and puts the result in the file "foo_merged.c"
>> without invoking gcc for compilation or linking.
>> This works perfectly if used in a shell like bash. Not sure if this kind
>> of command invocation also works with python.
>>
>>
>>
> That sounds like it could work. I can try it out and let you know.
>
>
>> There is also another way to get your files merged! You can use the CIL
>> executable directly rather than going through the cilly Pearl script. This
>> solution, however, may be less comfortable since you must do all
>> preprocessing and file handling yourself.
>>
>> You can use a command like this:
>> "cilly.asm.exe --mergedout foo_merged.c --extrafiles tmp.txt foo.i"
>>
>> It merges all files into foo_merged.c using the CIL executable. Note the
>> different command line option syntax and that all input files must be
>> already preprocessed.
>>
>>
> Yeah. It might be better to try to use the Cilly Perl script directly.
> Thanks!
>
>
>>
>> Hope this helps.
>> Cheers!
>> Oliver
>>
>>
>
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to