-
Notifications
You must be signed in to change notification settings - Fork 44
Use perl instead of sed #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use perl instead of sed #63
Conversation
|
Have converted to draft as though it works on windows it doesn't on linux. The problem is that |
|
It might be possible to do something like ifeq ($(strip $(OS_CLASS)),WIN32)
QUOTE="
else
QUOTE='
endif
$(COMMON_DIR)/siteEnvVars.substitutions: $(EPICS_BASE)/configure/CONFIG_SITE_ENV
@echo Expanding siteEnvVars.substitutions from CONFIG_SITE_ENV....
@echo file iocEnvVar.template> $@
@echo {>> $@
@echo pattern>> $@
@echo { ENVNAME, ENVVAR, ENVTYPE }>> $@
@perl -n -e $(QUOTE)$$m = s/^EPICS_([A-Z_]*).*/{$${1}, EPICS_$${1}, epics}/; print $$_ if $$m;$(QUOTE) < $< >> $@
@echo }>> $@
though I am not sure this is much better... 😄 |
|
Well it makes it clear what we are trying to do at least, I am happy to go with that if you are - thanks |
|
Unless you think putting the |
|
Surely it would be simpler to use a stand-alone Perl script to do the whole job of generating the |
|
Oh no more perl scripts 😄 Anyhow, I think you are correct in this case that a standalone script is easier; this is a pretty simple parsing, but the solution is better. |
iocAdmin/Db/genSiteEnvVars.pl
Outdated
| @@ -0,0 +1,9 @@ | |||
| print("file iocEnvVar.template\n"); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a shebang, usage, and copyright notice?
|
NB The Windows-2019 job failures here are because today is one of the days that GitHub is doing a brown-out of their windows-2019 CI runners, to remind everyone to upgrade. That also requires updating the Visual Studio version to 2022, see |
|
did you want me to rebase the branch onto latest base-7.0 ? |
|
sorry - talking rubbish - this isn't a base PR. Will make changes to iocStats CI |
01f1b69 to
8f8a475
Compare
|
I have updated the perl script to be in line with #74 and other changes, as well as rebased. @FreddieAkeroyd if you could have a look at this and make sure this lines up with what you like, and I will merge it. |
|
@nariox, if you could also take a look at this please. |
|
@anjohnson Would you mind giving this a quick sanity look? I'm not as much a perl-sort of person, and I would appreciate a second set of eyes on this before merging it in. |
|
Thanks @simon-ess looks fine to me when i build locally i get this message which doesn't seem to affect the build I see explicit dependency rules in the |
anjohnson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Simon, this looks okay to me, the comments below are a few tweaks but they aren't essential.
iocAdmin/Db/genSiteEnvVars.pl
Outdated
|
|
||
| my @epics_vars; | ||
| while(<>) { | ||
| $m = s/^EPICS_([A-Z_]*).*\n/${1}/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your regex does look to match the original given to sed, although it doesn't actually cover all of the env-params in the EPICS configure/CONFIG_{SITE_,}ENV files. It misses the three IOCSH_* variables, but maybe that's by design, I don't see that sites would need to see their values remotely.
Personally I might use this regex instead:
/^EPICS_([A-Z_0-9]+)\s*=.*\n/$1/and maybe instead of substituting the match into $_ I'd just write the loop body as
push @epics_vars, $1 if m/^EPICS_([A-Z_0-9]+)\s*=/;although I haven't actually tested that.
I guess not capturing the leading EPICS_ and then adding it back later was done to speed up the text processing, although IMO that makes the code slightly more brittle in the event of later changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, I think I should update to include 0-9 as well. Done.
|
|
||
| foreach (@unique_vars) { | ||
| print "{ $_, EPICS_$_, epics }\n" | ||
| } |
There was a problem hiding this comment.
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;8f8a475 to
8b137c6
Compare
Windows does not have
sedso change to useperlthat is already needed for building EPICSSee #62