Forums

How to compile cobra as a .proj

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

How to compile cobra as a .proj

Postby RIGHT_THEN » Tue Feb 08, 2011 7:28 am

Gentlemen,

i saw file-to-compile that install-from-workspace uses i have added those files to the solution. But it never works.
If cobra was to be presented in a .sln what might its .proj look like.

Thanking you
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: How to compile cobra as a .proj

Postby Charles » Wed Feb 09, 2011 8:36 pm

Sorry, I don't know. Maybe Matthew Strawbridge, the author of the Visual Studio plugin, can chime in.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: How to compile cobra as a .proj

Postby RIGHT_THEN » Thu Feb 10, 2011 12:00 am

Mr. Charles

I specifically wanted it so that assemblies of .net 4.0 could be referenced into it to take advantage of .net 4.0 features, but it gave certain errors when i tried, being away from programming for long now it was hard for me to grasp the nature of those errors so i did it the way i could understand it. I -kif:yesed all .cobra files turned it into a Csharp solution and compiled with .net 4.0. and there it was .net 4.0 cobra ready to
compile for .4.0 i checked it with your samples and howto examples. it compiled all well. but certain
examples in them are outdated and do not correspond with .net 4.0 assemblies and features for which additional references have to be made and then it works fine especially of WPF.

would it be allright with you if i were to post this Csharped Cobra solution with SD4 addin so users can take advantage of .net 4.0 and correct things if they found problems along the way. because DLR and MemoryMapped files are brain stimulators which ought not be deprived from.

One other thing Mr.Charles why did you chose CobraInfo To be code generated . I hope there are none
more of these Cobra codes which need to be changed by hand in strings. if at all there would be problems
along the way with this CSharped Solution , it would be from these kind of strings which i have missed, but none so far hence all good.but anyway this solution is not meant to produce ert`s but to run general code.


ThankingYou
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: How to compile cobra as a .proj

Postby Charles » Thu Feb 10, 2011 1:01 am

You can call me "Charles" or "Chuck" or "Cobra Commander" ;-) ... but no "Mr.".

Are memory mapped files really a .NET 4.0-only thing? I was on a C# project a few years back that used memory mapped files. Maybe they were using a 3rd party lib...

CobraInfo is generated to contain the path to the Cobra compiler used at compile-time which can vary and therefore cannot be baked in, for example, Cobra.Lang.dll. That path in turn can be used by the CobraCore methods for locating a Cobra compiler to use from a Cobra program. I'm not sure what problem it's causing you right now.

It's also possible that a "static main wrapper" is generated. See _createSharedMainWrapper in CobraWorkspace/Source/Phases/IdentifyMainPhase.cobra.

You mention keeping the C# code and then using the .NET 4.0 C# compiler on that. There is actually a Cobra command line option that lets you do this in one step. "cobra -native-compiler:/PATH/TO/csc.exe ..." I think I've seen at least one person already doing this.

Also, I'm interested to know what changes you needed to make outside of WPF issues in order to get .NET 4.0 working. Thanks.

Yes, feel free to post files and/or more comments on the steps you followed to use .NET 4.0.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: How to compile cobra as a .proj

Postby RIGHT_THEN » Fri Feb 11, 2011 10:18 am

It is Charles Then ,

If you find Mr. sprinkled here and there consider it a syntax error

Are memory mapped files really a .NET 4.0-only thing? I was on a C# project a few years back that used memory mapped files. Maybe they were using a 3rd party lib...


Yes sir indeed i am sure of that.you certainly might be using 3rd party lib..
http://msdn.microsoft.com/en-us/magazine/ee428166.aspx

You mention keeping the C# code and then using the .NET 4.0 C# compiler on that. There is actually a Cobra command line option that lets you do this in one step. "cobra -native-compiler:/PATH/TO/csc.exe ..." I think I've seen at least one person already doing this


I was reminded of that when trying 4.0 I did use that initially and thought it would work
but it gave as i allready mentioned BADimage error that from Cobra side suggesting something
like what i am trying to use is newer than what Cobra is made up of.
I could only think of one reason for that. That when i referenced .net 4.0
assemblies internally you might be trying to fetch and read inside of them
access and implement their object for C# files which then would be passed on to
C# compiler. and it might be this fetching or something along those lines causing mixing
of 2.0 with 4.0 and resulting in this error, before even reaching C# compiler. because if it would have reached C# compiler, there seems no reason for this.

So what to do since Cobra compiler would not accecpt 4.0 either to compile itself
or programms for 4.0.

knowing little what i know and Cobra internal working being a black box to me .I thought of taking cobra compiler out of the picture for a while and sending contents directly to C# compiler, but for that C# files were needed hence i -kif:yes(ed) the Cobra itself
during install-from-workspace process.

Yes, feel free to post files and/or more comments on the steps you followed to use .NET 4.0.


so i continue..

Now i included every file into a .proj keeping ditto with what is in the Source folder.
while -kif:(ing) Native_ert_Guidnumber.cobra.cs is produced and there are two places where
Cobra.Lang source is located
1) Snapshot
2) Cobra.Lang

at this point i had to drink water.

So i hit the compile button. getting reminded by errors that same things are decalred twice or
some duplication was happening. So i removed Cobra.Lang folder alltogether , now it worked but
for CobraInfo. it could not locate this Class anywhere i also looked franticaly here and there
to see where it might be i could niether see a file named that or implemented along with someother class.

at this point above water got evaporated quickly. and just when i was ready to blame the world.
I found it where the error had occured i could see CobraInfo sitting inside of a string as if entire class was to be written to a file.

A-han i thought Charles sure has sense of humour practising strings like that
i immidiatley created a cobraInfo file changed the string to C# equivalent just to see if it works and Ta-Da compilation succeded.

at this point above water reapeared along with endless shouting of yes yes inside of me.

i thought since CobraLang files have been compiled into the compiler no Cobra.Lang was needed
separatly soon to be proved wrong.
so i created a separate Project for Cobra.Lang this time including back the folder Cobra.Lang
from the Source Folder which i had earlier removed in compiler making.
now i removed all the _ert_guidstrings from Cobra.Lang_ert_guidstrings from the Cobra.Lang folder files. and compiled it and there it was Cobra.Lang ready. i refrenced it into the compiler project
recompiled it and every thing seems to work okay.
i have two assemblies now

1) CobraAsCSharp.exe
2) Cobra.Lang.dll

they seem to be doing okay for what little i used. i am posting it on SD4 plugin site
for use with SD4 so those who know better can rectify it for full use.





Icon.jpg
Icon for Cobra
Icon.jpg (9.63 KiB) Viewed 7115 times


How about this file to use as icon for cobra and for its files in Sharpdevelop
i think i need to streamline the pencil a little bit more on this file.


ThankingYou
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: How to compile cobra as a .proj

Postby Charles » Fri Feb 11, 2011 7:56 pm

Thanks for the link and the notes. That's some interesting water you're drinking!

Regarding the icon, it didn't strike me well, but feel free to use any icons you like.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: How to compile cobra as a .proj

Postby Charles » Fri Feb 11, 2011 11:01 pm

This works for me:
Code: Select all
cobra -v:2 -d -c -native-compiler:C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe  hello.cobra
hello.exe

But I haven't tried more complex examples, or getting the Cobra compiler itself to run on 4.0.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 71 guests

cron