Skip to content
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

Makefile.include: fix board/cpu inconsistent include order #8717

Merged
merged 1 commit into from
Jul 4, 2018

Conversation

cladmi
Copy link
Contributor

@cladmi cladmi commented Mar 1, 2018

Contribution description

Re-organize headers include directories order to be consistent to include first all things related to board then all things related to CPU.

I did a check to verify there were no header names conflicts between boards and cpu so changing the order has no impact. Output and verification script below.

Details

Include order for board and cpu was

  1. cpu include
  2. board include
  3. board common includes
  4. cpu common includes

Its now changed to:

  1. board include
  2. board common includes
  3. cpu include
  4. cpu common includes

Further steps

I plan to move the two lines with "INCLUDE +=" and "include ../Makefile.include" into dedicated files in boards and cpu to allow further cleanup, but it requires the include order to be solved before.

Changes INCLUDES output

Using #8714 with examples/gnrc_networking for iotlab-m3:

Without the PR, notice the cpu/stm32f1 before the boards include:

INCLUDES: 
        -isystem  
        /usr/arm-none-eabi/include/newlib-nano  
        -I/home/harter/work/git/RIOT/core/include  
        -I/home/harter/work/git/RIOT/drivers/include  
        -I/home/harter/work/git/RIOT/sys/include  
        -I/home/harter/work/git/RIOT/cpu/stm32f1/include  
        -I/home/harter/work/git/RIOT/boards/iotlab-m3/include  
        -I/home/harter/work/git/RIOT/boards/common/iotlab/include  
        -I/home/harter/work/git/RIOT/boards/iotlab-m3/include  # This is currently re-added in the board/Makefile.include
        -I/home/harter/work/git/RIOT/cpu/stm32_common/include  
        -I/home/harter/work/git/RIOT/cpu/cortexm_common/include  
        -I/home/harter/work/git/RIOT/cpu/cortexm_common/include/vendor  
        -I/home/harter/work/git/RIOT/sys/libc/include  
        -I/home/harter/work/git/RIOT/drivers/at86rf2xx/include

With the PR

INCLUDES:                                                                                                                                                     
        -isystem  
        /usr/arm-none-eabi/include/newlib-nano  
        -I/home/harter/work/git/RIOT/core/include  
        -I/home/harter/work/git/RIOT/drivers/include  
        -I/home/harter/work/git/RIOT/sys/include  
        -I/home/harter/work/git/RIOT/boards/iotlab-m3/include  
        -I/home/harter/work/git/RIOT/boards/common/iotlab/include  
        -I/home/harter/work/git/RIOT/boards/iotlab-m3/include  # This is currently re-added in the board/Makefile.include
        -I/home/harter/work/git/RIOT/cpu/stm32f1/include  
        -I/home/harter/work/git/RIOT/cpu/stm32_common/include  
        -I/home/harter/work/git/RIOT/cpu/cortexm_common/include  
        -I/home/harter/work/git/RIOT/cpu/cortexm_common/include/vendor  
        -I/home/harter/work/git/RIOT/sys/libc/include  
        -I/home/harter/work/git/RIOT/drivers/at86rf2xx/include

Verifications

There are no common headers names between boards and cpus.
Except native that has a 'periph_conf.h' in cpu instead of being in board.

Checking boards and cpu uniq headers names

wc -l ${BOARDS_HEADERS} 50
wc -l ${CPU_HEADERS} 630

Common headers between boards and cpu
      2 periph_conf.h

Culprit for common header
cpu/native/include/periph_conf.h

I used the following script to test this.

#! /bin/bash

find_headers_in_dir() {
    local directory="$1"
    find "${directory}" -name '*.h' -exec basename {} \;
}

BOARDS_HEADERS=$(find_headers_in_dir boards | sort -u)
CPU_HEADERS=$(find_headers_in_dir cpu | sort -u)

echo Checking boards and cpu uniq headers names
echo ""

# echo "${BOARDS_HEADERS}"
# echo "${CPU_HEADERS}"

echo -n 'wc -l ${BOARDS_HEADERS} '
echo "${BOARDS_HEADERS}" | wc -l
echo -n 'wc -l ${CPU_HEADERS} '
echo "${CPU_HEADERS}" | wc -l
echo

echo "Common headers between boards and cpu"
echo "${BOARDS_HEADERS}" "${CPU_HEADERS}" | sort | uniq -c -d
echo ""

echo "Culprit for common header"
find cpu -name periph_conf.h

Issues/PRs references

Part of Issue #8713

@cladmi cladmi added Area: build system Area: Build system Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 1, 2018
@cladmi cladmi requested a review from jnohlgard March 1, 2018 15:48
Makefile.include Outdated
INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
include $(RIOTBOARD)/$(BOARD)/Makefile.include
Copy link
Member

Choose a reason for hiding this comment

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

There could be a reason to include defaultmodules.inc.mk and pseudomodules.inc.mk in the same order as before, in case they are used by the board and cpu makefiles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are currently no difference, but I agree there is no reason to change the order. I will fix it.

Copy link
Member

@jnohlgard jnohlgard left a comment

Choose a reason for hiding this comment

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

I agree with the general idea, but see my inline comment regarding makefile include order

@jnohlgard jnohlgard added this to the Release 2018.04 milestone Mar 2, 2018
@jnohlgard jnohlgard self-assigned this Mar 2, 2018
@miri64
Copy link
Member

miri64 commented Mar 15, 2018

ping @gebart

@cladmi
Copy link
Contributor Author

cladmi commented Mar 15, 2018

I developed some scripts to check the difference in included headers for #8652. I will run them for this PR too to check that indeed no includes changed and give some more tested feedback.

@cladmi
Copy link
Contributor Author

cladmi commented Mar 19, 2018

I ran buildtest on all examples without cleaning intermediates and generated .d files are the same on master and on this branch rebased meaning the same headers are included.

I did not run on tests at the same time because it was taking too much space as packages are re-downloaded many times.

I could re-run it only on tests if you want.

@kaspar030
Copy link
Contributor

Not release critical, untagging.

@kaspar030 kaspar030 removed this from the Release 2018.04 milestone Apr 11, 2018
@cladmi cladmi added this to the Release 2018.07 milestone Apr 12, 2018
Include order for board and cpu was

1. cpu include
2. board include
3. board common includes
4. cpu common includes

Its now changed to:

1. board include
2. board common includes
3. cpu include
4. cpu common includes

Verifications:

There are no common headers names between boards and cpus.
Except native that has a 'periph_conf.h' in cpu instead of being in board.
@cladmi cladmi force-pushed the pr/makefile/change_include_order branch from 5f93b8b to f7f2494 Compare July 4, 2018 07:21
@cladmi
Copy link
Contributor Author

cladmi commented Jul 4, 2018

Rebased, and I re-ran the test mentioned and there is still no names conflicts.

@cladmi cladmi requested a review from smlng July 4, 2018 07:31
@smlng
Copy link
Member

smlng commented Jul 4, 2018

tested on macOS for native, output for make -C examples/gnrc_networking info-build INCLUDES:

master

INCLUDES: 
	-I/Volumes/devel/github/smlng/RIOT/core/include  
	-I/Volumes/devel/github/smlng/RIOT/drivers/include  
	-I/Volumes/devel/github/smlng/RIOT/sys/include  
	-I/Volumes/devel/github/smlng/RIOT/cpu/native/include  
	-I/Volumes/devel/github/smlng/RIOT/boards/native/include  
	-DNATIVE_INCLUDES  
	-I/Volumes/devel/github/smlng/RIOT/boards/native/include/  
	-I/Volumes/devel/github/smlng/RIOT/core/include/  
	-I/Volumes/devel/github/smlng/RIOT/drivers/include/  
	-I/Volumes/devel/github/smlng/RIOT/cpu/native/include  
	-I/Volumes/devel/github/smlng/RIOT/sys/include  
	-I/Volumes/devel/github/smlng/RIOT/cpu/native/osx-libc-extra  
	-I/Volumes/devel/github/smlng/RIOT/sys/net/gnrc/netif/include

This PR

INCLUDES: 
	-I/Volumes/devel/github/smlng/RIOT/core/include  
	-I/Volumes/devel/github/smlng/RIOT/drivers/include  
	-I/Volumes/devel/github/smlng/RIOT/sys/include  
	-I/Volumes/devel/github/smlng/RIOT/boards/native/include  
	-DNATIVE_INCLUDES  
	-I/Volumes/devel/github/smlng/RIOT/boards/native/include/  
	-I/Volumes/devel/github/smlng/RIOT/core/include/  
	-I/Volumes/devel/github/smlng/RIOT/drivers/include/  
	-I/Volumes/devel/github/smlng/RIOT/cpu/native/include  
	-I/Volumes/devel/github/smlng/RIOT/sys/include  
	-I/Volumes/devel/github/smlng/RIOT/cpu/native/osx-libc-extra  
	-I/Volumes/devel/github/smlng/RIOT/cpu/native/include  
	-I/Volumes/devel/github/smlng/RIOT/sys/net/gnrc/netif/include

Order looks better and works but for native there are several duplicated includes which looks a bit strange - this just an info and might be worth looking into in a followup PR

Copy link
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

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

tested ACK

@cladmi
Copy link
Contributor Author

cladmi commented Jul 4, 2018

Murdock is happy, thank you for testing.

@cladmi cladmi merged commit 499d6b4 into RIOT-OS:master Jul 4, 2018
@cladmi cladmi deleted the pr/makefile/change_include_order branch July 4, 2018 08:38
@cladmi
Copy link
Contributor Author

cladmi commented Jul 4, 2018

The duplicate includes for native are there because currently NATIVEINCLUDES are added to INCLUDES:

export INCLUDES += $(NATIVEINCLUDES)

@cladmi cladmi mentioned this pull request Aug 21, 2018
18 tasks
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 CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants