forked from robin-raymond/zsLib-eventing
-
Notifications
You must be signed in to change notification settings - Fork 4
/
runIDLCompiler.py
67 lines (48 loc) · 1.81 KB
/
runIDLCompiler.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import sys
dir_path = os.path.dirname(os.path.realpath(__file__))
inputArray=sys.argv
idlPath=inputArray[1]
idlAlreadyCompletedFlagFile=inputArray[2]
toolchainCPU=inputArray[3]
idlOutputPath=inputArray[4]
idlLanguages=inputArray[5]
hostCPU=inputArray[6]
def getCompilerPath():
compilerNewPath = os.getcwd() + "/" + compilerPath;
if os.path.isfile(compilerNewPath):
return compilerNewPath
compilerNewPath = os.getcwd() + "/" + toolchainCPU + "/" + compilerPath;
if os.path.isfile(compilerNewPath):
return compilerNewPath
compilerNewPath = os.getcwd() + "/" + hostCPU + "/" + compilerPath;
if os.path.isfile(compilerNewPath):
return compilerNewPath
return
if (os.name == "posix"):
compilerPath="zslib-eventing-tool-compiler"
else:
compilerPath="zslib-eventing-tool-compiler.exe"
currentWorkingPath=os.getcwd()
pathname = os.path.dirname(sys.argv[0])
idlCompilationFlagPath=dir_path + "/" + idlAlreadyCompletedFlagFile
if not os.path.isfile(idlCompilationFlagPath):
print("Running idls compilation...")
compilerFullPath = getCompilerPath()
if (compilerFullPath==None):
sys.exit("Idl compiler doesn't exist")
os.chdir(os.path.dirname(idlPath))
jsonFile=os.path.basename(idlPath)
useImplFlag = os.getenv('IDL_COMPILER_IMPL', None)
if useImplFlag:
commandToExecute = compilerFullPath + " -idl " + idlLanguages + " impl -c " + jsonFile + " -o " + idlOutputPath
else:
commandToExecute = compilerFullPath + " -idl " + idlLanguages + " -c " + jsonFile + " -o " + idlOutputPath
print("commandToExecute:" + commandToExecute)
result = os.system(commandToExecute)
if result == 0:
open(idlCompilationFlagPath,'w').close()
else:
sys.exit("Failed idls compilation with error code " + str(result))
else:
print("Idls have been already compiled")