Skip to content

Commit

Permalink
Build System: Resolve CPU-specific logic in common build files
Browse files Browse the repository at this point in the history
* tools/Config.mk - Add empty definition POSTBUILD
* tools/Makefile.unix/win - Replace CXD56xx specific logic with $(call POSTBUILD)
* boards/arm/cxd56xx/scripts/cxd56xx_Config.mk - Add POSTBUILD definitions with logic removed from Makefile.unix/win
* boards/arm/cxd56xx/spresense/scripts/Make.defs - Include cxd56xx_Config.mk immediately after tools/Config.mk so that the empty POSTBUILD definition will be replaced with the correct one

NOTE: There is a precedent for this approach.  This is the way that other architecture-specific build options are implemented.  See, for example, tools/zds/zds_Config.mk
  • Loading branch information
gregory-nutt committed Mar 6, 2020
1 parent 45a8edd commit a0fc80f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 28 deletions.
41 changes: 41 additions & 0 deletions boards/arm/cxd56xx/scripts/cxd56xx_Config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
############################################################################
# board/arm/cxd56xx/script/cxd56xx_Config.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

# These are the macros that will be used in the NuttX make system to compile
# and assembly source files and to insert the resulting object files into an
# archive. These replace the default definitions at tools/Config.mk

# POSTBUILD -- Perform post build operations

ifeq ($(CONFIG_CXD56_BINARY),y)
define POSTBUILD
$(Q) if [ ! -f "tools/cxd56/mkspk" ] ; then \
echo ""; \
echo "Please run the following command to build the needed tool"; \
echo ""; \
echo "cd tools/cxd56 && make && cd ../.."; \
echo ""; \
echo "run make again to create the nuttx.spk image."; \
else \
echo "Generating: $(NUTTXNAME).spk"; \
tools/cxd56/mkspk -c2 nuttx nuttx nuttx.spk; \
fi
endef
endif
1 change: 1 addition & 0 deletions boards/arm/cxd56xx/spresense/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/boards/arm/cxd56xx/scripts/cxd56xx_Config.mk
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs

# Setup for the kind of memory that we are executing from
Expand Down
11 changes: 10 additions & 1 deletion tools/Config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# tools/Config.mk
# Global build rules and macros.
#
# Copyright (C) 2011, 2013-2014, 2018-2019 Gregory Nutt. All rights
# Copyright (C) 2011, 2013-2014, 2018-2019, 2020 Gregory Nutt. All rights
# reserved.
# Author: Richard Cochran
# Gregory Nutt <[email protected]>
Expand Down Expand Up @@ -239,6 +239,15 @@ define PRELINK
endef
endif

# POSTBUILD -- Perform post build operations
# Some architectures require the use of special tools and special handling
# AFTER building the NuttX binary. Make.defs files for thos architectures
# should override the following define with the correct operations for
# that platform

define POSTBUILD
endef

# DELFILE - Delete one file

ifeq ($(CONFIG_WINDOWS_NATIVE),y)
Expand Down
14 changes: 1 addition & 13 deletions tools/Makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -480,19 +480,6 @@ ifeq ($(CONFIG_RAW_BINARY),y)
@echo "CP: $(NUTTXNAME).bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(NUTTXNAME).bin
endif
ifeq ($(CONFIG_CXD56_BINARY),y)
$(Q) if [ ! -f "tools/cxd56/mkspk" ] ; then \
echo ""; \
echo "Please run the following command to build the needed tool"; \
echo ""; \
echo "cd tools/cxd56 && make && cd ../.."; \
echo ""; \
echo "run make again to create the nuttx.spk image."; \
else \
echo "Generating: $(NUTTXNAME).spk"; \
tools/cxd56/mkspk -c2 nuttx nuttx nuttx.spk; \
fi
endif
ifeq ($(CONFIG_UBOOT_UIMAGE),y)
@echo "MKIMAGE: uImage"
$(Q) mkimage -A $(CONFIG_ARCH) -O linux -C none -T kernel -a $(CONFIG_UIMAGE_LOAD_ADDRESS) \
Expand All @@ -501,6 +488,7 @@ ifeq ($(CONFIG_UBOOT_UIMAGE),y)
cp -f uImage /tftpboot/uImage; \
fi
endif
$(call POSTBUILD)

# $(BIN)
#
Expand Down
14 changes: 1 addition & 13 deletions tools/Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -490,19 +490,7 @@ ifeq ($(CONFIG_RAW_BINARY),y)
@echo "CP: $(NUTTXNAME).bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(NUTTXNAME).bin
endif
ifeq ($(CONFIG_CXD56_BINARY),y)
$(Q) if [ ! -f "tools/cxd56/mkspk.exe" ] ; then \
echo ""; \
echo "Please run the following command to build the needed tool"; \
echo ""; \
echo "cd tools/cxd56 && make && cd ../.."; \
echo ""; \
echo "run make again to create the nuttx.spk image."; \
else \
echo "Generating: $(NUTTXNAME).spk"; \
tools\cxd56\mkspk.exe -c2 nuttx nuttx nuttx.spk; \
fi
endif
$(call POSTBUILD)

# $(BIN)
#
Expand Down
2 changes: 1 addition & 1 deletion tools/zds/zds_Config.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
############################################################################
# tools/zds/zds_Config.defs
# tools/zds/zds_Config.mk
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
Expand Down

0 comments on commit a0fc80f

Please sign in to comment.