Scott:
 Yes. Output is a .lib extension that can work with EDKII build system. .rc 
file build Rule is also required. Could you send one formal patch to add this 
rule?

Thanks
Liming
-----Original Message-----
From: Scott Duplichan [mailto:[email protected]] 
Sent: Friday, October 17, 2014 3:40 AM
To: [email protected]
Subject: Re: [edk2] How to Set File Version etc.?

Gurinder Singh [mailto:[email protected]]  wrote:


]Hi guys,
]
]I tried to get the resource compiler invoked in the build process.
]However, I am not quite sure how I can link the .res file generated ]by the 
resource compiler to the efi file (you need to link to the .res ]file for the 
file metadata to get baked into the binary). How do I ]hook into the EDKII 
build chain and get this to work? Any ideas?
]
]Thanks in advance.
]
]-Gurinder

The .res can be converted to .obj using cvtres.exe, or you can let the linker 
do it automatically. But in either case, naming the file .obj causes the build 
system to put it in a library, and the linker will throw out resource data 
found in libraries. A work around is to name the rc.exe output file so that it 
has a .lib extension. That way, the edk2 build system will pass it to the 
linker directly. That causes the resource section to be placed into both the 
DLL and EFI file. A problem is that the Windows explorer will show file version 
resource data only for file types such as .sys, .dll, and .exe. So for example 
Windows will show version data for shell.dll but not for shell.efi. Other 
resource viewers are available that do not have this limitation. For example, 
this one shows the file version resource data for .efi files:
http://sourceforge.net/projects/resourcesviewer/

Here is a patch that demonstrates adding version resource data to
shell.efi:

Index: BaseTools/Conf/build_rule.template
===================================================================
--- BaseTools/Conf/build_rule.template  (revision 16219)
+++ BaseTools/Conf/build_rule.template  (working copy)
@@ -572,3 +572,15 @@
         GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) 
--hiibinpackage $(HII_BINARY_PACKAGES)
         
         
+[Resource-File]
+    <InputFile>
+        ?.rc
+
+    <ExtraDependency>
+        $(MAKE_FILE)
+
+    <OutputFile>
+        $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.lib
+
+    <Command.MSFT, Command.INTEL>
+        "$(RC)" /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.lib $(RC_FLAGS) 
+ ${src}
Index: ShellPkg/Application/Shell/Resource.rc
===================================================================
--- ShellPkg/Application/Shell/Resource.rc      (revision 0)
+++ ShellPkg/Application/Shell/Resource.rc      (working copy)
@@ -0,0 +1,25 @@
+    1              VERSIONINFO
+    FILEVERSION    1,2,3,4
+    PRODUCTVERSION 2,2,2,2
+    FILEOS         0x00040004
+    FILETYPE       2
+    FILEFLAGSMASK  0x3F
+{
+    BLOCK "StringFileInfo"
+        {
+        BLOCK "040904b0"
+            {
+            VALUE "CompanyName",        "Company name"
+            VALUE "FileDescription",    "your text goes here"
+            VALUE "FileVersion",        "0.1.a prerelease beta"
+            VALUE "LegalCopyright",     "yes"
+            VALUE "OriginalFilename",   "Shell.dll"
+            VALUE "ProductName",        "Shell"
+            VALUE "ProductVersion",     "experimental"
+            }
+        }
+    BLOCK "VarFileInfo"
+        {
+        VALUE "Translation", 0x409, 1200
+        }
+    }
Index: ShellPkg/Application/Shell/Shell.inf
===================================================================
--- ShellPkg/Application/Shell/Shell.inf        (revision 16219)
+++ ShellPkg/Application/Shell/Shell.inf        (working copy)
@@ -47,6 +47,7 @@
   ConsoleLogger.h
   ConsoleWrappers.c
   ConsoleWrappers.h
+  Resource.rc
 
 [Packages]
   MdePkg/MdePkg.dec

-- 

With this patch, the http://sourceforge.net/projects/resourcesviewer/
shows this output for shell.efi:

FixedFileInfo
    Signature:      0xFEEF04BD (VS_FFI_SIGNATURE)
    StrucVersion:   0x00010000 (VS_FFI_STRUCVERSION)
    FileVersion:    1.2.3.4
    ProductVersion: 2.2.2.2
    FileFlagsMask:  0x0000003F (VS_FFI_FILEFLAGSMASK)
    FileFlags:      0x00000000
    FileOS:         0x00040004 (VOS_NT_WINDOWS32)
    FileType:       0x00000002 (VFT_DLL)
    FileSubType:    0x00000000 (VFT2_UNKNOWN)
    FileDate:       01/01/0001 12:00:00 AM
StringFileInfo
    BlockHeader: 040904b0 (en-US, Unicode)
        CompanyName:      Company name
        FileDescription:  your text goes here
        FileVersion:      0.1.a prerelease beta
        LegalCopyright:   yes
        OriginalFilename: Shell.dll
        ProductName:      Shell
        ProductVersion:   experimental
VarFileInfo
    Translation
        04B00409 (en-US, Unicode)

Thanks,
Scott


]On Mon, Oct 13, 2014 at 4:45 PM, Gurinder Singh <[email protected]> 
wrote:
]Hi guys,
]
]How can I set the Windows files system fields like "File Version", "File 
Description", "Product Name", "Copyright" etc. on an ].efi binary I'm building?
]
]I know I can do this by creating a resource file containing these fields and 
then linking it to the .efi. But I was wondering if ]there's some standard way 
of achieving this in EDKII (perhaps by setting some fields in the .inf file or 
something).
]
]Thanks in advance.
]
]Regards,
]Gurinder

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to