diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /searchlib/src/forcelink.sh |
Publish
Diffstat (limited to 'searchlib/src/forcelink.sh')
-rwxr-xr-x | searchlib/src/forcelink.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/searchlib/src/forcelink.sh b/searchlib/src/forcelink.sh new file mode 100755 index 00000000000..b088b8363a5 --- /dev/null +++ b/searchlib/src/forcelink.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +project=searchlib + +if [ X$1 == "Xupdate" ]; then + # update forcelink.hpp + echo "generating forcelink.hpp..." + guard=`pwd | sed -e "s|.*/${project}/||" -e "s|/|_|g"` + prefix=forcelink_file_${project}_${guard}_ + echo "#ifndef GUARD_${project}_${guard}_FORCELINK" > forcelink.hpp + echo "#define GUARD_${project}_${guard}_FORCELINK" >> forcelink.hpp + echo "" >> forcelink.hpp + find . -name "*.cpp" -maxdepth 1 | sed -e "s|.*/\(.*\)\.cpp|void ${prefix}\1();|" >> forcelink.hpp + echo "" >> forcelink.hpp + echo "void forcelink_${project}_${guard}() {" >> forcelink.hpp + find . -name "*.cpp" -maxdepth 1 | sed -e "s|.*/\(.*\)\.cpp| ${prefix}\1();|" >> forcelink.hpp + echo "}" >> forcelink.hpp + echo "" >> forcelink.hpp + echo "#endif" >> forcelink.hpp + echo "invoke 'forcelink_${project}_${guard}()' to force link this directory" + + # update .cpp files + for file in *.cpp; do + name=`echo "${prefix}${file}" | sed 's|\(.*\)\.cpp|\1|'` + found=`grep ${name} ${file} | wc -l` + if [ $found == "0" ]; then + echo "updating ${file}..." + echo "" >> $file + echo "// this function was added by $0" >> $file + echo "void ${name}() {}" >> $file + fi + done +else + echo "This is a small utility script that might help out when trying to" + echo "force the linkage of object files. When run in a subdirectory within" + echo "${project}, it will create a 'forcelink.hpp' file that contains the" + echo "force linkage wrapping code. It will also update any .cpp files in the" + echo "directory with appropriate dummy functions to allow consistent force" + echo "linkage. Note that this script will make a large" + echo "number of assumptions; USE AT YOUR OWN RISK!" + echo "" + echo "if you feel lucky, run:" + echo "$0 update" +fi |