Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Rev 36 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36 Rev 37
Line 38... Line 38...
38
        exit 1
38
        exit 1
39
}
39
}
40
 
40
 
41
# verify we're a x86_64 Linux host
41
# verify we're a x86_64 Linux host
42
if [ ! "$(uname)" = "Linux" ] || [ ! "$(uname -m)" = "x86_64" ]; then
42
if [ ! "$(uname)" = "Linux" ] || [ ! "$(uname -m)" = "x86_64" ]; then
43
        print_error_and_die "Error: this script requires a x86_64 Linux machine (possibly a virtual machine, or WSL) as the build host."
43
        print_error_and_die "Error: this script requires a x86_64 Linux machine (possibly a virtual machine, or WSL2) as the build host."
44
fi
44
fi
45
 
45
 
46
# verify that we have the required tools
46
# verify that we have the required tools
47
for REQUIRED_TOOL in ${REQUIRED_TOOLS}; do
47
for REQUIRED_TOOL in ${REQUIRED_TOOLS}; do
48
        "${REQUIRED_TOOL}" --version > /dev/null 2>&1 || print_error_and_die \
48
        "${REQUIRED_TOOL}" --version > /dev/null 2>&1 || print_error_and_die \
Line 74... Line 74...
74
        # we're not in WSL. We can expect reasonably good file access speeds to the QNX SDP that's bundled with this repository, so just use it.
74
        # we're not in WSL. We can expect reasonably good file access speeds to the QNX SDP that's bundled with this repository, so just use it.
75
        QNXSDK_CANONICAL_PATH="$(realpath "${CURRENT_DIR}/${QNXSDK_PATH}")"
75
        QNXSDK_CANONICAL_PATH="$(realpath "${CURRENT_DIR}/${QNXSDK_PATH}")"
76
fi
76
fi
77
 
77
 
78
# verify that the symlinks are deployed in the SDK -- just test one of them in each relevant directory ($QNX_HOST for the tools, $QNX_TARGET for the sysroot)
78
# verify that the symlinks are deployed in the SDK -- just test one of them in each relevant directory ($QNX_HOST for the tools, $QNX_TARGET for the sysroot)
79
if [ ! -e "${QNXSDK_CANONICAL_PATH}/${QNXSDK_HOSTPATH}/usr/bin/ntox86_64-gcc" ] || [ ! -e "${QNXSDK_CANONICAL_PATH}/${QNXSDK_TARGETPATH}/usr/include/readline.h" ]; then
79
if [ ! -e "${QNXSDK_CANONICAL_PATH}/${QNXSDK_HOSTPATH}/usr/bin/ntox86_64-gcc" ]; then
80
        print_error_and_die \
-
 
81
                "Error: the toolchain platform-specific symbolic links have not been deployed in this QNX SDK. Please run" \
80
        # symlinks not deployed in the QNX SDK: do so
82
                "(on a POSIX machine:)" \
81
        OLDDIR="$(pwd)"
83
                "       cd ${QNXSDK_CANONICAL_PATH}" \
82
        cd "${QNXSDK_CANONICAL_PATH}"
84
                "       find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state" \
83
        find . -name symlinks.lst -exec ./symlinks.sh {} create \; && printf 'present-v2' > .symlinks-state
85
                "(else on a Windows machine:)" \
-
 
86
                "       cd ${QNXSDK_CANONICAL_PATH}" \
84
        cd "${OLDDIR}"
87
                "       host\\win64\\x86_64\\usr\\bin\\busybox.exe sh -c \"find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state\"" \
-
 
88
                "Note that this step WILL take time on a Win32 machine, but is only done once."
-
 
89
fi
85
fi
90
 
86
 
91
# Create a symlink in /tmp that will lead to the QNX platform SDK so as to avoid spaces in paths if it doesn't exist already
87
# Create a symlink in /tmp that will lead to the QNX platform SDK so as to avoid spaces in paths if it doesn't exist already
92
# (this is totally prohibitive with the official QNX toolchain)
88
# (this is totally prohibitive with the official QNX toolchain)
93
if [ ! -L /tmp/qnxsdk ] || [ ! "$(readlink /tmp/qnxsdk)" = "${QNXSDK_CANONICAL_PATH}" ]; then
89
if [ ! -L /tmp/qnxsdk ] || [ ! "$(readlink /tmp/qnxsdk)" = "${QNXSDK_CANONICAL_PATH}" ]; then
Line 104... Line 100...
104
 
100
 
105
# print the build environment
101
# print the build environment
106
echo "QNX_HOST=${QNX_HOST}"
102
echo "QNX_HOST=${QNX_HOST}"
107
echo "QNX_TARGET=${QNX_TARGET}"
103
echo "QNX_TARGET=${QNX_TARGET}"
108
echo "MAKEFLAGS=${MAKEFLAGS}"
104
echo "MAKEFLAGS=${MAKEFLAGS}"
109
 
-
 
110
# construct the target triple (actually a quadruple)
-
 
111
export TARGET_ARCH="${BUILD_TARGET_ARCH}"
-
 
112
test "${BUILD_TARGET_ARCH}" = "x86_64" && export TARGET_VENDOR="pc" || export TARGET_VENDOR="unknown"
-
 
113
export TARGET_KERNEL="nto"
-
 
114
export TARGET_SYSTEM="qnx${QNXSDK_VERSION}"
-
 
115
export TARGET_TRIPLE="${TARGET_ARCH}-${TARGET_VENDOR}-${TARGET_KERNEL}-${TARGET_SYSTEM}"
-
 
116
echo "Will build for ${TARGET_TRIPLE}"
-
 
117
 
105
 
118
# download the involved source packages and unpack them if not done yet
106
# download the involved source packages and unpack them if not done yet
119
download_and_unpack_if_necessary()
107
download_and_unpack_if_necessary()
120
{
108
{
121
        # helper function that downloads a sources tarball, extracts it and patches it if necessary
109
        # helper function that downloads a sources tarball, extracts it and patches it if necessary
Line 128... Line 116...
128
                        rm -f "${CURRENT_DIR}/${2}"
116
                        rm -f "${CURRENT_DIR}/${2}"
129
                        exit 1
117
                        exit 1
130
                fi
118
                fi
131
        fi
119
        fi
132
        echo "Extracting ${1} sources..."
120
        echo "Extracting ${1} sources..."
-
 
121
        STARTDIR="$(pwd)"
133
        cd "$(dirname "${1}")"
122
        cd "$(dirname "${1}")"
134
        if echo "${2}"|grep -q "\.tar\.bz2$"; then
123
        if echo "${2}"|grep -q "\.tar\.bz2$"; then
135
                # BZip2 tarball
124
                # BZip2 tarball
136
                tar xjf "${CURRENT_DIR}/${2}" || exit 1
125
                tar xjf "${CURRENT_DIR}/${2}" || exit 1
137
        elif echo "${2}"|grep -q "\.tar\.xz$"; then
126
        elif echo "${2}"|grep -q "\.tar\.xz$"; then
Line 142... Line 131...
142
                tar xzf "${CURRENT_DIR}/${2}" || exit 1
131
                tar xzf "${CURRENT_DIR}/${2}" || exit 1
143
        else
132
        else
144
                print_error_and_die "Error: unsupported file extension. Please improve the download_and_unpack_if_necessary() shell function to support it."
133
                print_error_and_die "Error: unsupported file extension. Please improve the download_and_unpack_if_necessary() shell function to support it."
145
        fi
134
        fi
146
        # make sure the expected directory is here after extraction
135
        # make sure the expected directory is here after extraction
147
        if [ ! -d "${1}" ]; then
136
        if [ ! -d "$(basename "${1}")" ]; then
148
                print_error_and_die "Error: couldn't find ${1} in extracted sources."
137
                print_error_and_die "Error: couldn't find ${1} in extracted sources."
149
        fi
138
        fi
150
        # do we have a patchset to apply ?
139
        # do we have a patchset to apply ?
151
        if [ -n "${4}" ]; then
140
        if [ -n "${4}" ]; then
-
 
141
                if [ ! -s "${CURRENT_DIR}/${2}.patchset" ]; then
152
                echo "Downloading ${1} patchset from ${4}..."
142
                        echo "Downloading ${1} patchset from ${4}..."
153
                wget -O "${CURRENT_DIR}/${2}.patchset" "${4}" || exit 1
143
                        wget -O "${CURRENT_DIR}/${2}.patchset" "${4}" || exit 1
-
 
144
                fi
154
                echo "Applying patchset..."
145
                echo "Applying patchset..."
155
                OLDDIR="$(pwd)"
146
                OLDDIR="$(pwd)"
156
                cd "${1}"
147
                cd "$(basename "${1}")"
157
                patch -N -Z -p1 < "${CURRENT_DIR}/${2}.patchset" || exit 1
148
                patch -N -Z -p1 < "${CURRENT_DIR}/${2}.patchset" || exit 1
158
                cd "${OLDDIR}"
149
                cd "${OLDDIR}"
159
                unset OLDDIR
150
                unset OLDDIR
160
        fi
151
        fi
-
 
152
        cd "${STARTDIR}"
-
 
153
        unset STARTDIR
161
        return 0
154
        return 0
162
}
155
}
163
download_and_unpack_if_necessary "${LLVM_SOURCES_DIR}" "${LLVM_SOURCES_FILE}" "${LLVM_SOURCES_URL}" || exit 1
156
download_and_unpack_if_necessary "${LLVM_SOURCES_DIR}" "${LLVM_SOURCES_FILE}" "${LLVM_SOURCES_URL}" || exit 1
-
 
157
 
-
 
158
# construct the target triple (actually a quadruple)
-
 
159
export TARGET_ARCH="${BUILD_TARGET_ARCH}"
-
 
160
test "${BUILD_TARGET_ARCH}" = "x86_64" && export TARGET_VENDOR="pc" || export TARGET_VENDOR="unknown"
-
 
161
export TARGET_KERNEL="nto"
-
 
162
export TARGET_SYSTEM="qnx${QNXSDK_VERSION}"
-
 
163
export TARGET_TRIPLE="${TARGET_ARCH}-${TARGET_VENDOR}-${TARGET_KERNEL}-${TARGET_SYSTEM}"
-
 
164
echo "Will build for ${TARGET_TRIPLE}"
164
 
165
 
165
# create the build directory
166
# create the build directory
166
echo "Wiping out build directory..."
167
echo "Wiping out build directory..."
167
test -e "${BUILD_DIR_NAME}" && rm -rf "${BUILD_DIR_NAME}"
168
test -e "${BUILD_DIR_NAME}" && rm -rf "${BUILD_DIR_NAME}"
168
mkdir "${BUILD_DIR_NAME}" || exit 1
169
mkdir "${BUILD_DIR_NAME}" || exit 1