Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions iocAdmin/Db/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,5 @@ $(COMMON_DIR)/iocAdminVxWorks.db: $(COMMON_DIR)/iocAdminScanMon.db $(COMMON_DIR)

$(COMMON_DIR)/siteEnvVars.substitutions: $(EPICS_BASE)/configure/CONFIG_SITE_ENV $(EPICS_BASE)/configure/CONFIG_ENV
@echo Expanding siteEnvVars.substitutions from $^....
@echo file iocEnvVar.template > $@
@echo { >> $@
@echo pattern >> $@
@echo { ENVNAME, ENVVAR, ENVTYPE } >> $@
@sed -n "s/^EPICS_\([A-Z_]*\).*/{\1, EPICS_\1, epics}/p" $^ >> $@
@echo } >> $@
@$(RM) $@
@$(PERL) ../genSiteEnvVars.pl $^ > $@
29 changes: 29 additions & 0 deletions iocAdmin/Db/genSiteEnvVars.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env perl
#
# Usage: genSiteEnvVars.pl CONFIG_SITE_ENV [ ... ]
#
# Reads an EPICS CONFIG_SITE_ENV file and outputs
# a substitutions file to generate appropriate EPICS
# records for those variables via iocEnvVar.template
#
Comment thread
simon-ess marked this conversation as resolved.
use strict;
use warnings;

print <<__END__;
file "iocEnvVar.template" {
pattern { ENVNAME, ENVVAR, ENVTYPE }
__END__

my @epics_vars;
while(<>) {
my $m = s/^EPICS_([A-Z_0-9]*).*\n/${1}/;
push(@epics_vars, $_) if $m;
}

my %varcount;
my @unique_vars = grep { not $varcount{$_}++ } @epics_vars;

foreach (@unique_vars) {
print "{ $_, EPICS_$_, epics }\n"
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be written on one line instead of 3, but I doubt if there'd be any measurable performance difference:

print "{ $_, EPICS_$_, epics }\n" for @unique_vars;

print("}\n");