From 4d28daf6a0f1bf0aeb23e9963636d0388b5057b4 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 4 Oct 2010 03:04:35 -0300 Subject: [PATCH] Environment variable SCHHIST_ADDLIBS to force libraries to be present. - schhist/sanitize-profile: ensure that the libraries listed in SCHHIST_ADDLIBS are present in the profile - schhist/Makefile (board-qi-avt2): use SCHHIST_ADDLIBS to add the "device" library --- schhist/Makefile | 1 + schhist/sanitize-profile | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/schhist/Makefile b/schhist/Makefile index 8306f29..d593e65 100644 --- a/schhist/Makefile +++ b/schhist/Makefile @@ -102,6 +102,7 @@ board-qi-avt2: SCHHIST_TITLE="AVT2" \ SCHHIST_HOME_URL=http://projects.qi-hardware.com/index.php/p/board-qi-avt2/ \ SCHHIST_COMMIT_TEMPLATE='http://projects.qi-hardware.com/index.php/p/board-qi-avt2/source/commit/{}/' \ + SCHHIST_ADDLIBS=device \ ./schhist2web -S ../../board-qi-avt2 \ main/Qi_AVT2.sch _avt2 diff --git a/schhist/sanitize-profile b/schhist/sanitize-profile index 9a7aea8..1ca3c59 100755 --- a/schhist/sanitize-profile +++ b/schhist/sanitize-profile @@ -22,6 +22,7 @@ sub rewrite return $s if $section ne "eeschema/libraries"; return $s unless /^LibName(\d+)=(.*)\s*$/; my $lib = $2; + delete $add{$lib}; if ($1 == $in_lib) { $in_lib++; } else { @@ -42,6 +43,17 @@ sub rewrite } +sub complement +{ + for (sort keys %add) { + print STDERR "adding $_\n"; + $out_lib++; + push(@f, "LibName$out_lib=$_\n"); + delete $add{$_}; + } +} + + sub usage { print STDERR "usage: $0 file.pro [outfile]\n"; @@ -49,6 +61,10 @@ sub usage } +for (split(",", $ENV{"SCHHIST_ADDLIBS"})) { + $add{$_} = 1 if $_ ne ""; +} + ($file, $out) = @ARGV; &usage if $#ARGV > 1; @@ -58,11 +74,13 @@ $dir = "." if $dir eq ""; open(FILE, $file) || die "$file: $!"; while () { if (/^\[(\S+)\]/) { - $section = $1; - if ($section eq "eeschema/libraries") { + if ($1 eq "eeschema/libraries") { $in_lib = 1; $out_lib = 0; + } else { + &complement if $section eq "eeschema/libraries"; } + $section = $1; } if ($section eq "eeschema") { $libdir = $1 if /^LibDir=(.*)\s*$/; @@ -71,6 +89,7 @@ while () { push(@f, $s) if defined $s; } close FILE; +∁ if (!defined $out) { rename($file, "$file.bak");