Skip to content

Conversation

cladmi
Copy link

@cladmi cladmi commented Oct 18, 2018

Contribution description

This should address my remarks from comment

RIOT-OS#10038 (review)

  • add a .gitignore
  • make it mounted by docker
  • add a test to run in docker

Testing procedure

rm -rf /tmp/riot/build; \
make -C tests/build_system_builddir_docker clean all test \
    BUILD_DIR=/tmp/riot/build \
    BUILD_IN_DOCKER=1 DOCKER='sudo docker'

It should work without errors.

To make it more visible, the $(Q) can be removed in the file creation target.

I put the commit in an order with the test first, so it can be tested without the fix more easily by doing git checkout on the test commit. They will need to be re-organized later.

Issues/PRs references

RIOT-OS#10038

@smlng
Copy link
Owner

smlng commented Oct 22, 2018

thanks for helping, I get this error

make: *** No rule to make target `/tmp/riot/build', needed by `..in-docker-container'.  Stop.

also I'm not sure about adding the test because its scope and purpose is very different, i.e. checking the build/make system and not RIOT code. So maybe such should rather go into dist/tests, or so?

@cladmi
Copy link
Author

cladmi commented Oct 22, 2018

Mac make not handling the implicit rule :/ >< Can you try debugging why it is not using this rule ?

https://github.com/smlng/RIOT/pull/6/files#diff-ebbb3165b3276a049759e5cb4e04d6a4R715

A solution could be to replace it with $(BUILD_DIR)/: %/: but then we will need to add all directories to this list (I plan to add $(BINDIR) there soon). So I would prefer to know if it is really needed.

The test was not 100% necessary, it was just to show that the new directory was lacking a proper docker integration. And if a mistake can be made like this, having a test verifying it still works is for me important.

There is already build system/BSP tests like tests/libc_newlib/ and tests/cortexm_common_ldscript/ but these must compile for a board.
So sure I could move it to dist/tests. I can do it after it is tested and works for you.

The build system is part of the riot distribution, if not, we coul remove it and the flash scripts and not bother. That's why I want to start adding non regressions tests.

@smlng smlng force-pushed the pr/make/buildoutdir branch 2 times, most recently from b70c936 to d625b57 Compare October 24, 2018 12:01
@cladmi
Copy link
Author

cladmi commented Nov 19, 2018

Hmm just noticed than it is complaining about /tmp/riot/build instead of /tmp/riot/build/… so maybe there is something else.

Does this work ? (would explain things about MAKEOVERRIDES)

rm -rf /tmp/riot/build; \
BUILD_DIR=/tmp/riot/build BUILD_IN_DOCKER=1 DOCKER="sudo docker" make -C tests/build_system_builddir_docker clean all test

or this ? (with the directory with a slash but still on the command line)

rm -rf /tmp/riot/build; \
make -C tests/build_system_builddir_docker clean all test \
    BUILD_DIR=/tmp/riot/build/ \
    BUILD_IN_DOCKER=1 DOCKER='sudo docker'

@smlng
Copy link
Owner

smlng commented Nov 21, 2018

@cladmi when I manually create the directory, i.e. mkdir -p /tmp/riot/build, before running the build in docker command it works - though there also is a problem with the /etc/localtime on macOS, but that's a different story. So it seems that it does not create the BUILD_DIR first, or at least is not able to.

@cladmi
Copy link
Author

cladmi commented Nov 22, 2018

Yep that is the reason.

If I comment the target with the mkdir in Makefile.include, I get

make: *** No rule to make target '/tmp/riot/build/', needed by '..in-docker-container'.  Stop

So build/ with a terminating /.

It looks like it is an issue with make 3.81 as explained at the end of this post http://ismail.badawi.io/blog/2017/03/28/automatic-directory-creation-in-make/

I will update my branch to test the fix he did.

@cladmi
Copy link
Author

cladmi commented Nov 22, 2018

If this works, I can do a single PR to discuss the directory creation rule.

To not wait for it, the other solution is to do the mkdir -p inside of the ..in-docker-container target as it was done for others already. I could update it later.

The 'build' directory should not be tracked by git.
@smlng
Copy link
Owner

smlng commented Dec 10, 2018

does work now on macOS (after rebasing on latest RIOT master). How to proceed here? You wanna squash yourself or should I merge and squash you commits in my branch?

@cladmi
Copy link
Author

cladmi commented Jan 7, 2019

I will do a PR on RIOT about directory creation.

Because the way I did it for the moment is also wrong.
It was only for testing on mac and for this specific case. When we will work with BINDIR it will not work.

A target should never directly depend on a directory as the directory modification date is the last created file inside. It should be done by using an order only dependency.

But as I tested before and re-verified, this does not work when doing make clean all -j with order-only targets (deleting and creating files at the same time is not supposed to mean anything so it's hard to make it handled).

For the time being I will replace with only doing a mkdir -p inside the target.

cladmi added 2 commits January 7, 2019 16:10
The directory variable should not be exported as it is an 'host' path.
It should however be mounted in the container.
The 'build' directory should be created before starting docker.
If not it will be created as root.

Also add mapping for the directory in docker.

Currently create the directory in the target until there is a directory
creation target.
@cladmi
Copy link
Author

cladmi commented Jan 7, 2019

I replaced with creating the directory in the target. I also currently removed the test.
Before removing commits, I saved the branch to https://github.com/cladmi/RIOT/tree/pr/common/build_saved_with_tests

I re-ran the test from the previous branch and it is working.

You can merge/rebase in your branch if you want.

@smlng smlng merged commit 6158d57 into smlng:pr/make/buildoutdir Jan 7, 2019
@cladmi cladmi deleted the pr/common/build branch January 21, 2019 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants