forked from ome/openmicroscopy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Building on @rleigh-dundee's recent changes, this refactors the work from build.py into a python script like source-archive. That with the aid of ``` <var name="x" unset="true"/> ``` elements, it's possible to remove the requirement to use build.py.
- Loading branch information
Showing
6 changed files
with
215 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<project name="version" default="version" basedir="."> | ||
<!-- | ||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# | ||
# Copyright 2014 Glencoe Software, Inc. All rights reserved. | ||
# Use is subject to license terms supplied in LICENSE.txt | ||
# | ||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Written by: Josh Moore, josh at glencoesoftware.com | ||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
--> | ||
<description> | ||
Provides git-based version strings. These can be overwritten on the | ||
command-line by setting the following properties: | ||
|
||
omero.version 5.0.0-ice35-b10, etc. | ||
omero.plainversion e.g. 5.0.0-SNAPSHOT | ||
omero.shortversion e.g. 5.0.0 | ||
|
||
The omero.v namespace is for properties internal to this build file | ||
and should not be modified. | ||
</description> | ||
|
||
<property name="omero.v.regexp" value="^(v.)?(.*?)(-[0-9]+)?((-)g(.*?))?$"/> | ||
|
||
<!-- Unset from etc/local.properties --> | ||
<if> | ||
<equals arg1="${omero.version}" arg2="UNKNOWN"/> | ||
<then> | ||
<var name="omero.version" unset="true"/> | ||
</then> | ||
</if> | ||
|
||
<macrodef name="omero_v_was_preset"> | ||
<attribute name="property"/> | ||
<sequential> | ||
<if> | ||
<isset property="@{property}"/> | ||
<then> | ||
<property name="@{property}.source" value="preset"/> | ||
</then> | ||
</if> | ||
</sequential> | ||
</macrodef> | ||
|
||
<trycatch> | ||
<try> | ||
<!-- *EITHER* these values are preset --> | ||
<omero_v_was_preset property="omero.version"/> | ||
<omero_v_was_preset property="omero.plainversion"/> | ||
<omero_v_was_preset property="omero.shortversion"/> | ||
|
||
<!-- *OR* they'll be set by git --> | ||
<git command="describe" output="omero.v.git" failonerror="true"> | ||
<args> | ||
<arg value="--match"/> | ||
<arg value="${gitmatch}"/> | ||
<arg line="--dirty"/> | ||
</args> | ||
</git> | ||
<propertyregex property="omero.shortversion" | ||
input="${omero.v.git}" regexp="${omero.v.regexp}" select="\2"/> | ||
<propertyregex property="omero.plainversion" | ||
input="${omero.v.git}" regexp="${omero.v.regexp}" select="\2\3\5\6"/> | ||
<exec executable = "python" dir = "${basedir}/components/antlib/scripts" | ||
outputproperty = "omero.version" | ||
failonerror = "true"> | ||
<arg value = "parse_version" /> | ||
<arg value = "${omero.plainversion}-ice${versions.ice_lib}"/> | ||
</exec> | ||
<property name="omero.version.source" value="git"/> | ||
<property name="omero.plainversion.source" value="git"/> | ||
<property name="omero.shortversion.source" value="git"/> | ||
</try> | ||
<catch> | ||
<!-- *OR* we'll finally fall back to UNKNOWN --> | ||
<property name="omero.version" value="UNKNOWN"/> | ||
<property name="omero.plainversion" value="UNKNOWN"/> | ||
<property name="omero.shortversion" value="UNKNOWN"/> | ||
</catch> | ||
</trycatch> | ||
|
||
<target name="version-info"> | ||
<echo>Git describe output: ${omero.v.git}</echo> | ||
<echo>Official: ${omero.version} (${omero.version.source})</echo> | ||
<echo>Plain: ${omero.plainversion} (${omero.plainversion.source})</echo> | ||
<echo>Short: ${omero.shortversion} (${omero.shortversion.source})</echo> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# | ||
# Copyright (C) 2014 Glencoe Software, Inc. All Rights Reserved. | ||
# Use is subject to license terms supplied in LICENSE.txt | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
""" | ||
Helper script to simpliy version.xml | ||
""" | ||
|
||
import os | ||
import re | ||
import sys | ||
|
||
def choose_omero_version(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 BUILD_NUMER is set, then "-Domero.version=${omero.version}-b${BUILD_NUMBER}" | ||
otherwise nothing. | ||
""" | ||
|
||
omero_build = os.environ.get("BUILD_NUMBER", "") | ||
if omero_build: | ||
omero_build = "-b%s" % omero_build | ||
|
||
err = "" | ||
try: | ||
if not omero_build: | ||
try: | ||
omero_version = snapshot_logic(omero_version) | ||
except: | ||
pass | ||
return "%s%s" % (omero_version, omero_build) | ||
except: | ||
print "Error getting version for BUILD_NUMBER=%s" % omero_build | ||
if err: | ||
print err | ||
sys.exit(1) | ||
|
||
def snapshot_logic(omero_version): | ||
""" | ||
If we're not on hudson, then we don't want to force | ||
users to deal with rebuilding after each commit. | ||
Instead, drop everything except for "-DEV" | ||
See gh-67 for the discussion. | ||
""" | ||
|
||
omero_version = re.sub("([-]DEV)?-\d+-[a-f0-9]+(-dirty)?-ice[0-9]+$", | ||
"-SNAPSHOT", omero_version) | ||
|
||
# For maven-compatibility, we take "SNAPSHOT" of the _next_ version | ||
try: | ||
# First we try to use distutils | ||
from distutils.version import LooseVersion | ||
version = LooseVersion(omero_version).version | ||
# Find the last index which is an int | ||
for idx in range(len(version)-1, 0, -1): | ||
val = version[idx] | ||
if isinstance(val, int): | ||
version[idx] += 1 | ||
break | ||
|
||
last_int = False | ||
new_vers = "" | ||
for val in version: | ||
if isinstance(val, int): | ||
if last_int: | ||
new_vers += "." | ||
else: | ||
last_int = True | ||
else: | ||
last_int = False | ||
new_vers += str(val) | ||
omero_version = new_vers | ||
except: | ||
# But if that doesn't work, we brute force with regex | ||
m = re.match("^([^\d]*\d+[.]\d+[.])(\d+)-SNAPSHOT$", omero_version) | ||
if m: | ||
next = int(m.group(2)) + 1 | ||
omero_version = "%s%s-SNAPSHOT" % (m.group(1), next) | ||
return omero_version | ||
|
||
if __name__ == "__main__": | ||
print choose_omero_version(sys.argv[1]), |
Oops, something went wrong.