Skip to content

WIP CLEANUP TESTING NEEDED pkg/pkg.mk: use intermediate state files#11553

Closed
cladmi wants to merge 11 commits intoRIOT-OS:masterfrom
cladmi:pr/pkg/save_state_and_dependencies
Closed

WIP CLEANUP TESTING NEEDED pkg/pkg.mk: use intermediate state files#11553
cladmi wants to merge 11 commits intoRIOT-OS:masterfrom
cladmi:pr/pkg/save_state_and_dependencies

Conversation

@cladmi
Copy link
Copy Markdown
Contributor

@cladmi cladmi commented May 20, 2019

Contribution description

Rely on file creation and dependencies instead of .PHONY targets.
Files will be rebuilt when changing version as the main Makefile will
have been updated. All steps are re-done on version change.

When deleting patches, the '.prepare' step should be redone thanks
to the included 'patch-dep.inc' file (TODO TEST ME).

Implementation in order:

  • '.git': means the repository has been cloned.
  • '.git-downloaded': Fetches the wanted version
  • '.git-prepared': will clean checkout the version and apply patches

Somehow the base is that patching can only be done on the correct commit, so lets do it all at once.

Infos:

  • This is a one commit change to first see if it makes sense at all.
  • This currently do not use the 'smart fetch' from pkg/pkg.mk: Avoid doing a git fetch if we already have the commit. #11491
  • Some parts may be possible to not re-do. Maybe the .prepare should use the content of .git-downloaded instead of the variable.
  • Did not remove the :: rules but should maybe be the occasion to clean this.

Should git-downloaded be updated only with lazy_sponge to not trigger more rebuild ?
I think .git-prepare must be always re-done as the package makefile may do further modifications afterwards… so not sure it would change anything

TODO:

Change so that packages include pkg/pkg.mk earlier. Some packages use PKG_BUILDDIR before it is defined.

Update to use $(PKG_PREPARED) instead of the .PHONY target.

Testing/Reviewing procedure

  • Build all packages (lets see CI)
  • See if it is indeed incremental
  • See if it detects package deletion
  • Any ideas on what to test ?

Issues/PRs references

Discussions coming out of #11491

@cladmi cladmi added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Area: build system Area: Build system Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 20, 2019
@cladmi cladmi added this to the Release 2019.07 milestone May 20, 2019
@cladmi cladmi requested review from jcarrano and kaspar030 May 20, 2019 14:42
@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented May 20, 2019

This should address the issue shown in #11129 too as preparing now always checkouts and patch if there are patches.

The fix for #11129 should have be to only re-do .git-downloaded when $(PKG)/Makefile changed as it is the base state file there.

In here, .git-downloaded only takes care of the fetch where checkout is a separate task.

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented May 20, 2019

Fixed the fail because of PKG_VERSION = 60ea749837362c226e8501718f505ab138e5c19d # v0.98 that led to PKG_VERSION having a space.

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Jun 3, 2019

After thinking about it more, I think it would be good to add an intermediate .git-patched and .git-prepared only creating the file. So packages could do the extra modifications between patching and being prepared with a file target of course.

Then all would always depend on .git-prepared which should do nothing as already up to date as done during prepare.

@cladmi cladmi force-pushed the pr/pkg/save_state_and_dependencies branch from f0e6756 to dd7271e Compare July 8, 2019 18:44
@fjmolinas
Copy link
Copy Markdown
Contributor

This needs a rebase.

@fjmolinas
Copy link
Copy Markdown
Contributor

I did a quick round of testing and this fixed some issue I had where some packages kept beeing recompiled all the time. Does this still need to be wip?

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Oct 2, 2019

It was still WIP in my mind but I can do another pass.

@cladmi cladmi force-pushed the pr/pkg/save_state_and_dependencies branch from af0baa7 to 8570a6f Compare October 2, 2019 09:21
@fjmolinas
Copy link
Copy Markdown
Contributor

It was still WIP in my mind but I can do another pass.

Well, I'm going to start rebasing my branch's on this most of the time now so I'll be testing continuously :).

And if you need help let me know, I'm very interested in getting this in.

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Oct 2, 2019

There are things I should split I guess even if they are done before the real fix like moving pkg/pkg.mk earlier in the file as several targets use PKG_BUILDDIR and refactoring.

@cladmi cladmi force-pushed the pr/pkg/save_state_and_dependencies branch from 8570a6f to 2876d4c Compare October 2, 2019 09:45
@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Oct 2, 2019

One thing that I may need help too, is seeing if other packages must be updated too. This takes a lot of time.
But the current documentation may lack things too.

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Oct 2, 2019

I am also in a place where, either I change the minimal things in a package but keep it in a non reliable state, or I do the work for the migration correctly.
But that requires a lot of cleaning.

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Oct 2, 2019

Somehow for the implementation I also have a question.

When having a $(PREPARED) file, every targets in a package should depend on it. Currently packages do not do it constantly.

So I do not know, should I do it automatically for all in the pkg/pkg.mk but then, when anybody needs another sub-target, it should discover that this target must also depend of it, it could be documented but different than the all target in the minimal packages or should every package repeat all: $(PKG_STATE_PREPARED) ?

@fjmolinas
Copy link
Copy Markdown
Contributor

One thing that I may need help too, is seeing if other packages must be updated too. This takes a lot of time

I can help with this.

@fjmolinas
Copy link
Copy Markdown
Contributor

Somehow for the implementation I also have a question.

When having a $(PREPARED) file, every targets in a package should depend on it. Currently packages do not do it constantly.

So I do not know, should I do it automatically for all in the pkg/pkg.mk but then, when anybody needs another sub-target, it should discover that this target must also depend of it, it could be documented but different than the all target in the minimal packages or should every package repeat all: $(PKG_STATE_PREPARED) ?

To be honest I got a little confused here with the difference between $(PREPARED), $(PKG_STATE_PREPARED) and what I see in code $(PKG_PREPARED).

What is an example of a "minimal package"?

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Oct 2, 2019

It's all PKG_PREPARED I put the wrong name in my comment ><

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Oct 2, 2019

I am thinking that I should refactor to split the git handling from the pkg handling. This way, even if we plan to change the interface, the low level could be correctly abstracted already.

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Oct 4, 2019

The minimal one is this one:

RIOT/pkg/Makefile.git

Lines 1 to 10 in 7d7596e

PKG_NAME= # name of the package
PKG_URL= # source url of the package's git repository
PKG_VERSION= # version of the package to use e.g. a git commit/ref
.PHONY: all
all:
$(MAKE) -C $(CURDIR)/$(PKG_NAME)
include $(RIOTBASE)/pkg/pkg.mk

To be consistent, I would move the include at the beginning to have all the variables defined when using the value immediately. Which is already the case that the PKG_BUILDDIR variable is used before it is set right now.

When adding states, the targets would then all need to depend on $(PKG_PREPARED) which I currently did in the pkg/pkg.mk so the basic packages would not even change. (I even added .PHONY: all to remove this one).
So basic packages do not even change. I noticed almost all packages would not change right now. I will move the pkg/pkg.mk before in a separate commit.

Hovewer, if a package needs to do additional steps before compiling, then, these steps would need to depend on $(PKG_PREPARED) to be re-run if the preparation was re-done.

$(PKG_BUILDDIR)/bin/Makefile: $(PKG_PREPARED) $(TOOLCHAIN_FILE) | ..cmake_version_supported
	cmake -B$(PKG_BUILDDIR)/bin -H$(PKG_BUILDDIR)/src \
	      -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE) \
	      -DCCNL_RIOT=1 -DRIOT_CFLAGS="$(RIOT_CFLAGS)" -DBUILD_TESTING=OFF

But it comes out of nowhere as it was not required for all.

It is a question of balance between, do we make the default simpler but then the different one requiring a lot of new handling, or do we remove the magic and make the dependency explicit in the default case to teach how to handle the more advanced ones.

For the first version I could keep the magic to not modify them too much.

This "ISC License" is the value found by github

https://github.com/atomicobject/heatshrink/blob/7d419e1fa4830d0b919b9b6a91fe2fb786cf3280/LICENSE

    A permissive license lets people do anything with your code with proper
    attribution and without warranty. The ISC license is functionally
    equivalent to the BSD 2-Clause and MIT licenses, removing some language
    that is no longer necessary.
The 'BSD 3-Clause "New" or "Revised" License' is the value found by
github

https://github.com/openthread/openthread/blob/3a248f649acd16448c7f27fe7f17f6f0bb6696f6/LICENSE

> A permissive license similar to the BSD 2-Clause License, but with a 3rd
> clause that prohibits others from using the name of the project or its
> contributors to promote derived products without written consent.
Ensure the required variables are defined before including 'pkg.mk'.
The file must not change the default goal otherwise it could change
packages behavior.
Prepare for handling pkg state with files.
So it requires having the path defined before declaring targets.
@cladmi cladmi force-pushed the pr/pkg/save_state_and_dependencies branch from 2876d4c to 617f671 Compare October 11, 2019 18:31
This should prevent issues where the Makefile use 'PKG_BUILDDIR' before
them being defined.

This will also allow changing the state targets to be file targets.
Rely on file creation and dependencies instead of .PHONY targets.
Files will be rebuilt when changing version as the main `Makefile` will
have been updated. All steps are re-done on version change.

When deleting patches, the '.prepare' step should be redone thanks
to the included 'patch-dep.inc' file (TODO TEST ME).

Implementation in order:

* '.git': means the repository has been cloned.
* '.git-downloaded': Fetches the wanted version
* '.git-prepared': will clean checkout the version and apply patches
This should prevent issues when the directory is not a git repository
which would for example checkout force or clean in the RIOT repository
instead.
@cladmi cladmi force-pushed the pr/pkg/save_state_and_dependencies branch from 617f671 to 14e275f Compare October 11, 2019 18:45
@fjmolinas
Copy link
Copy Markdown
Contributor

@cladmi from talking IRL I think you have not pushed some chages :)

@basilfx
Copy link
Copy Markdown
Member

basilfx commented Jan 6, 2020

@cladmi @fjmolinas Created #13036 as an updated version.

.PHONY: all
include $(RIOTBASE)/pkg/pkg.mk

all: git-download
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
all: git-download
all:

@fjmolinas
Copy link
Copy Markdown
Contributor

Closing now that #13036 is in

@fjmolinas fjmolinas closed this Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants