Skip to content

Commit 13c8f9b

Browse files
committed
internal: Split up fbcInit2() into smaller subs
to make the code easier to read, and to allow for -print option handling to be inserted between the individual steps more easily in the future.
1 parent 66cd17d commit 13c8f9b

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

src/compiler/fbc.bas

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,12 +2259,8 @@ private sub hParseArgs( byval argc as integer, byval argv as zstring ptr ptr )
22592259
'' ignore silently (that might not even be too bad for portability)?
22602260
end sub
22612261

2262-
'' After command line parsing
2263-
private sub fbcInit2( )
2264-
''
2265-
'' Determine base/prefix path
2266-
''
2267-
2262+
'' Determine base/prefix path
2263+
private sub fbcDeterminePrefix( )
22682264
'' Not already set from -prefix command line option?
22692265
if( len( fbc.prefix ) = 0 ) then
22702266
'' Then default to exepath() or the hard-coded prefix
@@ -2281,9 +2277,9 @@ private sub fbcInit2( )
22812277
else
22822278
fbc.prefix += FB_HOST_PATHDIV
22832279
end if
2280+
end sub
22842281

2285-
''
2286-
'' Setup compiler paths
2282+
private sub fbcSetupCompilerPaths( )
22872283
''
22882284
'' Standalone (classic FB):
22892285
''
@@ -2358,23 +2354,21 @@ private sub fbcInit2( )
23582354
fbc.incpath = fbc.prefix + "include" + FB_HOST_PATHDIV + fbname
23592355
fbc.libpath = fbc.prefix + libdirname + FB_HOST_PATHDIV + fbname + FB_HOST_PATHDIV + targetid
23602356
#endif
2357+
end sub
23612358

2362-
if( fbc.verbose ) then
2363-
var s = targetid
2364-
s += ", " + *fbGetFbcArch( )
2365-
s += ", " & fbGetBits( ) & "bit"
2366-
#ifndef ENABLE_STANDALONE
2367-
if( len( fbc.target ) > 0 ) then
2368-
s += " (" + fbc.target + ")"
2369-
end if
2370-
#endif
2371-
print "target:", s
2372-
end if
2373-
2374-
'' Tell the compiler about the default include path (added after
2375-
'' the command line ones, so those will be searched first)
2376-
fbAddIncludePath( fbc.incpath )
2359+
private sub fbcPrintTargetInfo( )
2360+
var s = fbGetTargetId( )
2361+
s += ", " + *fbGetFbcArch( )
2362+
s += ", " & fbGetBits( ) & "bit"
2363+
#ifndef ENABLE_STANDALONE
2364+
if( len( fbc.target ) > 0 ) then
2365+
s += " (" + fbc.target + ")"
2366+
end if
2367+
#endif
2368+
print "target:", s
2369+
end sub
23772370

2371+
private sub fbcDetermineMainName( )
23782372
'' Determine the main module path/name if not given via -m
23792373
if (len(fbc.mainname) = 0) then
23802374
'' 1) First input .bas module
@@ -2400,7 +2394,6 @@ private sub fbcInit2( )
24002394
end if
24012395
fbc.mainname = hStripExt(fbc.mainname)
24022396
end if
2403-
24042397
end sub
24052398

24062399
'' Build the intermediate file name for the given module and step
@@ -3349,7 +3342,18 @@ end sub
33493342
fbcEnd( 1 )
33503343
end if
33513344

3352-
fbcInit2( )
3345+
fbcDeterminePrefix( )
3346+
fbcSetupCompilerPaths( )
3347+
3348+
if( fbc.verbose ) then
3349+
fbcPrintTargetInfo( )
3350+
end if
3351+
3352+
'' Tell the compiler about the default include path (added after
3353+
'' the command line ones, so those will be searched first)
3354+
fbAddIncludePath( fbc.incpath )
3355+
3356+
fbcDetermineMainName( )
33533357

33543358
'' Answer -print query, if any, and stop
33553359
'' The -print option is intended to allow shell scripts, makefiles, etc.

0 commit comments

Comments
 (0)