forked from len0rd/rockbox
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
This commit is contained in:
parent
62524237f0
commit
20e114c1a0
1 changed files with 50 additions and 24 deletions
|
@ -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
|
# check if line matches the setting string or if it contains a regex
|
||||||
# that contains the targets resolution
|
# 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) = @_;
|
my ($line, $string, $remote) = @_;
|
||||||
if ($line =~ /^${string}: *(.*)/i) {
|
if ($line =~ /^$string: *(.*)/i) {
|
||||||
return $1;
|
return $1;
|
||||||
}
|
}
|
||||||
elsif($line =~ /^${string}.(.*): *(.*)/i) {
|
elsif($line =~ /^$string\.(.*): *(.*)/i) {
|
||||||
# $1 is a resolution regex, $2 the filename incl. resolution
|
# $1 is a resolution/feature regex, $2 the filename incl. resolution
|
||||||
|
my $substr = $1;
|
||||||
my $fn = $2;
|
my $fn = $2;
|
||||||
|
my $feature;
|
||||||
my $size_str = "${main_width}x${main_height}x${main_depth}";
|
my $size_str = "${main_width}x${main_height}x${main_depth}";
|
||||||
if ($remote) {
|
if ($remote) {
|
||||||
$size_str = "${remote_width}x${remote_height}x${remote_depth}";
|
$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, "<apps/features");
|
||||||
|
chomp(my @lines = <FEAT>);
|
||||||
|
close(FEAT);
|
||||||
|
my $matches = (grep { /$feature/ } @lines);
|
||||||
|
return $fn if $matches > 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# no feature constraint
|
||||||
|
return $fn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -452,22 +478,22 @@ while(<WPS>) {
|
||||||
if ($l =~ /^ *<\/main>/i) {
|
if ($l =~ /^ *<\/main>/i) {
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "wps")) {
|
elsif($_ = check_res_feature($l, "wps")) {
|
||||||
$wps = $_;
|
$wps = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "sbs")) {
|
elsif($_ = check_res_feature($l, "sbs")) {
|
||||||
$sbs = $_;
|
$sbs = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "fms")) {
|
elsif($_ = check_res_feature($l, "fms")) {
|
||||||
$fms = $_;
|
$fms = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "Font")) {
|
elsif($_ = check_res_feature($l, "Font")) {
|
||||||
$font = $_;
|
$font = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "Statusbar")) {
|
elsif($_ = check_res_feature($l, "Statusbar")) {
|
||||||
$statusbar = $_;
|
$statusbar = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "Backdrop")) {
|
elsif($_ = check_res_feature($l, "Backdrop")) {
|
||||||
$backdrop = $_;
|
$backdrop = $_;
|
||||||
}
|
}
|
||||||
elsif($l =~ /^Foreground Color: *(.*)/i) {
|
elsif($l =~ /^Foreground Color: *(.*)/i) {
|
||||||
|
@ -482,13 +508,13 @@ while(<WPS>) {
|
||||||
elsif($l =~ /^line selector end color: *(.*)/i) {
|
elsif($l =~ /^line selector end color: *(.*)/i) {
|
||||||
$lineselectend = $1;
|
$lineselectend = $1;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "selector type")) {
|
elsif($_ = check_res_feature($l, "selector type")) {
|
||||||
$selecttype = $_;
|
$selecttype = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "iconset")) {
|
elsif($_ = check_res_feature($l, "iconset")) {
|
||||||
$iconset = $_;
|
$iconset = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "viewers iconset")) {
|
elsif($_ = check_res_feature($l, "viewers iconset")) {
|
||||||
$viewericon = $_;
|
$viewericon = $_;
|
||||||
}
|
}
|
||||||
elsif($l =~ /^show icons: *(.*)/i) {
|
elsif($l =~ /^show icons: *(.*)/i) {
|
||||||
|
@ -500,7 +526,7 @@ while(<WPS>) {
|
||||||
elsif($l =~ /^filetype colours: *(.*)/i) {
|
elsif($l =~ /^filetype colours: *(.*)/i) {
|
||||||
$filetylecolor = $1;
|
$filetylecolor = $1;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "ui viewport")) {
|
elsif($_ = check_res_feature($l, "ui viewport")) {
|
||||||
$listviewport = $_;
|
$listviewport = $_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,28 +541,28 @@ while(<WPS>) {
|
||||||
elsif(!$has_remote) {
|
elsif(!$has_remote) {
|
||||||
next; # dont parse <remote> section
|
next; # dont parse <remote> section
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "rwps", 1)) {
|
elsif($_ = check_res_feature($l, "rwps", 1)) {
|
||||||
$rwps = $_;
|
$rwps = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "rsbs", 1)) {
|
elsif($_ = check_res_feature($l, "rsbs", 1)) {
|
||||||
$rsbs = $_;
|
$rsbs = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "rfms", 1)) {
|
elsif($_ = check_res_feature($l, "rfms", 1)) {
|
||||||
$rfms = $_;
|
$rfms = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "Font", 1)) {
|
elsif($_ = check_res_feature($l, "Font", 1)) {
|
||||||
$remotefont = $_;
|
$remotefont = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "iconset", 1)) {
|
elsif($_ = check_res_feature($l, "iconset", 1)) {
|
||||||
$remoteiconset = $_;
|
$remoteiconset = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "viewers iconset", 1)) {
|
elsif($_ = check_res_feature($l, "viewers iconset", 1)) {
|
||||||
$remoteviewericon = $_;
|
$remoteviewericon = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "statusbar", 1)) {
|
elsif($_ = check_res_feature($l, "statusbar", 1)) {
|
||||||
$remotestatusbar = $_;
|
$remotestatusbar = $_;
|
||||||
}
|
}
|
||||||
elsif($_ = check_res($l, "ui viewport", 1)) {
|
elsif($_ = check_res_feature($l, "ui viewport", 1)) {
|
||||||
$remotelistviewport = $_;
|
$remotelistviewport = $_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue