@@ -113,12 +113,13 @@ type FBCCTX
113
113
objinf as FBC_OBJINF
114
114
end type
115
115
116
- enum
116
+ enum FBCTOOL
117
117
FBCTOOL_AS = 0
118
118
FBCTOOL_AR
119
119
FBCTOOL_LD
120
120
FBCTOOL_GCC
121
121
FBCTOOL_LLC
122
+ FBCTOOL_CLANG
122
123
FBCTOOL_DLLTOOL
123
124
FBCTOOL_GORC
124
125
FBCTOOL_WINDRES
@@ -131,20 +132,50 @@ enum
131
132
FBCTOOL__COUNT
132
133
end enum
133
134
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 ) = _
135
157
{ _
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 ) _
141
173
}
142
174
143
175
declare sub fbcFindBin _
144
176
( _
145
177
byval tool as integer , _
146
- byref path as string , _
147
- byref relying_on_system as integer = FALSE _
178
+ byref path as string _
148
179
)
149
180
150
181
#macro safeKill(f)
@@ -382,27 +413,24 @@ end sub
382
413
private sub fbcFindBin _
383
414
( _
384
415
byval tool as integer , _
385
- byref path as string , _
386
- byref relying_on_system as integer _
416
+ byref path as string _
387
417
)
388
418
389
- static as integer lasttool = - 1 , last_relying_on_system
390
- static as string lastpath
391
-
392
419
'' 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
396
422
exit sub
397
423
end if
398
424
399
- relying_on_system = FALSE
425
+ fbctoolUnsetFlags( tool, FBCTOOLFLAG_RELYING_ON_SYSTEM )
400
426
401
427
'' 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
403
431
if ( len( path ) = 0 ) then
404
432
'' b) Try bin/ directory
405
- path = fbc.binpath + toolnames (tool) + FB_HOST_EXEEXT
433
+ path = fbc.binpath + fbctoolTB (tool).name + FB_HOST_EXEEXT
406
434
407
435
#ifndef ENABLE_STANDALONE
408
436
if ( (hFileExists( path ) = FALSE ) and _
@@ -419,18 +447,17 @@ private sub fbcFindBin _
419
447
if ( hFileExists( path ) = FALSE ) then
420
448
'' d) Rely on PATH
421
449
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
423
451
else
424
- path = toolnames (tool)
452
+ path = fbctoolTB (tool).name
425
453
end if
426
- relying_on_system = TRUE
454
+ fbctoolSetFlags( tool, FBCTOOLFLAG_RELYING_ON_SYSTEM )
427
455
end if
428
456
# endif
429
457
end if
430
458
431
- lasttool = tool
432
- lastpath = path
433
- last_relying_on_system = relying_on_system
459
+ fbctoolTB( tool ).path = path
460
+ fbctoolSetFlags( tool, FBCTOOLFLAG_FOUND )
434
461
end sub
435
462
436
463
private function fbcRunBin _
@@ -440,10 +467,10 @@ private function fbcRunBin _
440
467
byref ln as string _
441
468
) as integer
442
469
443
- dim as integer result = any, relying_on_system = any
470
+ dim as integer result = any
444
471
dim as string path
445
472
446
- fbcFindBin( tool, path, relying_on_system )
473
+ fbcFindBin( tool, path )
447
474
448
475
if ( fbc.verbose ) then
449
476
print *action + ": " , path + " " + ln
@@ -456,7 +483,7 @@ private function fbcRunBin _
456
483
result = exec( path, ln )
457
484
# else
458
485
'' Found at bin/?
459
- if ( relying_on_system = FALSE ) then
486
+ if ( fbctoolGetFlags( tool, FBCTOOLFLAG_RELYING_ON_SYSTEM ) = FALSE ) then
460
487
result = exec( path, ln )
461
488
else
462
489
result = shell( path + " " + ln )
@@ -839,7 +866,7 @@ private function hLinkFiles( ) as integer
839
866
if ( fbGetOption( FB_COMPOPT_OBJINFO ) and _
840
867
(fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_DARWIN) and _
841
868
(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 _
843
870
( not fbcIsUsingGoldLinker( )) ) then
844
871
ldcline += " -T """ + fbc.libpath + (FB_HOST_PATHDIV + "fbextra.x""" )
845
872
end if
0 commit comments