Skip to content

Commit 4de0f76

Browse files
committed
fbc: internal restructure of fbctools table and fbcFindBin()
- refactor fbcFindBin() to solve out relying_on_system parameter
1 parent 279e2bf commit 4de0f76

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Version 1.09.0
1414
- fbc: internal function fbcQueryGcc() to ask gcc for the correct as & ld to use (TeeEmCee)
1515
- rtlib: freebsd: minimum thread stacksize 8192 KiB
1616
- sf.net #666: allow overload 'as string' with 'as zstring ptr' parameters
17-
- fbc: internal changes to restructure fbctools table, cache search results in fbctoolTB()
17+
- fbc: internal changes to restructure fbctools table, cache search results in fbctoolTB(), solve out fbcFindBin() parameters
1818

1919
[added]
2020
- fbc: add '-z fbrt' command line option to link against libfbrt*.a instead of libfb*.a

src/compiler/fbc.bas

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ type FBCTOOLINFO
148148
path as zstring * (FB_MAXPATHLEN + 1)
149149
end type
150150

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+
151155
'' must be same order as enum FBCTOOL
152156
static shared as FBCTOOLINFO fbctoolTB(0 to FBCTOOL__COUNT-1) = _
153157
{ _
@@ -171,8 +175,7 @@ static shared as FBCTOOLINFO fbctoolTB(0 to FBCTOOL__COUNT-1) = _
171175
declare sub fbcFindBin _
172176
( _
173177
byval tool as integer, _
174-
byref path as string, _
175-
byref relying_on_system as integer = FALSE _
178+
byref path as string _
176179
)
177180

178181
#macro safeKill(f)
@@ -410,18 +413,16 @@ end sub
410413
private sub fbcFindBin _
411414
( _
412415
byval tool as integer, _
413-
byref path as string, _
414-
byref relying_on_system as integer _
416+
byref path as string _
415417
)
416418

417419
'' Re-use path from last time if possible
418-
if( ( fbctoolTB( tool ).flags and FBCTOOLFLAG_FOUND ) <> 0 ) then
420+
if( fbctoolGetFlags( tool, FBCTOOLFLAG_FOUND ) ) then
419421
path = fbctoolTB( tool ).path
420-
relying_on_system = ((fbctoolTB( tool ).flags and FBCTOOLFLAG_RELYING_ON_SYSTEM) <> 0 )
421422
exit sub
422423
end if
423424

424-
relying_on_system = FALSE
425+
fbctoolUnsetFlags( tool, FBCTOOLFLAG_RELYING_ON_SYSTEM )
425426

426427
'' a) Use the path from the corresponding environment variable if it's set
427428
if( (fbctoolTB(tool).flags and FBCTOOLFLAG_CAN_USE_ENVIRON) <> 0 ) then
@@ -450,17 +451,13 @@ private sub fbcFindBin _
450451
else
451452
path = fbctoolTB(tool).name
452453
end if
453-
relying_on_system = TRUE
454+
fbctoolSetFlags( tool, FBCTOOLFLAG_RELYING_ON_SYSTEM )
454455
end if
455456
#endif
456457
end if
457458

458-
459459
fbctoolTB( tool ).path = path
460-
fbctoolTB( tool ).flags or= FBCTOOLFLAG_FOUND
461-
fbctoolTB( tool ).flags = iif( relying_on_system, _
462-
fbctoolTB( tool ).flags or FBCTOOLFLAG_RELYING_ON_SYSTEM, _
463-
fbctoolTB( tool ).flags and not FBCTOOLFLAG_RELYING_ON_SYSTEM )
460+
fbctoolSetFlags( tool, FBCTOOLFLAG_FOUND )
464461
end sub
465462

466463
private function fbcRunBin _
@@ -470,10 +467,10 @@ private function fbcRunBin _
470467
byref ln as string _
471468
) as integer
472469

473-
dim as integer result = any, relying_on_system = any
470+
dim as integer result = any
474471
dim as string path
475472

476-
fbcFindBin( tool, path, relying_on_system )
473+
fbcFindBin( tool, path )
477474

478475
if( fbc.verbose ) then
479476
print *action + ": ", path + " " + ln
@@ -486,7 +483,7 @@ private function fbcRunBin _
486483
result = exec( path, ln )
487484
#else
488485
'' Found at bin/?
489-
if( relying_on_system = FALSE ) then
486+
if( fbctoolGetFlags( tool, FBCTOOLFLAG_RELYING_ON_SYSTEM ) = FALSE ) then
490487
result = exec( path, ln )
491488
else
492489
result = shell( path + " " + ln )

0 commit comments

Comments
 (0)