]>
Commit | Line | Data |
---|---|---|
7ccc9c95 YZ |
1 | ## @file\r |
2 | # This module provide command line entry for generating package document!\r | |
3 | #\r | |
4 | # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
5 | #\r | |
2e351cbe | 6 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r |
7ccc9c95 YZ |
7 | #\r |
8 | \r | |
1ccc4d89 | 9 | from __future__ import print_function\r |
7ccc9c95 YZ |
10 | import os, sys, logging, traceback, subprocess\r |
11 | from optparse import OptionParser\r | |
12 | \r | |
9ab4ec51 FZ |
13 | from plugins.EdkPlugins.edk2.model import baseobject\r |
14 | from plugins.EdkPlugins.edk2.model import doxygengen\r | |
7ccc9c95 YZ |
15 | \r |
16 | gArchMarcoDict = {'ALL' : 'MDE_CPU_IA32 MDE_CPU_X64 MDE_CPU_EBC MDE_CPU_IPF _MSC_EXTENSIONS __GNUC__ __INTEL_COMPILER',\r | |
17 | 'IA32_MSFT': 'MDE_CPU_IA32 _MSC_EXTENSIONS',\r | |
18 | 'IA32_GNU' : 'MDE_CPU_IA32 __GNUC__',\r | |
19 | 'X64_MSFT' : 'MDE_CPU_X64 _MSC_EXTENSIONS ASM_PFX= OPTIONAL= ',\r | |
20 | 'X64_GNU' : 'MDE_CPU_X64 __GNUC__ ASM_PFX= OPTIONAL= ',\r | |
21 | 'IPF_MSFT' : 'MDE_CPU_IPF _MSC_EXTENSIONS ASM_PFX= OPTIONAL= ',\r | |
22 | 'IPF_GNU' : 'MDE_CPU_IPF __GNUC__ ASM_PFX= OPTIONAL= ',\r | |
23 | 'EBC_INTEL': 'MDE_CPU_EBC __INTEL_COMPILER ASM_PFX= OPTIONAL= '}\r | |
24 | \r | |
25 | def parseCmdArgs():\r | |
26 | parser = OptionParser(version="Package Document Generation Tools - Version 0.1")\r | |
27 | parser.add_option('-w', '--workspace', action='store', type='string', dest='WorkspacePath',\r | |
28 | help='Specify workspace absolute path. For example: c:\\tianocore')\r | |
29 | parser.add_option('-p', '--decfile', action='store', dest='PackagePath',\r | |
30 | help='Specify the absolute path for package DEC file. For example: c:\\tianocore\\MdePkg\\MdePkg.dec')\r | |
31 | parser.add_option('-x', '--doxygen', action='store', dest='DoxygenPath',\r | |
32 | help='Specify the absolute path of doxygen tools installation. For example: C:\\Program Files\\doxygen\bin\doxygen.exe')\r | |
33 | parser.add_option('-o', '--output', action='store', dest='OutputPath',\r | |
34 | help='Specify the document output path. For example: c:\\docoutput')\r | |
7cc7e054 | 35 | parser.add_option('-a', '--arch', action='store', dest='Arch', choices=list(gArchMarcoDict.keys()),\r |
7ccc9c95 YZ |
36 | help='Specify the architecture used in preprocess package\'s source. For example: -a IA32_MSFT')\r |
37 | parser.add_option('-m', '--mode', action='store', dest='DocumentMode', choices=['CHM', 'HTML'],\r | |
38 | help='Specify the document mode from : CHM or HTML')\r | |
39 | parser.add_option('-i', '--includeonly', action='store_true', dest='IncludeOnly',\r | |
40 | help='Only generate document for package\'s public interfaces produced by include folder. ')\r | |
41 | parser.add_option('-c', '--htmlworkshop', dest='HtmlWorkshopPath',\r | |
42 | help='Specify the absolute path for Microsoft HTML Workshop\'s hhc.exe file. For example: C:\\Program Files\\HTML Help Workshop\\hhc.exe')\r | |
43 | (options, args) = parser.parse_args()\r | |
44 | \r | |
45 | # validate the options\r | |
46 | errors = []\r | |
4231a819 | 47 | if options.WorkspacePath is None:\r |
7ccc9c95 YZ |
48 | errors.append('- Please specify workspace path via option -w!')\r |
49 | elif not os.path.exists(options.WorkspacePath):\r | |
50 | errors.append("- Invalid workspace path %s! The workspace path should be exist in absolute path!" % options.WorkspacePath)\r | |
51 | \r | |
4231a819 | 52 | if options.PackagePath is None:\r |
7ccc9c95 YZ |
53 | errors.append('- Please specify package DEC file path via option -p!')\r |
54 | elif not os.path.exists(options.PackagePath):\r | |
55 | errors.append("- Invalid package's DEC file path %s! The DEC path should be exist in absolute path!" % options.PackagePath)\r | |
56 | \r | |
57 | default = "C:\\Program Files\\doxygen\\bin\\doxygen.exe"\r | |
4231a819 | 58 | if options.DoxygenPath is None:\r |
7ccc9c95 | 59 | if os.path.exists(default):\r |
72443dd2 | 60 | print("Warning: Assume doxygen tool is installed at %s. If not, please specify via -x" % default)\r |
7ccc9c95 YZ |
61 | options.DoxygenPath = default\r |
62 | else:\r | |
63 | errors.append('- Please specify the path of doxygen tool installation via option -x! or install it in default path %s' % default)\r | |
64 | elif not os.path.exists(options.DoxygenPath):\r | |
65 | errors.append("- Invalid doxygen tool path %s! The doxygen tool path should be exist in absolute path!" % options.DoxygenPath)\r | |
66 | \r | |
4231a819 | 67 | if options.OutputPath is not None:\r |
7ccc9c95 YZ |
68 | if not os.path.exists(options.OutputPath):\r |
69 | # create output\r | |
70 | try:\r | |
71 | os.makedirs(options.OutputPath)\r | |
72 | except:\r | |
73 | errors.append('- Fail to create the output directory %s' % options.OutputPath)\r | |
74 | else:\r | |
4231a819 | 75 | if options.PackagePath is not None and os.path.exists(options.PackagePath):\r |
7ccc9c95 YZ |
76 | dirpath = os.path.dirname(options.PackagePath)\r |
77 | default = os.path.join (dirpath, "Document")\r | |
72443dd2 | 78 | print('Warning: Assume document output at %s. If not, please specify via option -o' % default)\r |
7ccc9c95 YZ |
79 | options.OutputPath = default\r |
80 | if not os.path.exists(default):\r | |
81 | try:\r | |
82 | os.makedirs(default)\r | |
83 | except:\r | |
84 | errors.append('- Fail to create default output directory %s! Please specify document output diretory via option -o' % default)\r | |
85 | else:\r | |
86 | errors.append('- Please specify document output path via option -o!')\r | |
87 | \r | |
4231a819 | 88 | if options.Arch is None:\r |
7ccc9c95 | 89 | options.Arch = 'ALL'\r |
72443dd2 | 90 | print("Warning: Assume arch is \"ALL\". If not, specify via -a")\r |
7ccc9c95 | 91 | \r |
4231a819 | 92 | if options.DocumentMode is None:\r |
7ccc9c95 | 93 | options.DocumentMode = "HTML"\r |
72443dd2 | 94 | print("Warning: Assume document mode is \"HTML\". If not, specify via -m")\r |
7ccc9c95 | 95 | \r |
4231a819 | 96 | if options.IncludeOnly is None:\r |
7ccc9c95 | 97 | options.IncludeOnly = False\r |
72443dd2 | 98 | print("Warning: Assume generate package document for all package\'s source including publich interfaces and implementation libraries and modules.")\r |
7ccc9c95 YZ |
99 | \r |
100 | if options.DocumentMode.lower() == 'chm':\r | |
101 | default = "C:\\Program Files\\HTML Help Workshop\\hhc.exe"\r | |
4231a819 | 102 | if options.HtmlWorkshopPath is None:\r |
7ccc9c95 | 103 | if os.path.exists(default):\r |
72443dd2 | 104 | print('Warning: Assume the installation path of Microsoft HTML Workshop is %s. If not, specify via option -c.' % default)\r |
7ccc9c95 YZ |
105 | options.HtmlWorkshopPath = default\r |
106 | else:\r | |
107 | errors.append('- Please specify the installation path of Microsoft HTML Workshop via option -c!')\r | |
108 | elif not os.path.exists(options.HtmlWorkshopPath):\r | |
109 | errors.append('- The installation path of Microsoft HTML Workshop %s does not exists. ' % options.HtmlWorkshopPath)\r | |
110 | \r | |
111 | if len(errors) != 0:\r | |
72443dd2 | 112 | print('\n')\r |
7ccc9c95 YZ |
113 | parser.error('Fail to start due to following reasons: \n%s' %'\n'.join(errors))\r |
114 | return (options.WorkspacePath, options.PackagePath, options.DoxygenPath, options.OutputPath,\r | |
115 | options.Arch, options.DocumentMode, options.IncludeOnly, options.HtmlWorkshopPath)\r | |
116 | \r | |
117 | def createPackageObject(wsPath, pkgPath):\r | |
118 | try:\r | |
119 | pkgObj = baseobject.Package(None, wsPath)\r | |
120 | pkgObj.Load(pkgPath)\r | |
121 | except:\r | |
122 | logging.getLogger().error ('Fail to create package object!')\r | |
123 | return None\r | |
124 | \r | |
125 | return pkgObj\r | |
126 | \r | |
127 | def callbackLogMessage(msg, level):\r | |
72443dd2 | 128 | print(msg.strip())\r |
7ccc9c95 YZ |
129 | \r |
130 | def callbackCreateDoxygenProcess(doxPath, configPath):\r | |
131 | if sys.platform == 'win32':\r | |
132 | cmd = '"%s" %s' % (doxPath, configPath)\r | |
133 | else:\r | |
134 | cmd = '%s %s' % (doxPath, configPath)\r | |
72443dd2 | 135 | print(cmd)\r |
7ccc9c95 YZ |
136 | subprocess.call(cmd, shell=True)\r |
137 | \r | |
138 | \r | |
139 | def DocumentFixup(outPath, arch):\r | |
140 | # find BASE_LIBRARY_JUMP_BUFFER structure reference page\r | |
141 | \r | |
72443dd2 | 142 | print('\n >>> Start fixup document \n')\r |
7ccc9c95 YZ |
143 | \r |
144 | for root, dirs, files in os.walk(outPath):\r | |
145 | for dir in dirs:\r | |
146 | if dir.lower() in ['.svn', '_svn', 'cvs']:\r | |
147 | dirs.remove(dir)\r | |
148 | for file in files:\r | |
149 | if not file.lower().endswith('.html'): continue\r | |
150 | fullpath = os.path.join(outPath, root, file)\r | |
151 | try:\r | |
152 | f = open(fullpath, 'r')\r | |
153 | text = f.read()\r | |
154 | f.close()\r | |
155 | except:\r | |
156 | logging.getLogger().error('\nFail to open file %s\n' % fullpath)\r | |
157 | continue\r | |
158 | if arch.lower() == 'all':\r | |
159 | if text.find('BASE_LIBRARY_JUMP_BUFFER Struct Reference') != -1:\r | |
160 | FixPageBASE_LIBRARY_JUMP_BUFFER(fullpath, text)\r | |
161 | if text.find('MdePkg/Include/Library/BaseLib.h File Reference') != -1:\r | |
162 | FixPageBaseLib(fullpath, text)\r | |
163 | if text.find('IA32_IDT_GATE_DESCRIPTOR Union Reference') != -1:\r | |
164 | FixPageIA32_IDT_GATE_DESCRIPTOR(fullpath, text)\r | |
165 | if text.find('MdePkg/Include/Library/UefiDriverEntryPoint.h File Reference') != -1:\r | |
166 | FixPageUefiDriverEntryPoint(fullpath, text)\r | |
167 | if text.find('MdePkg/Include/Library/UefiApplicationEntryPoint.h File Reference') != -1:\r | |
168 | FixPageUefiApplicationEntryPoint(fullpath, text)\r | |
169 | \r | |
72443dd2 | 170 | print(' >>> Finish all document fixing up! \n')\r |
7ccc9c95 YZ |
171 | \r |
172 | def FixPageBaseLib(path, text):\r | |
72443dd2 | 173 | print(' >>> Fixup BaseLib file page at file %s \n' % path)\r |
7ccc9c95 YZ |
174 | lines = text.split('\n')\r |
175 | lastBaseJumpIndex = -1\r | |
176 | lastIdtGateDescriptor = -1\r | |
177 | for index in range(len(lines) - 1, -1, -1):\r | |
178 | line = lines[index]\r | |
179 | if line.strip() == '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4 </td>':\r | |
180 | lines[index] = '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4 [IA32] </td>'\r | |
181 | if line.strip() == '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10 </td>':\r | |
182 | lines[index] = '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10 [IPF] </td>'\r | |
183 | if line.strip() == '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8 </td>':\r | |
184 | lines[index] = '<td class="memname">#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 9 [EBC, x64] </td>'\r | |
185 | if line.find('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a> 4') != -1:\r | |
186 | lines[index] = lines[index].replace('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a> 4',\r | |
187 | 'BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a> 4 [IA32]')\r | |
188 | if line.find('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a> 0x10') != -1:\r | |
189 | lines[index] = lines[index].replace('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a> 0x10',\r | |
190 | 'BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a> 0x10 [IPF]')\r | |
191 | if line.find('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a> 8') != -1:\r | |
192 | lines[index] = lines[index].replace('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a> 8',\r | |
193 | 'BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT</a> 8 [x64, EBC]')\r | |
194 | if line.find('>BASE_LIBRARY_JUMP_BUFFER</a>') != -1:\r | |
195 | if lastBaseJumpIndex != -1:\r | |
196 | del lines[lastBaseJumpIndex]\r | |
197 | lastBaseJumpIndex = index\r | |
198 | if line.find('>IA32_IDT_GATE_DESCRIPTOR</a></td>') != -1:\r | |
199 | if lastIdtGateDescriptor != -1:\r | |
200 | del lines[lastIdtGateDescriptor]\r | |
201 | lastIdtGateDescriptor = index\r | |
202 | try:\r | |
203 | f = open(path, 'w')\r | |
204 | f.write('\n'.join(lines))\r | |
205 | f.close()\r | |
206 | except:\r | |
207 | logging.getLogger().error(" <<< Fail to fixup file %s\n" % path)\r | |
208 | return\r | |
72443dd2 | 209 | print(" <<< Finish to fixup file %s\n" % path)\r |
7ccc9c95 YZ |
210 | \r |
211 | def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text):\r | |
72443dd2 | 212 | print(' >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file %s \n' % path)\r |
7ccc9c95 YZ |
213 | lines = text.split('\n')\r |
214 | for index in range(len(lines) - 1, -1, -1):\r | |
215 | line = lines[index].strip()\r | |
216 | if line.find('struct {</td>') != -1 and lines[index - 2].find('>Uint64</a></td>') != -1:\r | |
217 | lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For X64</h2></td></tr>')\r | |
218 | if line.find('struct {</td>') != -1 and lines[index - 1].find('Data Fields') != -1:\r | |
219 | lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For IA32</h2></td></tr>')\r | |
220 | try:\r | |
221 | f = open(path, 'w')\r | |
222 | f.write('\n'.join(lines))\r | |
223 | f.close()\r | |
224 | except:\r | |
225 | logging.getLogger().error(" <<< Fail to fixup file %s\n" % path)\r | |
226 | return\r | |
72443dd2 | 227 | print(" <<< Finish to fixup file %s\n" % path)\r |
7ccc9c95 YZ |
228 | \r |
229 | def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text):\r | |
72443dd2 | 230 | print(' >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file %s \n' % path)\r |
7ccc9c95 YZ |
231 | lines = text.split('\n')\r |
232 | bInDetail = True\r | |
233 | bNeedRemove = False\r | |
234 | for index in range(len(lines) - 1, -1, -1):\r | |
235 | line = lines[index]\r | |
236 | if line.find('Detailed Description') != -1:\r | |
237 | bInDetail = False\r | |
238 | if line.startswith('EBC context buffer used by') and lines[index - 1].startswith('x64 context buffer'):\r | |
239 | lines[index] = "IA32/IPF/X64/" + line\r | |
240 | bNeedRemove = True\r | |
241 | if line.startswith("x64 context buffer") or line.startswith('IPF context buffer used by') or \\r | |
242 | line.startswith('IA32 context buffer used by'):\r | |
243 | if bNeedRemove:\r | |
244 | lines.remove(line)\r | |
245 | if line.find('>R0</a>') != -1 and not bInDetail:\r | |
246 | if lines[index - 1] != '<tr><td colspan="2"><br><h2>Data Fields For EBC</h2></td></tr>':\r | |
247 | lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For EBC</h2></td></tr>')\r | |
248 | if line.find('>Rbx</a>') != -1 and not bInDetail:\r | |
249 | if lines[index - 1] != '<tr><td colspan="2"><br><h2>Data Fields For X64</h2></td></tr>':\r | |
250 | lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For X64</h2></td></tr>')\r | |
251 | if line.find('>F2</a>') != -1 and not bInDetail:\r | |
252 | if lines[index - 1] != '<tr><td colspan="2"><br><h2>Data Fields For IPF</h2></td></tr>':\r | |
253 | lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For IPF</h2></td></tr>')\r | |
254 | if line.find('>Ebx</a>') != -1 and not bInDetail:\r | |
255 | if lines[index - 1] != '<tr><td colspan="2"><br><h2>Data Fields For IA32</h2></td></tr>':\r | |
256 | lines.insert(index, '<tr><td colspan="2"><br><h2>Data Fields For IA32</h2></td></tr>')\r | |
257 | try:\r | |
258 | f = open(path, 'w')\r | |
259 | f.write('\n'.join(lines))\r | |
260 | f.close()\r | |
261 | except:\r | |
262 | logging.getLogger().error(" <<< Fail to fixup file %s" % path)\r | |
263 | return\r | |
72443dd2 | 264 | print(" <<< Finish to fixup file %s\n" % path)\r |
7ccc9c95 YZ |
265 | \r |
266 | def FixPageUefiDriverEntryPoint(path, text):\r | |
72443dd2 | 267 | print(' >>> Fixup file reference MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path)\r |
7ccc9c95 YZ |
268 | lines = text.split('\n')\r |
269 | bInModuleEntry = False\r | |
270 | bInEfiMain = False\r | |
271 | ModuleEntryDlCount = 0\r | |
272 | ModuleEntryDelStart = 0\r | |
273 | ModuleEntryDelEnd = 0\r | |
274 | EfiMainDlCount = 0\r | |
275 | EfiMainDelStart = 0\r | |
276 | EfiMainDelEnd = 0\r | |
277 | \r | |
278 | for index in range(len(lines)):\r | |
279 | line = lines[index].strip()\r | |
280 | if line.find('EFI_STATUS</a> EFIAPI _ModuleEntryPoint </td>') != -1:\r | |
281 | bInModuleEntry = True\r | |
282 | if line.find('EFI_STATUS</a> EFIAPI EfiMain </td>') != -1:\r | |
283 | bInEfiMain = True\r | |
284 | if line.startswith('<p>References <a'):\r | |
285 | if bInModuleEntry:\r | |
286 | ModuleEntryDelEnd = index - 1\r | |
287 | bInModuleEntry = False\r | |
288 | elif bInEfiMain:\r | |
289 | EfiMainDelEnd = index - 1\r | |
290 | bInEfiMain = False\r | |
291 | if bInModuleEntry:\r | |
292 | if line.startswith('</dl>'):\r | |
293 | ModuleEntryDlCount = ModuleEntryDlCount + 1\r | |
294 | if ModuleEntryDlCount == 1:\r | |
295 | ModuleEntryDelStart = index + 1\r | |
296 | if bInEfiMain:\r | |
297 | if line.startswith('</dl>'):\r | |
298 | EfiMainDlCount = EfiMainDlCount + 1\r | |
299 | if EfiMainDlCount == 1:\r | |
300 | EfiMainDelStart = index + 1\r | |
301 | \r | |
302 | if EfiMainDelEnd > EfiMainDelStart:\r | |
303 | for index in range(EfiMainDelEnd, EfiMainDelStart, -1):\r | |
304 | del lines[index]\r | |
305 | if ModuleEntryDelEnd > ModuleEntryDelStart:\r | |
306 | for index in range(ModuleEntryDelEnd, ModuleEntryDelStart, -1):\r | |
307 | del lines[index]\r | |
308 | \r | |
309 | try:\r | |
310 | f = open(path, 'w')\r | |
311 | f.write('\n'.join(lines))\r | |
312 | f.close()\r | |
313 | except:\r | |
314 | logging.getLogger().error(" <<< Fail to fixup file %s" % path)\r | |
315 | return\r | |
72443dd2 | 316 | print(" <<< Finish to fixup file %s\n" % path)\r |
7ccc9c95 YZ |
317 | \r |
318 | \r | |
319 | def FixPageUefiApplicationEntryPoint(path, text):\r | |
72443dd2 | 320 | print(' >>> Fixup file reference MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path)\r |
7ccc9c95 YZ |
321 | lines = text.split('\n')\r |
322 | bInModuleEntry = False\r | |
323 | bInEfiMain = False\r | |
324 | ModuleEntryDlCount = 0\r | |
325 | ModuleEntryDelStart = 0\r | |
326 | ModuleEntryDelEnd = 0\r | |
327 | EfiMainDlCount = 0\r | |
328 | EfiMainDelStart = 0\r | |
329 | EfiMainDelEnd = 0\r | |
330 | \r | |
331 | for index in range(len(lines)):\r | |
332 | line = lines[index].strip()\r | |
333 | if line.find('EFI_STATUS</a> EFIAPI _ModuleEntryPoint </td>') != -1:\r | |
334 | bInModuleEntry = True\r | |
335 | if line.find('EFI_STATUS</a> EFIAPI EfiMain </td>') != -1:\r | |
336 | bInEfiMain = True\r | |
337 | if line.startswith('<p>References <a'):\r | |
338 | if bInModuleEntry:\r | |
339 | ModuleEntryDelEnd = index - 1\r | |
340 | bInModuleEntry = False\r | |
341 | elif bInEfiMain:\r | |
342 | EfiMainDelEnd = index - 1\r | |
343 | bInEfiMain = False\r | |
344 | if bInModuleEntry:\r | |
345 | if line.startswith('</dl>'):\r | |
346 | ModuleEntryDlCount = ModuleEntryDlCount + 1\r | |
347 | if ModuleEntryDlCount == 1:\r | |
348 | ModuleEntryDelStart = index + 1\r | |
349 | if bInEfiMain:\r | |
350 | if line.startswith('</dl>'):\r | |
351 | EfiMainDlCount = EfiMainDlCount + 1\r | |
352 | if EfiMainDlCount == 1:\r | |
353 | EfiMainDelStart = index + 1\r | |
354 | \r | |
355 | if EfiMainDelEnd > EfiMainDelStart:\r | |
356 | for index in range(EfiMainDelEnd, EfiMainDelStart, -1):\r | |
357 | del lines[index]\r | |
358 | if ModuleEntryDelEnd > ModuleEntryDelStart:\r | |
359 | for index in range(ModuleEntryDelEnd, ModuleEntryDelStart, -1):\r | |
360 | del lines[index]\r | |
361 | \r | |
362 | try:\r | |
363 | f = open(path, 'w')\r | |
364 | f.write('\n'.join(lines))\r | |
365 | f.close()\r | |
366 | except:\r | |
367 | logging.getLogger().error(" <<< Fail to fixup file %s" % path)\r | |
368 | return\r | |
72443dd2 | 369 | print(" <<< Finish to fixup file %s\n" % path)\r |
7ccc9c95 YZ |
370 | \r |
371 | if __name__ == '__main__':\r | |
372 | wspath, pkgpath, doxpath, outpath, archtag, docmode, isinc, hwpath = parseCmdArgs()\r | |
373 | \r | |
374 | # configure logging system\r | |
375 | logfilepath = os.path.join(outpath, 'log.txt')\r | |
376 | logging.basicConfig(format='%(levelname)-8s %(message)s', level=logging.DEBUG)\r | |
377 | \r | |
378 | # create package model object firstly\r | |
379 | pkgObj = createPackageObject(wspath, pkgpath)\r | |
4231a819 | 380 | if pkgObj is None:\r |
7ccc9c95 YZ |
381 | sys.exit(-1)\r |
382 | \r | |
383 | # create doxygen action model\r | |
384 | arch = None\r | |
385 | tooltag = None\r | |
386 | if archtag.lower() != 'all':\r | |
387 | arch = archtag.split('_')[0]\r | |
388 | tooltag = archtag.split('_')[1]\r | |
389 | else:\r | |
390 | arch = 'all'\r | |
391 | tooltag = 'all'\r | |
392 | \r | |
393 | # preprocess package and call doxygen\r | |
394 | try:\r | |
395 | action = doxygengen.PackageDocumentAction(doxpath,\r | |
396 | hwpath,\r | |
397 | outpath,\r | |
398 | pkgObj,\r | |
399 | docmode,\r | |
400 | callbackLogMessage,\r | |
401 | arch,\r | |
402 | tooltag,\r | |
403 | isinc,\r | |
404 | True)\r | |
405 | action.RegisterCallbackDoxygenProcess(callbackCreateDoxygenProcess)\r | |
406 | action.Generate()\r | |
407 | except:\r | |
408 | message = traceback.format_exception(*sys.exc_info())\r | |
409 | logging.getLogger().error('Fail to create doxygen action! \n%s' % ''.join(message))\r | |
410 | sys.exit(-1)\r | |
411 | \r | |
412 | DocumentFixup(outpath, arch)\r | |
413 | \r | |
414 | # generate CHM is necessary\r | |
415 | if docmode.lower() == 'chm':\r | |
416 | indexpath = os.path.join(outpath, 'html', 'index.hhp')\r | |
417 | if sys.platform == 'win32':\r | |
418 | cmd = '"%s" %s' % (hwpath, indexpath)\r | |
419 | else:\r | |
420 | cmd = '%s %s' % (hwpath, indexpath)\r | |
421 | subprocess.call(cmd)\r | |
72443dd2 | 422 | print('\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.chm'))\r |
7ccc9c95 | 423 | else:\r |
72443dd2 | 424 | print('\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.html'))\r |