-
Notifications
You must be signed in to change notification settings - Fork 893
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
cli(tcl): add ability to pass argument to tcl script from cli #3973
Conversation
for |
Possible to just have a comment to know if there a problem with this or if i just need to wait please ? |
I think this would break passing arguments to yosys itself. For example a common use case is |
Adding a getopt_long and using -- to pass down arguments to tcl ? |
I'm sure all people understand cannot pass cmd line argument is a major problem. For that, i didn't understand why this verilog file isn't a tcl argument ?
|
Tbh I don't understand how this is a "major problem". You can just use something like the following to pass whatever you want through the environment instead:
|
That seems reasonable, can you update the PR? |
Yes, i'll do this asap |
Was tired no need to use getopt long, update done |
b48a254
to
871d037
Compare
Can i do someting else, to get it accepted ? |
Thanks, at first glance it looks good, it's just that we need to find some time to review/try it out now! |
Okay thanks |
I gave the current PR a try and it's not quite implementing what we had in mind with The idea was that you can use When I tried making a small change to your existing PR to implement this, I realized that on linux glibc's I'm not sure what's the best way to solve this, one way would be to switch the argument handling to something that doesn't depend on the platform's Another way that would work, but where I'm not sure if it is something we would want to add that way (@nakengelhardt ?), would be to use a separator for input files and tcl arguments that is not handled by |
deb779d
to
8f30f6f
Compare
Ok found why here : https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/libutil-getopt-3.html I updated my changes to have well working on linux/macos/windows with passing down to frontend arguments before the '--' and to tcl arguments after the '--' 3 solutions are easy to use : |
Using + at the opstring start or using the current windows fallback everywhere is a backwards incompatible change for the command line parsing on Linux. As I wrote above, it would be OK to allow mixing options and positional args on non-Linux platforms but not ok to suddenly forbid mixing on Linux as that would break existing uses. More concretely |
So what about using a - at start of opstring :
and adding a rule '\001' to handle arguments like now on linux (and maybe at same time code this behavior in the windows version, for mac os it's harder to implement) |
ab50d3d
to
8a11d87
Compare
I made an update to use getopt implementation on all platform and fit to RETURN_IN_ORDER behavior. Hope this will be ok for you, it's a pain to have to use a fork in our CI and our project. |
* Keep the previous behavior when no tcl script is used * Do not treat "-" as a flag but as a positional argument * Keep including <unistd.h> as it's also used for other functions (at least for the emscripten build) * Move the custom getopt implementation into the Yosys namespace to avoid potential collisions
Testing revealed an issue with a lone "-" as argument (used to read from stdin, should be treated as positional argument) and build failures for the emscripten build, additionally there was another small change needed to make sure existing uses of |
Thanks a lot, can i do anything else ? |
I think this is ready now, but given that this affects code used for every yosys invocation and we're about to make a new release, I want to wait a few days and merge it after the release is made to give us a chance to spot any issues I might have missed before it makes it into the release after that. |
Ok thanks a lot for your help |
Pass all argument after the tcl script name to tcl execution in argv, argument number in argc and tcl script name in argv0 like in tclsh or wish :
https://wiki.tcl-lang.org/page/argv