[PATCH] scripts/carray: change to using single .awk script to generate .c

Ben Dooks ben.dooks at codethink.co.uk
Sun Dec 1 03:18:32 PST 2024


On 01/12/2024 11:12, Ben Dooks wrote:
> On 01/12/2024 11:08, Anup Patel wrote:
>> On Fri, Nov 29, 2024 at 3:39 PM Ben Dooks <ben.dooks at codethink.co.uk> 
>> wrote:
>>>
>>> The shell script makes multiple call-outs to awk to get information
>>> from the configuration file. It would be easier to just write the
>>> whole thing in one .awk script and have the makefile altered to call
>>> that instead.
>>>
>>> There should be no functional difference other than the script type
>>> and has been tested with PLATFORM=generic build. This should be both
>>> quicker and easier to understand.
>>>
>>> Signed-off-by: Ben Dooks <ben.dooks at codethink.co.uk>
>>> ---
>>> v2:
>>>    - updated with the new bits from Samuel Holland's changes
>>>    - minor tweaks to the awk script to fix the output spacing
>>
>> The "./scripts/carray.awk -h" is not showing the help text.
>>
>> Also, I tried compiling OpenSBI with this patch on Ubuntu 24.04
>> but it does not boot because the generated C arrays are empty.
> 
> Hmm, it might be worth adding an option to warn if the lists are
> zero length?
> 
> I seem to have forgotten to add -h
> 
> I'll try running it under standard awk, I think my debian install
> maybe using gawk by default.
> 
> Does anyone know if awk has some way of deal with options? I couldn't
> find anything that shows anything like getopt() library.
> 
> Thanks.
> 

I found an issue with -h is that (g)awk takes this as an argument
for itself.

I am considering moving to wrapping the awk in bash and having bash
sort the arguments out and then invoking the awk directly from the
bash script. I'll look at this for v3.

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html



More information about the opensbi mailing list