[Beignet] [PATCH 1/3] Add one script for generating the PCH files.
junyan.he at inbox.com
junyan.he at inbox.com
Thu Dec 12 23:30:51 PST 2013
From: Junyan He <junyan.he at linux.intel.com>
The gen_ocl_pch will be used to generate the PCH files
based on the different CL options.
the -u file will be used to force update the PCH files,
ignore the Clang version
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
backend/src/gen_ocl_pch.sh | 117 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 117 insertions(+)
create mode 100755 backend/src/gen_ocl_pch.sh
diff --git a/backend/src/gen_ocl_pch.sh b/backend/src/gen_ocl_pch.sh
new file mode 100755
index 0000000..69fe3d9
--- /dev/null
+++ b/backend/src/gen_ocl_pch.sh
@@ -0,0 +1,117 @@
+#! /bin/sh -e
+
+build_pch_version=0
+build_pch_magic=0
+force_update=""
+
+pch_prefix="/usr/share/beignet"
+pch_version_file=""
+header_file=""
+pch_file=""
+
+if [ x$1 = x ]; then
+ pch_version_file=/usr/share/beignet/ocl_pch.version
+ header_file=/usr/share/beignet/ocl_stdlib.h
+ pch_file=/usr/share/beignet/ocl_pch
+else
+ while getopts "v:i:o:p:uh" arg
+ do
+ case $arg in
+ v)
+ pch_version_file=$OPTARG
+ ;;
+
+ i)
+ header_file=$OPTARG
+ ;;
+
+ o)
+ pch_file=$OPTARG
+ ;;
+
+ p)
+ pch_prefix=$OPTARG
+ ;;
+
+ u)
+ force_update="yes"
+ ;;
+
+ h)
+ echo "Using the Script to build and rebuild the PCH"
+ echo "This Script will check the clang version in the current"
+ echo "environment with the old one stored in the ocl_pch.version"
+ echo "file. If not match, new PCHs will be generated."
+ echo "Usage:"
+ echo "-u Force to update"
+ echo "-p Specify the prefix, all the file name will be added after"
+ echo " this prefix. The default is /usr/share/beignet"
+ echo "-v Specify the version file name"
+ echo "-i Specify the ocl header file name"
+ echo "-o Specify the pch out name stem, suffix may be added for each build option"
+ exit
+ ;;
+
+ ?)
+ echo "unkonw argument"
+ ;;
+ esac
+ done
+fi
+
+if [ x${pch_version_file} = x ]; then
+ pch_version_file=${pch_prefix}/ocl_pch.version
+fi
+
+if [ x${header_file} = x ]; then
+ header_file=${pch_prefix}/ocl_stdlib.h
+fi
+
+if [ x${pch_file} = x ]; then
+ pch_file=${pch_prefix}/ocl_pch
+fi
+
+echo "PCH version file is " ${pch_version_file}
+echo "OCL header is " ${header_file}
+echo "PCH output file is " ${pch_file}"_xxx.pch"
+
+if [ -f ${pch_version_file} ]; then
+ build_pch_version=`cat ${pch_version_file} | awk -F "=" '/^build_pch_version/{print $NF}'`
+ build_pch_magic=`cat ${pch_version_file} | awk -F "=" '/^build_pch_magic/{print $NF}'`
+fi
+
+echo "build_pch_version is " ${build_pch_version}
+echo "build_pch_magic is " ${build_pch_magic}
+
+clang_magic=`clang --version | awk '/^clang/{print $NF}' | sed 's/^(//g' | sed 's/)$//g'`
+clang_ver=`clang --version | awk '/^clang/{print $3*10}'`
+
+
+if [ x${force_update} = x"yes" -o x${build_pch_version} != x${clang_ver} -o x${build_pch_magic} != x${clang_magic} ]; then
+ need_rebuild="yes"
+fi
+
+
+if [ ${clang_ver} -gt "32" ]; then
+ clang_cmd="-cc1 -x cl -triple spir -ffp-contract=off -emit-pch"
+else
+ if [ ${clang_ver} -gt "31" ]; then
+ clang_cmd="-cc1 -x cl -triple nvptx -ffp-contract=off -emit-pch"
+ else
+ clang_cmd="-cc1 -x cl -triple ptx32 -emit-pch"
+ fi
+fi
+clang_cmd="${clang_cmd} -fno-builtin -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND"
+
+
+if [ x${need_rebuild} = x"yes" ]; then
+ echo "***** Using Clang Version: " ${clang_ver} " Magic: " ${clang_magic} "to build the PCH *****"
+ echo "clang" ${clang_cmd} ${header_file} " -o" ${pch_file}".pch"
+ eval "clang" ${clang_cmd} ${header_file} " -o" ${pch_file}".pch"
+ echo "clang" ${clang_cmd} ${header_file} "-cl-single-precision-constant" " -o" ${pch_file}"-cl-single-precision-constant.pch"
+ eval "clang" ${clang_cmd} ${header_file} "-cl-single-precision-constant" " -o" ${pch_file}"-cl-single-precision-constant.pch"
+ echo "clang" ${clang_cmd} ${header_file} "-cl-std=CL1.1" " -o" ${pch_file}"-cl-std=CL1.1.pch"
+ eval "clang" ${clang_cmd} ${header_file} "-cl-std=CL1.1" " -o" ${pch_file}"-cl-std=CL1.1.pch"
+ echo "build_pch_version"=${clang_ver} > ${pch_version_file}
+ echo "build_pch_magic"=${clang_magic} >> ${pch_version_file}
+fi
--
1.8.3.2
More information about the Beignet
mailing list