diff options
author | Thomas Martitz <kugel@rockbox.org> | 2014-01-13 23:06:28 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2014-03-03 15:14:15 +0100 |
commit | 20e114c1a0f086e432f374fe0ecebf014a571448 (patch) | |
tree | 3e515cef06f8210b4d5283be438294f608e7ceeb | |
parent | 62524237f0055d2825d6cde90c49840404c57e30 (diff) | |
download | rockbox-20e114c1a0f086e432f374fe0ecebf014a571448.tar.gz rockbox-20e114c1a0f086e432f374fe0ecebf014a571448.zip |
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
-rwxr-xr-x | wps/wpsbuild.pl | 74 |
1 files 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); | |||
328 | 328 | ||
329 | # check if line matches the setting string or if it contains a regex | 329 | # check if line matches the setting string or if it contains a regex |
330 | # that contains the targets resolution | 330 | # that contains the targets resolution |
331 | sub check_res { | 331 | # |
332 | # the line can be of the from | ||
333 | # 1) setting: value (handled above) | ||
334 | # 2) setting.128x96x2: value | ||
335 | # 3) setting.128x96x2&touchscreen: value | ||
336 | # The resolution pattern can be a perl-comatible regex | ||
337 | sub check_res_feature { | ||
332 | my ($line, $string, $remote) = @_; | 338 | my ($line, $string, $remote) = @_; |
333 | if ($line =~ /^${string}: *(.*)/i) { | 339 | if ($line =~ /^$string: *(.*)/i) { |
334 | return $1; | 340 | return $1; |
335 | } | 341 | } |
336 | elsif($line =~ /^${string}.(.*): *(.*)/i) { | 342 | elsif($line =~ /^$string\.(.*): *(.*)/i) { |
337 | # $1 is a resolution regex, $2 the filename incl. resolution | 343 | # $1 is a resolution/feature regex, $2 the filename incl. resolution |
344 | my $substr = $1; | ||
338 | my $fn = $2; | 345 | my $fn = $2; |
346 | my $feature; | ||
339 | my $size_str = "${main_width}x${main_height}x${main_depth}"; | 347 | my $size_str = "${main_width}x${main_height}x${main_depth}"; |
340 | if ($remote) { | 348 | if ($remote) { |
341 | $size_str = "${remote_width}x${remote_height}x${remote_depth}"; | 349 | $size_str = "${remote_width}x${remote_height}x${remote_depth}"; |
342 | } | 350 | } |
343 | if ($size_str =~ /$1$/) { | 351 | |
344 | return $fn; | 352 | # extract feature constraint, if any |
353 | if ($substr =~ /&([a-z0-9_]+)/) { | ||
354 | $feature = $1; | ||
355 | $substr =~ s/&$feature//; | ||
356 | } | ||
357 | |||
358 | if ($size_str =~ /$substr$/) { | ||
359 | if ($feature) { | ||
360 | # check feature constrait | ||
361 | open(FEAT, "<apps/features"); | ||
362 | chomp(my @lines = <FEAT>); | ||
363 | close(FEAT); | ||
364 | my $matches = (grep { /$feature/ } @lines); | ||
365 | return $fn if $matches > 0; | ||
366 | } | ||
367 | else { | ||
368 | # no feature constraint | ||
369 | return $fn; | ||
370 | } | ||
345 | } | 371 | } |
346 | } | 372 | } |
347 | return ""; | 373 | return ""; |
@@ -452,22 +478,22 @@ while(<WPS>) { | |||
452 | if ($l =~ /^ *<\/main>/i) { | 478 | if ($l =~ /^ *<\/main>/i) { |
453 | last; | 479 | last; |
454 | } | 480 | } |
455 | elsif($_ = check_res($l, "wps")) { | 481 | elsif($_ = check_res_feature($l, "wps")) { |
456 | $wps = $_; | 482 | $wps = $_; |
457 | } | 483 | } |
458 | elsif($_ = check_res($l, "sbs")) { | 484 | elsif($_ = check_res_feature($l, "sbs")) { |
459 | $sbs = $_; | 485 | $sbs = $_; |
460 | } | 486 | } |
461 | elsif($_ = check_res($l, "fms")) { | 487 | elsif($_ = check_res_feature($l, "fms")) { |
462 | $fms = $_; | 488 | $fms = $_; |
463 | } | 489 | } |
464 | elsif($_ = check_res($l, "Font")) { | 490 | elsif($_ = check_res_feature($l, "Font")) { |
465 | $font = $_; | 491 | $font = $_; |
466 | } | 492 | } |
467 | elsif($_ = check_res($l, "Statusbar")) { | 493 | elsif($_ = check_res_feature($l, "Statusbar")) { |
468 | $statusbar = $_; | 494 | $statusbar = $_; |
469 | } | 495 | } |
470 | elsif($_ = check_res($l, "Backdrop")) { | 496 | elsif($_ = check_res_feature($l, "Backdrop")) { |
471 | $backdrop = $_; | 497 | $backdrop = $_; |
472 | } | 498 | } |
473 | elsif($l =~ /^Foreground Color: *(.*)/i) { | 499 | elsif($l =~ /^Foreground Color: *(.*)/i) { |
@@ -482,13 +508,13 @@ while(<WPS>) { | |||
482 | elsif($l =~ /^line selector end color: *(.*)/i) { | 508 | elsif($l =~ /^line selector end color: *(.*)/i) { |
483 | $lineselectend = $1; | 509 | $lineselectend = $1; |
484 | } | 510 | } |
485 | elsif($_ = check_res($l, "selector type")) { | 511 | elsif($_ = check_res_feature($l, "selector type")) { |
486 | $selecttype = $_; | 512 | $selecttype = $_; |
487 | } | 513 | } |
488 | elsif($_ = check_res($l, "iconset")) { | 514 | elsif($_ = check_res_feature($l, "iconset")) { |
489 | $iconset = $_; | 515 | $iconset = $_; |
490 | } | 516 | } |
491 | elsif($_ = check_res($l, "viewers iconset")) { | 517 | elsif($_ = check_res_feature($l, "viewers iconset")) { |
492 | $viewericon = $_; | 518 | $viewericon = $_; |
493 | } | 519 | } |
494 | elsif($l =~ /^show icons: *(.*)/i) { | 520 | elsif($l =~ /^show icons: *(.*)/i) { |
@@ -500,7 +526,7 @@ while(<WPS>) { | |||
500 | elsif($l =~ /^filetype colours: *(.*)/i) { | 526 | elsif($l =~ /^filetype colours: *(.*)/i) { |
501 | $filetylecolor = $1; | 527 | $filetylecolor = $1; |
502 | } | 528 | } |
503 | elsif($_ = check_res($l, "ui viewport")) { | 529 | elsif($_ = check_res_feature($l, "ui viewport")) { |
504 | $listviewport = $_; | 530 | $listviewport = $_; |
505 | } | 531 | } |
506 | } | 532 | } |
@@ -515,28 +541,28 @@ while(<WPS>) { | |||
515 | elsif(!$has_remote) { | 541 | elsif(!$has_remote) { |
516 | next; # dont parse <remote> section | 542 | next; # dont parse <remote> section |
517 | } | 543 | } |
518 | elsif($_ = check_res($l, "rwps", 1)) { | 544 | elsif($_ = check_res_feature($l, "rwps", 1)) { |
519 | $rwps = $_; | 545 | $rwps = $_; |
520 | } | 546 | } |
521 | elsif($_ = check_res($l, "rsbs", 1)) { | 547 | elsif($_ = check_res_feature($l, "rsbs", 1)) { |
522 | $rsbs = $_; | 548 | $rsbs = $_; |
523 | } | 549 | } |
524 | elsif($_ = check_res($l, "rfms", 1)) { | 550 | elsif($_ = check_res_feature($l, "rfms", 1)) { |
525 | $rfms = $_; | 551 | $rfms = $_; |
526 | } | 552 | } |
527 | elsif($_ = check_res($l, "Font", 1)) { | 553 | elsif($_ = check_res_feature($l, "Font", 1)) { |
528 | $remotefont = $_; | 554 | $remotefont = $_; |
529 | } | 555 | } |
530 | elsif($_ = check_res($l, "iconset", 1)) { | 556 | elsif($_ = check_res_feature($l, "iconset", 1)) { |
531 | $remoteiconset = $_; | 557 | $remoteiconset = $_; |
532 | } | 558 | } |
533 | elsif($_ = check_res($l, "viewers iconset", 1)) { | 559 | elsif($_ = check_res_feature($l, "viewers iconset", 1)) { |
534 | $remoteviewericon = $_; | 560 | $remoteviewericon = $_; |
535 | } | 561 | } |
536 | elsif($_ = check_res($l, "statusbar", 1)) { | 562 | elsif($_ = check_res_feature($l, "statusbar", 1)) { |
537 | $remotestatusbar = $_; | 563 | $remotestatusbar = $_; |
538 | } | 564 | } |
539 | elsif($_ = check_res($l, "ui viewport", 1)) { | 565 | elsif($_ = check_res_feature($l, "ui viewport", 1)) { |
540 | $remotelistviewport = $_; | 566 | $remotelistviewport = $_; |
541 | } | 567 | } |
542 | } | 568 | } |