Skip to content

Commit afeb29b

Browse files
committed
fbc: internal restructure of fbctools table
- internal changes to prepare for new options on fbc's tools and invocation - name FBCTOOLS_* in the enum FBCTOOL - add enum FBCTOOLFLAG to specify tool options - add FBCTOOLINFO structure to track additional information for each tool
1 parent 27f305a commit afeb29b

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +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
1718

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

src/compiler/fbc.bas

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,13 @@ type FBCCTX
113113
objinf as FBC_OBJINF
114114
end 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,13 +132,37 @@ enum
131132
FBCTOOL__COUNT
132133
end 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+
140+
FBCTOOLFLAG_DEFAULT = FBCTOOLFLAG_ASSUME_EXISTS or FBCTOOLFLAG_CAN_USE_ENVIRON
141+
end enum
142+
143+
type FBCTOOLINFO
144+
name as zstring * 16
145+
flags as FBCTOOLFLAG
146+
end type
147+
148+
'' must be same order as enum FBCTOOL
149+
static shared as FBCTOOLINFO fbctoolTB(0 to FBCTOOL__COUNT-1) = _
135150
{ _
136-
"as", "ar", "ld", "gcc", "llc", "dlltool", "GoRC", "windres", "cxbe", "dxe3gen", _
137-
"emcc", _
138-
"emar", _
139-
"emcc", _
140-
"emcc" _
151+
/' FBCTOOL_AS '/ ( "as" , FBCTOOLFLAG_DEFAULT ), _
152+
/' FBCTOOL_AR '/ ( "ar" , FBCTOOLFLAG_DEFAULT ), _
153+
/' FBCTOOL_LD '/ ( "ld" , FBCTOOLFLAG_DEFAULT ), _
154+
/' FBCTOOL_GCC '/ ( "gcc" , FBCTOOLFLAG_DEFAULT ), _
155+
/' FBCTOOL_LLC '/ ( "llc" , FBCTOOLFLAG_DEFAULT ), _
156+
/' FBCTOOL_CLANG '/ ( "clang" , FBCTOOLFLAG_DEFAULT ), _
157+
/' FBCTOOL_DLLTOOL '/ ( "dlltool", FBCTOOLFLAG_DEFAULT ), _
158+
/' FBCTOOL_GORC '/ ( "GoRC" , FBCTOOLFLAG_DEFAULT ), _
159+
/' FBCTOOL_WINDRES '/ ( "windres", FBCTOOLFLAG_DEFAULT ), _
160+
/' FBCTOOL_CXBE '/ ( "cxbe" , FBCTOOLFLAG_DEFAULT ), _
161+
/' FBCTOOL_DXEGEN '/ ( "dxe3gen", FBCTOOLFLAG_DEFAULT ), _
162+
/' FBCTOOL_EMAS '/ ( "emcc" , FBCTOOLFLAG_DEFAULT ), _
163+
/' FBCTOOL_EMAR '/ ( "emar" , FBCTOOLFLAG_DEFAULT ), _
164+
/' FBCTOOL_EMLD '/ ( "emcc" , FBCTOOLFLAG_DEFAULT ), _
165+
/' FBCTOOL_EMCC '/ ( "emcc" , FBCTOOLFLAG_DEFAULT ) _
141166
}
142167

143168
declare sub fbcFindBin _
@@ -399,10 +424,12 @@ private sub fbcFindBin _
399424
relying_on_system = FALSE
400425

401426
'' a) Use the path from the corresponding environment variable if it's set
402-
path = environ( ucase( toolnames(tool) ) )
427+
if( (fbctoolTB(tool).flags and FBCTOOLFLAG_CAN_USE_ENVIRON) <> 0 ) then
428+
path = environ( ucase( fbctoolTB(tool).name ) )
429+
end if
403430
if( len( path ) = 0 ) then
404431
'' b) Try bin/ directory
405-
path = fbc.binpath + toolnames(tool) + FB_HOST_EXEEXT
432+
path = fbc.binpath + fbctoolTB(tool).name + FB_HOST_EXEEXT
406433

407434
#ifndef ENABLE_STANDALONE
408435
if( (hFileExists( path ) = FALSE) and _
@@ -419,9 +446,9 @@ private sub fbcFindBin _
419446
if( hFileExists( path ) = FALSE ) then
420447
'' d) Rely on PATH
421448
if( fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_JS ) then
422-
path = fbc.targetprefix + toolnames(tool) + FB_HOST_EXEEXT
449+
path = fbc.targetprefix + fbctoolTB(tool).name + FB_HOST_EXEEXT
423450
else
424-
path = toolnames(tool)
451+
path = fbctoolTB(tool).name
425452
end if
426453
relying_on_system = TRUE
427454
end if
@@ -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

Comments
 (0)