| 1 |
import os,shutil |
| 2 |
import sys |
| 3 |
|
| 4 |
import os |
| 5 |
from sys import platform |
| 6 |
|
| 7 |
class WinKernel2Source(object): |
| 8 |
def __init__(self, component='vp'): |
| 9 |
self.input_dir = '.\\' |
| 10 |
self.bin_dir ='.\\compile' |
| 11 |
self.component = 'vp' |
| 12 |
self.bintool = 'GenKrnBin.exe' |
| 13 |
self.sourcetool = 'KernelBinToSource.exe' |
| 14 |
|
| 15 |
def iga_compile(self): |
| 16 |
for filename in os.listdir('.\\Source'): |
| 17 |
fp = os.path.join('.\\Source', filename) |
| 18 |
fileext = os.path.splitext(filename)[1] |
| 19 |
if os.path.isfile(fp) and 'asm' in fileext: |
| 20 |
newfilename = os.path.splitext(filename)[0] |
| 21 |
newfilename += '.krn' |
| 22 |
newfp = os.path.join('.\\Source', newfilename) |
| 23 |
command = '.\\compile\\IGA\\iga64.exe -p 11 -a ' |
| 24 |
command += fp |
| 25 |
command += ' -o ' |
| 26 |
command += newfp; |
| 27 |
os.system(command) |
| 28 |
|
| 29 |
command_Hex = '.\\compile\\KrnToHex_IGA.exe ' |
| 30 |
command_Hex += newfp; |
| 31 |
os.system(command_Hex) |
| 32 |
|
| 33 |
hexfilename = os.path.splitext(filename)[0] |
| 34 |
hexfilename += '.hex' |
| 35 |
hexfp = os.path.join(".\\Source", hexfilename) |
| 36 |
|
| 37 |
isExists=os.path.exists("component_release") |
| 38 |
|
| 39 |
if not isExists: |
| 40 |
os.mkdir("component_release") |
| 41 |
|
| 42 |
shutil.copy(hexfp, "component_release") |
| 43 |
|
| 44 |
os.remove(newfp) |
| 45 |
os.remove(hexfp) |
| 46 |
|
| 47 |
print("Compiled %s" % fp); |
| 48 |
|
| 49 |
def kernel2bin(self): |
| 50 |
cmd = '.\\compile\\GenKrnBin.exe component_release vp' |
| 51 |
os.system(cmd) |
| 52 |
|
| 53 |
def bin2source(self): |
| 54 |
cmd = '.\\compile\\KernelBinToSource.exe -i .\\component_release\\igvpkrn_g11_icllp.bin -o .\\' |
| 55 |
os.system(cmd) |
| 56 |
os.remove(r'..\\..\\..\\..\\..\\media_common\\agnostic\\common\\vp\\kernel\\vpkrnheader.h') |
| 57 |
os.rename('.\\component_release\\igvpkrn_g11_icllp.h', '..\\..\\..\\..\\..\\media_common\\agnostic\\common\\vp\\kernel\\vpkrnheader.h') |
| 58 |
os.remove(r'.\\component_release\\igvpkrn_g11_icllp.bin') |
| 59 |
|
| 60 |
class LinuxKernel2Source(object): |
| 61 |
def __init__(self, component='vp'): |
| 62 |
self.input_dir = './' |
| 63 |
self.bin_dir ='./compile' |
| 64 |
self.component = 'vp' |
| 65 |
self.bintool = 'GenKrnBin' |
| 66 |
self.sourcetool = 'KernelBinToSource' |
| 67 |
|
| 68 |
def iga_compile(self): |
| 69 |
for filename in os.listdir('./Source'): |
| 70 |
fp = os.path.join('./Source', filename) |
| 71 |
fileext = os.path.splitext(filename)[1] |
| 72 |
if os.path.isfile(fp) and 'asm' in fileext: |
| 73 |
newfilename = os.path.splitext(filename)[0] |
| 74 |
newfilename += '.krn' |
| 75 |
newfp = os.path.join('./Source', newfilename) |
| 76 |
command = './compile/IGA/iga64.exe -p 11 -a ' |
| 77 |
command += fp |
| 78 |
command += ' -o ' |
| 79 |
command += newfp; |
| 80 |
os.system(command) |
| 81 |
|
| 82 |
command_Hex = './compile/KrnToHex_IGA ' |
| 83 |
command_Hex += newfp; |
| 84 |
os.system(command_Hex) |
| 85 |
|
| 86 |
print ('test') |
| 87 |
|
| 88 |
hexfilename = os.path.splitext(filename)[0] |
| 89 |
hexfilename += '.hex' |
| 90 |
hexfp = os.path.join("./Source", hexfilename) |
| 91 |
|
| 92 |
isExists=os.path.exists("component_release") |
| 93 |
|
| 94 |
if not isExists: |
| 95 |
os.mkdir("component_release") |
| 96 |
|
| 97 |
shutil.copy(hexfp, "component_release") |
| 98 |
|
| 99 |
os.remove(newfp) |
| 100 |
os.remove(hexfp) |
| 101 |
|
| 102 |
print("Compiled %s" % fp); |
| 103 |
|
| 104 |
def kernel2bin(self): |
| 105 |
cmd = './compile/GenKrnBin component_release vp' |
| 106 |
os.system(cmd) |
| 107 |
|
| 108 |
def bin2source(self): |
| 109 |
cmd = './compile/KernelBinToSource -i ./component_release/igvpkrn_g11_icllp.bin -o ./' |
| 110 |
os.system(cmd) |
| 111 |
os.remove(r'../../../../../media_common/agnostic/common/vp/kernel/vpkrnheader.h') |
| 112 |
os.rename('./component_release/igvpkrn_g11_icllp.h', '../../../../../media_common/agnostic/common/vp/kernel/vpkrnheader.h') |
| 113 |
os.remove(r'./component_release/igvpkrn_g11_icllp.bin') |
| 114 |
|
| 115 |
def main(): |
| 116 |
if platform == "linux" or platform == "linux2": |
| 117 |
k2s = LinuxKernel2Source() |
| 118 |
else: |
| 119 |
k2s = WinKernel2Source() |
| 120 |
|
| 121 |
k2s.iga_compile() |
| 122 |
k2s.kernel2bin() |
| 123 |
k2s.bin2source() |
| 124 |
|
| 125 |
if __name__=='__main__': |
| 126 |
main() |