class: ParserFlags
authorClaus Gittinger <cg@exept.de>
Mon, 15 Jun 2015 10:07:13 +0200
changeset 3653 08ddf71e42b2
parent 3651 f01a2d800d05
child 3654 3f96747e4c10
child 3655 c6a2d886cfe9
class: ParserFlags class definition added: #useClang changed: #initialize #initializeSTCFlagsForTopDirectory:
ParserFlags.st
--- a/ParserFlags.st	Thu Jun 11 22:58:23 2015 +0200
+++ b/ParserFlags.st	Mon Jun 15 10:07:13 2015 +0200
@@ -96,7 +96,8 @@
 		DefineForBorlandC DefineForVisualC DefineForMSC DefineForGNUC
 		PerMethodFlags AllowSTXDelimiterComments DefineForMINGW32
 		DefineForMINGW64 DefineForMINGW WarnAssignmentToBlockArgument
-		WarnAssignmentToPoolVariable WarnAssignmentToMethodArgument'
+		WarnAssignmentToPoolVariable WarnAssignmentToMethodArgument
+		DefineForCLANG'
 	poolDictionaries:''
 	category:'System-Compiler'
 !
@@ -515,6 +516,12 @@
     "Created: / 15-03-2007 / 13:33:32 / cg"
 !
 
+useClang
+    "true if clang compiler should be used"
+
+    ^ self usedCompilerDefine = DefineForCLANG
+!
+
 useCompilerDefine: aCompilerDefine
     "enforce a particular compiler to be used (independent from
      what the system was compiled with)"
@@ -1579,21 +1586,22 @@
     DefineForMINGW := '__MINGW__'.
     DefineForMINGW32 := '__MINGW32__'.
     DefineForMINGW64 := '__MINGW64__'.
+    DefineForCLANG := '__clang__'.
 
     (executablePath := OperatingSystem pathOfSTXExecutable) notNil ifTrue:[
-	executablePath := executablePath asFilename directory.
-	(((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
-	  or:[
-	    executablePath := executablePath directory.
-	    ((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
-	      or:[
-		executablePath := executablePath directory.
-		((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
-	      ]
-	   ]
-	) ifTrue:[
-	    self initializeSTCFlagsForTopDirectory: executablePath.
-	]
+        executablePath := executablePath asFilename directory.
+        (((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
+          or:[
+            executablePath := executablePath directory.
+            ((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
+              or:[
+                executablePath := executablePath directory.
+                ((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
+              ]
+           ]
+        ) ifTrue:[
+            self initializeSTCFlagsForTopDirectory: executablePath.
+        ]
     ].
 
     "
@@ -1613,127 +1621,131 @@
 
     topDir := topDirArg.
     OperatingSystem isMSWINDOWSlike ifTrue:[
-	topDirArg isString ifTrue:[
-	    topDir := topDirArg copyReplaceAll:$/ with:$\ ifNone:topDirArg.
-	]
+        topDirArg isString ifTrue:[
+            topDir := topDirArg copyReplaceAll:$/ with:$\ ifNone:topDirArg.
+        ]
     ].
     topDir := topDir asFilename.
     topDirName := topDir name.
 
     "/ if in the development directory, use ./modules
     Smalltalk isSmalltalkDevelopmentSystem ifTrue:[
-	STCModulePath := 'modules'.
+        STCModulePath := 'modules'.
     ] ifFalse:[
-	STCModulePath := Filename tempDirectory constructString:'modules'.
+        STCModulePath := Filename tempDirectory constructString:'modules'.
     ].
 
     (topDir construct:'stc') exists ifFalse:[
-	('ParserFlags [warning]: stc not found in "',topDirName,'"') infoPrintCR.
-	'ParserFlags [warning]: stc-compiling (primitive code) will not work in the browser' infoPrintCR.
-	STCCompilation := #never.
+        ('ParserFlags [warning]: stc not found in "',topDirName,'"') infoPrintCR.
+        'ParserFlags [warning]: stc-compiling (primitive code) will not work in the browser' infoPrintCR.
+        STCCompilation := #never.
     ].
 
     OperatingSystem isMSWINDOWSlike ifTrue:[
-	useBorlandC := useVisualC := useMingw := false.
-	programFiles := OperatingSystem getEnvironment:'ProgramFiles'.
-	programFiles isEmptyOrNil ifTrue:[ programFiles := 'C:\Program Files' ].
-
-	STCCompilationIncludes := '-I',topDirName,'\include -I',topDirName,'\libopengl'.
-	(bccTop := BCCTop) isNil ifTrue:[
-	    borlandDir := OperatingSystem getEnvironment:'BCCDIR'.
-	    borlandDir isEmptyOrNil ifTrue:[ borlandDir := 'C:\Borland\bcc55' ].
-	    bccTop := {
-			(borlandDir) .
-			(programFiles , '\Borland\bcc55') .
-			(programFiles , '\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 := topDirName,'\lib\bc'.
-	    LinkArgs := '-L',topDirName,'\lib\bc'.
-	    LinkArgs := LinkArgs,' -L',bccTop,'\Lib -r -c -ap -Tpd -Gi -w-dup'.
-	    CCPath := 'bcc32'.
-	    MakeCommand := 'bmake'.
-	    LinkCommand := 'ilink32'.
-	    CCCompilationOptions := '-w-'.
-	    useBorlandC := true.
-	] ifFalse:[
-	    (vcTop := VCTop) isNil ifTrue:[
-		vcTop := {
-			    (programFiles,'\Microsoft Visual Studio 12.0\VC') .
-			    (programFiles,'\Microsoft Visual Studio 11.0\VC') .
-			    (programFiles,'\Microsoft Visual Studio 10.0\VC') .
-			    (programFiles,'\Microsoft Visual Studio 9.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 := {
-				(programFiles,'\Microsoft SDKs\Windows\v8.0A') .
-				(programFiles,'\Microsoft SDKs\Windows\v7.0A') .
-				(programFiles,'\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 := topDirName,'\lib\vc'.
-		LinkArgs := '-L',topDirName,'\lib\vc'.
-		LinkArgs := LinkArgs,' -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:\xxxxx\Include'.
-		LibDirectory := topDirName,'\lib\vc'.
-		LinkArgs := '-L',topDirName,'\lib\vc'.
-		LinkArgs := LinkArgs,' -r -c -ap -Tpd -Gi -w-dup'.
-	    ].
-	].
-	STCCompilationDefines := '-DWIN32'.
-	STCCompilationOptions := '+optinline +inlineNew'.
-	(topDirName,'\stc\stc.exe') asFilename exists ifTrue:[
-	    STCPath := (topDirName,'\stc\stc.exe').
-	] ifFalse:[
-	    STCPath := 'stc.exe'.
-	].
-	LibPath := ''.
-	SearchedLibraries := #('import32.lib').
-	"/ SearchedLibraries := #('import32.lib' 'glu32.lib' 'opengl32.lib').
+        useBorlandC := useVisualC := useMingw := false.
+        programFiles := OperatingSystem getEnvironment:'ProgramFiles'.
+        programFiles isEmptyOrNil ifTrue:[ programFiles := 'C:\Program Files' ].
+
+        STCCompilationIncludes := '-I',topDirName,'\include -I',topDirName,'\libopengl'.
+        (bccTop := BCCTop) isNil ifTrue:[
+            borlandDir := OperatingSystem getEnvironment:'BCCDIR'.
+            borlandDir isEmptyOrNil ifTrue:[ borlandDir := 'C:\Borland\bcc55' ].
+            bccTop := {
+                        (borlandDir) .
+                        (programFiles , '\Borland\bcc55') .
+                        (programFiles , '\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 := topDirName,'\lib\bc'.
+            LinkArgs := '-L',topDirName,'\lib\bc'.
+            LinkArgs := LinkArgs,' -L',bccTop,'\Lib -r -c -ap -Tpd -Gi -w-dup'.
+            CCPath := 'bcc32'.
+            MakeCommand := 'bmake'.
+            LinkCommand := 'ilink32'.
+            CCCompilationOptions := '-w-'.
+            useBorlandC := true.
+        ] ifFalse:[
+            (vcTop := VCTop) isNil ifTrue:[
+                vcTop := {
+                            (programFiles,'\Microsoft Visual Studio 12.0\VC') .
+                            (programFiles,'\Microsoft Visual Studio 11.0\VC') .
+                            (programFiles,'\Microsoft Visual Studio 10.0\VC') .
+                            (programFiles,'\Microsoft Visual Studio 9.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 := {
+                                (programFiles,'\Microsoft SDKs\Windows\v8.0A') .
+                                (programFiles,'\Microsoft SDKs\Windows\v7.0A') .
+                                (programFiles,'\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 := topDirName,'\lib\vc'.
+                LinkArgs := '-L',topDirName,'\lib\vc'.
+                LinkArgs := LinkArgs,' -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:\xxxxx\Include'.
+                LibDirectory := topDirName,'\lib\vc'.
+                LinkArgs := '-L',topDirName,'\lib\vc'.
+                LinkArgs := LinkArgs,' -r -c -ap -Tpd -Gi -w-dup'.
+            ].
+        ].
+        STCCompilationDefines := '-DWIN32'.
+        STCCompilationOptions := '+optinline +inlineNew'.
+        (topDirName,'\stc\stc.exe') asFilename exists ifTrue:[
+            STCPath := (topDirName,'\stc\stc.exe').
+        ] ifFalse:[
+            STCPath := 'stc.exe'.
+        ].
+        LibPath := ''.
+        SearchedLibraries := #('import32.lib').
+        "/ SearchedLibraries := #('import32.lib' 'glu32.lib' 'opengl32.lib').
     ] ifFalse:[
-	STCCompilationIncludes := '-I',topDirName,'/include'.
-	STCCompilationDefines := ''.
-	STCCompilationOptions := '+optinline +inlineNew'.
-	STCPath := topDirName,'/stc/stc'.
-
-	m32 := ''.
-	(ExternalAddress pointerSize == 4) ifTrue:[
-	    m32 := ' -m32'
-	].
-	CCCompilationOptions := OperatingSystem getCPUDefine,
-				' -D', self usedCompilerDefine,
-				' ', OperatingSystem getOSDefine,
-				' ', '-O', m32.
-	ParserFlags useGnuC ifTrue:[
-	    CCPath := 'gcc'
-	] ifFalse:[
-	    CCPath := 'cc'
-	].
-	LinkArgs := m32.
-	LinkSharedArgs := '-shared', m32.
-	LinkCommand := CCPath.
-	LibPath := ''.
-	SearchedLibraries := #().
-	MakeCommand := 'make'.
+        STCCompilationIncludes := '-I',topDirName,'/include'.
+        STCCompilationDefines := ''.
+        STCCompilationOptions := '+optinline +inlineNew'.
+        STCPath := topDirName,'/stc/stc'.
+
+        m32 := ''.
+        (ExternalAddress pointerSize == 4) ifTrue:[
+            m32 := ' -m32'
+        ].
+        CCCompilationOptions := OperatingSystem getCPUDefine,
+                                ' -D', self usedCompilerDefine,
+                                ' ', OperatingSystem getOSDefine,
+                                ' ', '-O', m32.
+        ParserFlags useClang ifTrue:[
+            CCPath := 'clang'
+        ] ifFalse:[
+            ParserFlags useGnuC ifTrue:[
+                CCPath := 'gcc'
+            ] ifFalse:[
+                CCPath := 'cc'
+            ].
+        ].
+        LinkArgs := m32.
+        LinkSharedArgs := '-shared', m32.
+        LinkCommand := CCPath.
+        LibPath := ''.
+        SearchedLibraries := #().
+        MakeCommand := 'make'.
     ].
 
     "
@@ -2661,11 +2673,11 @@
 !ParserFlags class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/ParserFlags.st,v 1.124 2015-02-07 11:32:37 cg Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libcomp/ParserFlags.st,v 1.124 2015-02-07 11:32:37 cg Exp $'
+    ^ '$Header$'
 ! !