added new build scripts to handle changing of the build version. ant script will now generate Wagic_Version.h and update AndroidManifest.xml

This commit is contained in:
techdragon.nguyen@gmail.com
2012-04-19 07:03:05 +00:00
parent e447a9c48d
commit 41e5dfe68a
7 changed files with 149 additions and 24 deletions

View File

@@ -1,24 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.wagic.app"
android:versionCode="184"
android:versionName="0.18.4">
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"></uses-permission>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="0184" android:versionName="0.18.4" package="net.wagic.app">
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:label="@string/app_name" android:icon="@drawable/icon" android:debuggable="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity android:name="org.libsdl.app.SDLActivity"
android:configChanges="keyboard|keyboardHidden"
android:screenOrientation="sensorLandscape"
android:label="@string/app_name" >
<application android:debuggable="true" android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity android:configChanges="keyboard|keyboardHidden" android:label="@string/app_name" android:name="org.libsdl.app.SDLActivity" android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden" android:screenOrientation="sensorLandscape"/>
<activity android:configChanges="keyboard|keyboardHidden" android:name="com.google.ads.AdActivity" android:screenOrientation="sensorLandscape"/>
</application>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9"/>
</manifest>
</manifest>

View File

@@ -0,0 +1,3 @@
build.major = 0
build.minor = 18
build.point = 4

View File

@@ -0,0 +1 @@
groovy.dir=tools/build/lib

81
projects/mtg/build.xml Normal file
View File

@@ -0,0 +1,81 @@
<project name="Wagic">
<!-- build.properties should contain the values for major, minor and point -->
<property file="build.properties" />
<property file="build.number.properties" />
<path id="groovy.class.path" >
<fileset dir="${groovy.dir}" />
</path>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="groovy.class.path" />
<tstamp>
<format property="TODAY" pattern="EEE, dd-MMM-yyyy HH::mm:ss" />
</tstamp>
<target name="setup.major" >
<echo message="incrementing Major Version number by 1" />
</target>
<target name="setup.minor" >
<echo message="incrementing minor Version number by 1" />
</target>
<target name="setup.point" >
<echo message="incrementing point Version number by 1" />
</target>
<target name="update" description="Updates the AndroidManifest and Wagic_Version.h with the current version information" >
<antcall target="build.wagic.header" />
<antcall target="update.android.manifest" />
</target>
<target name="update.android.manifest" description="Updates the AndroidManifest.xml with the current version information" >
<groovy src="${basedir}/updateAndroidManifest.groovy" classpathref="groovy.class.path" >
<arg value="Android/AndroidManifest.xml" />
</groovy>
</target>
<target name="build.wagic.header" description="Create the Wagic_Version.h file" >
<echo message="Creating Wagic_Version.h" />
<echo file="${basedir}/include/Wagic_Version.h" >
/*
This file was auto-generated by ant build script on ${TODAY}
*/
#ifndef wagic_Wagic_Version_h
#define wagic_Wagic_Version_h
/* Wagic versions */
#define WAGIC_VERSION_MAJOR ${build.major}
#define WAGIC_VERSION_MEDIUM ${build.minor}
#define WAGIC_VERSION_MINOR ${build.point}
#define VERSION_DOT(a, b, c) a ##.## b ##.## c
#define VERSION_WITHOUT_DOT(a, b, c) a ## b ## c
#define VERSION_GAME(a, b, c) VERSION_DOT(a, b, c)
#define VERSION_FILE(a, b, c) VERSION_WITHOUT_DOT(a, b, c)
#define VERSION_TOSTRING(a) #a
#define VERSION_STRINGIFY(a) VERSION_TOSTRING(a)
#define WAGIC_VERSION VERSION_GAME(WAGIC_VERSION_MAJOR, WAGIC_VERSION_MEDIUM, WAGIC_VERSION_MINOR)
#define WAGIC_RESOURCE_VERSION VERSION_FILE(WAGIC_VERSION_MAJOR, WAGIC_VERSION_MEDIUM, WAGIC_VERSION_MINOR)
#define WAGIC_VERSION_STRING VERSION_STRINGIFY(WAGIC_VERSION)
#define WAGIC_CORE_VERSION_STRING "core_" VERSION_STRINGIFY(WAGIC_RESOURCE_VERSION)
#define WAGIC_RESOURCE_NAME WAGIC_CORE_VERSION_STRING ".zip"
#endif
</echo>
</target>
<target name="current">
<echo message="Current version: ${build.major}.${build.minor}.${build.point} "/>
</target>
</project>

View File

@@ -1,15 +1,11 @@
//
// Wagic_Version.h
// wagic
//
// Created by Michael Nguyen on 2/5/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
/*
This file was auto-generated by ant build script on Thu, 19-Apr-2012 00::00:30
*/
#ifndef wagic_Wagic_Version_h
#define wagic_Wagic_Version_h
/* Wagic versions */
#define WAGIC_VERSION_MAJOR 0
#define WAGIC_VERSION_MEDIUM 18
@@ -28,5 +24,6 @@
#define WAGIC_CORE_VERSION_STRING "core_" VERSION_STRINGIFY(WAGIC_RESOURCE_VERSION)
#define WAGIC_RESOURCE_NAME WAGIC_CORE_VERSION_STRING ".zip"
#endif

Binary file not shown.

View File

@@ -0,0 +1,49 @@
import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
String android_manifest_filename=args[0];
File fXmlFile = new File(android_manifest_filename);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
Element rootNode=doc.getDocumentElement();
/*
package="net.wagic.app"
android:versionCode="184"
android:versionName="0.18.4"
*/
def props = new Properties();
new File("build.number.properties").withInputStream {
stream -> props.load(stream)
}
// accessing the property from Properties object using Groovy's map notation
println "capacity.created=" + props["build.major"]
def config = new ConfigSlurper().parse(props)
// accessing the property from ConfigSlurper object using GPath expression
String major_version=props["build.major"];
String minor_version=props["build.minor"];
String point_version=props["build.point"];
DOMSource source = new DOMSource(doc);
rootNode.setAttribute("android:versionName", major_version + "." + minor_version + "." + point_version);
rootNode.setAttribute("android:versionCode", major_version + minor_version + point_version);
File outputFile = new File(android_manifest_filename );
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty("indent", "yes");
StreamResult result = new StreamResult(new FileOutputStream(outputFile) );
transformer.transform(source, result);