forked from ome/openmicroscopy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.py
executable file
·115 lines (99 loc) · 3.13 KB
/
build.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python
#
# $Id$
#
# Copyright 2009 Glencoe Software, Inc. All rights reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
# General build scripts.
import os
import sys
import subprocess
def build_hudson():
"""
Top-level build called by hudson for testing all components,
generating documentation, etc.
"""
#
# Cleaning to prevent strange hudson errors about
# stale tests and general weirdness.
#
java_omero("clean")
# Build & Test
java_omero("build-all")
java_omero("test-integration")
java_omero("test-dist")
#
# Documentation and build reports
#
java_omero("release-docs")
java_omero("release-findbugs")
## java_omero("release-jdepend") ## Doesn't yet work. Running from hudson
#
# Prepare a distribution
#
"rm -f OMERO.server-build*.zip"
java_omero(["-f","components/tools/OmeroImporter/build.xml","release-win-zip"])
java_omero(["-f","components/tools/OmeroImporter/build.xml","release-osx-zip"])
java_omero("release-zip")
# Install into the hudson repository
## Disabling until 4.1 with more work
## on integration
##java_omero("release-hudson")
def java_omero(args):
command = [ find_java() ]
p = os.path.join( os.path.curdir, "lib", "log4j-build.xml")
command.append("-Dlog4j.configuration=%s" % p)
command.extend( calculate_memory_args() )
command.extend(["omero"])
command.extend(choose_omero_version())
if isinstance(args,str):
command.append(args)
else:
command.extend(args)
execute(command)
def find_java():
return "java"
def calculate_memory_args():
return "-Xmx600M -Djavac.maxmem=600M -Djavadoc.maxmem=600M -XX:MaxPermSize=256m".split(" ")
def choose_omero_version():
"""
Returns an array specifying the build parameter for
ant. Returned as an array so that an empty value can
be extended into the build command.
If OMERO_BULID is set, then "-Domero.version=${omero-version}-${OMERO_BUILD}"
otherwise nothing.
"""
try:
omero_build = os.environ["OMERO_BUILD"]
command = [ find_java(), "omero","-q","version" ]
try:
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
omero_version,err = p.communicate()
omero_version = omero_version.split()[1]
return [ "-Domero.version=%s-%s" % (omero_version, omero_build) ]
except:
print "Error getting version for OMERO_BUILD=%s" % omero_build
print err
except KeyError, ke:
return [] # Use default
def execute(args):
rc = subprocess.call(args)
if rc != 0:
sys.exit(rc)
if __name__ == "__main__":
#
# If this is a hudson build, then call the special build_hudson
# method. Otherwise, use java_omero which will specially configure
# the build system.
#
args = list(sys.argv)
args.pop(0)
try:
if len(args) > 0 and args[0] == "-hudson":
build_hudson()
else:
java_omero(args)
except KeyboardInterrupt:
sys.stderr.write("\nCancelled by user\n")
sys.exit(2)