blob: 7aa167549bb2d88c08723338641149a43d4dcf0b [file] [log] [blame]
lhauch8014e7c2008-02-22 16:31:23 +00001@REM @file
2@REM Windows batch file to setup a WORKSPACE environment
bbahnsen878ddf12006-04-21 22:54:32 +00003@REM
Liming Gaocc7c6a32016-04-08 13:32:07 +08004@REM Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
Cinnamon Shia92063b02016-10-19 12:31:36 +08005@REM (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
hhtian24542fb2010-04-29 15:17:20 +00006@REM This program and the accompanying materials
bbahnsen878ddf12006-04-21 22:54:32 +00007@REM are licensed and made available under the terms and conditions of the BSD License
8@REM which accompanies this distribution. The full text of the license may be found at
9@REM http://opensource.org/licenses/bsd-license.php
yshi8a29212b2006-05-09 06:11:05 +000010@REM
bbahnsen878ddf12006-04-21 22:54:32 +000011@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13@REM
14
yshi8a29212b2006-05-09 06:11:05 +000015@REM set CYGWIN_HOME=C:\cygwin
bbahnsen878ddf12006-04-21 22:54:32 +000016
lhauch8014e7c2008-02-22 16:31:23 +000017@REM usage:
18@REM edksetup.bat [--nt32] [AntBuild] [Rebuild] [ForceRebuild] [Reconfig]
lhauch302e0e42006-06-09 15:26:28 +000019@REM if the argument, skip is present, only the paths and the
20@REM test and set of environment settings are performed.
bbahnsen878ddf12006-04-21 22:54:32 +000021
22@REM ##############################################################
23@REM # You should not have to modify anything below this line
24@REM #
25
26@echo off
27
yshi8a29212b2006-05-09 06:11:05 +000028@REM
jwang363fab94e2007-06-22 06:25:37 +000029@REM Set the WORKSPACE to the current working directory
30@REM
jwang36b7509082007-10-11 08:58:33 +000031pushd .
32cd %~dp0
jwang363fab94e2007-06-22 06:25:37 +000033
lgao4dff26732010-01-26 04:58:56 +000034if not defined WORKSPACE (
Olivier Martin7ef23d92014-02-24 14:09:00 +000035 goto SetWorkSpace
lgao4d27bd9e2010-01-26 02:42:37 +000036)
37
lgao4dff26732010-01-26 04:58:56 +000038if %WORKSPACE% == %CD% (
39 @REM Workspace is not changed.
Olivier Martin7ef23d92014-02-24 14:09:00 +000040 goto ParseArgs
lgao4dff26732010-01-26 04:58:56 +000041)
42
43:SetWorkSpace
lgao4d27bd9e2010-01-26 02:42:37 +000044@REM set new workspace
45@REM clear EFI_SOURCE and EDK_SOURCE for the new workspace
Liming Gaodcc80782015-10-08 09:29:09 +000046if not defined WORKSPACE (
47 set WORKSPACE=%CD%
48 set EFI_SOURCE=
49 set EDK_SOURCE=
50)
lgao4d27bd9e2010-01-26 02:42:37 +000051
52:ParseArgs
Olivier Martin7ef23d92014-02-24 14:09:00 +000053if /I "%1"=="-h" goto Usage
54if /I "%1"=="-help" goto Usage
55if /I "%1"=="--help" goto Usage
56if /I "%1"=="/h" goto Usage
57if /I "%1"=="/?" goto Usage
58if /I "%1"=="/help" goto Usage
lhauch8014e7c2008-02-22 16:31:23 +000059
Olivier Martin7ef23d92014-02-24 14:09:00 +000060if /I "%1"=="NewBuild" shift
Liming Gaocc7c6a32016-04-08 13:32:07 +080061if not defined EDK_TOOLS_PATH (
62 if exist %WORKSPACE%\BaseTools (
63 set EDK_TOOLS_PATH=%WORKSPACE%\BaseTools
Liming Gaodcc80782015-10-08 09:29:09 +000064 ) else (
Liming Gaocc7c6a32016-04-08 13:32:07 +080065 if defined PACKAGES_PATH (
66 for %%i IN (%PACKAGES_PATH%) DO (
67 if exist %%~fi\BaseTools (
68 set EDK_TOOLS_PATH=%%~fi\BaseTools
Cinnamon Shia92063b02016-10-19 12:31:36 +080069 goto checkNt32Flag
Liming Gaocc7c6a32016-04-08 13:32:07 +080070 )
71 )
72 ) else (
73 echo.
74 echo !!! ERROR !!! Cannot find BaseTools !!!
75 echo.
76 goto BadBaseTools
77 )
Liming Gaodcc80782015-10-08 09:29:09 +000078 )
79)
Liming Gaodcc80782015-10-08 09:29:09 +000080
Cinnamon Shia92063b02016-10-19 12:31:36 +080081:checkNt32Flag
Liming Gao4e908972016-10-26 11:31:52 +080082if exist %EDK_TOOLS_PATH%\Source set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%
83
Cinnamon Shia92063b02016-10-19 12:31:36 +080084@REM The Nt32 Emluation Platform requires Microsoft Libraries
85@REM and headers to interface with Windows.
86if /I "%1"=="--nt32" (
87 if /I "%2"=="X64" (
88 shift
89 call "%BASE_TOOLS_PATH%\Scripts\SetVisualStudio.bat"
90 ) else (
91 call "%BASE_TOOLS_PATH%\get_vsvars.bat"
92 )
93 shift
94)
95
Liming Gaodcc80782015-10-08 09:29:09 +000096:checkBaseTools
Olivier Martin7ef23d92014-02-24 14:09:00 +000097IF NOT EXIST "%EDK_TOOLS_PATH%\toolsetup.bat" goto BadBaseTools
98call %EDK_TOOLS_PATH%\toolsetup.bat %*
99if /I "%1"=="Reconfig" shift
Yonghong Zhu910e2062016-07-15 17:41:17 +0800100goto check_NASM
Olivier Martin7ef23d92014-02-24 14:09:00 +0000101goto check_cygwin
lhauch8014e7c2008-02-22 16:31:23 +0000102
103:BadBaseTools
104 @REM
Olivier Martin7ef23d92014-02-24 14:09:00 +0000105 REM Need the BaseTools Package in order to build
lhauch8014e7c2008-02-22 16:31:23 +0000106 @REM
Olivier Martin7ef23d92014-02-24 14:09:00 +0000107 @echo.
108 @echo !!! ERROR !!! The BaseTools Package was not found !!!
109 @echo.
110 @echo Set the system environment variable, EDK_TOOLS_PATH to the BaseTools,
111 @echo For example,
112 @echo set EDK_TOOLS_PATH=C:\MyTools\BaseTools
113 @echo The setup script, toolsetup.bat must reside in this folder.
114 @echo.
115 goto end
lhauch8014e7c2008-02-22 16:31:23 +0000116
Yonghong Zhu910e2062016-07-15 17:41:17 +0800117:check_NASM
118if not defined NASM_PREFIX (
119 @echo.
120 @echo !!! WARNING !!! NASM_PREFIX environment variable is not set
121 @if exist "C:\nasm\nasm.exe" @set "NASM_PREFIX=C:\nasm\"
122 @if exist "C:\nasm\nasm.exe" @echo Found nasm.exe, setting the environment variable to C:\nasm\
123 @if not exist "C:\nasm\nasm.exe" echo Attempting to build modules that require NASM will fail.
124)
125
yshi8a29212b2006-05-09 06:11:05 +0000126:check_cygwin
Olivier Martin1f9c8602014-02-24 14:14:13 +0000127if defined CYGWIN_HOME (
128 if not exist "%CYGWIN_HOME%" (
129 @echo.
130 @echo !!! WARNING !!! CYGWIN_HOME not found, gcc build may not be used !!!
131 @echo.
132 )
133) else (
Olivier Martin7ef23d92014-02-24 14:09:00 +0000134 if exist c:\cygwin (
135 set CYGWIN_HOME=c:\cygwin
lhauch8014e7c2008-02-22 16:31:23 +0000136 ) else (
lhauch3a6b4552008-12-31 16:57:24 +0000137 @echo.
138 @echo !!! WARNING !!! No CYGWIN_HOME set, gcc build may not be used !!!
139 @echo.
lhauch8014e7c2008-02-22 16:31:23 +0000140 )
Olivier Martin1f9c8602014-02-24 14:14:13 +0000141)
bbahnsen878ddf12006-04-21 22:54:32 +0000142
Olivier Martin1f9c8602014-02-24 14:14:13 +0000143:cygwin_done
144if "%1"=="" goto end
wuyizhong2fcfed32006-10-17 07:07:24 +0000145
lhauch70edbc32006-07-14 06:46:15 +0000146:Usage
lhauch3a6b4552008-12-31 16:57:24 +0000147 @echo.
Cinnamon Shia92063b02016-10-19 12:31:36 +0800148 @echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [--nt32 [X64]] [Reconfig]"
149 @echo --nt32 [X64] If a compiler tool chain is not available in the
150 @echo environment, call a script to attempt to set one up.
151 @echo This flag is only required if building the
152 @echo Nt32Pkg/Nt32Pkg.dsc system emulator.
153 @echo If the X64 argument is set, and a compiler tool chain is
154 @echo not available, attempt to set up a tool chain that will
155 @echo create X64 binaries. Setting these two options have the
156 @echo potential side effect of changing tool chains used for a
157 @echo rebuild.
lhauch3a6b4552008-12-31 16:57:24 +0000158 @echo.
159 @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
160 @echo.
161 @echo Note that target.template, tools_def.template and build_rules.template
Olivier Martin1f9c8602014-02-24 14:14:13 +0000162 @echo will only be copied to target.txt, tools_def.txt and build_rule.txt
163 @echo respectively if they do not exist. Use option [Reconfig] to force the copy.
lhauch3a6b4552008-12-31 16:57:24 +0000164 @echo.
Olivier Martin7ef23d92014-02-24 14:09:00 +0000165 goto end
jwang363fab94e2007-06-22 06:25:37 +0000166
bbahnsen878ddf12006-04-21 22:54:32 +0000167:end
Olivier Martin7ef23d92014-02-24 14:09:00 +0000168 popd
bbahnsen878ddf12006-04-21 22:54:32 +0000169