Debian Codegraph @

src/deprecated_library/fpc_path_detect.bat

raw
1 :: Auto-detect fpc.exe location
2 @echo off
3
4 :: Test if fpc is in %PATH%, return empty string
5 where /q fpc.exe
6 if not ERRORLEVEL 1 (
7 echo.
8 exit /B
9 )
10
11 setlocal
12
13 :: see if environment variable exists
14 if defined FPCDIR (
15 set FPC_MAIN=%FPCDIR%
16 ) else (
17 :: Check if standalone FPC installation exists
18 if exist c:\fpc (
19 set FPC_MAIN=c:\fpc
20 ) else (
21 :: See if is under Lazarus
22 if exist c:\lazarus\fpc (
23 set FPC_MAIN=c:\lazarus\fpc
24 ) else (
25 :: See if is under fpcupdeluxe
26 if exist c:\fpcupdeluxe\fpc set FPC_MAIN=c:\fpcupdeluxe\fpc
27 )
28 )
29 )
30
31 ::echo fpc main folder: %FPC_MAIN%
32
33 :: If FPC not found, let's just silently suppose it is in PATH as we have to return something
34 if not defined FPC_MAIN (
35 echo.
36 exit /B
37 )
38
39 if "%FPC_MAIN%" == "c:\fpcupdeluxe\fpc" (
40 :: fpcdeluxe doesn't use version subfolder
41 set FPC_VER_DIR=%FPC_MAIN%
42 ) else (
43 :: Find FPC version folder under fpc folder, e.g. c:\lazarus\fpc\3.0.2
44 for /d %%D in (%FPC_MAIN%\*.*) do set FPC_VER_DIR=%%D
45 )
46
47 ::echo fpc version folder: %FPC_VER_DIR%
48
49 :: Find installed FPC platform (win32 or win64), e.g. c:\lazarus\fpc\3.0.2\bin\x86_64-win64
50 for /d %%D in (%FPC_VER_DIR%\bin\*.*) do set FPC_EXE_DIR=%%D
51 if not defined FPC_EXE_DIR set FPC_EXE_DIR=%FPC_VER_DIR%\bin
52
53 :: Return path including the ending slash (to be able to pass empty string too when fpc.exe is in path)
54 echo %FPC_EXE_DIR%\