summaryrefslogtreecommitdiff
path: root/scripts/carray.sh
AgeCommit message (Collapse)AuthorFilesLines
2024-12-15scripts/carray: change to using single awk invocation to generate .cBen Dooks1-33/+99
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@codethink.co.uk> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15script/carry.sh: send error to stderrBen Dooks1-6/+8
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 <ben.dooks@codethink.co.uk> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-28scripts/carray.sh: Allow referencing a struct memberSamuel Holland1-2/+9
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 <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-28scripts/carray.sh: Avoid useless use of catSamuel Holland1-3/+3
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 <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-28treewide: Make carray arrays const and NULL-terminatedSamuel Holland1-4/+3
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 <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-07-04scripts/carray.sh: Add comment to generated filesIvan Orlov1-0/+1
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 <ivan.orlov0322@gmail.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Reviewed-by: Anup Patel <anup@brainfault.org>
2022-12-10scripts: use env to invoke bashHimanshu Chauhan1-1/+1
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 <hchauhan@ventanamicro.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2022-05-13Makefile: Add support for generating C array at compile timeAnup Patel1-0/+77
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 <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>