edk2-basetools icon indicating copy to clipboard operation
edk2-basetools copied to clipboard

The command line macro definitions of the build utility do not end up in the Makefile for .c/.cpp

Open ogamespec opened this issue 3 years ago • 3 comments

We know from the manual that build takes a set of macros (option -D). But after generating the Makefile for the .c/.cpp modules, for some reason these macros do not end up in the Makefile.

ogamespec avatar Mar 18 '22 08:03 ogamespec

Do you mean all the -D macro are not generated into Makefile? Could you show me your build command and the incorrect Makefile?

BobCF avatar Mar 21 '22 14:03 BobCF

Demo project: HelloWorldPkg.zip

All I want to do is pull the macro definition (-D) from the build command:

build -a X64 -p HelloWorldPkg\Hello.dsc -t VS2019 -D TEST=1

And use it in the code like this:

EFI_STATUS EFIAPI UefiEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE* SystemTable)
{
#if defined(TEST)
	Print (L"Test macro\n");
#endif

	return EFI_SUCCESS;
}

But after generating the Makefile, for some reason the macro defined with -D does not get into CC_FLAGS:

CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Z7 /Gw
CC = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\cl.exe

I wanted it that way:

CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Z7 /Gw  /D TEST=1
CC = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\cl.exe

ogamespec avatar Mar 21 '22 18:03 ogamespec

Any progress?

ogamespec avatar Jan 16 '24 08:01 ogamespec