pretty code

2019年3月12日 星期二

How to build Win32 "BaseTools" in UDK2018

The "UDK2018" is "UDK2018" branch in git, not "vUDK2018" tag in git.

OS: Windows 7 64 bit
VC: VS2015 (from VS2017 community installation)
UDK2018: I download the zip from git on 3/4, 2019.
Python: 2.7.11 64 bit
cx_Freeze module: 4.3.3 (from cx_Freeze-4.3.3.win-amd64-py2.7.msi)

You will not have any problems if you use these tools above.

The steps to build
0. Modify line  826 in "C:\Python27\Lib\site-packages\cx_Freeze\hooks.py". (sys.base_prefix -> 'C:\Python27'). This will solve "Python 3 Syntax" problem.
1. Open "VS2015 x86 Native Tools Command Prompt" link from Windows Program menu.
2. Enter your "UDK2018" folder.(my example is "C:\UDK2018_Branch")
3. set PYTHON_HOME=C:\Python27
4. set PYTHON_FREEZER_PATH=C:\Python27\Scripts
5. Run "edksetup Rebuild".

If you like to use Python 3, here are some hints.
1. Don't use "Python37", I can't install "cx_Freeze" 5.x in it.
2. Use" Python36", I can install cx_Freeze 5.x. But after completing to build the "BaseTools", you will encounter "build__init_" module issue when you start to build something. I guess the solution is to install old version of "cx_Freeze" as I did in Python 2.
3. Modify some codes in "C:\UDK2018_Branch\BaseTools\Source\Python" because source code use some "Python 2 Syntax".

4 則留言:

Unknown 提到...

Hi,

many thanks for your how to. It helps me a lot to build the UDK2018 Base tools!

But once I've tried to build e.g. AppPkg (using: build -p AppPkg/AppPkg.dsc) the compilation ends with error (see snippet below, the error log is much longer - can send whole if interested)
The selected architecture is X64, Build target is set to RELEASE, Toolchain is set to VS2015.

Snippet from error log:

Building ... c:\myworkspace\StdLib\LibC\LibC.inf [X64]
c:\myworkspace\StdLib\Include\sys/EfiCdefs.h(342): error C2220: warning treated as error - no 'object' file generated
c:\myworkspace\StdLib\Include\sys/EfiCdefs.h(342): warning C4117: macro name '__STDC_HOSTED__' is reserved, '#define' ignored
c:\myworkspace\StdLib\Include\sys/EfiCdefs.h(342): error C2220: warning treated as error - no 'object' file generated
Bsearch.c
c:\myworkspace\StdLib\Include\sys/EfiCdefs.h(342): warning C4117: macro name '__STDC_HOSTED__' is reserved, '#define' ignored
c:\myworkspace\StdLib\Include\sys/EfiCdefs.h(342): error C2220: warning treated as error - no 'object' file generated
c:\myworkspace\StdLib\Include\sys/EfiCdefs.h(342): warning C4117: macro name '__STDC_HOSTED__' is reserved, '#define' ignored
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Vc\bin\x86_amd64\cl.exe" /Foc:\myworkspace\Build\AppPkg\RELEASE_VS2015\X64\StdLib\LibC\Ctype\Ctype\OUTPUT\.\iCtype.obj /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Gw /GL- /X /Zc:wchar_t /D UEFI_C_SOURCE /Wv:11 /Ic:\myworkspace\StdLib\LibC\Ctype /Ic:\myworkspace\Build\AppPkg\RELEASE_VS2015\X64\StdLib\LibC\Ctype\Ctype\DEBUG /Ic:\myworkspace\StdLib /Ic:\myworkspace\StdLib\Include /Ic:\myworkspace\StdLib\Include\X64 /Ic:\myworkspace\StdLibPrivateInternalFiles /Ic:\myworkspace\StdLibPrivateInternalFiles\Include /Ic:\myworkspace\StdLibPrivateInternalFiles\Include\X64 /Ic:\myworkspace\MdePkg /Ic:\myworkspace\MdePkg\Include /Ic:\myworkspace\MdePkg\Include\X64 c:\myworkspace\StdLib\LibC\Ctype\iCtype.c
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'
Stop.
c:\myworkspace\StdLib\Include\sys/EfiCdefs.h(342): error C2220: warning treated as error - no 'object' file generated
c:\myworkspace\StdLib\Include\sys/EfiCdefs.h(342): warning C4117: macro name '__STDC_HOSTED__' is reserved, '#define' ignored
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Vc\bin\x86_amd64\cl.exe" /Foc:\myworkspace\Build\AppPkg\RELEASE_VS2015\X64\StdLib\LibC\Locale\Locale\OUTPUT\.\__mb_cur_max.obj /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Gw /X /Zc:wchar_t /D UEFI_C_SOURCE /Wv:11 /Ic:\myworkspace\StdLib\LibC\Locale /Ic:\myworkspace\Build\AppPkg\RELEASE_VS2015\X64\StdLib\LibC\Locale\Locale\DEBUG /Ic:\myworkspace\StdLib /Ic:\myworkspace\StdLib\Include /Ic:\myworkspace\StdLib\Include\X64 /Ic:\myworkspace\StdLibPrivateInternalFiles /Ic:\myworkspace\StdLibPrivateInternalFiles\Include /Ic:\myworkspace\StdLibPrivateInternalFiles\Include\X64 /Ic:\myworkspace\MdePkg /Ic:\myworkspace\MdePkg\Include /Ic:\myworkspace\MdePkg\Include\X64 c:\myworkspace\StdLib\LibC\Locale\__mb_cur_max.c


build...
: error 7000: Failed to execute command
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Vc\bin\nmake.exe /nologo tbuild [c:\myworkspace\Build\AppPkg\RELEASE_VS2015\X64\StdLib\PosixLib\Gen\LibGen]
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'

Many thanks in advance for any hint.

Martin

tylpk 提到...

Hi Martin,

I guess that the problem is the same like link below.
https://tylpk.blogspot.com/2019/03/build-apppkg-in-udk2018.html

Maybe you could comment the "__STDC_HOSTED__".

Thanks.

Unknown 提到...

Hi tylpk,

I've wound that enough is to suppress the warning 4117 by adding /wd4117 to the CC_FLAGS.
Once this is done the AppPkg is possible to successfully compile. I've tested the resulting binaries including LUA interpreter under X64 EFI shell, and it works properly.

Kind Regards, Martin

tylpk 提到...

Hi Martin,

Thank you for your sharing.

You could also use macro to disable warning.
#pragma warning(disable:4117)

Thanks.