ParserFlags.st
changeset 2645 0c873acfa7b4
parent 2626 76a39762314a
child 2652 6c326d458be5
--- a/ParserFlags.st	Mon Aug 08 23:03:12 2011 +0200
+++ b/ParserFlags.st	Mon Aug 08 23:04:58 2011 +0200
@@ -82,7 +82,7 @@
 		CCCompilationOptions CCPath LinkArgs LinkSharedArgs LinkCommand
 		LibPath SearchedLibraries MakeCommand AllowCaretAsBinop
 		AllowUnicodeStrings AllowUnicodeCharacters AllowCharacterEscapes
-		AllowStringEscapes LibDirectory'
+		AllowStringEscapes LibDirectory VCTop SDKTop BCCTop'
 	poolDictionaries:''
 	category:'System-Compiler'
 !
@@ -211,6 +211,16 @@
 
 !ParserFlags class methodsFor:'accessing-stc compilation control'!
 
+bccTop:aPath
+    "windows only: define the borland-C installation directory.
+     must contain bin\bcc32.exe and include.
+     Typically, something like 'C:\borland\bcc55'"
+
+    BCCTop := aPath
+
+    "Created: / 08-08-2011 / 22:41:48 / cg"
+!
+
 ccCompilationOptions
     ^ CCCompilationOptions ? ''
 !
@@ -283,6 +293,16 @@
     "Created: / 09-08-2006 / 18:45:12 / fm"
 !
 
+sdkTop:aPath
+    "windows only: define the SDK top directory.
+     must include folder with windows header files.
+     Typically something like 'C:\Program Files\Microsoft SDKs\Windows\v6.0A'"
+
+    SDKTop := aPath
+
+    "Created: / 08-08-2011 / 22:39:24 / cg"
+!
+
 searchedLibraries
     ^ SearchedLibraries
 !
@@ -383,6 +403,9 @@
 !
 
 useBorlandC
+    "no longer needed - now we can link visual-C dll 
+     with borland-generated VM and vice versa"
+
 "/    ^ true.
     ^ OperatingSystem getCCDefine ='__BORLANDC__'
 
@@ -395,6 +418,26 @@
     "Created: / 15-03-2007 / 13:34:49 / cg"
 !
 
+useVisualC
+    "no longer needed - now we can link visual-C dll 
+     with borland-generated VM and vice versa"
+
+"/    ^ true.
+    ^ OperatingSystem getCCDefine ='__VISUALC__'
+
+    "Created: / 08-08-2011 / 22:50:25 / cg"
+!
+
+vcTop:aPath
+    "windows only: define the visual-C top directory.
+     must contain bin\cl.exe and include.
+     Typically, something like 'C:\Program Files\Microsoft Visual Studio 10.0\VC'"
+
+    VCTop := aPath
+
+    "Created: / 08-08-2011 / 22:39:15 / cg"
+!
+
 withSTCCompilation:howSymbol do:aBlock
     |prev|
 
@@ -1222,7 +1265,10 @@
 !
 
 initializeSTCFlagsForTopDirectory:topDirArg
-    |topDir|
+    "notice: for now, can only initialize for borland+windows or linux;
+     visualC setup still fails"
+
+    |topDir vcTop sdkTop bccTop useBorlandC useVisualC|
 
     topDir := topDirArg.
     OperatingSystem isMSWINDOWSlike ifTrue:[
@@ -1238,21 +1284,62 @@
     STCCompilation := #default.
 
     (topDir asFilename construct:'stc') exists ifFalse:[
-        'Warning: stv not found in ../..' infoPrintCR.
-        STCCompilation := #never.
+        'Warning: stc not found in "../.."' infoPrintCR.
+       STCCompilation := #never.
     ].
 
     OperatingSystem isMSWINDOWSlike ifTrue:[
+        useBorlandC := useVisualC := false.
+
         STCCompilationIncludes := '-I',topDir,'\include -I',topDir,'\libopengl'.
-        LibDirectory := topDir,'\libbc'.
-        LinkArgs := '-L',topDir,'\libbc'.
-
-        'C:\Borland\bcc55' asFilename exists ifTrue:[
-            STCCompilationIncludes := STCCompilationIncludes,' -IC:\Borland\bcc55\Include'.
-            LinkArgs := LinkArgs,' -LC:\Borland\bcc55\Lib -r -c -ap -Tpd -Gi -w-dup'.
+        (bccTop := BCCTop) isNil ifTrue:[
+            bccTop := #(
+                        'C:\Borland\bcc55'
+                       ) detect:[:path | path asFilename exists and:[(path asFilename construct:'include') exists]] ifNone:nil.
+        ].
+
+        (bccTop notNil and:[bccTop asFilename exists]) ifTrue:[
+            STCCompilationIncludes := STCCompilationIncludes,' -I',bccTop,'\Include'.
+            LibDirectory := topDir,'\libbc'.
+            LinkArgs := '-L',topDir,'\libbc'.
+            LinkArgs := LinkArgs,' -L',bccTop,'\Lib -r -c -ap -Tpd -Gi -w-dup'.
+            CCPath := 'bcc32'.
+            MakeCommand := 'bmake'.
+            LinkCommand := 'ilink32'.
+            CCCompilationOptions := '-w-'.
+            useBorlandC := true.
         ] ifFalse:[
-            STCCompilationIncludes := STCCompilationIncludes,' -IC:\Borland\xxxxx\Include'.
-            LinkArgs := LinkArgs,' -LC:\Borland\xxxxx\Lib -r -c -ap -Tpd -Gi -w-dup'.
+            (vcTop := VCTop) isNil ifTrue:[
+                vcTop := #(
+                            'C:\Program Files\Microsoft Visual Studio 10.0\VC'
+                          ) detect:[:path | path asFilename exists and:[(path asFilename construct:'bin/cl.exe') exists]] ifNone:nil.
+            ].
+            (vcTop notNil and:[vcTop asFilename exists]) ifTrue:[
+                useVisualC := true.
+                STCCompilationIncludes := STCCompilationIncludes,' -I',vcTop,'include'.
+
+                (sdkTop := SDKTop) isNil ifTrue:[
+                    sdkTop := #(
+                                'C:\Program Files\Microsoft SDKs\Windows\v6.0A'
+                              ) detect:[:path | path asFilename exists and:[(path asFilename construct:'include') exists]] ifNone:nil.
+                ].
+                (sdkTop notNil and:[sdkTop asFilename exists]) ifTrue:[
+                    STCCompilationIncludes := STCCompilationIncludes,' -I',sdkTop,'\include'.
+                ].
+                LibDirectory := topDir,'\libvc'.
+                LinkArgs := '-L',topDir,'\libvc'.
+                LinkArgs := LinkArgs,' -LC:\Borland\bcc55\Lib -r -c -ap -Tpd -Gi -w-dup'.
+                CCPath := vcTop,'\bin\cl.exe'.
+                LinkCommand := 'ilink32'.
+                MakeCommand := 'vcmake'.
+                CCCompilationOptions := '/nologo /ZI  /w /GF /EHsc /FR.\objvc\'.
+            ] ifFalse:[
+                "/ add definitions for lcc, mingc etc. 
+                STCCompilationIncludes := STCCompilationIncludes,' -IC:\Borland\xxxxx\Include'.
+                LibDirectory := topDir,'\libbc'.
+                LinkArgs := '-L',topDir,'\libbc'.
+                LinkArgs := LinkArgs,' -LC:\Borland\xxxxx\Lib -r -c -ap -Tpd -Gi -w-dup'.
+            ].
         ].
         STCCompilationDefines := '-DWIN32'.
         STCCompilationOptions := '+optinline +inlineNew'.
@@ -1261,16 +1348,6 @@
         ] ifFalse:[
             STCPath := 'stc.exe'.
         ].
-        self useBorlandC ifTrue:[
-            CCPath := 'bcc32'.
-            MakeCommand := 'bmake'.
-            CCCompilationOptions := '-w-'.
-        ] ifFalse:[
-            CCPath := 'cl'.
-            MakeCommand := 'nmake'.
-            CCCompilationOptions := '-w-'.
-        ].
-        LinkCommand := 'ilink32'.
         LibPath := ''.
         SearchedLibraries := #('import32.lib').
         "/ SearchedLibraries := #('import32.lib' 'glu32.lib' 'opengl32.lib').
@@ -2089,11 +2166,11 @@
 !ParserFlags class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/ParserFlags.st,v 1.66 2011-08-07 12:05:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/ParserFlags.st,v 1.67 2011-08-08 21:04:58 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libcomp/ParserFlags.st,v 1.66 2011-08-07 12:05:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/ParserFlags.st,v 1.67 2011-08-08 21:04:58 cg Exp $'
 ! !
 
 ParserFlags initialize!