Author: sskracic
Date: 2004-11-12 23:41:29 +0100 (Fri, 12 Nov 2004)
New Revision: 100
Added:
tools/trunk/misc/expand-dependencies
Modified:
tools/trunk/misc/build-all.sh
Log:
Dependency expansion now properly handled by a Perl script.
Modified: tools/trunk/misc/build-all.sh
===================================================================
--- tools/trunk/misc/build-all.sh 2004-11-12 21:17:15 UTC (rev 99)
+++ tools/trunk/misc/build-all.sh 2004-11-12 22:41:29 UTC (rev 100)
@@ -302,12 +302,9 @@
set -e
cd $i
# Generate skeleton project.xml.
- # We will cheat and simply copy the <ccm:dependencies>
- # from application.xml into <ccm:prebuilt> block of
- # project.xml. By doing this we will satisfy
- # the dependency information needed to perform XSL
- # transformation when creating the build.xml.
- appxml=$(cat $i/application.xml)
+ # We will generate the <ccm:prebuilt> block by expanding
+ # the <ccm:dependencies> for each required CCM app in turn.
+ # The actual crunching work will be done by a perl script.
cat > project.xml <<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
@@ -322,7 +319,8 @@
</ccm:build>
<ccm:prebuilt>
-$(sed -n '/<ccm:dependencies>/,/<\/ccm:dependencies>/s/requires/application/p' < $CCM_APP/application.xml)
+$($BUILD_HOME/tools/misc/expand-dependencies $BUILD_HOME $CCM_APP | \
+ sed 's/\(.*\) -> \(.*\)/<ccm:application name="\1" version="\2"\/>/')
</ccm:prebuilt>
</ccm:project>
Added: tools/trunk/misc/expand-dependencies
===================================================================
--- tools/trunk/misc/expand-dependencies 2004-11-12 21:17:15 UTC (rev 99)
+++ tools/trunk/misc/expand-dependencies 2004-11-12 22:41:29 UTC (rev 100)
@@ -0,0 +1,76 @@
+#! /usr/bin/perl -w
+
+use strict;
+
+sub traverse_deps;
+sub get_direct_deps;
+
+if ($#ARGV != 1) {
+ print "syntax: expand-dependencies BUILD_DIR ccm-app-name\n:";
+ exit -1;
+}
+
+my ($build_dir, $app_name) = (shift, shift);
+my %alldeps;
+traverse_deps($build_dir, $app_name, \%alldeps);
+foreach (keys %alldeps) {
+ print "$_ -> $alldeps{$_}\n";
+}
+exit;
+
+
+# Given the app name, finds all direct dependencies this
+# app has (calling get_direct_deps), and then recursively
+# calls itself to expand the dependency list.
+# The final list is automagically freed from duplicates,
+# thanks to hashes.
+#
+# Arguments:
+# 1. BUILD_DIR
+# 2. app name
+# 3. reference to expanded dependency hash (processed so far).
+#
+sub traverse_deps ($$$) {
+ my ($build_dir, $app_name, $expanded_deps_ref) = (shift, shift, shift);
+ my $xml_file = "$build_dir/$app_name/$app_name/application.xml";
+ my %deps = get_direct_deps($xml_file);
+ foreach (keys %deps) {
+ $expanded_deps_ref->{$_} = $deps{$_};
+ traverse_deps($build_dir, $_, $expanded_deps_ref);
+ }
+}
+
+
+# Parses the application.xml for the given app
+# and returns the hash with required app names as keys,
+# and version number as value.
+# Arguments:
+# 1. path to application.xml
+# Returns:
+# - hash of the form:
+# ccm-ldn-util -> 1.4.1
+# ccm-core -> 6.1.0
+# ccm-ldn-terms -> 1.0.1
+# ccm-cms -> 6.1.0
+#
+sub get_direct_deps ($) {
+ my $app_filepath = shift;
+ my %deps;
+ open FILE, "<$app_filepath" or die "Could not open app file: $|";
+ my @app_xml = <FILE>;
+ my $app_name;
+ # First get the app name out of XML
+ if ("@app_xml" =~ m{<ccm:application\b[^>]*\bname="([^"]+)"[^>]*>}s) {
+ $app_name = $1;
+ } else {
+ die "Could not find application name in $app_filepath";
+ }
+
+ # Extract the <ccm:dependencies> block
+ if ("@app_xml" =~ m{<ccm:dependencies>(.*)</ccm:dependencies>}s) {
+ $_ = $1;
+ %deps = m{<ccm:requires name="([^"]*)" version="([^"]*)"[^/>]*/>}sg;
+ }
+ return %deps;
+}
+
Property changes on: tools/trunk/misc/expand-dependencies
___________________________________________________________________
Name: svn:executable
+ *
|