]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Add $(INC)-like support when compiling .nasm files
authorZhiju.Fan <zhijux.fan@intel.com>
Tue, 18 Dec 2018 16:13:12 +0000 (00:13 +0800)
committerBobCF <bob.c.feng@intel.com>
Wed, 19 Dec 2018 00:42:14 +0000 (08:42 +0800)
current edk2\BaseTools\Conf\build_rule.template, the compile of nasm
source files does not have the $(INC) support.

The '-I' option only includes the directory of the nasm source file
(${s_path}(+)). Hence, it will be impossible for nasm files to include
files outside of the nasm source file directory.

As a comparison, the compile of both .s and .asm have $(INC) support
in their compile commands.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=1085
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/Python/AutoGen/GenMake.py

index d94d8f9368e30497346917bf2d92b9a3133464f2..ef7bc845d0237766d826a80e2efde2e4dd0aec8b 100644 (file)
@@ -167,7 +167,7 @@ class BuildFile(object):
         "gmake" :   "include"\r
     }\r
 \r
-    _INC_FLAG_ = {TAB_COMPILER_MSFT : "/I", "GCC" : "-I", "INTEL" : "-I", "RVCT" : "-I"}\r
+    _INC_FLAG_ = {TAB_COMPILER_MSFT : "/I", "GCC" : "-I", "INTEL" : "-I", "RVCT" : "-I", "NASM" : "-I"}\r
 \r
     ## Constructor of BuildFile\r
     #\r
@@ -596,6 +596,24 @@ cleanlib:
                                                 }\r
                                                 )\r
         FileMacroList.append(FileMacro)\r
+        # Add support when compiling .nasm source files\r
+        for File in self.FileCache.keys():\r
+            if not str(File).endswith('.nasm'):\r
+                continue\r
+            IncludePathList = []\r
+            for P in  MyAgo.IncludePathList:\r
+                IncludePath = self._INC_FLAG_['NASM'] + self.PlaceMacro(P, self.Macros)\r
+                if IncludePath.endswith(os.sep):\r
+                    IncludePath = IncludePath.rstrip(os.sep)\r
+                # When compiling .nasm files, need to add a literal backslash at each path\r
+                # To specify a literal backslash at the end of the line, precede it with a caret (^)\r
+                if P == MyAgo.IncludePathList[-1] and os.sep == '\\':\r
+                    IncludePath = ''.join([IncludePath, '^', os.sep])\r
+                else:\r
+                    IncludePath = os.path.join(IncludePath, '')\r
+                IncludePathList.append(IncludePath)\r
+            FileMacroList.append(self._FILE_MACRO_TEMPLATE.Replace({"macro_name": "NASM_INC", "source_file": IncludePathList}))\r
+            break\r
 \r
         # Generate macros used to represent files containing list of input files\r
         for ListFileMacro in self.ListFileMacros:\r