Skip to content

Commit 279e2bf

Browse files
committed
fbc: internal restructure of fbctools table and fbcFindBin
- refactor fbcFindBin() to solve out variables lasttool, last_relying_on_system, and lastpath and store in fbcToolTB()
1 parent afeb29b commit 279e2bf

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
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
17+
- fbc: internal changes to restructure fbctools table, cache search results in fbctoolTB()
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: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,16 @@ enum FBCTOOLFLAG
136136
FBCTOOLFLAG_INVALID = 0 '' tool is disabled
137137
FBCTOOLFLAG_ASSUME_EXISTS = 1 '' assume the tool exists
138138
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
139141

140142
FBCTOOLFLAG_DEFAULT = FBCTOOLFLAG_ASSUME_EXISTS or FBCTOOLFLAG_CAN_USE_ENVIRON
141143
end enum
142144

143145
type FBCTOOLINFO
144146
name as zstring * 16
145147
flags as FBCTOOLFLAG
148+
path as zstring * (FB_MAXPATHLEN + 1)
146149
end type
147150

148151
'' must be same order as enum FBCTOOL
@@ -411,13 +414,10 @@ private sub fbcFindBin _
411414
byref relying_on_system as integer _
412415
)
413416

414-
static as integer lasttool = -1, last_relying_on_system
415-
static as string lastpath
416-
417417
'' Re-use path from last time if possible
418-
if( lasttool = tool ) then
419-
path = lastpath
420-
relying_on_system = last_relying_on_system
418+
if( ( fbctoolTB( tool ).flags and FBCTOOLFLAG_FOUND ) <> 0 ) then
419+
path = fbctoolTB( tool ).path
420+
relying_on_system = ((fbctoolTB( tool ).flags and FBCTOOLFLAG_RELYING_ON_SYSTEM) <> 0 )
421421
exit sub
422422
end if
423423

@@ -455,9 +455,12 @@ private sub fbcFindBin _
455455
#endif
456456
end if
457457

458-
lasttool = tool
459-
lastpath = path
460-
last_relying_on_system = relying_on_system
458+
459+
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 )
461464
end sub
462465

463466
private function fbcRunBin _

0 commit comments

Comments
 (0)