Skip to content

Added a small usability improve for Unix.mk savedefconfig #16312

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ValentiWorkLearning
Copy link
Contributor

@ValentiWorkLearning ValentiWorkLearning commented May 5, 2025

Note: Please adhere to Contributing Guidelines.

Summary

I've found that while working on the custom board initial platform bringup it's a kind of:

  • make menuconfig
  • make savedefconfig
  • git add
  • git commit

When the board is configured to be out-of-tree, then it's possible to simply forget where the defconfig is stored/how to navigate into it.

Impact

Buildsystem

Testing

Just a simple make savedefconfig is enough:

"The defconfig was generated successfully at /workspaces/rtos_labs/nuttxspace/nuttx/defconfig .If you're building out-of-tree configuration, then copy it to your configuration defconfig"

@github-actions github-actions bot added Area: Tooling Area: Build system Size: XS The size of the change in this PR is very small labels May 5, 2025
@simbit18
Copy link
Contributor

simbit18 commented May 5, 2025

hi @ValentiWorkLearning replace Unix.ml with Unix.mk in the title

@@ -768,6 +768,7 @@ savedefconfig: apps_preconfig
$(Q) rm -f warning.tmp
$(Q) rm -f defconfig.tmp
$(Q) rm -f sortedconfig.tmp
$(info "The defconfig was generated successfully at $(PWD)/defconfig .If you're building out-of-tree configuration, then don't forget to copy it into your defconfig original location")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's implement autosave directly, aligning with cmake's behavior

https://github.com/apache/nuttx/blob/master/cmake/menuconfig.cmake#L98-L99

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anchao hm.. That's good idea. It seems that this flow has to be same for other tools(buildroot for instance). So, technically make savedefconfig should directly write to the original defconfig file. Would this be the expected behaviour?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no standard that specifies the behavior of savedefconfig. I think the change is worth if the improvement could make developers more efficient,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anchao what is the goal of this cmake autosave? If I understood correctly when user run "make savedefconfig" it will replace the original defconfig for current board profile. Although this behavior seems good at first glance, the reason because Greg didn't implement this way it because normally the developer will use a base board:nsh profile to modify and create a local defconfig that he/she will move to a new configs/namedir that will be created. I think the cmake autosave should require a flag to force this behavior, something like "make -f savedefconfig". Maybe @patacongo could give more details here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anchao what is the goal of this cmake autosave? If I understood correctly when user run "make savedefconfig" it will replace the original defconfig for current board profile. Although this behavior seems good at first glance, the reason because Greg didn't implement this way it because normally the developer will use a base board:nsh profile to modify and create a local defconfig that he/she will move to a new configs/namedir that will be created. I think the cmake autosave should require a flag to force this behavior, something like "make -f savedefconfig". Maybe @patacongo could give more details here.

My view is straightforward: change it in a way that is most convenient for developers.
Not replacing the original defconfig with savedefconfig was reasonable before the emergence of git, developers did not have diff tools to check for differences between their work and original config
After git, if the original configuration is directly replaced by savedefconfig, developers can easily use git diff to check whether the changes as expectations. If not, they only need to use git checkout to restore the file.
I think for 90% of individual developers, this approach will enhance their efficiency.

Furthermore, this improvement could also shorten the CI-CD time, and the process of refresh.sh could be optimized.

refresh.sh (6s)

archer@archer:~/code/nuttx/n6/nuttx$ time ./tools/refresh.sh --silent sim/nsh
  [1/1] Normalize sim/nsh

real	0m6.049s
user	0m3.137s
sys	0m1.988s

autosave (1.5s)

archer@archer:~/code/nuttx/n6/nuttx$ time make savedefconfig
Loaded configuration '.config'
Minimal configuration saved to 'defconfig.tmp'

real	0m1.363s
user	0m0.802s
sys	0m0.422s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anchao your point makes sense, but then it should be important to have an option to not replace the original defconfig, because it will add a more steps for developers creating new profiles: currently after the "cmake savedefconfig" they will need:
cp boards/xxx/xxx/xxxx/configs/nsh/defconfig /backup/configs/
git checkout boards/xxx/xxx/xxxx/configs/nsh/defconfig
mkdir boards/xxx/xxx/xxxx/configs/newbrdcfg/
cp /backup/configs/defconfig boards/xxx/xxx/xxxx/configs/newbrdcfg/

Compared with current way using "make savedefconfig":
mkdir boards/xxx/xxx/xxxx/configs/newbrdcfg/
cp defconfig boards/xxx/xxx/xxxx/configs/newbrdcfg/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acassis please think about when users would want to do the savedefconfig. Could it be to save a copy? I don't think so, What they actually want is to replace the original version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anchao your point makes sense, but then it should be important to have an option to not replace the original defconfig, because it will add a more steps for developers creating new profiles: currently after the "cmake savedefconfig" they will need: cp boards/xxx/xxx/xxxx/configs/nsh/defconfig /backup/configs/ git checkout boards/xxx/xxx/xxxx/configs/nsh/defconfig mkdir boards/xxx/xxx/xxxx/configs/newbrdcfg/ cp /backup/configs/defconfig boards/xxx/xxx/xxxx/configs/newbrdcfg/

Compared with current way using "make savedefconfig": mkdir boards/xxx/xxx/xxxx/configs/newbrdcfg/ cp defconfig boards/xxx/xxx/xxxx/configs/newbrdcfg/

Regarding first case, why not back up the old version first?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acassis please think about when users would want to do the savedefconfig. Could it be to save a copy? I don't think so, What they actually want is to replace the original version.

@anchao I think we are talking about different things. Normally users create a new config using an old one as base. But of course, it is possible to change the way the do it, now instead of using boardname:nsh as start point the need first to copy the "nsh" board profile to a new place (i.e. "newbrdcfg") and the run boardname:newbrdcfg

I think this approach is ok, we just need to change the way normally people do it (as I described previously)

@ValentiWorkLearning ValentiWorkLearning changed the title Added a small usability improve for Unix.ml savedefconfig Added a small usability improve for Unix.mk savedefconfig May 5, 2025
@ValentiWorkLearning
Copy link
Contributor Author

Re-requested review just to ask, what should be done with this PR then 😄
Should I refactor it somehow or can we merge it?

@xiaoxiang781216
Copy link
Contributor

Re-requested review just to ask, what should be done with this PR then 😄 Should I refactor it somehow or can we merge it?

@anchao do you have more concern?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Build system Area: Tooling Size: XS The size of the change in this PR is very small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants