Forums

cobra -lib:'{EnvironmentVar}\...\{@latest}'

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

cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby Charles » Sat Nov 30, 2013 8:58 pm

I have enhanced the -lib option to take environment variables as well as the special variable {@latest}. Here is a real example used for Windows Presentation Foundation (WPF) which was the main inspiration for this:

Code: Select all
# at the command line:
cobra -lib:'{ProgramFiles|ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\.NETFramework\{@latest}' foo.cobra ...

# or you can put it in your source code with @args:
@args lib:'{ProgramFiles|ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\.NETFramework\{@latest}'

@ref 'WindowsBase'
@ref 'PresentationCore'
@ref 'PresentationFramework'
@ref 'System.Xaml'

use System.Windows
use System.Windows.Media
# ...

As you can see from the example you can actually have more than one env var separated by vertical bars: {foo|bar|baz}

The first path that actually exists on disk at the time of compilation "wins". Then {@latest} can be used to distinguish between directories like "v4.0", "v4.5" and "v4.5.1". The "v" prefix is optional.

Those of you who run the compiler test suite shouldn't see any more WPF errors. If you do, let me know.

For everyone: If you have problems with this, let me know here. If you come up with other uses for it besides WPF, please share in this thread.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby hopscc » Mon Dec 02, 2013 6:25 am

Still gives WPF compile errors on my system ( Windows 7 64 bit Net4)

The new expansion code works fine but on this system there is no '.NetFramework' dir in
'{ProgramFiles|ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\''

theres only version dirs for net version 3 (v3.0 and v3.5).

The requisite files are in '{WinDir}\Microsoft.NET/{Framework|Framework64}/' but then you have to somehow wire/detect/use the
correct platform bitsize (64 or 32 bit platform) so a simple either-or existence option test is still insufficient.

I went through this when doing the patch for ticket:332
and vaguely recollect that one of the SDK/IDE installs sets up the 'Reference Assemblies' dir for some platforms - but not mine - or I just havent installed the 'right' IDE/SDK software pkg or something ... Its subject to installation/config instability anyway.

Think you're better off providing a magic static tag value for most of the framework path that the compiler expands for the platform...
It does its own probing/detection/lookup to work out what that is exactly.....
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby Charles » Mon Dec 02, 2013 10:36 am

Thanks for the report and details. How sad that the .NET cannot decide where to put their damn files.

What exactly do you see in your '{WinDir}\Microsoft.NET/{Framework|Framework64}/' directory? In other words, does that have "v4.0" and "v4.5"?

What shall we call the special {@var}? Maybe {@framework}
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby hopscc » Tue Dec 03, 2013 12:17 am

Just 4, nothing later ( no 4.5)

Code: Select all
591 xx:...wkspace1/Source> ls /Windows/Microsoft.NET/Framework64
SharedReg12.dll  sbscmp20_mscorwks.dll     v2.0.50727  v3.5
sbscmp10.dll     sbscmp20_perfcounter.dll  v3.0        v4.0.30319

592 xx:...wkspace1/Source> ls /Windows/Microsoft.NET/Framework
NETFXSBS10.exe                             sbs_system.data.dll
SharedReg12.dll                            sbs_system.enterpriseservices.dll
netfxsbs12.hkf                             sbs_wminet_utils.dll
sbs_VsaVb7rt.dll                           sbscmp10.dll
sbs_diasymreader.dll                       sbscmp20_mscorwks.dll
sbs_iehost.dll                             sbscmp20_perfcounter.dll
sbs_microsoft.jscript.dll                  v1.0.3705
sbs_microsoft.vsa.vb.codedomprocessor.dll  v1.1.4322
sbs_mscordbi.dll                           v2.0.50727
sbs_mscorrc.dll                            v3.0
sbs_mscorsec.dll                           v3.5
sbs_system.configuration.install.dll       v4.0.30319
593 xx:...wkspace1/Source>


Have a look at the ticket/patch
I made two variables one for the full (latest) frame work path ( called {_FWP} -> '{@FullFrameworkPath}')
and one for just the
single directory for current Framework-with-wordsize expansion ( '{_FW}' -> '{@FrameworkSize}' (??)

this allows simple compiler determine spec of 'system' path
Code: Select all
@args -lib:'{_FWP}\WPF'

@ref 'PresentationFramework'
@ref 'PresentationCore'
@ref 'WindowsBase'
# can also fully detail overiding
#@ref '{_FWP}\WPF\PresentationCore'
#@ref 'C:\Windows\Microsoft.NET\{_FW}\v4.0.30319\WPF\WindowsBase'
@ref 'System.Xaml'


or full detail specified breakdown
Code: Select all
@ref 'C:\Windows\Microsoft.NET\{_FW}\v4.0.30319\WPF\PresentationFramework'
# better
#@ref 'C:\Windows\Microsoft.NET\{_FW}\{@latest}\WPF\PresentationFramework'

or
@args -lib: '{WinDir}\Microsoft.NET\{_FW}\{@latest}\WPF'
@ref 'PresentationFramework'
@ref 'PresentationCore'
@ref 'WindowsBase'
@ref 'System.Xaml'

or (current only allow @latest last)
@args -lib: '{WinDir}\Microsoft.NET\{_FW}\{@latest}'
@ref 'WPF\PresentationFramework'
@ref 'WPF\PresentationCore'
@ref 'WPF\WindowsBase'
@ref 'System.Xaml'
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby Charles » Tue Dec 03, 2013 2:04 am

I haven't tried these yet and I'm about to turn in, but I noticed you have "...\WPF" in your lib paths, but there is no WPF subdirectory in the .NET 4.5.1 SDK on Win 8.1. It's simply:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1

PresentationCore.dll is directly in there right next to various other DLLs like System.Data.dll. So a directive, whether -lib or @ref, that uses "\WPF" will still fail in some environments (and vice versa).
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby Charles » Tue Dec 03, 2013 2:12 am

@hops, can you give me the output for this on your system:

C:\>dir PresentationCore.dll /s

For me, it's:
Code: Select all
 Volume in drive C is Windows8_OS
 Volume Serial Number is E2AD-01A1

 Directory of C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0

08/02/2013  08:47 PM         3,999,232 PresentationCore.dll
               1 File(s)      3,999,232 bytes

 Directory of C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1

08/02/2013  11:51 PM         1,300,080 PresentationCore.dll
               1 File(s)      1,300,080 bytes

 Directory of C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0

08/02/2013  08:41 PM         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\assembly\GAC_32\PresentationCore\3.0.0.0__31bf3856ad364e35

08/02/2013  08:41 PM         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\assembly\GAC_64\PresentationCore\3.0.0.0__31bf3856ad364e35

08/02/2013  08:47 PM         3,999,232 PresentationCore.dll
               1 File(s)      3,999,232 bytes

 Directory of C:\Windows\Microsoft.NET\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35

10/07/2013  04:47 PM         3,229,808 PresentationCore.dll
               1 File(s)      3,229,808 bytes

 Directory of C:\Windows\Microsoft.NET\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35

10/07/2013  04:46 PM         3,208,816 PresentationCore.dll
               1 File(s)      3,208,816 bytes

 Directory of C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF

10/07/2013  04:47 PM         3,229,808 PresentationCore.dll
               1 File(s)      3,229,808 bytes

 Directory of C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF

10/07/2013  04:46 PM         3,208,816 PresentationCore.dll
               1 File(s)      3,208,816 bytes

 Directory of C:\Windows\WinSxS\amd64_presentationcore_31bf3856ad364e35_4.0.9600.16404_none_d2ae39b6b0bbd8b3

11/21/2013  05:49 PM            13,576 PresentationCore.dll
               1 File(s)         13,576 bytes

 Directory of C:\Windows\WinSxS\amd64_presentationcore_31bf3856ad364e35_4.0.9600.16423_none_d2b05112b0b9f1c0

10/07/2013  04:46 PM         3,208,816 PresentationCore.dll
               1 File(s)      3,208,816 bytes

 Directory of C:\Windows\WinSxS\amd64_presentationcore_31bf3856ad364e35_6.3.9600.16384_none_9cef724a63eb4ff0

08/02/2013  08:47 PM         3,999,232 PresentationCore.dll
               1 File(s)      3,999,232 bytes

 Directory of C:\Windows\WinSxS\x86_presentationcore_31bf3856ad364e35_4.0.9600.16404_none_1a5b708dc53801b9

11/21/2013  05:59 PM            16,650 PresentationCore.dll
               1 File(s)         16,650 bytes

 Directory of C:\Windows\WinSxS\x86_presentationcore_31bf3856ad364e35_4.0.9600.16423_none_1a5d87e9c5361ac6

10/07/2013  04:47 PM         3,229,808 PresentationCore.dll
               1 File(s)      3,229,808 bytes

 Directory of C:\Windows\WinSxS\x86_presentationcore_31bf3856ad364e35_6.3.9600.16384_none_40d0d6c6ab8ddeba

08/02/2013  08:41 PM         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

     Total Files Listed:
              15 File(s)     45,300,514 bytes
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby Charles » Tue Dec 03, 2013 2:17 am

Here is another interesting one to run:

C:\>dir "Reference Assemblies" /s

Directory of C:\Program Files

10/31/2013 08:06 PM <DIR> Reference Assemblies
0 File(s) 0 bytes

Directory of C:\Program Files (x86)

10/31/2013 08:06 PM <DIR> Reference Assemblies
0 File(s) 0 bytes
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby hopscc » Wed Dec 04, 2013 12:58 am

re WPF
I'm on Windows 7 (Microsoft Windows 6.1.7601).
I dont have Net4.5 installed SFAICT - no Net 4.5 dirs

Both /Windows/Microsoft.NET/Framework/v4.0.30319 and /Windows/Microsoft.NET/Framework64/v4.0.30319
have WPF directories
( those examples were out of the ticket patch I made - all passed )

dir PresentationCore.dll (run in command.exe from C:\)
Code: Select all

C:\>dir PresentationCore.dll /s
 Volume in drive C is OS
 Volume Serial Number is 22B1-6FBF

 Directory of C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0

16/04/2013  11:55 a.m.         3,998,208 PresentationCore.dll
               1 File(s)      3,998,208 bytes

 Directory of C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
.0

16/04/2013  11:56 a.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\wbin86\Reference Assemblies\Microsoft\Framework\v3.0

16/04/2013  11:56 a.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\assembly\GAC_32\PresentationCore\3.0.0.0__31bf3856ad3
e35

16/04/2013  11:56 a.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\assembly\GAC_64\PresentationCore\3.0.0.0__31bf3856ad3
e35

16/04/2013  11:55 a.m.         3,998,208 PresentationCore.dll
               1 File(s)      3,998,208 bytes

 Directory of C:\Windows\Microsoft.NET\assembly\GAC_32\PresentationCore\v4.0_4
.0.0__31bf3856ad364e35

11/09/2013  10:33 p.m.         3,226,224 PresentationCore.dll
               1 File(s)      3,226,224 bytes

 Directory of C:\Windows\Microsoft.NET\assembly\GAC_64\PresentationCore\v4.0_4
.0.0__31bf3856ad364e35

11/09/2013  07:39 p.m.         3,207,792 PresentationCore.dll
               1 File(s)      3,207,792 bytes

 Directory of C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF

11/09/2013  10:33 p.m.         3,226,224 PresentationCore.dll
               1 File(s)      3,226,224 bytes

 Directory of C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF

11/09/2013  07:39 p.m.         3,207,792 PresentationCore.dll
               1 File(s)      3,207,792 bytes

 Directory of C:\Windows\winsxs\amd64_presentationcore_31bf3856ad364e35_6.1.76
.17514_none_0a5717aea693d3bd

21/11/2010  04:24 p.m.         3,997,696 PresentationCore.dll
               1 File(s)      3,997,696 bytes

 Directory of C:\Windows\winsxs\amd64_presentationcore_31bf3856ad364e35_6.1.76
.17755_none_0a2cdc14a6b35726

04/01/2012  04:34 p.m.         3,997,696 PresentationCore.dll
               1 File(s)      3,997,696 bytes

 Directory of C:\Windows\winsxs\amd64_presentationcore_31bf3856ad364e35_6.1.76
.17777_none_0a193cd0a6c1c1b6

11/02/2012  12:29 p.m.         3,998,208 PresentationCore.dll
               1 File(s)      3,998,208 bytes

 Directory of C:\Windows\winsxs\amd64_presentationcore_31bf3856ad364e35_6.1.76
.18140_none_0a328862a6afe739

16/04/2013  11:55 a.m.         3,998,208 PresentationCore.dll
               1 File(s)      3,998,208 bytes

 Directory of C:\Windows\winsxs\amd64_presentationcore_31bf3856ad364e35_6.1.76
.21890_none_0a8637bdbff5e801

04/01/2012  03:50 p.m.         3,998,720 PresentationCore.dll
               1 File(s)      3,998,720 bytes

 Directory of C:\Windows\winsxs\amd64_presentationcore_31bf3856ad364e35_6.1.76
.21921_none_0ad2e961bfbc3ae8

11/02/2012  12:30 p.m.         3,999,232 PresentationCore.dll
               1 File(s)      3,999,232 bytes

 Directory of C:\Windows\winsxs\amd64_presentationcore_31bf3856ad364e35_6.1.76
.22309_none_0af0695dbfa4f875

16/04/2013  11:55 a.m.         3,999,232 PresentationCore.dll
               1 File(s)      3,999,232 bytes

 Directory of C:\Windows\winsxs\x86_presentationcore_31bf3856ad364e35_6.1.7601
7514_none_ae387c2aee366287

21/11/2010  04:24 p.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\winsxs\x86_presentationcore_31bf3856ad364e35_6.1.7601
7755_none_ae0e4090ee55e5f0

04/01/2012  03:50 p.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\winsxs\x86_presentationcore_31bf3856ad364e35_6.1.7601
7777_none_adfaa14cee645080

11/02/2012  12:31 p.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\winsxs\x86_presentationcore_31bf3856ad364e35_6.1.7601
8140_none_ae13ecdeee527603

16/04/2013  11:56 a.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\winsxs\x86_presentationcore_31bf3856ad364e35_6.1.7601
1890_none_ae679c3a079876cb

04/01/2012  03:50 p.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\winsxs\x86_presentationcore_31bf3856ad364e35_6.1.7601
1921_none_aeb44dde075ec9b2

11/02/2012  12:30 p.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

 Directory of C:\Windows\winsxs\x86_presentationcore_31bf3856ad364e35_6.1.7601
2309_none_aed1cdda0747873f

16/04/2013  11:55 a.m.         4,218,880 PresentationCore.dll
               1 File(s)      4,218,880 bytes

     Total Files Listed:
              23 File(s)     91,042,240 bytes
               0 Dir(s)  630,163,152,896 bytes free


"Reference Assemblies"
Code: Select all

C:\>dir "Reference Assemblies" /s
 Volume in drive C is OS
 Volume Serial Number is 22B1-6FBF

 Directory of C:\Program Files

14/07/2009  06:32 p.m.    <DIR>          Reference Assemblies
               0 File(s)              0 bytes

 Directory of C:\Program Files (x86)

14/07/2009  06:32 p.m.    <DIR>          Reference Assemblies
               0 File(s)              0 bytes

 Directory of C:\wbin86

14/07/2009  06:32 p.m.    <DIR>          Reference Assemblies
               0 File(s)              0 bytes

     Total Files Listed:
               0 File(s)              0 bytes
               3 Dir(s)  630,163,013,632 bytes free

C:\>

(wbin86 is (my added) space free link to "Program Files (86)" )
:)
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby Charles » Thu Dec 05, 2013 9:46 am

Part of your output came through as:
Code: Select all
 Directory of C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
.0

In any case, what I have read is that \Windows\Microsoft.NET... is the GAC which is read only at run-time and \Program Files...\Reference Assemblies\... contains reference assemblies that are only read at compile-time. Although I haven't read a clear explanation of what the motivation or benefit is for separating the two.

Getting back to your machine, it's apparent that you have installed the .NET 4 client, but not the SDK or Visual Studio. So the question is whether or not we want to require the SDK when developing for Cobra?

I thought I also read somewhere that the .NET run-time no longer ships with csc.exe which we rely on. That would add more weight to requiring the SDK if that's true.

Also, I'm curious where your msbuild for .NET 4 is located or if you even have one.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: cobra -lib:'{EnvironmentVar}\...\{@latest}'

Postby nerdzero » Thu Dec 05, 2013 12:25 pm

Charles wrote:Also, I'm curious where your msbuild for .NET 4 is located or if you even have one.

MSBuild.exe should be in C:\Windows\Microsoft.NET\Framework|Framework64\v4.0.30319 for .NET 4. It will no longer be shipped with .NET in the future and instead is bundled with Visual Studio or as part of a separate SDK install.
nerdzero
 
Posts: 286
Location: Chicago, IL

Next

Return to Discussion

Who is online

Users browsing this forum: No registered users and 22 guests