From 90f47c7b1d9725c13d972a0e2a61b2cd966bbab5 Mon Sep 17 00:00:00 2001 From: dhewg Date: Sat, 9 Apr 2011 18:28:02 +0200 Subject: ANDOID: Replace mkmanifest.pl with sh/sed code Removes build dependencies like perl and its XML modules --- dists/android/mkmanifest.pl | 170 ----------------------------------- dists/android/mkplugin.sh | 17 ++++ dists/android/plugin-manifest.xml | 35 ++++++++ dists/android/plugin-manifest.xml.in | 35 ++++++++ dists/android/plugin-strings.xml | 7 ++ 5 files changed, 94 insertions(+), 170 deletions(-) delete mode 100755 dists/android/mkmanifest.pl create mode 100755 dists/android/mkplugin.sh create mode 100644 dists/android/plugin-manifest.xml create mode 100644 dists/android/plugin-manifest.xml.in create mode 100644 dists/android/plugin-strings.xml (limited to 'dists/android') diff --git a/dists/android/mkmanifest.pl b/dists/android/mkmanifest.pl deleted file mode 100755 index 62caa64a55..0000000000 --- a/dists/android/mkmanifest.pl +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/perl - -use File::Basename qw(dirname); -use File::Path qw(mkpath); -use IO::File; -use XML::Writer; -use XML::Parser; -use Getopt::Long; - -use warnings; -use strict; - -use constant ANDROID => 'http://schemas.android.com/apk/res/android'; - -my $id; -my $package_versionName; -my $package_versionCode; -my $configure = 'configure'; -my $stringres = 'res/string/values.xml'; -my $manifest = 'AndroidManifest.xml'; -my $master_manifest; -my @unpack_libs; -GetOptions('id=s' => \$id, - 'version-name=s' => \$package_versionName, - 'version-code=i' => \$package_versionCode, - 'configure=s' => \$configure, - 'stringres=s' => \$stringres, - 'manifest=s' => \$manifest, - 'master-manifest=s' => \$master_manifest, - 'unpacklib=s' => \@unpack_libs, - ) or die; -die "Missing required arg" - unless $id and $package_versionName and $package_versionCode; - - -sub grope_engine_info { - my $configure = shift; - my @ret; - while (<$configure>) { - m/^add_engine \s+ (\w+) \s+ "(.*?)" \s+ \w+ (?:\s+ "([\w\s]*)")?/x - or next; - my $subengines = $3 || ''; - my %info = (id => $1, name => $2, - subengines => [split / /, $subengines]); - push @ret, \%info; - } - return @ret; -} - -sub read_constraints { - my $manifest = shift; - my @constraints; - my $parser = new XML::Parser Handlers => { - Start => sub { - my $expat = shift; - my $elem = shift; - return if $elem !~ - /^(uses-configuration|supports-screens|uses-sdk)$/; - my @constraint = ($elem); - while (@_) { - my $attr = shift; - my $value = shift; - $attr = [ANDROID, $attr] if $attr =~ s/^android://; - push @constraint, $attr, $value; - } - push @constraints, \@constraint; - }, - }; - $parser->parse($manifest); - return @constraints; -} - -sub print_stringres { - my $output = shift; - my $info = shift; - - my $writer = new XML::Writer(OUTPUT => $output, ENCODING => 'utf-8', - DATA_MODE => 1, DATA_INDENT => 2); - - $writer->xmlDecl(); - $writer->startTag('resources'); - - while (my ($k,$v) = each %$info) { - $writer->dataElement('string', $v, name => $k); - } - - $writer->endTag('resources'); - $writer->end(); -} - -sub print_manifest { - my $output = shift; - my $info = shift; - my $constraints = shift; - - my $writer = new XML::Writer(OUTPUT => $output, ENCODING => 'utf-8', - DATA_MODE => 1, DATA_INDENT => 2, - NAMESPACES => 1, - PREFIX_MAP => {ANDROID, 'android'}); - - $writer->xmlDecl(); - - $writer->startTag( - 'manifest', - 'package' => "org.inodes.gus.scummvm.plugin.$info->{name}", - [ANDROID, 'versionCode'] => $package_versionCode, - [ANDROID, 'versionName'] => $package_versionName, - [ANDROID, 'installLocation'] => 'preferExternal', - ); - - $writer->startTag( - 'application', - [ANDROID, 'label'] => '@string/app_name', - [ANDROID, 'description'] => '@string/app_desc', - [ANDROID, 'icon'] => '@drawable/scummvm', - ); - - $writer->startTag( - 'receiver', - [ANDROID, 'name'] => 'org.inodes.gus.scummvm.PluginProvider', - [ANDROID, 'process'] => 'org.inodes.gus.scummvm'); - - $writer->startTag('intent-filter'); - $writer->emptyTag('action', [ANDROID, 'name'] => - 'org.inodes.gus.scummvm.action.PLUGIN_QUERY'); - $writer->emptyTag('category', [ANDROID, 'name'] => - 'android.intent.category.INFO'); - $writer->endTag('intent-filter'); - $writer->emptyTag( - 'meta-data', - [ANDROID, 'name'] => 'org.inodes.gus.scummvm.meta.UNPACK_LIB', - [ANDROID, 'value'] => $_) - for @{$info->{unpack_libs}}; - - $writer->endTag('receiver'); - $writer->endTag('application'); - - $writer->emptyTag('uses-permission', [ANDROID, 'name'] => - 'org.inodes.gus.scummvm.permission.SCUMMVM_PLUGIN'); - - $writer->emptyTag(@$_) foreach @$constraints; - - $writer->endTag('manifest'); - $writer->end(); -} - - -my %engines; -for my $engine (grope_engine_info(new IO::File $configure, 'r')) { - $engines{$engine->{id}} = $engine; -} - -my @games = ($id, @{$engines{$id}{subengines}}); -my $games_desc = join('; ', map $engines{$_}{name}, @games); - -my @constraints = read_constraints(new IO::File $master_manifest, 'r'); - -print "Writing $stringres ...\n"; -mkpath(dirname($stringres)); -print_stringres(IO::File->new($stringres, 'w'), - {app_name => qq{ScummVM plugin: "$id"}, - app_desc => "Game engine for: $games_desc", - }); - -print "Writing $manifest ...\n"; -mkpath(dirname($manifest)); -print_manifest(IO::File->new($manifest, 'w'), - {name => $id, unpack_libs => \@unpack_libs}, \@constraints); - -exit 0; diff --git a/dists/android/mkplugin.sh b/dists/android/mkplugin.sh new file mode 100755 index 0000000000..f4643132cf --- /dev/null +++ b/dists/android/mkplugin.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ $# -ne 5 ]; then + echo "usage: $0 configure plugin template versioncode target" + exit 1 +fi + +CONFIGURE=$1 +PLUGIN_NAME=$2 +TEMPLATE=$3 +PLUGIN_VERSION_CODE=$4 +TARGET=$5 + +PLUGIN_DESC=`sed -n s/add_engine\s$PLUGIN_NAME\s\"\(.\+\)\"\s.*/\1/p` < $CONFIGURE + +sed "s|@PLUGIN_NAME@|$PLUGIN_NAME|;s|@PLUGIN_VERSION_CODE@|$PLUGIN_VERSION_CODE|;s|@PLUGIN_DESC@|$PLUGIN_DESC|" < $TEMPLATE > $TARGET + diff --git a/dists/android/plugin-manifest.xml b/dists/android/plugin-manifest.xml new file mode 100644 index 0000000000..2442d3f32a --- /dev/null +++ b/dists/android/plugin-manifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dists/android/plugin-manifest.xml.in b/dists/android/plugin-manifest.xml.in new file mode 100644 index 0000000000..c941b2f48c --- /dev/null +++ b/dists/android/plugin-manifest.xml.in @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dists/android/plugin-strings.xml b/dists/android/plugin-strings.xml new file mode 100644 index 0000000000..363503f8d8 --- /dev/null +++ b/dists/android/plugin-strings.xml @@ -0,0 +1,7 @@ + + + + ScummVM plugin: "@PLUGIN_NAME@" + Game engine for: @PLUGIN_DESC@ + + -- cgit v1.2.3