summaryrefslogtreecommitdiff
path: root/scripts/carray.sh
AgeCommit message (Collapse)Author
2024-12-15scripts/carray: change to using single awk invocation to generate .cBen Dooks
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 <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-12-15script/carry.sh: send error to stderrBen Dooks
Send the errors to stderr, otherwise they end up being written to the file the script was redirecting to in the Makefile Also, use EOF block to make it easier to redirect Signed-off-by: Ben Dooks <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-28scripts/carray.sh: Allow referencing a struct memberSamuel Holland
It can be useful to embed the objects referenced by a carray inside another struct. To avoid type punning, the generated carray code must use the correct type for the enclosing struct and member access to compute the desired object address. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-28scripts/carray.sh: Avoid useless use of catSamuel Holland
awk(1) takes input files as positional arguments, so there is no need to read the file with cat(1). Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-28treewide: Make carray arrays const and NULL-terminatedSamuel Holland
This allows the compiler to generate significantly better code, because it does not have to maintain either the loop counter or loop limit. Plus there are half as many symbols to relocate. This also simplifies passing carray arrays to helper functions. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-07-04scripts/carray.sh: Add comment to generated filesIvan Orlov
Add a comment about where auto-generated file came from to the carray.sh output. This should help avoiding confusion for the developers looking at the build artifacts and finding .c files there. Signed-off-by: Ivan Orlov <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Ben Dooks <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-10scripts: use env to invoke bashHimanshu Chauhan
Not all systems have bash at a fixed location like /bin/bash. FreeBSD, for example, would typically have it at /usr/local/bin/bash. When building OpenSBI on freebsd system, the build breaks. Its advisable to use: #!/usr/bin/env bash Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-05-13Makefile: Add support for generating C array at compile timeAnup Patel
Generating C array at compile time based on details provided by objects.mk is a very useful feature which will help us compile only a subset of drivers or modules. We add a bash script (carray.sh) which takes array details and object/variable list from command-line to generate a C source containing array of object/variable pointers. We also extend top-level makefile to use carray.sh whenever specified through objects.mk. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>