mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-305: reverse search order (dir, then PATH) for better compatibility
This commit is contained in:
parent
ba88bcaab9
commit
4d2095bc6f
@ -26,15 +26,24 @@ if not "x%DISPLAY%" == "x" set DISPLAY=
|
||||
|
||||
rem --------------------------------------------------------------------------
|
||||
rem To build the OpenPilot software we need few tools in the PATH.
|
||||
rem Here we attempt to guess tools location using PATH or set them
|
||||
rem directly using hard-coded locations, if not found in PATH.
|
||||
rem You may want to update paths according to your installation.
|
||||
rem Here we attempt to guess tools location searching in the given
|
||||
rem directories first, and in the PATH last, if not found where expected.
|
||||
rem
|
||||
rem Also you can add any paths below just by adding extra call :which
|
||||
rem Please note that if you have few similar tools installed somewhere but
|
||||
rem not in the expected location, and they are in the PATH, then the script
|
||||
rem can detect wrong directories. For instance, if you have QtSDK installed
|
||||
rem on the D: drive, but have separately installed MinGW toolkit which is
|
||||
rem in the PATH, then this script detects this MinGW instead of QtSDK's one.
|
||||
rem As a result, the SDL headers will not be found, if they were copied into
|
||||
rem QtSDK's MinGW directory. In that case make sure that you have correct
|
||||
rem directories specified here.
|
||||
rem
|
||||
rem Also you can add any paths below just by adding extra 'call :which'
|
||||
rem lines with the following parameters:
|
||||
rem - environment variable which will be set to the path found (or empty)
|
||||
rem - expected directory which will be tried if not found in the current PATH
|
||||
rem - any executable file which is expected to be found in PATH or directory
|
||||
rem - environment variable which will be set to the tool location, if found;
|
||||
rem - expected directory for the executable which will be searched first;
|
||||
rem - any executable file which will be searched in the given directory
|
||||
rem or in the PATH, if not found where expected.
|
||||
rem All they will be added to the PATH in order of appearance.
|
||||
rem --------------------------------------------------------------------------
|
||||
|
||||
@ -80,18 +89,18 @@ echo Cannot find bash, exiting with error
|
||||
exit 1
|
||||
|
||||
rem --------------------------------------------------------------------------
|
||||
rem Attempt to find executable in the PATH or at expected location.
|
||||
rem Attempt to find executable in the directory given or in the PATH
|
||||
rem --------------------------------------------------------------------------
|
||||
|
||||
:which
|
||||
rem search in the PATH first
|
||||
for %%F in (%3) do set FP=%%~$PATH:F
|
||||
if exist "%FP%" goto found_in_path
|
||||
|
||||
rem search at expected location last
|
||||
rem search in the directory given first
|
||||
for %%F in (%2) do set FP=%%~F\%3
|
||||
if exist "%FP%" goto found_directly
|
||||
|
||||
rem search in the PATH last
|
||||
for %%F in (%3) do set FP=%%~$PATH:F
|
||||
if exist "%FP%" goto found_in_path
|
||||
|
||||
:not_found
|
||||
for %%F in (%2) do set FP=%%~F
|
||||
rem echo %3: not found, expected in %FP%
|
||||
@ -99,14 +108,14 @@ set FP=
|
||||
set NOT_FOUND=%NOT_FOUND% %3
|
||||
goto set
|
||||
|
||||
:found_in_path
|
||||
for %%F in ("%FP%") do set FP=%%~dpsF
|
||||
rem echo %3: found in the PATH: %FP%
|
||||
goto set
|
||||
|
||||
:found_directly
|
||||
for %%F in ("%FP%") do set FP=%%~dpsF
|
||||
rem echo %3: found at: %FP%
|
||||
goto set
|
||||
|
||||
:found_in_path
|
||||
for %%F in ("%FP%") do set FP=%%~dpsF
|
||||
rem echo %3: found in the PATH: %FP%
|
||||
|
||||
:set
|
||||
rem set results regardless of was it found or not
|
||||
|
Loading…
x
Reference in New Issue
Block a user