File: version.cpp.maker.py

package info (click to toggle)
freespace2-launcher-wxlauncher 0.11.0%2Bdfsg-3
  • links: PTS, VCS
  • area: contrib
  • in suites: bullseye
  • size: 2,368 kB
  • sloc: cpp: 13,446; python: 797; makefile: 12; sh: 12
file content (41 lines) | stat: -rw-r--r-- 1,028 bytes parent folder | download | duplicates (4)
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
from optparse import OptionParser
import os.path
import sys

from version_file_builder import VersionFileBuilder

WORKFILE=3
OUTFILE=2
JOB=1

def main(argv):
  parser = OptionParser(usage="%prog <jobtype> <outfile> <workfile> [options]")
  
  parser.add_option("", "--gitpath",
    help="use GITPATH as the executable that will be used to generate the version.cpp file.  Defaults to hg",
    metavar="GITPATH", default="git")

  (options, args) = parser.parse_args(argv)
  
  if len(args) != 4:
    parser.error("Incorrect number of arguments")
  
  work = os.path.normcase(os.path.normpath(args[WORKFILE]))
  file = os.path.normcase(os.path.normpath(args[OUTFILE]))
  
  maker = VersionFileBuilder(work, file, options.gitpath)
  
  if args[JOB] == "build":
    maker.build()
  elif args[JOB] == "rebuild":
    maker.rebuild()
  elif args[JOB] == "clean":
    maker.clean()
  else:
    parser.error("Invalid JOB type. Use build, rebuild, or clean.")
    sys.exit(2)
  
  sys.exit(0)

if __name__ == "__main__":
  main(sys.argv)