1414# Usage:
1515# ./copy_sources.sh --executorch-root <path> --build-dir <path> \
1616# --pack-staging <path>
17- set -e
17+ set -euo pipefail
1818
1919SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
2020PACK_DIR=" $( cd " $SCRIPT_DIR /../../cmsis_pack" && pwd) "
@@ -115,7 +115,7 @@ cp -r "${PACK_SRC}/src/kernels" "${PACK_SRC}/include/executorch/"
115115
116116echo " Copying extension sources..."
117117mkdir -p " ${PACK_SRC} /src/extension"
118- for d in data_loader memory_allocator runner_util; do
118+ for d in data_loader memory_allocator runner_util tensor ; do
119119 if [[ -d " ${EXECUTORCH_ROOT} /extension/$d " ]]; then
120120 cp -r " ${EXECUTORCH_ROOT} /extension/$d " " ${PACK_SRC} /src/extension/"
121121 fi
@@ -138,6 +138,18 @@ for candidate in \
138138 break
139139 fi
140140done
141+ # A pack without the generated flatbuffers schema headers compiles nothing:
142+ # every consumer fails at executorch/schema/program_generated.h. Fail here
143+ # rather than shipping a broken archive.
144+ for required in program_generated.h scalar_type_generated.h; do
145+ if [[ ! -f " ${PACK_SRC} /src/schema/${required} " ]]; then
146+ echo " ERROR: ${required} not found in the CMake build tree." >&2
147+ echo " Looked in: ${BUILD_DIR} /schema/include/executorch/schema" >&2
148+ echo " Run the ExecuTorch CMake configure+build first so BUILD_DIR" >&2
149+ echo " contains the generated schema headers (see build_pack.sh -h)." >&2
150+ exit 1
151+ fi
152+ done
141153cp -r " ${PACK_SRC} /src/schema" " ${PACK_SRC} /include/executorch/"
142154
143155echo " Copying generated flatbuffers headers..."
@@ -150,14 +162,27 @@ for candidate in \
150162 break
151163 fi
152164done
165+ # Same rule as the schema headers: the pack bundles flatbuffers/, and the
166+ # runtime does not compile without it. Refuse to produce a pack missing it.
167+ if [[ ! -f " ${PACK_SRC} /include/flatbuffers/flatbuffers.h" ]]; then
168+ echo " ERROR: flatbuffers headers not found in the CMake build tree." >&2
169+ echo " Looked in: ${BUILD_DIR} /third-party/{flatbuffers,flatc_ep}/include" >&2
170+ echo " Run the ExecuTorch CMake configure+build first so BUILD_DIR" >&2
171+ echo " contains the flatc external-project headers." >&2
172+ exit 1
173+ fi
153174
154- # Flatbuffers headers are redistributed inside the pack; ship the
155- # upstream Apache-2.0 LICENSE alongside per its terms.
156- if [[ -f " ${EXECUTORCH_ROOT} /third-party/flatbuffers/LICENSE" ]] \
157- && [[ -d " ${PACK_SRC} /include/flatbuffers" ]]; then
158- cp " ${EXECUTORCH_ROOT} /third-party/flatbuffers/LICENSE" \
159- " ${PACK_SRC} /include/flatbuffers/LICENSE"
175+ # Flatbuffers headers are redistributed inside the pack, so shipping the
176+ # upstream Apache-2.0 LICENSE alongside them is a condition of that
177+ # redistribution -- a pack without it must not be published.
178+ if [[ ! -f " ${EXECUTORCH_ROOT} /third-party/flatbuffers/LICENSE" ]]; then
179+ echo " ERROR: third-party/flatbuffers/LICENSE not found in the source tree." >&2
180+ echo " The pack redistributes the flatbuffers headers and must ship" >&2
181+ echo " their licence. Run: git submodule update --init third-party/flatbuffers" >&2
182+ exit 1
160183fi
184+ cp " ${EXECUTORCH_ROOT} /third-party/flatbuffers/LICENSE" \
185+ " ${PACK_SRC} /include/flatbuffers/LICENSE"
161186
162187echo " Creating c10 and torch include paths..."
163188C10_DIR=" ${PACK_SRC} /src/runtime/core/portable_type/c10/c10"
0 commit comments