banshee r3155 - in trunk/banshee: . src src/Extensions/Template



Author: abock
Date: Wed Feb  6 03:53:49 2008
New Revision: 3155
URL: http://svn.gnome.org/viewvc/banshee?rev=3155&view=rev

Log:
2008-02-05  Aaron Bockover  <abock gnome org>

    * src/create-extension: A simple script that will create some of the
    files necessary for creating new extensions; it allows you to specify
    the extension name extension points that will be implemented and it
    tries to build at least most of the necessary shell for the extension

    * src/Extensions/Template/Makefile.am:
    * src/Extensions/Template/Template.addin.xml:
    * src/Extensions/Template/Template.mdp: Files to use as the base for
    generated extensions



Added:
   trunk/banshee/src/Extensions/Template/
   trunk/banshee/src/Extensions/Template/Makefile.am
   trunk/banshee/src/Extensions/Template/Template.addin.xml
   trunk/banshee/src/Extensions/Template/Template.mdp
   trunk/banshee/src/create-extension   (contents, props changed)
Modified:
   trunk/banshee/ChangeLog

Added: trunk/banshee/src/Extensions/Template/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Template/Makefile.am	Wed Feb  6 03:53:49 2008
@@ -0,0 +1,10 @@
+ASSEMBLY = @EXTENSION_NAME@
+TARGET = library
+LINK = $(REF_FIXME)
+
+SOURCES =
+
+RESOURCES =
+
+include $(top_srcdir)/build/build.mk
+

Added: trunk/banshee/src/Extensions/Template/Template.addin.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Template/Template.addin.xml	Wed Feb  6 03:53:49 2008
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Addin 
+    id="@EXTENSION_NAME@"
+    version="1.0"
+    compatVersion="1.0"
+    copyright="Â 2008 Novell Inc. Licensed under the MIT X11 license."
+    name=""
+    category=""
+    description=""
+    author=""
+    url="http://banshee-project.org/";
+    defaultEnabled="true">
+
+ EXTENSION_DEPS@
+
+ EXTENSION_NODES@</Addin>

Added: trunk/banshee/src/Extensions/Template/Template.mdp
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Template/Template.mdp	Wed Feb  6 03:53:49 2008
@@ -0,0 +1,28 @@
+<Project name="@EXTENSION_NAME@" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+  <Configurations active="Debug">
+    <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+      <Output directory="../../../bin" assemblyKeyFile="." assembly="@EXTENSION_NAME@" />
+      <Build debugmode="True" target="Library" />
+      <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+  </Configurations>
+  <Contents>
+    <File name="@EXTENSION_NAME  addin xml" subtype="Code" buildaction="EmbedAsResource" />
+  </Contents>
+  <References>
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.Services" />
+    <ProjectReference type="Project" localcopy="True" refto="Hyena" />
+    <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  </References>
+  <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
+    <BuildFilesVar Sync="True" Name="SOURCES" />
+    <DeployFilesVar />
+    <ResourcesVar Sync="True" Name="RESOURCES" />
+    <OthersVar />
+    <GacRefVar />
+    <AsmRefVar />
+    <ProjectRefVar />
+  </MonoDevelop.Autotools.MakefileInfo>
+</Project>

Added: trunk/banshee/src/create-extension
==============================================================================
--- (empty file)
+++ trunk/banshee/src/create-extension	Wed Feb  6 03:53:49 2008
@@ -0,0 +1,132 @@
+#!/bin/bash
+
+function show_extension_points () {
+	echo "Valid extension points are:"
+	echo
+	for point in $V_EX_POINTS; do
+		echo "   ${point}"
+	done
+	echo
+}
+
+function find_extension_points () {
+	for file in $(find -iname '*addin.xml'); do
+		points=$(grep '<ExtensionPoint' $file | \
+			awk 'BEGIN { FS="=" } { print $2 }' | \
+			sed 's,[>"],,g')
+
+		id=$(awk 'BEGIN { FS="id=\"" } { print $2 }' < $file | \
+			awk 'BEGIN { FS="\" " } { print $1 }')
+		
+		[[ -z $points || -z $id ]] && continue
+
+		for point in $points; do
+			V_EX_POINTS="${V_EX_POINTS} ${point}"
+			V_EX_POINTS_IDS="${V_EX_POINTS_IDS} ${point},${id}"
+		done
+	done
+}
+
+function usage () {
+	echo "Usage: $0 <name> <path> [<extension-point> ...]"
+	echo
+	show_extension_points
+	exit 1
+}
+
+find_extension_points
+
+EX_NAME=$1; test -z $EX_NAME && usage || shift
+EX_PATH="Extensions"
+
+case "$1" in
+	\/*) ;;
+	*) test -z $1 || EX_PATH="$1"; shift ;;
+esac
+
+if test ! -d "${EX_PATH}"; then
+	echo "Extension root path \`${EX_PATH}' does not exist."
+	exit 1
+fi
+
+EX_PATH="${EX_PATH}/${EX_NAME}"
+TEMPLATE_PATH="Extensions/Template"
+
+if test ! -d $TEMPLATE_PATH; then
+	echo "Extension template path \`${TEMPLATE_PATH}' does not exist."
+	echo "This script must be run from the src/ directory of a Banshee checkout"
+	exit 1
+fi
+
+if test -d "${EX_PATH}"; then
+	echo "Extension \`${EX_PATH}' already exists."
+	exit 1
+fi
+
+for point in $@; do
+	found=0
+	for v_point in $V_EX_POINTS; do
+		if [ "x$point" = "x$v_point" ]; then
+			found=1
+			break
+		fi
+	done
+	if [ $found -eq 0 ]; then
+		echo "Extension point \`${point}' is not valid."
+		echo
+		show_extension_points
+		exit 1
+	fi
+done
+
+echo "Creating Extension ($EX_PATH)..."
+
+for point in $@; do
+	for v_point in $V_EX_POINTS_IDS; do
+		if [ "$point" = "${v_point%,*}" ]; then
+			dependency="${v_point##*,}"
+			dep_found=0
+			for dep_added in $deps_added; do
+				if test "x${dependency}" = "x${dep_added}"; then
+					dep_found=1
+					break
+				fi
+			done
+
+			if [ $dep_found -eq 0 ]; then
+				deps_added="${deps_added} ${dependency}"
+				EX_DEPS="${EX_DEPS}    <Addin id=\"${dependency}\" version=\"1.0\"/>^"
+			fi
+
+			name="${point##*/}"
+			EX_NODES="${EX_NODES}  <Extension path=\"${point}\">^    <${name} class=\"\"/>^  </Extension>^^"
+
+			echo "  Added extension node \`${name}' at path \`${point}'"
+		fi
+	done
+done
+
+EX_DEPS="  <Dependencies>^${EX_DEPS}^  </Dependencies>"
+
+mkdir -p "${EX_PATH}"
+cp ${TEMPLATE_PATH}/Template.mdp "${EX_PATH}/${EX_NAME}.mdp"
+cp ${TEMPLATE_PATH}/Template.addin.xml "${EX_PATH}/${EX_NAME}.addin.xml"
+cp ${TEMPLATE_PATH}/Makefile.am "${EX_PATH}"
+
+pushd "${EX_PATH}" &>/dev/null
+
+for file in *; do
+	sed -e "s/\ EXTENSION_NAME\@/${EX_NAME}/g" < $file > $file.tmp &&
+		mv $file.tmp $file
+	sed -e "s,\ EXTENSION_DEPS\@,${EX_DEPS},g" < $file | 
+		sed -r 's,[\^]+,\^,g' | tr ^ '\n' > $file.tmp &&
+		mv $file.tmp $file
+	sed -e "s,\ EXTENSION_NODES\@,${EX_NODES},g" < $file | 
+		tr ^ '\n' > $file.tmp &&
+		mv $file.tmp $file
+done
+
+popd &>/dev/null
+
+echo "Done."
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]