Script xalt_generate_assembly_in_py
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 from __future__ import print_function
27 import os, sys, time, platform
28
29 dirNm, execName = os.path.split(os.path.realpath(sys.argv[0]))
30 sys.path.insert(1,os.path.realpath(os.path.join(dirNm, "../libexec")))
31 sys.path.insert(1,os.path.realpath(os.path.join(dirNm, "../site")))
32
33 from xalt_util import config_logger, extract_compiler
34
35 logger = config_logger()
36
38 """
39 Build the XALT assembly code
40
41 @param uuid: UUID string
42 @param fn: The output file name
43 @param version: Current XALT version
44 @param syshost: System name (darter, stampede), not login1.stampede.tacc.utexas.edu
45 @param compiler: the name of the linking compiler
46 @param epochStr: Current Timestamp
47 """
48 user = os.environ.get("USER","unknown")
49 osName = platform.system() + "_%_%_" + platform.release()
50
51 year = time.strftime("%Y")
52 date = time.strftime("%c").replace(" ","_%_%_")
53
54 try:
55 f = open(fn,"w")
56 f.writelines("\t.section .xalt\n")
57 f.writelines("\t.asciz \"XALT_Link_Info\"\n")
58
59 f.writelines("\n\t.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n")
60 f.writelines("\t.asciz \"<XALT_Version>%%"+version+"%%\"\n")
61 f.writelines("\t.asciz \"<Build.Syshost>%%"+syshost+"%%\"\n")
62 f.writelines("\t.asciz \"<Build.compiler>%%"+compiler+"%%\"\n")
63 f.writelines("\t.asciz \"<Build.OS>%%"+osName+"%%\"\n")
64 f.writelines("\t.asciz \"<Build.User>%%"+user+"%%\"\n")
65 f.writelines("\t.asciz \"<Build.UUID>%%"+uuid+"%%\"\n")
66 f.writelines("\t.asciz \"<Build.Year>%%"+year+"%%\"\n")
67 f.writelines("\t.asciz \"<Build.date>%%"+date+"%%\"\n")
68 f.writelines("\t.asciz \"<Build.Epoch>%%"+epochStr+"%%\"\n")
69 f.writelines("\t.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n")
70 f.writelines("\t.asciz \"XALT_Link_Info_End\"\n")
71 except:
72 logger.exception("XALT_EXCEPTION:print_assembly")
73
74
76 """ Generate XALT assembly code """
77 try:
78 uuid = sys.argv[1]
79 syshost = sys.argv[2]
80 pstree = sys.argv[3]
81 fn = sys.argv[4]
82 version = "@version@"
83 epochStr = str(time.time())
84
85 compiler = extract_compiler(pstree)
86
87 print_assembly(uuid, fn, version, syshost, compiler, epochStr)
88
89 print(epochStr)
90 except:
91 logger.exception("XALT_EXCEPTION:xalt_generate_assembly")
92
93
94 if ( __name__ == '__main__'): main()
95