source: mainline/tools/jobfile.py@ 4dd3912

Last change on this file since 4dd3912 was 4dd3912, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update python scripts

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!/usr/bin/env python
2#
3# SPDX-FileCopyrightText: 2009 Martin Decky
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8"""
9Add a source/object file pair to a checker jobfile
10"""
11
12import sys
13import os
14import fcntl
15
16def usage(prname):
17 "Print usage syntax"
18 print(prname + " <JOBFILE> <CC> <INPUT> -o <OUTPUT> [CC_ARGUMENTS ...]")
19
20def main():
21 if (len(sys.argv) < 6):
22 usage(sys.argv[0])
23 return
24
25 jobfname = sys.argv[1]
26 ccname = sys.argv[2]
27 srcfname = sys.argv[3]
28 assert(not srcfname.startswith("-"))
29 assert(sys.argv[4] == "-o")
30 tgtfname = sys.argv[5]
31 options = " ".join(sys.argv[6:])
32 cwd = os.getcwd()
33
34 if srcfname.endswith(".c"):
35 toolname = "cc"
36 category = "core"
37
38 if srcfname.endswith(".s"):
39 toolname = "as"
40 category = "asm"
41
42 if srcfname.endswith(".S"):
43 toolname = "as"
44 category = "asm/preproc"
45
46 jobfile = open(jobfname, "a")
47 fcntl.lockf(jobfile, fcntl.LOCK_EX)
48 jobfile.write("{%s},{%s},{%s},{%s},{%s},{%s}\n" % (srcfname, tgtfname, toolname, category, cwd, options))
49 fcntl.lockf(jobfile, fcntl.LOCK_UN)
50 jobfile.close()
51
52 # Run the compiler proper.
53 os.execvp(ccname, sys.argv[2:])
54
55if __name__ == '__main__':
56 main()
Note: See TracBrowser for help on using the repository browser.