@@ -113,12 +113,13 @@ type FBCCTX
113113 objinf as FBC_OBJINF
114114end type
115115
116- enum
116+ enum FBCTOOL
117117 FBCTOOL_AS = 0
118118 FBCTOOL_AR
119119 FBCTOOL_LD
120120 FBCTOOL_GCC
121121 FBCTOOL_LLC
122+ FBCTOOL_CLANG
122123 FBCTOOL_DLLTOOL
123124 FBCTOOL_GORC
124125 FBCTOOL_WINDRES
@@ -131,20 +132,50 @@ enum
131132 FBCTOOL__COUNT
132133end enum
133134
134- static shared as zstring * 16 toolnames( 0 to FBCTOOL__COUNT- 1 ) = _
135+ enum FBCTOOLFLAG
136+ FBCTOOLFLAG_INVALID = 0 '' tool is disabled
137+ FBCTOOLFLAG_ASSUME_EXISTS = 1 '' assume the tool exists
138+ FBCTOOLFLAG_CAN_USE_ENVIRON = 2 '' allow path to tool to specified by environment variable
139+ FBCTOOLFLAG_FOUND = 4 '' tool was checked for
140+ FBCTOOLFLAG_RELYING_ON_SYSTEM = 8 '' tool is expected to be on system PATH
141+
142+ FBCTOOLFLAG_DEFAULT = FBCTOOLFLAG_ASSUME_EXISTS or FBCTOOLFLAG_CAN_USE_ENVIRON
143+ end enum
144+
145+ type FBCTOOLINFO
146+ name as zstring * 16
147+ flags as FBCTOOLFLAG
148+ path as zstring * (FB_MAXPATHLEN + 1 )
149+ end type
150+
151+ #define fbctoolGetFlags( tool, f ) ((fbctoolTB( tool ).flags and (f)) <> 0 )
152+ #define fbctoolSetFlags( tool, f ) fbctoolTB( tool ).flags or = f
153+ #define fbctoolUnsetFlags( tool, f ) fbctoolTB( tool ).flags and = not f
154+
155+ '' must be same order as enum FBCTOOL
156+ static shared as FBCTOOLINFO fbctoolTB( 0 to FBCTOOL__COUNT- 1 ) = _
135157{ _
136- "as" , "ar" , "ld" , "gcc" , "llc" , "dlltool" , "GoRC" , "windres" , "cxbe" , "dxe3gen" , _
137- "emcc" , _
138- "emar" , _
139- "emcc" , _
140- "emcc" _
158+ / ' FBCTOOL_AS '/ ( "as" , FBCTOOLFLAG_DEFAULT ), _
159+ / ' FBCTOOL_AR '/ ( "ar" , FBCTOOLFLAG_DEFAULT ), _
160+ / ' FBCTOOL_LD '/ ( "ld" , FBCTOOLFLAG_DEFAULT ), _
161+ / ' FBCTOOL_GCC '/ ( "gcc" , FBCTOOLFLAG_DEFAULT ), _
162+ / ' FBCTOOL_LLC '/ ( "llc" , FBCTOOLFLAG_DEFAULT ), _
163+ / ' FBCTOOL_CLANG '/ ( "clang" , FBCTOOLFLAG_DEFAULT ), _
164+ / ' FBCTOOL_DLLTOOL '/ ( "dlltool", FBCTOOLFLAG_DEFAULT ), _
165+ / ' FBCTOOL_GORC '/ ( "GoRC" , FBCTOOLFLAG_DEFAULT ), _
166+ / ' FBCTOOL_WINDRES '/ ( "windres", FBCTOOLFLAG_DEFAULT ), _
167+ / ' FBCTOOL_CXBE '/ ( "cxbe" , FBCTOOLFLAG_DEFAULT ), _
168+ / ' FBCTOOL_DXEGEN '/ ( "dxe3gen", FBCTOOLFLAG_DEFAULT ), _
169+ / ' FBCTOOL_EMAS '/ ( "emcc" , FBCTOOLFLAG_DEFAULT ), _
170+ / ' FBCTOOL_EMAR '/ ( "emar" , FBCTOOLFLAG_DEFAULT ), _
171+ / ' FBCTOOL_EMLD '/ ( "emcc" , FBCTOOLFLAG_DEFAULT ), _
172+ / ' FBCTOOL_EMCC '/ ( "emcc" , FBCTOOLFLAG_DEFAULT ) _
141173}
142174
143175declare sub fbcFindBin _
144176 ( _
145177 byval tool as integer , _
146- byref path as string , _
147- byref relying_on_system as integer = FALSE _
178+ byref path as string _
148179 )
149180
150181#macro safeKill(f)
@@ -382,27 +413,24 @@ end sub
382413private sub fbcFindBin _
383414 ( _
384415 byval tool as integer , _
385- byref path as string , _
386- byref relying_on_system as integer _
416+ byref path as string _
387417 )
388418
389- static as integer lasttool = - 1 , last_relying_on_system
390- static as string lastpath
391-
392419 '' Re-use path from last time if possible
393- if ( lasttool = tool ) then
394- path = lastpath
395- relying_on_system = last_relying_on_system
420+ if ( fbctoolGetFlags( tool, FBCTOOLFLAG_FOUND ) ) then
421+ path = fbctoolTB( tool ).path
396422 exit sub
397423 end if
398424
399- relying_on_system = FALSE
425+ fbctoolUnsetFlags( tool, FBCTOOLFLAG_RELYING_ON_SYSTEM )
400426
401427 '' a) Use the path from the corresponding environment variable if it's set
402- path = environ( ucase( toolnames(tool) ) )
428+ if ( (fbctoolTB(tool).flags and FBCTOOLFLAG_CAN_USE_ENVIRON) <> 0 ) then
429+ path = environ( ucase( fbctoolTB(tool).name ) )
430+ end if
403431 if ( len( path ) = 0 ) then
404432 '' b) Try bin/ directory
405- path = fbc.binpath + toolnames (tool) + FB_HOST_EXEEXT
433+ path = fbc.binpath + fbctoolTB (tool).name + FB_HOST_EXEEXT
406434
407435 #ifndef ENABLE_STANDALONE
408436 if ( (hFileExists( path ) = FALSE ) and _
@@ -419,18 +447,17 @@ private sub fbcFindBin _
419447 if ( hFileExists( path ) = FALSE ) then
420448 '' d) Rely on PATH
421449 if ( fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_JS ) then
422- path = fbc.targetprefix + toolnames (tool) + FB_HOST_EXEEXT
450+ path = fbc.targetprefix + fbctoolTB (tool).name + FB_HOST_EXEEXT
423451 else
424- path = toolnames (tool)
452+ path = fbctoolTB (tool).name
425453 end if
426- relying_on_system = TRUE
454+ fbctoolSetFlags( tool, FBCTOOLFLAG_RELYING_ON_SYSTEM )
427455 end if
428456 # endif
429457 end if
430458
431- lasttool = tool
432- lastpath = path
433- last_relying_on_system = relying_on_system
459+ fbctoolTB( tool ).path = path
460+ fbctoolSetFlags( tool, FBCTOOLFLAG_FOUND )
434461end sub
435462
436463private function fbcRunBin _
@@ -440,10 +467,10 @@ private function fbcRunBin _
440467 byref ln as string _
441468 ) as integer
442469
443- dim as integer result = any, relying_on_system = any
470+ dim as integer result = any
444471 dim as string path
445472
446- fbcFindBin( tool, path, relying_on_system )
473+ fbcFindBin( tool, path )
447474
448475 if ( fbc.verbose ) then
449476 print *action + ": " , path + " " + ln
@@ -456,7 +483,7 @@ private function fbcRunBin _
456483 result = exec( path, ln )
457484 # else
458485 '' Found at bin/?
459- if ( relying_on_system = FALSE ) then
486+ if ( fbctoolGetFlags( tool, FBCTOOLFLAG_RELYING_ON_SYSTEM ) = FALSE ) then
460487 result = exec( path, ln )
461488 else
462489 result = shell( path + " " + ln )
@@ -839,7 +866,7 @@ private function hLinkFiles( ) as integer
839866 if ( fbGetOption( FB_COMPOPT_OBJINFO ) and _
840867 (fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_DARWIN) and _
841868 (fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_SOLARIS) and _
842- ( fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_JS ) and _
869+ ( fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_JS ) and _
843870 ( not fbcIsUsingGoldLinker( )) ) then
844871 ldcline += " -T """ + fbc.libpath + (FB_HOST_PATHDIV + "fbextra.x""" )
845872 end if
0 commit comments