You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Tim Hardisty <ti...@gmail.com> on 2023/11/23 11:42:24 UTC
Dumb question re: "full path", out of tree board
Hi,
I have an out-of-tree custom board (which lives resides in my main NuttX
folder as ./../CustomBoards/boardname). I use checkpatch.sh even on my
board software in that locations as I like to be consistent, but it
complains that the path (line 2 of the header comment) must begin with
the root directory as it's a relative path other than "nuttx".
Fair enough, but I can't work out what path makes checkpatch.sh happy!
For CustomApps I use a symbolic link within the apps folder to "MyApps"
and have line 2 of my source files as apps/MyApps/appname/file.c and
it's happy with that but I just can't figure out what the custom board
header file path should be stated as.
I tried the symbolic link trick for this, too, but it didn't seem to
work, with the same error reported no matter what I put in line 2: and,
anyway, they are a pain since my link in apps gets trashed if I do a new
branch based on master (unless I'm missing a trick there?).
Thanks!
Re: Dumb question re: "full path", out of tree board
Posted by Karel Kočí <cy...@email.cz>.
Hello,
I am afraid that it is just not covered correctly by nxstyle. I was tackling the
same issue few times already.
nxstyle first resolves all symlinks with `realpath` and thus no magic with
symlinks will work.
https://github.com/apache/nuttx/blob/ed877fd494cc465671186a63a7fd9c41abf494ba/tools/nxstyle.c#L1138C37
The code checks if it is relative to NuttX directory with `strstr` which can be
abused. The second allowed is that it relative to apps directory path. This is
harder to abused. If neither is true then it prints tat error message. I do not
see where it would even try to check if path is absolute and thus the message is
just not correct in my eyes.
https://github.com/apache/nuttx/blob/ed877fd494cc465671186a63a7fd9c41abf494ba/tools/nxstyle.c#L1327
I know about three possible ways to get nxstyle work with external applications
and board code.
The first one is that you can just abuse the check for NuttX root directory. If
you have NuttX project in `/home/foo/nuttx` then `/home/foo/nuttx-myapps` and
such is considered to be relative to the NuttX root. It is simply abused but
sometimes it is possible to organize your project this way and get nxstyle to
work for free.
The second is what I am using right now and that is wrapper script around
nxstyle call that just disables that error. Appended at the end of my mail for
inspiration.
The third and last one is to figure out how it should work and implement it with
patch. I just haven't had time to do so. 😇
With regards
Karel Kočí
The promised script (placed in tool directory in our projects). It is not ideal
but it works:
#!/usr/bin/env bash
set -eu
# We want to make sure that our board sources are formatted correctly according
# the NuttX code style. At the same time we can't ensure simply that absolute
# path is in header and thus we just simply mask this type of error and keep
# path as it would be in NuttX repository.
project="${0%/*}/.."
nuttx_tools="${0%/*}/../core/tools"
export CROSSDEV="arm-none-eabihf-"
itype=' error'
imessage=' Path relative to repository other than "nuttx" must begin with the root directory'
ec=0
while IFS=: read -r file line char type message; do
echo -n "$file:$line:$char$type:$message" >&2
if [[ "$type" == "$itype" ]] && [[ "$message" == "$imessage" ]]; then
echo " (Ignored)"
else
echo
ec=1
fi
done <<<"$(git ls-files \
"$project/board/**" \
"$project/project-apps/**" \
"$project/project-libs/**" \
| xargs "$nuttx_tools/checkpatch.sh" -f)"
exit $ec
Excerpts from Nathan Hartman's message of November 23, 2023 1:58 pm:
> On Thu, Nov 23, 2023 at 6:42 AM Tim Hardisty <ti...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I have an out-of-tree custom board (which lives resides in my main NuttX
>> folder as ./../CustomBoards/boardname). I use checkpatch.sh even on my
>> board software in that locations as I like to be consistent, but it
>> complains that the path (line 2 of the header comment) must begin with
>> the root directory as it's a relative path other than "nuttx".
>
>
>
> I hope it is *not* requiring an absolute path here, because that would be
> unacceptable: a developer might put the NuttX tree in, e.g.,
> /home/bob/work/NuttX/... on one machine, and another team member might put
> it in /home/alice/NuttX, and if we're requiring an absolute path then the
> source files become tied to one particular machine with one particular
> layout which is not portable to other machines. This may or may not apply
> in Tim's case, but even if this doesn't apply to Tim's case, it would be
> incorrect.
>
> I am using my phone atm so I cannot dig into the sources right now, but
> I'll try to look a little later...
>
> Cheers
> Nathan
>
Re: Dumb question re: "full path", out of tree board
Posted by Nathan Hartman <ha...@gmail.com>.
On Thu, Nov 23, 2023 at 6:42 AM Tim Hardisty <ti...@gmail.com>
wrote:
> Hi,
>
> I have an out-of-tree custom board (which lives resides in my main NuttX
> folder as ./../CustomBoards/boardname). I use checkpatch.sh even on my
> board software in that locations as I like to be consistent, but it
> complains that the path (line 2 of the header comment) must begin with
> the root directory as it's a relative path other than "nuttx".
I hope it is *not* requiring an absolute path here, because that would be
unacceptable: a developer might put the NuttX tree in, e.g.,
/home/bob/work/NuttX/... on one machine, and another team member might put
it in /home/alice/NuttX, and if we're requiring an absolute path then the
source files become tied to one particular machine with one particular
layout which is not portable to other machines. This may or may not apply
in Tim's case, but even if this doesn't apply to Tim's case, it would be
incorrect.
I am using my phone atm so I cannot dig into the sources right now, but
I'll try to look a little later...
Cheers
Nathan