Browse code

Added command-line option parser and an unsigned build option to build_all.py

Modified win/build_all.py so that it parses command-line options using getopt.
Added option "-u / --unsigned" which allows forcing unsigned builds and a "-h /
--help" option. By default a signed build is generated, provided that the Python
SignTool module is installed. If not, the build is interrupted.

Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Peter Stuge <peter@stuge.se>
Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>

Samuli Seppänen authored on 2010/11/19 01:00:54
Showing 1 changed files
... ...
@@ -1,18 +1,59 @@
1
-from config_all import main as config_all
2
-from build import main as build_openvpn
3
-from build_ddk import main as build_ddk
4
-from sign import main as sign
5
-from make_dist import main as make_dist
6
-
7
-def main(config):
8
-    config_all(config)
9
-    build_openvpn()
10
-    build_ddk(config, 'tap', 'all')
11
-    build_ddk(config, 'tapinstall', 'all')
12
-    sign(config, 'all')
13
-    make_dist(config)
14
-
15
-# if we are run directly, and not loaded as a module
1
+import getopt, sys
2
+from config_all import main as config_all
3
+from build import main as build_openvpn
4
+from build_ddk import main as build_ddk
5
+from make_dist import main as make_dist
6
+
7
+def Usage():
8
+    '''Show usage information'''
9
+    print "Usage: build_all.py [OPTIONS]..."
10
+    print "Build OpenVPN using Visual Studio tools"
11
+    print
12
+    print " -h, --help		Show this help"
13
+    print " -u, --unsigned	Do not sign the TAP drivers"
14
+    sys.exit(1)
15
+
16
+def main(config):
17
+
18
+    # Do a signed build by default
19
+    signedBuild=True
20
+
21
+    # Parse the command line argument(s)
22
+    try:
23
+       opts, args = getopt.getopt(sys.argv[1:], "hu", ["help", "unsigned"])
24
+    except getopt.GetoptError:
25
+       Usage()
26
+
27
+    for o, a in opts:
28
+       if o in ("-h","--help"):
29
+          Usage()
30
+       if o in ("-u", "--unsigned"):
31
+          signedBuild=False
32
+
33
+
34
+    # Check if the SignTool module is present. This avoids ImportErrors popping
35
+    # up annoyingly _after_ the build.
36
+    if signedBuild:
37
+       try:
38
+          from signtool import SignTool
39
+       except (ImportError):
40
+          print "ERROR: SignTool python module not found! Can't do a signed build."
41
+          sys.exit(1)
42
+    else:
43
+       print "Doing an unsigned build as requested"
44
+
45
+    # Start the build
46
+    config_all(config)
47
+    build_openvpn()
48
+    build_ddk(config, 'tap', 'all')
49
+    build_ddk(config, 'tapinstall', 'all')
50
+
51
+    if signedBuild:
52
+       sign(config, 'all')
53
+
54
+    make_dist(config)
55
+
56
+# if we are run directly, and not loaded as a module
16 57
 if __name__ == "__main__":
17 58
     from wb import config
18 59
     main(config)