From 20e114c1a0f086e432f374fe0ecebf014a571448 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Mon, 13 Jan 2014 23:06:28 +0100 Subject: [PATCH] wpsbuild: The setting strings can now contain an additional feature constraint. The setting strings are now of the form setting[.resolution[&feature]] (resolution can be a regex, .+ to match all resultions). wpsbuild.pl will check against features.txt to see if the target meets it. This can be used, for example, to add/override default settings for touchscreen devices. Change-Id: I2eafa02f10b362a8e7de8e1f3a53115e70d28084 --- wps/wpsbuild.pl | 74 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl index 35febe3bcb..d6d8085449 100755 --- a/wps/wpsbuild.pl +++ b/wps/wpsbuild.pl @@ -328,20 +328,46 @@ $has_remote = 1 if ($remote_height && $remote_width && $remote_depth); # check if line matches the setting string or if it contains a regex # that contains the targets resolution -sub check_res { +# +# the line can be of the from +# 1) setting: value (handled above) +# 2) setting.128x96x2: value +# 3) setting.128x96x2&touchscreen: value +# The resolution pattern can be a perl-comatible regex +sub check_res_feature { my ($line, $string, $remote) = @_; - if ($line =~ /^${string}: *(.*)/i) { + if ($line =~ /^$string: *(.*)/i) { return $1; } - elsif($line =~ /^${string}.(.*): *(.*)/i) { - # $1 is a resolution regex, $2 the filename incl. resolution + elsif($line =~ /^$string\.(.*): *(.*)/i) { + # $1 is a resolution/feature regex, $2 the filename incl. resolution + my $substr = $1; my $fn = $2; + my $feature; my $size_str = "${main_width}x${main_height}x${main_depth}"; if ($remote) { $size_str = "${remote_width}x${remote_height}x${remote_depth}"; } - if ($size_str =~ /$1$/) { - return $fn; + + # extract feature constraint, if any + if ($substr =~ /&([a-z0-9_]+)/) { + $feature = $1; + $substr =~ s/&$feature//; + } + + if ($size_str =~ /$substr$/) { + if ($feature) { + # check feature constrait + open(FEAT, "); + close(FEAT); + my $matches = (grep { /$feature/ } @lines); + return $fn if $matches > 0; + } + else { + # no feature constraint + return $fn; + } } } return ""; @@ -452,22 +478,22 @@ while() { if ($l =~ /^ *<\/main>/i) { last; } - elsif($_ = check_res($l, "wps")) { + elsif($_ = check_res_feature($l, "wps")) { $wps = $_; } - elsif($_ = check_res($l, "sbs")) { + elsif($_ = check_res_feature($l, "sbs")) { $sbs = $_; } - elsif($_ = check_res($l, "fms")) { + elsif($_ = check_res_feature($l, "fms")) { $fms = $_; } - elsif($_ = check_res($l, "Font")) { + elsif($_ = check_res_feature($l, "Font")) { $font = $_; } - elsif($_ = check_res($l, "Statusbar")) { + elsif($_ = check_res_feature($l, "Statusbar")) { $statusbar = $_; } - elsif($_ = check_res($l, "Backdrop")) { + elsif($_ = check_res_feature($l, "Backdrop")) { $backdrop = $_; } elsif($l =~ /^Foreground Color: *(.*)/i) { @@ -482,13 +508,13 @@ while() { elsif($l =~ /^line selector end color: *(.*)/i) { $lineselectend = $1; } - elsif($_ = check_res($l, "selector type")) { + elsif($_ = check_res_feature($l, "selector type")) { $selecttype = $_; } - elsif($_ = check_res($l, "iconset")) { + elsif($_ = check_res_feature($l, "iconset")) { $iconset = $_; } - elsif($_ = check_res($l, "viewers iconset")) { + elsif($_ = check_res_feature($l, "viewers iconset")) { $viewericon = $_; } elsif($l =~ /^show icons: *(.*)/i) { @@ -500,7 +526,7 @@ while() { elsif($l =~ /^filetype colours: *(.*)/i) { $filetylecolor = $1; } - elsif($_ = check_res($l, "ui viewport")) { + elsif($_ = check_res_feature($l, "ui viewport")) { $listviewport = $_; } } @@ -515,28 +541,28 @@ while() { elsif(!$has_remote) { next; # dont parse section } - elsif($_ = check_res($l, "rwps", 1)) { + elsif($_ = check_res_feature($l, "rwps", 1)) { $rwps = $_; } - elsif($_ = check_res($l, "rsbs", 1)) { + elsif($_ = check_res_feature($l, "rsbs", 1)) { $rsbs = $_; } - elsif($_ = check_res($l, "rfms", 1)) { + elsif($_ = check_res_feature($l, "rfms", 1)) { $rfms = $_; } - elsif($_ = check_res($l, "Font", 1)) { + elsif($_ = check_res_feature($l, "Font", 1)) { $remotefont = $_; } - elsif($_ = check_res($l, "iconset", 1)) { + elsif($_ = check_res_feature($l, "iconset", 1)) { $remoteiconset = $_; } - elsif($_ = check_res($l, "viewers iconset", 1)) { + elsif($_ = check_res_feature($l, "viewers iconset", 1)) { $remoteviewericon = $_; } - elsif($_ = check_res($l, "statusbar", 1)) { + elsif($_ = check_res_feature($l, "statusbar", 1)) { $remotestatusbar = $_; } - elsif($_ = check_res($l, "ui viewport", 1)) { + elsif($_ = check_res_feature($l, "ui viewport", 1)) { $remotelistviewport = $_; } }