annotate lib/swig/swigwin-2.0.11/Tools/mkdist.py @ 1933:5fcf6023f9c3

DamageMonsterFromParty some additional vars removed, changed the ordering part to something more readable
author Grumpy7
date Wed, 23 Oct 2013 21:13:28 -0700
parents b3009adc0e2f
children
rev   line source
1899
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
1 #!/usr/bin/env python
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
2
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
3 # This script builds a swig-x.y.z distribution.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
4 # Usage : mkdist.py version, where version should be x.y.z
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
5
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
6 import sys
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
7 import string
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
8 import os
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
9 import subprocess
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
10
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
11 def failed():
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
12 print "mkdist.py failed to complete"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
13 sys.exit(2)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
14
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
15
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
16 try:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
17 version = sys.argv[1]
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
18 dirname = "swig-" + version
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
19 except:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
20 print "Usage: mkdist.py version, where version should be x.y.z"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
21 sys.exit(1)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
22
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
23 # Check name matches normal unix conventions
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
24 if string.lower(dirname) != dirname:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
25 print "directory name ("+dirname+") should be in lowercase"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
26 sys.exit(3)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
27
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
28 # If directory and tarball exist, remove it
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
29 print "Removing ", dirname
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
30 os.system("rm -rf "+dirname)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
31
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
32 print "Removing "+dirname+".tar if exists"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
33 os.system("rm -f "+dirname+".tar.gz")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
34
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
35 print "Removing "+dirname+".tar.gz if exists"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
36 os.system("rm -f "+dirname+".tar")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
37
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
38 # Grab the code from git
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
39
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
40 print "Checking git repository is in sync with remote repository"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
41 os.system("git remote update") == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
42 command = ["git", "status", "--porcelain", "-uno"]
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
43 out = subprocess.check_output(command)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
44 if out.strip() != "":
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
45 print "Local git repository has modifications"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
46 print " ".join(command)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
47 print out
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
48 sys.exit(3)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
49
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
50 command = ["git", "log", "--oneline", "master..origin/master"]
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
51 out = subprocess.check_output(command)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
52 if out.strip() != "":
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
53 print "Remote repository has additional modifications to local repository"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
54 print " ".join(command)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
55 print out
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
56 sys.exit(3)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
57
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
58 command = ["git", "log", "--oneline", "origin/master..master"]
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
59 out = subprocess.check_output(command)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
60 if out.strip() != "":
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
61 print "Local repository has modifications not pushed to the remote repository"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
62 print "These should be pushed and checked that they pass Continuous Integration testing before continuing"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
63 print " ".join(command)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
64 print out
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
65 sys.exit(3)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
66
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
67 print "Tagging release"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
68 tag = "'rel-" + version + "'"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
69 os.system("git tag -a -m " + tag + " " + tag) == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
70
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
71 outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
72 print "Grabbing tagged release git repository using 'git archive' into " + outdir
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
73 os.system("(cd .. && git archive --prefix=" + outdir + " " + tag + " . | tar -xf -)") == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
74
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
75 # Remove the debian directory -- it's not official
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
76
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
77 os.system("rm -Rf "+dirname+"/debian") == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
78
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
79 # Go build the system
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
80
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
81 print "Building system"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
82 os.system("cd "+dirname+" && ./autogen.sh") == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
83 os.system("cd "+dirname+"/Source/CParse && bison -y -d parser.y && mv y.tab.c parser.c && mv y.tab.h parser.h") == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
84 os.system("cd "+dirname+" && make -f Makefile.in libfiles srcdir=./") == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
85
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
86 # Remove autoconf files
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
87 os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
88
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
89 # Build documentation
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
90 print "Building html documentation"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
91 os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
92 print "Building man pages"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
93 os.system("cd "+dirname+"/CCache && yodl2man -o ccache-swig.1 ccache.yo") == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
94
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
95 # Build the tar-ball
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
96 os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
97 os.system("gzip "+dirname+".tar") == 0 or failed()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
98
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
99 print "Finished building "+dirname+".tar.gz"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
100