1695b41eeSopenharmony_ci#!/bin/sh 2695b41eeSopenharmony_ci# 3695b41eeSopenharmony_ci# Copyright 2001 Google Inc. All Rights Reserved. 4695b41eeSopenharmony_ci# 5695b41eeSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 6695b41eeSopenharmony_ci# you may not use this file except in compliance with the License. 7695b41eeSopenharmony_ci# You may obtain a copy of the License at 8695b41eeSopenharmony_ci# 9695b41eeSopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 10695b41eeSopenharmony_ci# 11695b41eeSopenharmony_ci# Unless required by applicable law or agreed to in writing, software 12695b41eeSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 13695b41eeSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14695b41eeSopenharmony_ci# See the License for the specific language governing permissions and 15695b41eeSopenharmony_ci# limitations under the License. 16695b41eeSopenharmony_ci 17695b41eeSopenharmony_ci# This quick script converts a text file into an #include-able header. 18695b41eeSopenharmony_ci# It expects the name of the variable as its first argument, and reads 19695b41eeSopenharmony_ci# stdin and writes stdout. 20695b41eeSopenharmony_ci 21695b41eeSopenharmony_civarname="$1" 22695b41eeSopenharmony_ci 23695b41eeSopenharmony_ci# 'od' and 'sed' may not be available on all platforms, and may not support the 24695b41eeSopenharmony_ci# flags used here. We must ensure that the script exits with a non-zero exit 25695b41eeSopenharmony_ci# code in those cases. 26695b41eeSopenharmony_cibyte_vals=$(od -t x1 -A n -v) || exit 1 27695b41eeSopenharmony_ciescaped_byte_vals=$(echo "${byte_vals}" \ 28695b41eeSopenharmony_ci | sed -e 's|^[\t ]\{0,\}$||g; s|[\t ]\{1,\}| |g; s| \{1,\}$||g; s| |\\x|g; s|^|"|; s|$|"|') \ 29695b41eeSopenharmony_ci || exit 1 30695b41eeSopenharmony_ci 31695b41eeSopenharmony_ci# Only write output once we have successfully generated the required data 32695b41eeSopenharmony_ciprintf "const char %s[] = \n%s;" "${varname}" "${escaped_byte_vals}" 33