Permalink
Browse files

Update how versions are handled when building

  • Loading branch information...
1 parent 2da57b8 commit eb2c4e87a075c2153d43c7b6c8213617ec10c84d @olabini committed Apr 21, 2011
View
@@ -7,6 +7,7 @@
<property file="build.properties"/>
<property file="default.build.properties"/>
+ <property file="version.properties"/>
<taskdef resource="tasks.properties">
<classpath>
@@ -34,9 +35,9 @@
<target name="compile" depends="generate_filters" description="Compile the source files for the project.">
<filter filtersfile="version_data.properties"/>
- <filter token="VERSION" value="P"/>
- <filter token="VERSION_RUNTIME" value="0.4.1-SNAPSHOT"/>
- <filter token="VERSION_STRING" value="Ioke P ikj 0.4.1-SNAPSHOT"/>
+ <filter token="VERSION" value="${VERSION_NAME}"/>
+ <filter token="VERSION_RUNTIME" value="${VERSION_NUMBER}${VERSION_ADDITION}"/>
+ <filter token="VERSION_STRING" value="Ioke ${VERSION_NAME} ikj ${VERSION_NUMBER}${VERSION_ADDITION}"/>
<javac destdir="${classes.dir}" debug="true" source="${javac.version}" target="${javac.version}" encoding="UTF-8">
<classpath refid="build.classpath"/>
@@ -178,7 +179,7 @@
</target>
<target name="dist-bin" depends="jar">
- <tar destfile="${release.dir}/ioke-P-ikj-0.4.1-SNAPSHOT.tar.gz" compression="gzip">
+ <tar destfile="${release.dir}/ioke-${VERSION_NAME}-ikj-${VERSION_NUMBER}${VERSION_ADDITION}.tar.gz" compression="gzip">
<tarfileset mode="755" dir="." prefix="ioke">
<include name="bin/*.bat"/>
<include name="bin/dokgen"/>
@@ -198,7 +199,7 @@
</tarfileset>
</tar>
- <zip destfile="${release.dir}/ioke-P-ikj-0.4.1-SNAPSHOT.zip">
+ <zip destfile="${release.dir}/ioke-${VERSION_NAME}-ikj-${VERSION_NUMBER}${VERSION_ADDITION}.zip">
<zipfileset filemode="755" dir="." prefix="ioke">
<include name="bin/*.bat"/>
<include name="bin/dokgen"/>
View
@@ -15,6 +15,30 @@
<property name="build.filtered.dir" value="${build.dir}/filtered"/>
<property name="test.results.dir" value="${build.dir}/test-results"/>
+ <script language="C#" prefix="version">
+ <code>
+ <![CDATA[
+ [Function("extract-property")]
+ public static string ExtractProperty(string name, string from) {
+ try {
+ string outp = System.IO.File.ReadAllText(from);
+ string[] pieces = outp.Split('\n');
+ foreach(string s in pieces) {
+ string[] keyAndValue = s.Split('=');
+ if(keyAndValue[0].Equals(name))
+ return keyAndValue[1];
+ }
+ return null;
+ } catch(System.Exception) { return null; }
+ }
+ ]]>
+ </code>
+ </script>
+
+ <property name="VERSION_NAME" value="${version::extract-property('VERSION_NAME', 'version.properties')}" />
+ <property name="VERSION_NUMBER" value="${version::extract-property('VERSION_NUMBER', 'version.properties')}" />
+ <property name="VERSION_ADDITION" value="${version::extract-property('VERSION_ADDITION', 'version.properties')}" />
+
<target name="prepare" description="Creates the directories needed for building">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.filtered.dir}"/>
@@ -34,35 +58,11 @@
</sources>
</csc>
- <script language="C#" prefix="version">
- <code>
- <![CDATA[
- [Function("extract-date")]
- public static string ExtractDate() {
- try {
- string outp = System.IO.File.ReadAllText("version_data.properties");
- string[] pieces = outp.Split('\n');
- return pieces[0].Split('=')[1];
- } catch(System.Exception) { return "???"; }
- }
-
- [Function("extract-commit")]
- public static string ExtractCommit() {
- try {
- string outp = System.IO.File.ReadAllText("version_data.properties");
- string[] pieces = outp.Split('\n');
- return pieces[1].Split('=')[1];
- } catch(System.Exception) { return "???"; }
- }
- ]]>
- </code>
- </script>
-
- <echo file="${build.filtered.dir}/Ioke.Lang.version.properties">ioke.build.version=E
-ioke.build.runtimeVersion=0.4.1-SNAPSHOT
-ioke.build.versionString=Ioke P ikc 0.4.1-SNAPSHOT
-ioke.build.date=${version::extract-date()}
-ioke.build.commit=${version::extract-commit()}
+ <echo file="${build.filtered.dir}/Ioke.Lang.version.properties">ioke.build.version=${VERSION_NAME}
+ioke.build.runtimeVersion=${VERSION_NUMBER}${VERSION_ADDITION}
+ioke.build.versionString=Ioke ${VERSION_NAME} ikc ${VERSION_NUMBER}${VERSION_ADDITION}
+ioke.build.date=${version::extract-property('DATE', 'version_data.properties')}
+ioke.build.commit=${version::extract-property('COMMIT', 'version_data.properties')}
</echo>
<csc target="library" output="${bin.dir}/Ioke.Lang.dll" debug="true">
@@ -132,7 +132,7 @@ ioke.build.commit=${version::extract-commit()}
</target>
<target name="dist-bin">
- <tar destfile="${release.dir}/ioke-P-ikc-0.4.1-SNAPSHOT.tar.gz" compression="GZip">
+ <tar destfile="${release.dir}/ioke-${VERSION_NAME}-ikc-${VERSION_NUMBER}${VERSION_ADDITION}.tar.gz" compression="GZip">
<fileset filemode="755" basedir="." prefix="ioke">
<include name="bin/*.dll"/>
<include name="bin/*.exe"/>
@@ -152,7 +152,7 @@ ioke.build.commit=${version::extract-commit()}
</fileset>
</tar>
- <zip zipfile="${release.dir}/ioke-P-ikc-0.4.1-SNAPSHOT.zip">
+ <zip zipfile="${release.dir}/ioke-${VERSION_NAME}-ikc-${VERSION_NUMBER}${VERSION_ADDITION}.zip">
<fileset basedir="." prefix="ioke">
<include name="bin/*.dll"/>
<include name="bin/*.exe"/>
@@ -1,2 +0,0 @@
-
-Runtime version = Origin with(machine: "ikc", versionNumber: [0,4,1])
@@ -365,6 +365,8 @@ public class Runtime : IokeData {
this.Iterator2Sequence.Init();
this.KeyValueIteratorSequence.Init();
+ AfterInitRuntime(this._Runtime);
+
AddBuiltinScript("benchmark", new Builtin.Delegate((runtime, context, message) => {
return Ioke.Lang.Extensions.Benchmark.Benchmark.Create(runtime);
}));
@@ -393,7 +395,6 @@ public class Runtime : IokeData {
EvaluateString("use(\"builtin/D40_text\")", Message, Ground);
EvaluateString("use(\"builtin/D43_regexp\")", Message, Ground);
EvaluateString("use(\"builtin/D45_fileSystem\")", Message, Ground);
- EvaluateString("use(\"builtin/D50_runtime\")", Message, Ground);
EvaluateString("use(\"builtin/F05_case\")", Message, Ground);
EvaluateString("use(\"builtin/F10_comprehensions\")", Message, Ground);
@@ -1070,6 +1071,54 @@ public class BindIndex {
((Message)IokeObject.dataOf(errorMessage)).SendTo(errorMessage, this.Ground, this.Ground, CreateMessage(Ioke.Lang.Message.Wrap(cond)));
}
+
+
+ public void AfterInitRuntime(IokeObject obj) {
+ try {
+ using(Stream str = typeof(IokeSystem).Assembly.GetManifestResourceStream("Ioke.Lang.version.properties")) {
+ using(StreamReader sr = new StreamReader(str, NETSystem.Text.Encoding.UTF8)) {
+ var result = new Dictionary<string, string>();
+ while(!sr.EndOfStream) {
+ string ss = sr.ReadLine();
+ if(ss.IndexOf('=') != -1) {
+ string[] parts = ss.Split('=');
+ result[parts[0].Trim()] = parts[1].Trim();
+ }
+ }
+
+ string version = result["ioke.build.version"];
+ string runtimeVersion = result["ioke.build.runtimeVersion"];
+ string versionString = result["ioke.build.versionString"];
+ string date = result["ioke.build.date"];
+ string commit = result["ioke.build.commit"];
+
+ IokeObject versionObj = NewFromOrigin();
+
+ versionObj.SetCell("machine", NewText("ikc"));
+
+ var versionParts = new SaneArrayList();
+ foreach(var s in runtimeVersion.Split(new Char[] {'.', '-'})) {
+ try {
+ versionParts.Add(NewNumber(s));
+ } catch(System.Exception e) {
+ versionParts.Add(NewText(s));
+ }
+ }
+
+ versionObj.SetCell("versionNumber", NewList(versionParts));
+ versionObj.SetCell("release", NewText(version));
+ versionObj.SetCell("fullVersion", NewText(versionString));
+ versionObj.SetCell("commit", NewText(commit));
+ versionObj.SetCell("date", NewText(date));
+
+ obj.SetCell("version", versionObj);
+ }
+ }
+ } catch(System.Exception) {
+ }
+ }
+
+
public static void InitRuntime(IokeObject obj) {
obj.Kind = "Runtime";
@@ -1,2 +0,0 @@
-
-Runtime version = Origin with(machine: "ikj", versionNumber: [0,4,1])
@@ -324,6 +324,8 @@ public void init() throws ControlFlow {
iteratorSequence.init();
keyValueIteratorSequence.init();
+ afterInitRuntime(runtime);
+
addBuiltinScript("benchmark", new Builtin() {
public IokeObject load(Runtime runtime, IokeObject context, IokeObject message) throws ControlFlow {
return ioke.lang.extensions.benchmark.Benchmark.create(runtime);
@@ -356,7 +358,6 @@ public IokeObject load(Runtime runtime, IokeObject context, IokeObject message)
evaluateString("use(\"builtin/D40_text\")", message, ground);
evaluateString("use(\"builtin/D43_regexp\")", message, ground);
evaluateString("use(\"builtin/D45_fileSystem\")", message, ground);
- evaluateString("use(\"builtin/D50_runtime\")", message, ground);
evaluateString("use(\"builtin/F05_case\")", message, ground);
evaluateString("use(\"builtin/F10_comprehensions\")", message, ground);
@@ -1174,6 +1175,39 @@ public void tearDown() throws ControlFlow.Exit {
}
}
+ public void afterInitRuntime(IokeObject obj) throws ControlFlow {
+ try {
+ java.util.Properties props = new java.util.Properties();
+ props.load(Main.class.getResourceAsStream("/ioke/lang/version.properties"));
+
+ String version = props.getProperty("ioke.build.version");
+ String runtimeVersion = props.getProperty("ioke.build.runtimeVersion");
+ String versionString = props.getProperty("ioke.build.versionString");
+ String date = props.getProperty("ioke.build.date");
+ String commit = props.getProperty("ioke.build.commit");
+
+ IokeObject versionObj = newFromOrigin();
+
+ versionObj.setCell("machine", newText("ikj"));
+ List<Object> versionParts = new ArrayList<Object>();
+ for(String s : runtimeVersion.split("[\\.-]")) {
+ try {
+ versionParts.add(newNumber(s));
+ } catch(Exception e) {
+ versionParts.add(newText(s));
+ }
+ }
+ versionObj.setCell("versionNumber", newList(versionParts));
+ versionObj.setCell("release", newText(version));
+ versionObj.setCell("fullVersion", newText(versionString));
+ versionObj.setCell("commit", newText(commit));
+ versionObj.setCell("date", newText(date));
+
+ obj.setCell("version", versionObj);
+ } catch(Exception e) {
+ }
+ }
+
public static void initRuntime(IokeObject obj) throws ControlFlow {
obj.setKind("Runtime");
View
@@ -21,20 +21,6 @@ describe(Runtime,
)
)
)
-
- describe("versionNumber",
- onlyWhen(System feature?(:java),
- it("should be the correct version",
- Runtime version versionNumber should == [0,4,1]
- )
- )
-
- onlyWhen(System feature?(:clr),
- it("should be the correct version",
- Runtime version versionNumber should == [0,4,1]
- )
- )
- )
)
describe("nodeId",
View
@@ -0,0 +1,3 @@
+VERSION_NAME=P
+VERSION_NUMBER=0.4.0
+VERSION_ADDITION=-SNAPSHOT

0 comments on commit eb2c4e8

Please sign in to comment.