VirtualBox

Changeset 1532 in kBuild


Ignore:
Timestamp:
Apr 20, 2008 2:33:00 AM (17 years ago)
Author:
bird
Message:

Revamped the script and did the environment variable change. It now sports most of the features found in the unix shell script (env.sh)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/envwin.cmd

    r1508 r1532  
    11@echo off
    2 REM # $Id: $
    3 REM ## @file
    4 REM #
    5 REM # Environment setup script.
    6 REM #
    7 REM # Copyright (c) 2005-2008 knut st. osmundsen <[email protected]>
    8 REM #
    9 REM #
    10 REM # This file is part of kBuild.
    11 REM #
    12 REM # kBuild is free software; you can redistribute it and/or modify
    13 REM # it under the terms of the GNU General Public License as published by
    14 REM # the Free Software Foundation; either version 2 of the License, or
    15 REM # (at your option) any later version.
    16 REM #
    17 REM # kBuild is distributed in the hope that it will be useful,
    18 REM # but WITHOUT ANY WARRANTY; without even the implied warranty of
    19 REM # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20 REM # GNU General Public License for more details.
    21 REM #
    22 REM # You should have received a copy of the GNU General Public License
    23 REM # along with kBuild; if not, write to the Free Software
    24 REM # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    25 REM #
    26 
    27 
    28 REM #
    29 REM # Deal with the arguments.
    30 REM #
    31 if ".%1" == ".-h"       goto help
    32 if ".%1" == "./h"       goto help
    33 if ".%1" == "./H"       goto help
    34 if ".%1" == ".-h"       goto help
    35 if ".%1" == ".-help"    goto help
    36 if ".%1" == ".--help"   goto help
    37 
    38 if ".%1" == ".-win"     goto want_win
    39 if ".%1" == ".-win32"   goto want_win32_bit
    40 if ".%1" == ".-win64"   goto want_win64_bit
    41 if ".%1" == ".-nt"      goto want_nt
    42 if ".%1" == ".-nt32"    goto want_nt32_bit
    43 if ".%1" == ".-nt64"    goto want_nt64_bit
     2REM $Id: $
     3REM REM @file
     4REM Environment setup script.
     5REM
     6
     7REM
     8REM Copyright (c) 2005-2008 knut st. osmundsen <[email protected]>
     9REM
     10REM This file is part of kBuild.
     11REM
     12REM kBuild is free software; you can redistribute it and/or modify
     13REM it under the terms of the GNU General Public License as published by
     14REM the Free Software Foundation; either version 2 of the License, or
     15REM (at your option) any later version.
     16REM
     17REM kBuild is distributed in the hope that it will be useful,
     18REM but WITHOUT ANY WARRANTY; without even the implied warranty of
     19REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20REM GNU General Public License for more details.
     21REM
     22REM You should have received a copy of the GNU General Public License
     23REM along with kBuild; if not, write to the Free Software
     24REM Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     25REM
     26
     27REM
     28REM Globals
     29REM
     30set _KBUILD_CURDIR=%CD%
     31for /f "tokens=*" %%d in ('cd') do set _KBUILD_CURDIR=%%d
     32
     33set _KBUILD_PATH=%KBUILD_PATH%
     34set _KBUILD_BIN_PATH=%KBUILD_BIN_PATH%
     35set _KBUILD_TYPE=%KBUILD_TYPE%
     36set _KBUILD_TARGET=%KBUILD_TARGET%
     37set _KBUILD_TARGET_ARCH=%KBUILD_TARGET_ARCH%
     38set _KBUILD_TARGET_CPU=%KBUILD_TARGET_CPU%
     39set _KBUILD_HOST=%KBUILD_HOST%
     40set _KBUILD_HOST_ARCH=%KBUILD_HOST_ARCH%
     41set _KBUILD_HOST_CPU=%KBUILD_HOST_CPU%
     42
     43set _KBUILD_OVERRIDE_TYPE=0
     44set _KBUILD_OVERRIDE_TARGET=0
     45set _KBUILD_OVERRIDE_TARGET_ARCH=0
     46
     47REM
     48REM Parse the arguments.
     49REM
     50REM Note: The 0 argument must be safed as it is also shifted.
     51REM
     52set _KBUILD_SELF=%0
     53set _KBUILD_OPT_FULL=0
     54set _KBUILD_OPT_LEGACY=0
     55set _KBUILD_OPT_VAR=
     56set _KBUILD_OPT_VALUE_ONLY=0
     57set _KBUILD_SHOW_VAR_PREFIX=
     58set _KBUILD_OPT_DBG=1
     59set _KBUILD_OPT_OVERRIDE_ALL=0
     60
     61:argument_loop
     62if ".%1" == ".-h"           goto do_help
     63if ".%1" == "./h"           goto do_help
     64if ".%1" == "./H"           goto do_help
     65if ".%1" == ".-h"           goto do_help
     66if ".%1" == ".-help"        goto do_help
     67if ".%1" == ".--help"       goto do_help
     68
     69if ".%1" == ".--win"        goto want_win
     70if ".%1" == ".-win"         goto want_win
     71if ".%1" == ".--win32"      goto want_win32_bit
     72if ".%1" == ".-win32"       goto want_win32_bit
     73if ".%1" == ".-win64"       goto want_win64_bit
     74if ".%1" == ".--win64"      goto want_win64_bit
     75if ".%1" == ".--nt"         goto want_nt
     76if ".%1" == ".-nt"          goto want_nt
     77if ".%1" == ".--nt32"       goto want_nt32_bit
     78if ".%1" == ".-nt32"        goto want_nt32_bit
     79if ".%1" == ".--nt64"       goto want_nt64_bit
     80if ".%1" == ".-nt64"        goto want_nt64_bit
     81
     82if ".%1" == ".--release"    goto want_release
     83if ".%1" == ".--profile"    goto want_profile
     84if ".%1" == ".--debug"      goto want_debug
     85
     86if ".%1" == ".--full"               goto opt_full
     87if ".%1" == ".--normal"             goto opt_normal
     88if ".%1" == ".--legacy"             goto opt_legacy
     89if ".%1" == ".--no-legacy"          goto opt_no_legacy
     90if ".%1" == ".--debug-script"       goto opt_debug_script
     91if ".%1" == ".--no-debug-script"    goto opt_no_debug_script
     92if ".%1" == ".--var"                goto opt_var
     93if ".%1" == ".--value-only"         goto opt_value_only
     94if ".%1" == ".--name-and-value"     goto opt_name_and_value
     95if ".%1" == ".--set"                goto opt_set
     96if ".%1" == ".--no-set"             goto opt_no_set
     97
    4498goto done_arguments
     99
     100:want_win
     101shift
     102set _KBUILD_TARGET=win
     103set _KBUILD_OVERRIDE_TARGET=1
     104goto argument_loop
     105
     106:want_win32_bit
     107shift
     108set _KBUILD_TARGET=win
     109set _KBUILD_TARGET_ARCH=x86
     110set _KBUILD_OVERRIDE_TARGET=1
     111set _KBUILD_OVERRIDE_TARGET_ARCH=1
     112goto argument_loop
     113
     114:want_win64_bit
     115shift
     116set _KBUILD_TARGET=win
     117set _KBUILD_TARGET_ARCH=amd64
     118set _KBUILD_OVERRIDE_TARGET=1
     119set _KBUILD_OVERRIDE_TARGET_ARCH=1
     120goto argument_loop
     121
     122:want_nt
     123shift
     124set _KBUILD_TARGET=nt
     125set _KBUILD_OVERRIDE_TARGET=1
     126goto argument_loop
     127
     128:want_nt32_bit
     129shift
     130set _KBUILD_TARGET=nt
     131set _KBUILD_TARGET_ARCH=x86
     132set _KBUILD_OVERRIDE_TARGET=1
     133set _KBUILD_OVERRIDE_TARGET_ARCH=1
     134goto argument_loop
     135
     136:want_nt64_bit
     137shift
     138set _KBUILD_TARGET=nt
     139set _KBUILD_TARGET_ARCH=amd64
     140set _KBUILD_OVERRIDE_TARGET=1
     141set _KBUILD_OVERRIDE_TARGET_ARCH=1
     142goto argument_loop
     143
     144:want_release
     145shift
     146set _KBUILD_TYPE=release
     147set _KBUILD_OVERRIDE_TYPE=1
     148goto argument_loop
     149
     150:want_profile
     151shift
     152set _KBUILD_TYPE=profile
     153set _KBUILD_OVERRIDE_TYPE=1
     154goto argument_loop
     155
     156:want_debug
     157shift
     158set _KBUILD_TYPE=debug
     159set _KBUILD_OVERRIDE_TYPE=1
     160goto argument_loop
     161
     162:opt_full
     163shift
     164set _KBUILD_OPT_FULL=1
     165goto argument_loop
     166
     167:opt_normal
     168shift
     169set _KBUILD_OPT_FULL=0
     170goto argument_loop
     171
     172:opt_legacy
     173shift
     174set _KBUILD_OPT_LEGACY=1
     175goto argument_loop
     176
     177:opt_no_legacy
     178shift
     179set _KBUILD_OPT_LEGACY=0
     180goto argument_loop
     181
     182:opt_debug_script
     183shift
     184set _KBUILD_OPT_DBG=1
     185goto argument_loop
     186
     187:opt_no_debug_script
     188shift
     189set _KBUILD_OPT_DBG=0
     190goto argument_loop
     191
     192:opt_var
     193shift
     194if ".%1" == "." echo syntax error: --var is missing it's variable name.
     195if ".%1" == "." goto failure
     196set _KBUILD_OPT_VAR=%_KBUILD_OPT_VAR% %1
     197shift
     198goto argument_loop
     199
     200:opt_value_only
     201shift
     202set _KBUILD_OPT_VALUE_ONLY=1
     203goto argument_loop
     204
     205:opt_name_and_value
     206shift
     207set _KBUILD_OPT_VALUE_ONLY=0
     208goto argument_loop
     209
     210:opt_set
     211shift
     212set _KBUILD_SHOW_VAR_PREFIX=SET %_KBUILD_NON_EXISTING_VAR%
     213goto argument_loop
     214
     215:opt_no_set
     216shift
     217set _KBUILD_SHOW_VAR_PREFIX=
     218goto argument_loop
     219
    45220
    46221REM #
    47222REM # Syntax
    48223REM #
    49 :help
     224:do_help
    50225echo kBuild environment setup script for Windows NT.
    51 echo Syntax: envwin.cmd [-win, -win32, -win64, -nt, -nt32 or -nt64] [command to be executed]
     226echo Syntax: envwin.cmd [options] [command to be executed]
     227echo     or: envwin.cmd [options] --var varname
     228echo .
     229echo Options:
     230echo   --win
     231echo       Force windows target and host platform.
     232echo   --win32
     233echo       Force x86 32-bit windows target platform.
     234echo   --win64
     235echo       Force AMD64 64-bit windows target platform.
     236echo   --nt
     237echo       Force NT target and host platform.
     238echo   --win32
     239echo       Force x86 32-bit NT target platform.
     240echo   --win64
     241echo       Force AMD64 64-bit NT target platform.
     242echo   --debug, --release, --profile
     243echo       Alternative way of specifying KBUILD_TYPE.
     244echo   --full, --normal
     245echo       Controls the variable set. Default: --normal
     246echo   --legacy, --no-legacy
     247echo       Include legacy variables in result. Default: --legacy
     248echo   --value-only, --name-and-value
     249echo       Controls what the result of a --var query. Default: --name-and-value
     250echo   --set, --no-set
     251echo       Whether to prefix the variable output with 'SET' or not.
     252echo       Default: --no-set
     253
    52254goto end
    53255
    54 
    55 :want_win
    56 shift
    57 set BUILD_TARGET=win
    58 set BUILD_PLATFORM=win
    59 goto done_arguments
    60 
    61 :want_win32_bit
    62 shift
    63 set BUILD_PLATFORM=win
    64 set BUILD_TARGET=win
    65 set BUILD_TARGET_ARCH=x86
    66 goto done_arguments
    67 
    68 :want_win64_bit
    69 shift
    70 set BUILD_TARGET=win
    71 set BUILD_TARGET_ARCH=amd64
    72 goto done_arguments
    73 
    74 :want_nt
    75 shift
    76 set BUILD_PLATFORM=nt
    77 set BUILD_TARGET=nt
    78 goto done_arguments
    79 
    80 :want_nt32_bit
    81 shift
    82 set BUILD_PLATFORM=nt
    83 set BUILD_TARGET=nt
    84 set BUILD_TARGET_ARCH=x86
    85 goto done_arguments
    86 
    87 :want_nt64_bit
    88 shift
    89 set BUILD_PLATFORM=nt
    90 set BUILD_TARGET=nt
    91 set BUILD_TARGET_ARCH=amd64
    92 goto done_arguments
    93 
    94256:done_arguments
    95257
    96 
    97 REM #
    98 REM # Check for illegal target/platforms.
    99 REM #
    100 if "%BUILD_TARGET" == "win32" goto illegal_target
    101 if "%BUILD_TARGET" == "win64" goto illegal_target
    102 
    103 if "%BUILD_PLATFORM" == "win32" goto illegal_platform
    104 if "%BUILD_PLATFORM" == "win64" goto illegal_platform
     258REM
     259REM Convert legacy variable names.
     260REM
     261if ".%_KBUILD_OPT_OVERRIDE_ALL%" == ".1" goto legacy_convertion_done
     262
     263set _KBUILD_VARS=KBUILD_HOST (%_KBUILD_HOST%) and BUILD_PLATFORM (%BUILD_PLATFORM%)
     264if not ".%BUILD_PLATFORM%" == "." if not ".%_KBUILD_HOST%" == "." if ".%_KBUILD_HOST%" == ".%BUILD_PLATFORM%" goto legacy_mismatch
     265if not ".%BUILD_PLATFORM%" == "." set _KBUILD_HOST=%BUILD_PLATFORM%
     266
     267set _KBUILD_VARS=KBUILD_HOST_ARCH (%_KBUILD_HOST_ARCH%) and BUILD_PLATFORM_ARCH (%BUILD_PLATFORM_ARCH%)
     268if not ".%BUILD_PLATFORM_ARCH%" == "." if not ".%_KBUILD_HOST_ARCH%" == "." if ".%_KBUILD_HOST_ARCH%" == ".%BUILD_PLATFORM_ARCH%" goto legacy_mismatch
     269if not ".%BUILD_PLATFORM_ARCH%" == "." set _KBUILD_HOST_ARCH=%BUILD_PLATFORM_ARCH%
     270
     271set _KBUILD_VARS=KBUILD_HOST_CPU (%_KBUILD_HOST_CPU%) and BUILD_PLATFORM_CPU (%BUILD_PLATFORM_CPU%)
     272if not ".%BUILD_PLATFORM_CPU%" == "." if not ".%_KBUILD_HOST_CPU%" == "." if ".%_KBUILD_HOST_CPU%" == ".%BUILD_PLATFORM_CPU%" goto legacy_mismatch
     273if not ".%BUILD_PLATFORM_CPU%" == "." set _KBUILD_HOST_CPU=%BUILD_PLATFORM_CPU%
     274
     275if ".%_KBUILD_OVERRIDE_TARGET%" == ".1" goto legacy_skip_target
     276set _KBUILD_VARS=KBUILD_TARGET (%_KBUILD_TARGET%) and BUILD_TARGET (%BUILD_TARGET%)
     277if not ".%BUILD_TARGET%" == "." if not ".%_KBUILD_TARGET%" == "." if ".%_KBUILD_TARGET%" == ".%BUILD_TARGET%" goto legacy_mismatch
     278if not ".%BUILD_TARGET%" == "." set _KBUILD_TARGET=%BUILD_TARGET%
     279:convert_skip_target
     280
     281if ".%_KBUILD_OVERRIDE_TARGET%" == ".1" goto legacy_skip_target_arch
     282set _KBUILD_VARS=KBUILD_TARGET_ARCH (%_KBUILD_TARGET_ARCH%) and BUILD_TARGET_ARCH (%BUILD_TARGET_ARCH%)
     283if not ".%BUILD_TARGET_ARCH%" == "." if not ".%_KBUILD_TARGET_ARCH%" == "." if ".%_KBUILD_TARGET_ARCH%" == ".%BUILD_TARGET_ARCH%" goto legacy_mismatch
     284if not ".%BUILD_TARGET_ARCH%" == "." set _KBUILD_TARGET_ARCH=%BUILD_TARGET_ARCH%
     285:legacy_skip_target_arch
     286
     287if ".%_KBUILD_OVERRIDE_TARGET%" == ".1" goto legacy_skip_target_cpu
     288set _KBUILD_VARS=KBUILD_TARGET_CPU (%_KBUILD_TARGET_CPU%) and BUILD_TARGET_CPU (%BUILD_TARGET_CPU%)
     289if not ".%BUILD_TARGET_CPU%" == "." if not ".%_KBUILD_TARGET_CPU%" == "." if ".%_KBUILD_TARGET_CPU%" == ".%BUILD_TARGET_CPU%" goto legacy_mismatch
     290if not ".%BUILD_TARGET_CPU%" == "." set _KBUILD_TARGET_CPU=%BUILD_TARGET_CPU%
     291:legacy_skip_target_cpu
     292
     293if ".%_KBUILD_OVERRIDE_TARGET%" == ".1" goto legacy_skip_type
     294set _KBUILD_VARS=KBUILD_TYPE (%_KBUILD_TYPE%) and BUILD_TYPE (%BUILD_TYPE%)
     295if not ".%BUILD_TYPE%" == "." if not ".%_KBUILD_TYPE%" == "." if ".%_KBUILD_TYPE%" == ".%BUILD_TYPE%" goto legacy_mismatch
     296if not ".%BUILD_TYPE%" == "." set _KBUILD_TYPE=%BUILD_TYPE%
     297:legacy_skip_type
     298
     299set _KBUILD_VARS=KBUILD_PATH (%_KBUILD_PATH%) and PATH_KBUILD (%PATH_KBUILD%)
     300if not ".%PATH_KBUILD%" == "." if not ".%_KBUILD_PATH%" == "." if ".%_KBUILD_PATH%" == ".%PATH_KBUILD%" goto legacy_mismatch
     301if not ".%PATH_KBUILD%" == "." set _KBUILD_PATH=%PATH_KBUILD%
     302goto legacy_convertion_done
     303
     304:legacy_mismatch
     305echo error: %_KBUILD_VARS% disagree.
     306goto failed
     307
     308:legacy_convertion_done
     309
     310
     311REM
     312REM Check for illegal target/platforms.
     313REM
     314:target_and_platform
     315if "%_KBUILD_TARGET" == "win32"  goto illegal_target
     316if "%_KBUILD_TARGET" == "win64"  goto illegal_target
     317if "%_KBUILD_HOST"   == "win32"  goto illegal_host
     318if "%_KBUILD_HOST"   == "win64"  goto illegal_host
    105319goto target_and_platform_ok
    106320
    107321:illegal_target
    108 echo error: BUILD_TARGET=%BUILD_TARGET is no longer valid.
     322echo error: KBUILD_TARGET=%KBUILD_TARGET% is no longer valid.
    109323echo        Only 'win' and 'nt' are permitted for targeting microsoft windows.
    110324goto failed
    111325
    112 :illegal_platform
    113 echo error: BUILD_PLATFORM=%BUILD_PLATFORM is no longer valid.
     326:illegal_host
     327echo error: KBUILD_HOST=%KBUILD_HOST is no longer valid.
    114328echo        Only 'win' and 'nt' are permitted for building on microsoft windows.
    115329goto failed
     
    117331:target_and_platform_ok
    118332
    119 
    120 REM #
    121 REM # figure the current directory.
    122 REM #
    123 for /f "tokens=*" %%d in ('cd') do set CURDIR=%%d
    124 
    125 REM #
    126 REM # find kBuild.
    127 REM #
    128 if exist %PATH_KBUILD%\footer.kmk       goto found_kbuild
    129 set PATH_KBUILD=%CURDIR
    130 if exist %PATH_KBUILD%\footer.kmk       goto found_kbuild
    131 set PATH_KBUILD=%CURDIR\kBuild
    132 if exist %PATH_KBUILD%\footer.kmk       goto found_kbuild
    133 set PATH_KBUILD=%CURDIR\..\kBuild
    134 if exist %PATH_KBUILD%\footer.kmk       goto found_kbuild
    135 set PATH_KBUILD=%CURDIR\..\..\kBuild
    136 if exist %PATH_KBUILD%\footer.kmk       goto found_kbuild
    137 set PATH_KBUILD=%CURDIR\..\..\..\kBuild
    138 if exist %PATH_KBUILD%\footer.kmk       goto found_kbuild
    139 set PATH_KBUILD=%CURDIR\..\..\..\..\kBuild
    140 if exist %PATH_KBUILD%\footer.kmk       goto found_kbuild
     333REM
     334REM Find kBuild.
     335REM
     336REM We'll try determin the location of this script first and use that
     337REM as a starting point for guessing the kBuild directory.
     338REM
     339
     340REM Check if set via KBUILD_PATH.
     341if not ".%_KBUILD_PATH%" == "."  if exist %_KBUILD_PATH%\footer.kmk goto found_kbuild
     342
     343REM Determin a correct self - by %0
     344if exist "%_KBUILD_SELF%" goto found_self
     345set _KBUILD_SELF=%_KBUILD_SELF%.cmd
     346if exist "%_KBUILD_SELF%" goto found_self
     347
     348REM Determin a correct self - by the PATH
     349REM This is very verbose because nested for loops didn't work out.
     350for /f "tokens=1  delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     351if exist "%_KBUILD_SELF%" goto found_self
     352for /f "tokens=2  delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     353if exist "%_KBUILD_SELF%" goto found_self
     354for /f "tokens=3  delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     355if exist "%_KBUILD_SELF%" goto found_self
     356for /f "tokens=4  delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     357if exist "%_KBUILD_SELF%" goto found_self
     358for /f "tokens=5  delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     359if exist "%_KBUILD_SELF%" goto found_self
     360for /f "tokens=6  delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     361if exist "%_KBUILD_SELF%" goto found_self
     362for /f "tokens=7  delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     363if exist "%_KBUILD_SELF%" goto found_self
     364for /f "tokens=8  delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     365if exist "%_KBUILD_SELF%" goto found_self
     366for /f "tokens=9  delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     367if exist "%_KBUILD_SELF%" goto found_self
     368for /f "tokens=10 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     369if exist "%_KBUILD_SELF%" goto found_self
     370for /f "tokens=11 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     371if exist "%_KBUILD_SELF%" goto found_self
     372for /f "tokens=12 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     373if exist "%_KBUILD_SELF%" goto found_self
     374for /f "tokens=13 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     375if exist "%_KBUILD_SELF%" goto found_self
     376for /f "tokens=14 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     377if exist "%_KBUILD_SELF%" goto found_self
     378for /f "tokens=15 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     379if exist "%_KBUILD_SELF%" goto found_self
     380for /f "tokens=16 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     381if exist "%_KBUILD_SELF%" goto found_self
     382for /f "tokens=17 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     383if exist "%_KBUILD_SELF%" goto found_self
     384for /f "tokens=18 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     385if exist "%_KBUILD_SELF%" goto found_self
     386for /f "tokens=19 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     387if exist "%_KBUILD_SELF%" goto found_self
     388for /f "tokens=20 delims=;" %%d in ("%PATH%") do set _KBUILD_SELF=%%d\envwin.cmd
     389if exist "%_KBUILD_SELF%" goto found_self
     390goto try_by_pwd
     391
     392:found_self
     393cd "%_KBUILD_SELF%\.."
     394for /f "tokens=*" %%d in ('cd') do set _KBUILD_PATH=%%d
     395cd "%_KBUILD_CURDIR%"
     396if exist "%_KBUILD_PATH%\footer.kmk"      goto found_kbuild
     397
     398REM Try relative to the current directory.
     399:try_by_pwd
     400if exist "%_KBUILD_PATH%\footer.kmk"    goto found_kbuild
     401set _KBUILD_PATH=%_KBUILD_CURDIR%
     402if exist "%_KBUILD_PATH%\footer.kmk"    goto found_kbuild
     403set _KBUILD_PATH=%_KBUILD_CURDIR%\kBuild
     404if exist "%_KBUILD_PATH%\footer.kmk"    goto found_kbuild
     405set _KBUILD_PATH=%_KBUILD_CURDIR%\..\kBuild
     406if exist "%_KBUILD_PATH%\footer.kmk"    goto found_kbuild
     407set _KBUILD_PATH=%_KBUILD_CURDIR%\..\..\kBuild
     408if exist "%_KBUILD_PATH%\footer.kmk"    goto found_kbuild
     409set _KBUILD_PATH=%_KBUILD_CURDIR%\..\..\..\kBuild
     410if exist "%_KBUILD_PATH%\footer.kmk"    goto found_kbuild
     411set _KBUILD_PATH=%_KBUILD_CURDIR%\..\..\..\..\kBuild
     412if exist "%_KBUILD_PATH%\footer.kmk"    goto found_kbuild
    141413echo kBuild: Can't find the kBuild directory!
    142414set CURDIR=
     
    144416
    145417:found_kbuild
    146 echo dbg: PATH_KBUILD=%PATH_KBUILD%
    147 set CURDIR=
    148 
    149 REM #
    150 REM # Type.
    151 REM #
    152 IF NOT ".%BUILD_TYPE%" == "."           goto have_BUILD_TYPE
    153 set BUILD_TYPE=release
    154 :have_BUILD_TYPE
    155 echo dbg: BUILD_TYPE=%BUILD_TYPE%
    156 
    157 
    158 REM #
    159 REM # Host platform.
    160 REM #
    161 IF NOT ".%BUILD_PLATFORM%" == "."       goto have_2_BUILD_PLATFORM
    162 set BUILD_PLATFORM=win
    163 echo dbg: BUILD_PLATFORM=%BUILD_PLATFORM%
    164 
    165 IF NOT ".%BUILD_PLATFORM_ARCH%" == "."  goto have_BUILD_PLATFORM_ARCH
    166 set TEST_PROCESSOR_ARCH=%PROCESSOR_ARCHITECTURE%
    167 IF NOT ".%PROCESSOR_ARCHITEW6432%" == "." set TEST_PROCESSOR_ARCH=%PROCESSOR_ARCHITEW6432%
    168 IF "%TEST_PROCESSOR_ARCH%" == "x86"     set BUILD_PLATFORM_ARCH=x86
    169 IF "%TEST_PROCESSOR_ARCH%" == "X86"     set BUILD_PLATFORM_ARCH=x86
    170 IF "%TEST_PROCESSOR_ARCH%" == "AMD64"   set BUILD_PLATFORM_ARCH=amd64
    171 IF "%TEST_PROCESSOR_ARCH%" == "x64"     set BUILD_PLATFORM_ARCH=amd64
    172 IF "%TEST_PROCESSOR_ARCH%" == "X64"     set BUILD_PLATFORM_ARCH=amd64
    173 IF NOT ".%BUILD_PLATFORM_ARCH%" == "."  goto have_BUILD_PLATFORM_ARCH
    174 set TEST_PROCESSOR_ARCH=
    175 echo kBuild: Cannot figure BUILD_PLATFORM_ARCH!
     418cd "%_KBUILD_PATH%"
     419for /f "tokens=*" %%d in ('cd') do set _KBUILD_PATH=%%d
     420cd "%_KBUILD_CURDIR%"
     421if ".%_KBUILD_OPT_DBG%" == ".1" echo dbg: _KBUILD_PATH=%_KBUILD_PATH%
     422
     423
     424REM
     425REM Type - release is the default.
     426REM
     427if not ".%_KBUILD_TYPE%" == "."         goto have_type
     428set _KBUILD_TYPE=release
     429:have_type
     430if ".%_KBUILD_OPT_DBG%" == ".1"         echo dbg: _KBUILD_TYPE=%_KBUILD_TYPE%
     431
     432
     433REM
     434REM Host platform - windows
     435REM
     436if not ".%_KBUILD_HOST%" == "."         goto have_host
     437set _KBUILD_HOST=win
     438if ".%_KBUILD_OPT_DBG%" == ".1"         echo dbg: _KBUILD_HOST=%_KBUILD_HOST%
     439:have_host
     440
     441if not ".%_KBUILD_HOST_ARCH%" == "."    goto have_host_arch
     442REM try guess from _KBUILD_HOST_CPU
     443if ".%KBUILD_HOST_CPU%" == ".i386"      set _KBUILD_HOST_ARCH=x86
     444if ".%KBUILD_HOST_CPU%" == ".i486"      set _KBUILD_HOST_ARCH=x86
     445if ".%KBUILD_HOST_CPU%" == ".i586"      set _KBUILD_HOST_ARCH=x86
     446if ".%KBUILD_HOST_CPU%" == ".i686"      set _KBUILD_HOST_ARCH=x86
     447if ".%KBUILD_HOST_CPU%" == ".i786"      set _KBUILD_HOST_ARCH=x86
     448if ".%KBUILD_HOST_CPU%" == ".i886"      set _KBUILD_HOST_ARCH=x86
     449if ".%KBUILD_HOST_CPU%" == ".i986"      set _KBUILD_HOST_ARCH=x86
     450if ".%KBUILD_HOST_CPU%" == ".k8"        set _KBUILD_HOST_ARCH=amd64
     451if ".%KBUILD_HOST_CPU%" == ".k9"        set _KBUILD_HOST_ARCH=amd64
     452if ".%KBUILD_HOST_CPU%" == ".k10"       set _KBUILD_HOST_ARCH=amd64
     453if not ".%_KBUILD_HOST_ARCH%" == "."    goto have_host_arch
     454REM try guess from PROCESSOR_ARCHITEW6432 and PROCESSOR_ARCHITECTURE
     455set _KBUILD_TMP=%PROCESSOR_ARCHITECTURE%
     456if not ".%PROCESSOR_ARCHITEW6432%" == "." set _KBUILD_TMP=%PROCESSOR_ARCHITEW6432%
     457if "%_KBUILD_TMP%" == "x86"             set _KBUILD_HOST_ARCH=x86
     458if "%_KBUILD_TMP%" == "X86"             set _KBUILD_HOST_ARCH=x86
     459if "%_KBUILD_TMP%" == "amd64"           set _KBUILD_HOST_ARCH=amd64
     460if "%_KBUILD_TMP%" == "Amd64"           set _KBUILD_HOST_ARCH=amd64
     461if "%_KBUILD_TMP%" == "AMD64"           set _KBUILD_HOST_ARCH=amd64
     462if "%_KBUILD_TMP%" == "x64"             set _KBUILD_HOST_ARCH=amd64
     463if "%_KBUILD_TMP%" == "X64"             set _KBUILD_HOST_ARCH=amd64
     464if not ".%_KBUILD_HOST_ARCH%" == "."    goto have_host_arch
     465echo error: Cannot figure KBUILD_HOST_ARCH!
    176466goto failed
    177 :have_BUILD_PLATFORM_ARCH
    178 echo dbg: BUILD_PLATFORM_ARCH=%BUILD_PLATFORM_ARCH%
    179 set TEST_PROCESSOR_ARCH=
    180 
    181 IF NOT ".%BUILD_PLATFORM_CPU%" == "."   goto have_BUILD_PLATFORM_CPU
    182 set BUILD_PLATFORM_CPU=blend
    183 IF NOT ".%BUILD_PLATFORM_CPU%" == "."   goto have_BUILD_PLATFORM_CPU
    184 echo kBuild: Cannot figure BUILD_PLATFORM_CPU!
     467:have_host_arch
     468if ".%_KBUILD_OPT_DBG%" == ".1"         echo dbg: _KBUILD_HOST_ARCH=%_KBUILD_HOST_ARCH%
     469
     470if not ".%_KBUILD_HOST_CPU%" == "."     goto have_host_cpu
     471set _KBUILD_HOST_CPU=blend
     472:have_host_cpu
     473if ".%_KBUILD_OPT_DBG%" == ".1"         echo dbg: _KBUILD_HOST_CPU=%_KBUILD_HOST_CPU%
     474
     475REM
     476REM The target platform.
     477REM Defaults to the host when not specified.
     478REM
     479if not ".%_KBUILD_TARGET%" == "."       goto have_target
     480set _KBUILD_TARGET=%_KBUILD_HOST%
     481:have_target
     482if ".%_KBUILD_OPT_DBG%" == ".1"         echo dbg: _KBUILD_TARGET=%_KBUILD_TARGET%
     483
     484if not ".%_KBUILD_TARGET_ARCH%" == "."  goto have_target_arch
     485set _KBUILD_TARGET_ARCH=%_KBUILD_HOST_ARCH%
     486:have_target_arch
     487if ".%_KBUILD_OPT_DBG%" == ".1"         echo dbg: _KBUILD_TARGET_ARCH=%_KBUILD_TARGET_ARCH%
     488
     489if not ".%_KBUILD_TARGET_CPU%" == "."  goto have_target_cpu
     490if ".%_KBUILD_TARGET_ARCH%" == ".%_KBUILD_HOST_ARCH%" set _KBUILD_TARGET_CPU=%_KBUILD_HOST_CPU%
     491if not ".%_KBUILD_TARGET_CPU%" == "."  goto have_target_cpu
     492set _KBUILD_TARGET_CPU=%_KBUILD_HOST_CPU%
     493:have_target_cpu
     494if ".%_KBUILD_OPT_DBG%" == ".1"         echo dbg: _KBUILD_TARGET_CPU=%_KBUILD_TARGET_CPU%
     495
     496REM
     497REM Calc KBUILD_BIN_PATH and the new PATH value.
     498REM
     499if not ".%_KBUILD_BIN_PATH%" == "."     goto have_kbuild_bin_path
     500set _KBUILD_BIN_PATH=%_KBUILD_PATH%\bin\win.%_KBUILD_HOST_ARCH%
     501:have_kbuild_bin_path
     502if ".%_KBUILD_OPT_DBG%" == ".1"         echo dbg: _KBUILD_BIN_PATH=%_KBUILD_BIN_PATH%
     503
     504set _KBUILD_NEW_PATH=%_KBUILD_BIN_PATH%;%PATH%
     505if ".%_KBUILD_OPT_DBG%" == ".1"         echo dbg: _KBUILD_NEW_PATH=%_KBUILD_NEW_PATH%
     506
     507REM
     508REM Sanity check.
     509REM
     510rem echo ON
     511if not exist "%_KBUILD_BIN_PATH%" goto missing_bin_path
     512if not exist "%_KBUILD_BIN_PATH%" goto done_chekcing_for_tools
     513set _KBUILD_TMP=kmk kDepPre kDepIDB kmk_append kmk_ash kmk_cat kmk_cp kmk_echo kmk_install kmk_ln kmk_mkdir kmk_mv kmk_rm kmk_rmdir kmk_sed
     514for %%i in ( %_KBUILD_TMP% ) do if not exist "%_KBUILD_BIN_PATH%\%%i.exe" echo warning: The %%i program doesn't exist for this platform. (%_KBUILD_BIN_PATH%\%%i.exe)"
     515goto done_chekcing_for_tools
     516
     517:missing_bin_path
     518echo warning: The bin directory for this platform doesn't exist. (%_KBUILD_BIN_PATH%)
     519:done_chekcing_for_tools
     520
     521REM
     522REM The environment is in place, now take the requested action.
     523REM
     524if ".%_KBUILD_OPT_VAR%" == "." goto exec_or_setup_env
     525rem goto show_variable
     526
     527REM
     528REM Show a set of variables.
     529REM
     530REM Note: 4nt doesn't grok the setlocal delayed expansion option.
     531REM       So, we'll have to identify which shell we're running.
     532REM
     533:show_variable
     534for %%i in ( %_KBUILD_OPT_VAR% ) do if "%%i" == "all" goto show_all_variables
     535
     536if not ".%_4VER%" == "." goto 4nt
     537setlocal ENABLEDELAYEDEXPANSION
     538if errorlevel 1 goto no_delay_expansion
     539
     540for %%i in ( %_KBUILD_OPT_VAR% ) do (
     541    set _KBUILD_VAR=%%i
     542    set _KBUILD_TMP=
     543    if "%%i" == "KBUILD_PATH"         set _KBUILD_TMP=%_KBUILD_PATH%
     544    if "%%i" == "KBUILD_BIN_PATH"     set _KBUILD_TMP=%_KBUILD_BIN_PATH%
     545    if "%%i" == "KBUILD_TYPE"         set _KBUILD_TMP=%_KBUILD_TYPE%
     546    if "%%i" == "KBUILD_HOST"         set _KBUILD_TMP=%_KBUILD_HOST%
     547    if "%%i" == "KBUILD_HOST_ARCH"    set _KBUILD_TMP=%_KBUILD_HOST_ARCH%
     548    if "%%i" == "KBUILD_HOST_CPU"     set _KBUILD_TMP=%_KBUILD_HOST_CPU%
     549    if "%%i" == "KBUILD_TARGET"       set _KBUILD_TMP=%_KBUILD_TARGET%
     550    if "%%i" == "KBUILD_TARGET_ARCH"  set _KBUILD_TMP=%_KBUILD_TARGET_ARCH%
     551    if "%%i" == "KBUILD_TARGET_CPU"   set _KBUILD_TMP=%_KBUILD_TARGET_CPU%
     552    if ".!_KBUILD_TMP!" == "."                      goto varible_not_found
     553    if not ".%_KBUILD_OPT_VALUE_ONLY%" == ".1"      echo %_KBUILD_SHOW_VAR_PREFIX%%%i=!_KBUILD_TMP!
     554    if ".%_KBUILD_OPT_VALUE_ONLY%" == ".1"          echo !_KBUILD_TMP!
     555)
     556
     557endlocal
     558
     559echo off
     560exit /b 0
     561goto end
     562
     563:no_delay_expansion
     564echo error: Unable to enable delayed expansion in the shell.
     565
     566:4nt
     567for %%i in ( %_KBUILD_OPT_VAR% ) do (
     568    set _KBUILD_VAR=%%i
     569    set _KBUILD_TMP=
     570    if "%%i" == "KBUILD_PATH"         set _KBUILD_TMP=%_KBUILD_PATH%
     571    if "%%i" == "KBUILD_BIN_PATH"     set _KBUILD_TMP=%_KBUILD_BIN_PATH%
     572    if "%%i" == "KBUILD_TYPE"         set _KBUILD_TMP=%_KBUILD_TYPE%
     573    if "%%i" == "KBUILD_HOST"         set _KBUILD_TMP=%_KBUILD_HOST%
     574    if "%%i" == "KBUILD_HOST_ARCH"    set _KBUILD_TMP=%_KBUILD_HOST_ARCH%
     575    if "%%i" == "KBUILD_HOST_CPU"     set _KBUILD_TMP=%_KBUILD_HOST_CPU%
     576    if "%%i" == "KBUILD_TARGET"       set _KBUILD_TMP=%_KBUILD_TARGET%
     577    if "%%i" == "KBUILD_TARGET_ARCH"  set _KBUILD_TMP=%_KBUILD_TARGET_ARCH%
     578    if "%%i" == "KBUILD_TARGET_CPU"   set _KBUILD_TMP=%_KBUILD_TARGET_CPU%
     579    if ".%_KBUILD_TMP%" == "."                      goto varible_not_found
     580    if not ".%_KBUILD_OPT_VALUE_ONLY%" == ".1"      echo %_KBUILD_SHOW_VAR_PREFIX%%i=%_KBUILD_TMP%
     581    if ".%_KBUILD_OPT_VALUE_ONLY%" == ".1"          echo %_KBUILD_TMP%
     582)
     583goto end
     584
     585:varible_not_found
     586echo error: Unknown variable %_KBUILD_VAR% specified in --var request.
    185587goto failed
    186 :have_BUILD_PLATFORM_CPU
    187 echo dbg: BUILD_PLATFORM_CPU=%BUILD_PLATFORM_CPU%
    188 goto process_BUILD_TARGET
    189 
    190 
    191 :have_2_BUILD_PLATFORM
    192 echo dbg: BUILD_PLATFORM=%BUILD_PLATFORM%
    193 IF NOT ".%BUILD_PLATFORM_ARCH%" == "."  goto have_2_BUILD_PLATFORM_ARCH
    194 set TEST_PROCESSOR_ARCH=%PROCESSOR_ARCHITECTURE%
    195 IF NOT ".%PROCESSOR_ARCHITEW6432%" == "." set TEST_PROCESSOR_ARCH=%PROCESSOR_ARCHITEW6432%
    196 IF "%TEST_PROCESSOR_ARCH%" == "x86"     set BUILD_PLATFORM_ARCH=x86
    197 IF "%TEST_PROCESSOR_ARCH%" == "X86"     set BUILD_PLATFORM_ARCH=x86
    198 IF "%TEST_PROCESSOR_ARCH%" == "AMD64"   set BUILD_PLATFORM_ARCH=amd64
    199 IF "%TEST_PROCESSOR_ARCH%" == "x64"     set BUILD_PLATFORM_ARCH=amd64
    200 IF "%TEST_PROCESSOR_ARCH%" == "X64"     set BUILD_PLATFORM_ARCH=amd64
    201 IF NOT ".%BUILD_PLATFORM_ARCH%" == "."  goto have_2_BUILD_PLATFORM_ARCH
    202 set TEST_PROCESSOR_ARCH=
    203 echo kBuild: Cannot figure BUILD_PLATFORM_ARCH!
    204 goto failed
    205 :have_2_BUILD_PLATFORM_ARCH
    206 echo dbg: BUILD_PLATFORM_ARCH=%BUILD_PLATFORM_ARCH%
    207 
    208 IF NOT ".%BUILD_PLATFORM_CPU%" == "."   goto have_2_BUILD_PLATFORM_CPU
    209 IF "%BUILD_PLATFORM_ARCH%" == "amd64"   set BUILD_PLATFORM_CPU=k8
    210 IF "%BUILD_PLATFORM_ARCH%" == "x86"     set BUILD_PLATFORM_CPU=i386
    211 IF NOT ".%BUILD_PLATFORM_CPU%" == "."   goto have_2_BUILD_PLATFORM_CPU
    212 echo kBuild: Cannot figure BUILD_PLATFORM_CPU!
    213 goto failed
    214 :have_2_BUILD_PLATFORM_CPU
    215 echo dbg: BUILD_PLATFORM_CPU=%BUILD_PLATFORM_CPU%
    216 
    217 
    218 REM #
    219 REM # Target platform.
    220 REM #
    221 :process_BUILD_TARGET
    222 IF NOT ".%BUILD_TARGET%" == "."         goto have_BUILD_TARGET
    223 set BUILD_TARGET=%BUILD_PLATFORM%
    224 IF NOT ".%BUILD_TARGET_ARCH%" == "."    goto have_BUILD_TARGET_ARCH
    225 set BUILD_TARGET_ARCH=%BUILD_PLATFORM_ARCH%
    226 :have_BUILD_TARGET_ARCH
    227 IF NOT ".%BUILD_TARGET_CPU%" == "."     goto have_BUILD_TARGET_CPU
    228 set BUILD_TARGET_CPU=%BUILD_PLATFORM_CPU%
    229 :have_BUILD_TARGET_CPU
    230 echo dbg: BUILD_TARGET=%BUILD_TARGET%
    231 echo dbg: BUILD_TARGET_ARCH=%BUILD_TARGET_ARCH%
    232 echo dbg: BUILD_TARGET_CPU=%BUILD_TARGET_CPU%
    233 goto next
    234 
    235 :have_BUILD_TARGET
    236 echo dbg: BUILD_TARGET=%BUILD_TARGET%
    237 IF NOT ".%BUILD_TARGET_ARCH%" == "."    goto have_2_BUILD_TARGET_ARCH
    238 IF "%BUILD_TARGET%" == "os2"            set BUILD_TARGET_ARCH=x86
    239 IF ".%BUILD_TARGET_ARCH%" == "."        set BUILD_TARGET_ARCH=%BUILD_PLATFORM_ARCH%
    240 :have_2_BUILD_TARGET_ARCH
    241 echo dbg: BUILD_TARGET_ARCH=%BUILD_TARGET_ARCH%
    242 IF NOT ".%BUILD_TARGET_CPU%" == "."     goto have_2_BUILD_TARGET_CPU
    243 set BUILD_TARGET_CPU=blend
    244 IF NOT ".%BUILD_TARGET_CPU%" == "."     goto have_2_BUILD_TARGET_CPU
    245 echo kBuild: Cannot figure BUILD_TARGET_CPU!
    246 goto failed
    247 :have_2_BUILD_TARGET_CPU
    248 echo dbg: BUILD_TARGET_CPU=%BUILD_TARGET_CPU%
    249 
    250 :next
    251 
    252 REM # The PATH.
    253 set PATH=%PATH_KBUILD%\bin\win.x86;%PATH%
    254 IF "%BUILD_PLATFORM_ARCH%" == "amd64" set PATH=%PATH_KBUILD%\bin\win.amd64;%PATH%
    255 echo dbg: PATH=%PATH%
    256 
    257 REM # Execute command
    258 IF ".%1" == "." goto end
     588
     589:show_all_variables
     590echo %_KBUILD_SHOW_VAR_PREFIX%KBUILD_PATH=%_KBUILD_PATH%
     591echo %_KBUILD_SHOW_VAR_PREFIX%KBUILD_BIN_PATH=%_KBUILD_BIN_PATH%
     592echo %_KBUILD_SHOW_VAR_PREFIX%KBUILD_TYPE=%_KBUILD_TYPE%
     593echo %_KBUILD_SHOW_VAR_PREFIX%KBUILD_HOST=%_KBUILD_HOST%
     594echo %_KBUILD_SHOW_VAR_PREFIX%KBUILD_HOST_ARCH=%_KBUILD_HOST_ARCH%
     595echo %_KBUILD_SHOW_VAR_PREFIX%KBUILD_HOST_CPU=%_KBUILD_HOST_CPU%
     596echo %_KBUILD_SHOW_VAR_PREFIX%KBUILD_TARGET=%_KBUILD_TARGET%
     597echo %_KBUILD_SHOW_VAR_PREFIX%KBUILD_TARGET_ARCH=%_KBUILD_TARGET_ARCH%
     598echo %_KBUILD_SHOW_VAR_PREFIX%KBUILD_TARGET_CPU=%_KBUILD_TARGET_CPU%
     599goto end
     600
     601REM
     602REM Setup environment for the current shell or execute a command.
     603REM
     604REM Note: We use setlocal if we're going to execute a command as we
     605REM       don't want the environment of the invoking shell to be changed.
     606REM
     607:exec_or_setup_env
     608if not ".%1" == "." setlocal
     609
     610REM The PATH is always set.
     611set PATH=%_KBUILD_NEW_PATH%
     612
     613REM Clear up anything that should be overridden.
     614if not "%_KBUILD_OPT_OVERRIDE_ALL%" == "1" goto skip_override_all
     615set KBUILD_TYPE=
     616set KBUILD_HOST=
     617set KBUILD_HOST_ARCH=
     618set KBUILD_HOST_CPU=
     619set KBUILD_TARGET=
     620set KBUILD_TARGET_ARCH=
     621set KBUILD_TARGET_CPU=
     622set KBUILD_PATH=
     623set KBUILD_BIN_PATH=
     624if not "%_KBUILD_OPT_LEGACY%" == "1" goto skip_override_all
     625set BUILD_TYPE=
     626set BUILD_PLATFORM=
     627set BUILD_PLATFORM_ARCH=
     628set BUILD_PLATFORM_CPU=
     629set BUILD_TARGET=
     630set BUILD_TARGET_ARCH=
     631set BUILD_TARGET_CPU=
     632set PATH_KBUILD=
     633set PATH_KBUILD_BIN=
     634:skip_override_all
     635
     636REM Specific overrides, these implicitly deletes the legacy variable.
     637if "%_KBUILD_OVERRIDE_TARGET%" == "1"       set KBUILD_TARGET=%_KBUILD_TARGET%
     638if "%_KBUILD_OVERRIDE_TARGET%" == "1"       set BUILD_TARGET=
     639if "%_KBUILD_OVERRIDE_TARGET_ARCH%" == "1"  set KBUILD_TARGET_ARCH=%_KBUILD_TARGET_ARCH%
     640if "%_KBUILD_OVERRIDE_TARGET_ARCH%" == "1"  set BUILD_TARGET_ARCH=
     641if "%_KBUILD_OVERRIDE_TYPE%" == "1"         set KBUILD_TYPE=%_KBUILD_TYPE%
     642if "%_KBUILD_OVERRIDE_TYPE%" == "1"         set BUILD_TYPE=
     643
     644if not "%_KBUILD_OPT_FULL%" == "1"          goto env_setup_done
     645set KBUILD_PATH=%_KBUILD_PATH%
     646set KBUILD_BIN_PATH=%_KBUILD_BIN_PATH%
     647set KBUILD_TYPE=%_KBUILD_TYPE%
     648set KBUILD_HOST=%_KBUILD_HOST%
     649set KBUILD_HOST_ARCH=%_KBUILD_HOST_ARCH%
     650set KBUILD_HOST_CPU=%_KBUILD_HOST_CPU%
     651set KBUILD_TARGET=%_KBUILD_TARGET%
     652set KBUILD_TARGET_ARCH=%_KBUILD_TARGET_ARCH%
     653set KBUILD_TARGET_CPU=%_KBUILD_TARGET_CPU%
     654
     655if not "%_KBUILD_OPT_LEGACY%" == "1"        goto env_setup_done
     656set PATH_KBUILD=%_KBUILD_PATH%
     657set PATH_KBUILD_BIN=%_KBUILD_BIN_PATH%
     658set BUILD_TYPE=%_KBUILD_TYPE%
     659set BUILD_PLATFORM=%_KBUILD_HOST%
     660set BUILD_PLATFORM_ARCH=%_KBUILD_HOST_ARCH%
     661set BUILD_PLATFORM_CPU=%_KBUILD_HOST_CPU%
     662set BUILD_TARGET=%_KBUILD_TARGET%
     663set BUILD_TARGET_ARCH=%_KBUILD_TARGET_ARCH%
     664set BUILD_TARGET_CPU=%_KBUILD_TARGET_CPU%
     665
     666:env_setup_done
     667if ".%1" == "." goto end
     668
     669REM Execute the specified command
     670if ".%_KBUILD_OPT_DBG%" == ".1" echo dbg: Executing: %1 %2 %3 %4 %5 %6 %7 %8 %9
     671set _KBUILD_CLEAN_GOTO=exec_command & goto cleanup
     672:exec_command
     673SET _KBUILD_CLEAN_GOTO=
    259674%1 %2 %3 %4 %5 %6 %7 %8 %9
    260 goto end
     675endlocal
     676goto end_no_exit
     677
     678
     679
     680REM
     681REM All exit paths leads to 'end' or 'failed' depending on
     682REM which exit code is desire. This is required as we're manually
     683REM performing environment cleanup (setlocal/endlocal is crap).
     684REM
     685:cleanup
     686set _KBUILD_CURDIR=
     687set _KBUILD_PATH=
     688set _KBUILD_BIN_PATH=
     689set _KBUILD_NEW_PATH=
     690set _KBUILD_TYPE=
     691set _KBUILD_TARGET=
     692set _KBUILD_TARGET_ARCH=
     693set _KBUILD_TARGET_CPU=
     694set _KBUILD_HOST=
     695set _KBUILD_HOST_ARCH=
     696set _KBUILD_HOST_CPU=
     697set _KBUILD_OPT_OVERRIDE_ALL=
     698set _KBUILD_OVERRIDE_TYPE=
     699set _KBUILD_OVERRIDE_TARGET=
     700set _KBUILD_OVERRIDE_TARGET_ARCH=
     701
     702set _KBUILD_SELF=
     703set _KBUILD_OPT_FULL=
     704set _KBUILD_OPT_LEGACY=
     705set _KBUILD_OPT_VAR=
     706set _KBUILD_OPT_VALUE_ONLY=
     707set _KBUILD_SHOW_VAR_PREFIX=
     708set _KBUILD_OPT_DBG=
     709set _KBUILD_OPT_OVERRIDE_ALL=
     710
     711set _KBUILD_TMP=
     712set _KBUILD_VAR=
     713set _KBUILD_VARS=
     714goto %_KBUILD_CLEAN_GOTO%
    261715
    262716:failed
     717set _KBUILD_CLEAN_GOTO=failed_done & goto cleanup
     718:failed_done
     719set _KBUILD_CLEAN_GOTO=
     720exit /b 1
     721
    263722:end
    264 
     723set _KBUILD_CLEAN_GOTO=end_done & goto cleanup
     724:end_done
     725set _KBUILD_CLEAN_GOTO=
     726exit /b 0
     727
     728:end_no_exit
     729
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette