Changeset 5208


Ignore:
Timestamp:
Mar 14, 2010, 9:25:03 PM (5 years ago)
Author:
oxygene
Message:

Add scan-build support to the build system.
When configured in Kconfig, just running "make"
calls scan-build as appropriate (however, it does not
check for the presence of scan-build)

The target directory for the scan-build report is configurable
and defaults to the scan-build default of /tmp/scan-build-$date-$num

abuild is adapted to properly run scanbuild when ran
with the -sb option.

Signed-off-by: Patrick Georgi <patrick.georgi@…>
Acked-by: Stefan Reinauer <stepan@…>

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        11build
        22coreboot-builds
         3.ccwrap
        34.config
        45.config.old
  • trunk/Makefile

    r5195 r5208  
    2020##
    2121
     22ifeq ($(INNER_SCANBUILD),y)
     23CC_real:=$(CC)
     24endif
    2225$(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile > .xcompile)))
    2326include .xcompile
     27ifeq ($(INNER_SCANBUILD),y)
     28CC:=$(CC_real)
     29HOSTCC:=$(CC_real) --hostcc
     30HOSTCXX:=$(CC_real) --hostcxx
     31endif
    2432
    2533export top := $(PWD)
     
    9199# other files
    92100
     101ifeq ($(INNER_SCANBUILD),y)
     102CONFIG_SCANBUILD_ENABLE:=
     103endif
     104
     105ifeq ($(CONFIG_SCANBUILD_ENABLE),y)
     106ifneq ($(CONFIG_SCANBUILD_REPORT_LOCATION),)
     107CONFIG_SCANBUILD_REPORT_LOCATION:=-o $(CONFIG_SCANBUILD_REPORT_LOCATION)
     108endif
     109all:
     110        echo '#!/bin/sh' > .ccwrap
     111        echo 'CC="$(CC)"' >> .ccwrap
     112        echo 'if [ "$$1" = "--hostcc" ]; then shift; CC="$(HOSTCC)"; fi' >> .ccwrap
     113        echo 'if [ "$$1" = "--hostcxx" ]; then shift; CC="$(HOSTCXX)"; fi' >> .ccwrap
     114        echo 'eval $$CC $$*' >> .ccwrap
     115        chmod +x .ccwrap
     116        scan-build $(CONFIG_SCANBUILD_REPORT_LOCATION) -analyze-headers --use-cc=$(top)/.ccwrap --use-c++=$(top)/.ccwrap $(MAKE) INNER_SCANBUILD=y
     117else
    93118all: coreboot
     119endif
    94120
    95121
     
    111137
    112138$(obj)/mainboard/$(MAINBOARDDIR)/static.o: $(obj)/mainboard/$(MAINBOARDDIR)/static.c
    113 #
     139        @printf "    CC         $(subst $(obj)/,,$(@))\n"
     140        $(CC) $(CFLAGS) -c -o $@ $<
     141
     142$(obj)/arch/i386/../../option_table.o: $(obj)/arch/i386/../../option_table.c
     143        @printf "    CC         $(subst $(obj)/,,$(@))\n"
     144        $(CC) $(CFLAGS) -c -o $@ $<
    114145
    115146objs:=$(obj)/mainboard/$(MAINBOARDDIR)/static.o
     
    326357
    327358clean: clean-for-update
    328         rm -f $(obj)/coreboot*
     359        rm -f $(obj)/coreboot* .ccwrap
    329360
    330361distclean: clean
  • trunk/src/Kconfig

    r5206 r5208  
    4646          Select the prefix to all files put into the image. It's "fallback"
    4747          by default, "normal" is a common alternative.
     48
     49config SCANBUILD_ENABLE
     50        bool "build with scan-build for static analysis"
     51        default n
     52        help
     53          Changes the build process to scan-build is used.
     54          Requires scan-build in path.
     55
     56config SCANBUILD_REPORT_LOCATION
     57        string "directory to put scan-build report in"
     58        default ""
     59        depends on SCANBUILD_ENABLE
     60        help
     61          Where the scan-build report should be stored
    4862
    4963endmenu
  • trunk/src/arch/i386/Makefile.inc

    r5206 r5208  
    6161$(obj)/coreboot_ram.o: $(obj)/arch/i386/lib/c_start.o $(drivers) $(obj)/coreboot.a $(LIBGCC_FILE_NAME)
    6262        @printf "    CC         $(subst $(obj)/,,$(@))\n"
    63         $(CC) -nostdlib -r -o $@ $(obj)/arch/i386/lib/c_start.o $(drivers) -Wl,-\( $(obj)/coreboot.a $(LIBGCC_FILE_NAME) -Wl,-\)
     63        $(CC) -nostdlib -r -o $@ $(obj)/arch/i386/lib/c_start.o $(drivers) -Wl,--start-group $(obj)/coreboot.a $(LIBGCC_FILE_NAME) -Wl,--end-group
    6464
    6565$(obj)/coreboot.a: $(objs)
  • trunk/src/cpu/x86/smm/Makefile.inc

    r5127 r5208  
    3939        (echo 'unsigned char smm[] = {'; od -vtx1 $(obj)/cpu/x86/smm/smm | sed -e 's,^[0-9]* *,,' -e 's:[0-9a-f][0-9a-f] :0x&,:g' -e 's:[0-9a-f][0-9a-f]$$:0x&,:'; echo '}; unsigned int smm_len = '; wc -c $(obj)/cpu/x86/smm/smm |awk '{print $$1;}' ; echo ';')  > $@
    4040
     41$(obj)/cpu/x86/smm/smm_bin.o: $(obj)/cpu/x86/smm/smm_bin.c
     42        @printf "    CC         $(subst $(obj)/,,$(@))\n"
     43        $(CC) $(CFLAGS) -c -o $@ $<
     44
    4145endif
    4246
  • trunk/util/abuild/abuild

    r5136 r5208  
    173173                        echo "CONFIG_DEFAULT_CONSOLE_LOGLEVEL_$loglevel=y" >> .config
    174174                        echo "CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$loglevel" >> .config
     175                fi
     176
     177                if [ "$scanbuild" = "true" ]; then
     178                        printf "(scan-build enabled) "
     179                        echo "CONFIG_SCANBUILD_ENABLE=y" >> .config
     180                        echo "CONFIG_SCANBUILD_REPORT_LOCATION=\"$TARGET/scan-build-results-tmp\"" >> .config
    175181                fi
    176182        fi
     
    363369        if  [ "$stackprotect" = "true" ]; then
    364370                CC="$CC -fno-stack-protector"
    365         fi
    366 
    367         if  [ "$scanbuild" = "true" ]; then
    368                 ccwrap=`mktemp`
    369                 mkdir -p $TARGET/${VENDOR}_${MAINBOARD}
    370                 mkdir -p $TARGET/scan-build-results-tmp
    371                 mv $ccwrap $TARGET/${VENDOR}_${MAINBOARD}
    372                 ccwrap=$TARGET/${VENDOR}_${MAINBOARD}/`basename $ccwrap`
    373                 echo '#!/bin/sh' > $ccwrap
    374                 echo $CC' "$@"' >> $ccwrap
    375                 chmod +x $ccwrap
    376                 origMAKE=$MAKE
    377                 MAKE="scan-build --use-cc=$ccwrap -o $TARGET/scan-build-results-tmp -analyze-headers $MAKE GCC=$ccwrap"
    378                 CC="\$(CC)"
    379                 HOSTCC="CCC_CC=$HOSTCC \$(CC)"
    380371        fi
    381372
Note: See TracChangeset for help on using the changeset viewer.