mirror of
https://github.com/apache/nuttx.git
synced 2025-12-06 09:01:15 +08:00
build/export: Fix missing gnu-elf.ld copy and toolchain script.
Some checks failed
Build Documentation / build-html (push) Has been cancelled
Some checks failed
Build Documentation / build-html (push) Has been cancelled
Fix missing `gnu-elf.ld` file copy during export generation and update `toolchain.cmake` script to ensure proper toolchain detection and configuration. * Prevents build failures when exporting projects. * Improves reproducibility of generated exports. Signed-off-by: trns1997 <trns1997@gmail.com>
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
# Get the input parameter list
|
||||
|
||||
USAGE="USAGE: $0 [-d] [-z] [-u] [-t <top-dir> [-x <lib-ext>] [-a <apps-dir>] [-m <make-exe>] -l \"lib1 [lib2 [lib3 ...]]\""
|
||||
@@ -185,9 +187,10 @@ cp "${TOPDIR}/tools/incdir.c" "${EXPORTDIR}/tools/."
|
||||
# Copy the board specific linker if found, or use the default when not.
|
||||
|
||||
APPLD=gnu-elf.ld
|
||||
|
||||
if [ -f "${BOARDDIR}/scripts/${APPLD}" ]; then
|
||||
cp -f "${BOARDDIR}/scripts/${APPLD}" "${EXPORTDIR}/scripts/."
|
||||
else
|
||||
elif [ -f "${TOPDIR}/libs/libc/elf/${APPLD}" ]; then
|
||||
cp -f "${TOPDIR}/libs/libc/elf/${APPLD}" "${EXPORTDIR}/scripts/."
|
||||
fi
|
||||
|
||||
@@ -364,70 +367,101 @@ cp -LR -p "${TOPDIR}/include" "${EXPORTDIR}/." || \
|
||||
${MAKE} -C ${ARCHDIR} export_startup TOPDIR=${TOPDIR} EXPORT_DIR="${EXPORTDIR}"
|
||||
|
||||
# Copy architecture-specific header files into the arch export sub-directory.
|
||||
# This is tricky because each architecture does things in a little different
|
||||
# way.
|
||||
#
|
||||
# First copy any header files in the architecture src/ sub-directory (some
|
||||
# architectures keep all of the header files there, some a few, and others
|
||||
# none
|
||||
# Some architectures keep all headers in src/, some only a few, and others none.
|
||||
|
||||
cp -f "${ARCHDIR}"/*.h "${EXPORTDIR}"/arch/. 2>/dev/null
|
||||
|
||||
# Then look a list of possible places where other architecture-specific
|
||||
# header files might be found. If those places exist (as directories or
|
||||
# as symbolic links to directories, then copy the header files from
|
||||
# those directories into the EXPORTDIR
|
||||
if [ -d "${ARCHDIR}" ]; then
|
||||
# Expand the glob safely
|
||||
set -- "${ARCHDIR}"/*.h
|
||||
if [ -e "$1" ]; then
|
||||
echo "MK: Copying architecture headers from ${ARCHDIR} to ${EXPORTDIR}/arch"
|
||||
if ! cp -f "$@" "${EXPORTDIR}/arch/"; then
|
||||
echo "MK: Error: Failed to copy headers from ${ARCHDIR}" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "MK: Notice: No header files found in ${ARCHDIR}" >&2
|
||||
fi
|
||||
else
|
||||
echo "MK: Warning: Architecture directory ${ARCHDIR} does not exist" >&2
|
||||
fi
|
||||
|
||||
if [ "X${USRONLY}" != "Xy" ]; then
|
||||
ARCH_HDRDIRS="arm armv7-m avr avr32 board common chip mips32"
|
||||
|
||||
for hdir in $ARCH_HDRDIRS; do
|
||||
srcdir="${ARCHDIR}/${hdir}"
|
||||
dstdir="${EXPORTDIR}/arch/${hdir}"
|
||||
|
||||
# Does the directory (or symbolic link) exist?
|
||||
if [ -d "$srcdir" ] || [ -h "$srcdir" ]; then
|
||||
mkdir -p "$dstdir" || {
|
||||
echo "MK: Error: mkdir $dstdir failed" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -d "${ARCHDIR}/${hdir}" -o -h "${ARCHDIR}/${hdir}" ]; then
|
||||
# Copy headers if they exist
|
||||
set -- "$srcdir"/*.h
|
||||
if [ -e "$1" ]; then
|
||||
echo "MK: Copying headers from $srcdir to $dstdir"
|
||||
if ! cp -f "$@" "$dstdir/"; then
|
||||
echo "MK: Error: Failed to copy headers from $srcdir" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "MK: Notice: No header files found in $srcdir" >&2
|
||||
fi
|
||||
|
||||
# Yes.. create a export sub-directory of the same name
|
||||
# Handle hardware subdir if it exists
|
||||
if [ -d "$srcdir/hardware" ]; then
|
||||
mkdir -p "$dstdir/hardware" || {
|
||||
echo "MK: Error: mkdir $dstdir/hardware failed" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
mkdir "${EXPORTDIR}/arch/${hdir}" || \
|
||||
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}' failed"; exit 1; }
|
||||
|
||||
# Then copy the header files (only) into the new directory
|
||||
|
||||
cp -f "${ARCHDIR}"/${hdir}/*.h "${EXPORTDIR}"/arch/${hdir}/. 2>/dev/null
|
||||
|
||||
# Most architectures have low directory called "hardware" that
|
||||
# holds the header files
|
||||
|
||||
if [ -d "${ARCHDIR}/${hdir}/hardware" ]; then
|
||||
|
||||
# Yes.. create a export sub-directory of the same name
|
||||
|
||||
mkdir "${EXPORTDIR}/arch/${hdir}/hardware" || \
|
||||
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}/hardware' failed"; exit 1; }
|
||||
|
||||
# Then copy the header files (only) into the new directory
|
||||
|
||||
cp -f "${ARCHDIR}"/${hdir}/hardware/*.h "${EXPORTDIR}"/arch/${hdir}/hardware/. 2>/dev/null
|
||||
set -- "$srcdir/hardware"/*.h
|
||||
if [ -e "$1" ]; then
|
||||
echo "MK: Copying headers from $srcdir/hardware to $dstdir/hardware"
|
||||
if ! cp -f "$@" "$dstdir/hardware/"; then
|
||||
echo "MK: Error: Failed to copy headers from $srcdir/hardware" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "MK: Notice: No hardware headers in $srcdir/hardware" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy OS internal header files as well. They are used by some architecture-
|
||||
# specific header files.
|
||||
|
||||
mkdir "${EXPORTDIR}/arch/os" || \
|
||||
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/os' failed"; exit 1; }
|
||||
# Copy OS internal header files
|
||||
mkdir -p "${EXPORTDIR}/arch/os" || {
|
||||
echo "MK: Error: mkdir ${EXPORTDIR}/arch/os failed" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
OSDIRS="clock environ errno group init irq mqueue paging pthread sched semaphore signal task timer wdog"
|
||||
|
||||
for dir in ${OSDIRS}; do
|
||||
mkdir "${EXPORTDIR}/arch/os/${dir}" || \
|
||||
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/os/${dir}' failed"; exit 1; }
|
||||
cp -f "${TOPDIR}"/sched/${dir}/*.h "${EXPORTDIR}"/arch/os/${dir}/. 2>/dev/null
|
||||
srcdir="${TOPDIR}/sched/${dir}"
|
||||
dstdir="${EXPORTDIR}/arch/os/${dir}"
|
||||
|
||||
mkdir -p "$dstdir" || {
|
||||
echo "MK: Error: mkdir $dstdir failed" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -- "$srcdir"/*.h
|
||||
if [ -e "$1" ]; then
|
||||
echo "MK: Copying OS headers from $srcdir to $dstdir"
|
||||
if ! cp -f "$@" "$dstdir/"; then
|
||||
echo "MK: Error: Failed to copy headers from $srcdir" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "MK: Notice: No headers in $srcdir" >&2
|
||||
fi
|
||||
done
|
||||
|
||||
# Add the board library to the list of libraries
|
||||
|
||||
# Add the board library if present
|
||||
if [ -f "${ARCHDIR}/board/libboard${LIBEXT}" ]; then
|
||||
LIBLIST="${LIBLIST} ${ARCHSUBDIR}/board/libboard${LIBEXT}"
|
||||
fi
|
||||
|
||||
@@ -19,20 +19,17 @@ set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
|
||||
${NUTTX_PATH}/include/${NUTTX_CXX} ${NUTTX_PATH}/include
|
||||
${NUTTX_PATH}/arch/chip)
|
||||
|
||||
file(GLOB STARTUP_OBJS ${NUTTX_PATH}/startup/*)
|
||||
|
||||
add_compile_options(-nostdlib)
|
||||
add_compile_options(-ffunction-sections -fdata-sections)
|
||||
|
||||
# same entry used for all build modes in crt0.c and arch/.../xxx_start.c
|
||||
|
||||
set(ENTRY_NAME "__start")
|
||||
|
||||
set(CMAKE_C_LINK_EXECUTABLE
|
||||
"<CMAKE_LINKER> ${LDFLAGS} --entry=${ENTRY_NAME} -T${LINKER_SCRIPT} <OBJECTS> ${STARTUP_OBJS} -o <TARGET> <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} ${EXTRA_LIBS} --end-group"
|
||||
"<CMAKE_LINKER> ${LDFLAGS} --entry=${ENTRY_NAME} -T${LINKER_SCRIPT} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} ${EXTRA_LIBS} --end-group"
|
||||
)
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE
|
||||
"<CMAKE_LINKER> ${LDFLAGS} --entry=${ENTRY_NAME} -T${LINKER_SCRIPT} <OBJECTS> ${STARTUP_OBJS} -o <TARGET> <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} ${EXTRA_LIBS} --end-group"
|
||||
"<CMAKE_LINKER> ${LDFLAGS} --entry=${ENTRY_NAME} -T${LINKER_SCRIPT} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} ${EXTRA_LIBS} --end-group"
|
||||
)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
Reference in New Issue
Block a user