Description: Remove build path from generated header files
Author: Fabian Wolff <fabi.wolff@arcor.de>
Forwarded: https://github.com/CVC4/CVC4/pull/4980
Last-Update: 2020-08-31
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/src/expr/mkexpr
+++ b/src/expr/mkexpr
@@ -18,6 +18,7 @@
 copyright=2010-2014
 
 filename=`basename "$1" | sed 's,_template,,'`
+template_rel="<CVC4>/"$(realpath --relative-to $CMAKE_SOURCE_DIR $1)
 
 cat <<EOF
 /*********************                                                        */
@@ -26,10 +27,7 @@
  ** Copyright $copyright  New York University and The University of Iowa,
  ** and as below.
  **
- ** This file automatically generated by:
- **
- **     $0 $@
- **
+ ** This file automatically generated
  ** for the CVC4 project.
  **/
 
@@ -48,7 +46,7 @@
 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
 
 /* Edit the template file instead:                     */
-/* $1 */
+/* $template_rel */
 
 EOF
 
@@ -150,9 +148,9 @@
   lineno=${BASH_LINENO[0]}
   check_theory_seen
   typerules="${typerules}
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
   case kind::$1:
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
     typeNode = $2::computeType(nodeManager, n, check);
     break;
 "
@@ -163,9 +161,9 @@
   lineno=${BASH_LINENO[0]}
   check_theory_seen
   construles="${construles}
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
   case kind::$1:
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
     return $2::computeIsConst(nodeManager, n);
 "
 }
@@ -218,26 +216,26 @@
   fi
 
   mkConst_instantiations="${mkConst_instantiations}
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
 template <> Expr ExprManager::mkConst($2 const& val);
 "
   mkConst_implementations="${mkConst_implementations}
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
 template <> Expr ExprManager::mkConst($2 const& val) {
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel \"
   return Expr(this, new Node(d_nodeManager->mkConst< $2 >(val)));
 }
 "
   getConst_instantiations="${getConst_instantiations}
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
 template <> $2 const & Expr::getConst< $2 >() const;
 "
   getConst_implementations="${getConst_implementations}
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
 template <> $2 const & Expr::getConst() const {
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
   PrettyCheckArgument(getKind() == ::CVC4::kind::$1, *this, \"Improper kind for getConst<$2>()\");
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
   return d_node->getConst< $2 >();
 }
 "
@@ -270,6 +268,7 @@
 
 while [ $# -gt 0 ]; do
   kf=$1
+  kf_rel="<CVC4>/"$(realpath --relative-to "$CMAKE_SOURCE_DIR" $kf)
   seen_theory=false
   seen_endtheory=false
   b=$(basename $(dirname "$kf"))
@@ -295,7 +294,7 @@
 text=$(cat "$template")
 for var in \
     includes \
-    template \
+    template_rel \
     getConst_instantiations \
     getConst_implementations \
     mkConst_instantiations \
--- a/src/expr/mkkind
+++ b/src/expr/mkkind
@@ -17,6 +17,7 @@
 copyright=2010-2014
 
 filename=`basename "$1" | sed 's,_template,,'`
+template_rel="<CVC4>/"$(realpath --relative-to $CMAKE_SOURCE_DIR $1)
 
 cat <<EOF
 /*********************                                                        */
@@ -25,10 +26,7 @@
  ** Copyright $copyright  New York University and The University of Iowa,
  ** and as below.
  **
- ** This header file automatically generated by:
- **
- **     $0 $@
- **
+ ** This header file automatically generated
  ** for the CVC4 project.
  **/
 
@@ -47,7 +45,7 @@
 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
 
 /* Edit the template file instead:                     */
-/* $1 */
+/* $template_rel */
 
 EOF
 
@@ -257,23 +255,23 @@
 "
   type_constant_to_theory_id="${type_constant_to_theory_id}  case $id: return $theory_id;
 "
-  type_constant_cardinalities="${type_constant_cardinalities}#line $lineno \"$kf\"
+  type_constant_cardinalities="${type_constant_cardinalities}#line $lineno \"$kf_rel\"
   case $id: return Cardinality($cardinality);
 "
-  type_constant_wellfoundednesses="${type_constant_wellfoundednesses}#line $lineno \"$kf\"
+  type_constant_wellfoundednesses="${type_constant_wellfoundednesses}#line $lineno \"$kf_rel\"
   case $id: return $wellfoundedness;
 "
   if [ -n "$groundterm" ]; then
-    type_constant_groundterms="${type_constant_groundterms}#line $lineno \"$kf\"
+    type_constant_groundterms="${type_constant_groundterms}#line $lineno \"$kf_rel\"
   case $id: return $groundterm;
 "
     if [ -n "$header" ]; then
-      type_properties_includes="${type_properties_includes}#line $lineno \"$kf\"
+      type_properties_includes="${type_properties_includes}#line $lineno \"$kf_rel\"
 #include \"$header\"
 "
     fi
   else
-    type_constant_groundterms="${type_constant_groundterms}#line $lineno \"$kf\"
+    type_constant_groundterms="${type_constant_groundterms}#line $lineno \"$kf_rel\"
   case $id: Unhandled() << tc;
 "
   fi
@@ -284,11 +282,11 @@
   cardinality_computer=$(sed 's,%TYPE%,typeNode,g' <<<"$2")
   header=$3
 
-  type_cardinalities="${type_cardinalities}#line $lineno \"$kf\"
+  type_cardinalities="${type_cardinalities}#line $lineno \"$kf_rel\"
   case $id: return $cardinality_computer;
 "
   if [ -n "$header" ]; then
-    type_properties_includes="${type_properties_includes}#line $lineno \"$kf\"
+    type_properties_includes="${type_properties_includes}#line $lineno \"$kf_rel\"
 #include \"$header\"
 "
   fi
@@ -314,20 +312,20 @@
     fi
   fi
 
-  type_wellfoundednesses="${type_wellfoundednesses}#line $lineno \"$kf\"
+  type_wellfoundednesses="${type_wellfoundednesses}#line $lineno \"$kf_rel\"
   case $id: return $wellfoundedness_computer;
 "
   if [ -n "$groundterm_computer" ]; then
-    type_groundterms="${type_groundterms}#line $lineno \"$kf\"
+    type_groundterms="${type_groundterms}#line $lineno \"$kf_rel\"
   case $id: return $groundterm_computer;
 "
   else
-    type_groundterms="${type_groundterms}#line $lineno \"$kf\"
+    type_groundterms="${type_groundterms}#line $lineno \"$kf_rel\"
   case $id: Unhandled() << typeNode;
 "
   fi
   if [ -n "$header" ]; then
-    type_properties_includes="${type_properties_includes}#line $lineno \"$kf\"
+    type_properties_includes="${type_properties_includes}#line $lineno \"$kf_rel\"
 #include \"$header\"
 "
   fi
@@ -366,6 +364,7 @@
 
 while [ $# -gt 0 ]; do
   kf=$1
+  kf_rel="<CVC4>/"$(realpath --relative-to "$CMAKE_SOURCE_DIR" $kf)
   seen_theory=false
   seen_endtheory=false
   b=$(basename $(dirname "$kf"))
@@ -409,7 +408,7 @@
     type_groundterms \
     type_constant_groundterms \
     type_properties_includes \
-    template \
+    template_rel \
     ; do
   eval text="\${text//\\\$\\{$var\\}/\${$var}}"
 done
--- a/src/expr/mkmetakind
+++ b/src/expr/mkmetakind
@@ -18,6 +18,7 @@
 #
 
 copyright=2010-2014
+template_rel="<CVC4>/"$(realpath --relative-to $CMAKE_SOURCE_DIR $1)
 
 cat <<EOF
 /*********************                                                        */
@@ -26,10 +27,7 @@
  ** Copyright $copyright  New York University and The University of Iowa,
  ** and as below.
  **
- ** This header file automatically generated by:
- **
- **     $0 $@
- **
+ ** This header file automatically generated
  ** for the CVC4 project.
  **/
 
@@ -270,19 +268,19 @@
 "
   metakind_constHashes="${metakind_constHashes}
   case kind::$1:
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
     return $3()(nv->getConst< $2 >());
 "
   metakind_constPrinters="${metakind_constPrinters}
   case kind::$1:
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
     out << nv->getConst< $2 >();
     break;
 "
   cname=`echo "$2" | awk 'BEGIN {FS="::"} {print$NF}'`
   metakind_constDeleters="${metakind_constDeleters}
   case kind::$1:
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
     std::allocator< $2 >().destroy(reinterpret_cast< $2* >(nv->d_children));
     break;
 "
@@ -301,7 +299,7 @@
   operatorKind=$1
   applyKind=$2
   metakind_operatorKinds="${metakind_operatorKinds}
-#line $lineno \"$kf\"
+#line $lineno \"$kf_rel\"
     case kind::$applyKind: return kind::$operatorKind;";
 }
 
@@ -372,6 +370,7 @@
 
 while [ $# -gt 0 ]; do
   kf=$1
+  kf_rel="<CVC4>/"$(realpath --relative-to "$CMAKE_SOURCE_DIR" $kf)
   seen_theory=false
   seen_endtheory=false
   b=$(basename $(dirname "$kf"))
@@ -414,7 +413,7 @@
     metakind_ubchildren \
     metakind_lbchildren \
     metakind_operatorKinds \
-    template \
+    template_rel \
     ; do
   eval text="\${text//\\\$\\{$var\\}/\${$var}}"
 done
--- a/src/expr/CMakeLists.txt
+++ b/src/expr/CMakeLists.txt
@@ -115,6 +115,7 @@
 add_custom_command(
   OUTPUT kind.h
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkkind_script}
     ${CMAKE_CURRENT_LIST_DIR}/kind_template.h
     ${KINDS_FILES}
@@ -125,6 +126,7 @@
 add_custom_command(
   OUTPUT kind.cpp
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkkind_script}
     ${CMAKE_CURRENT_LIST_DIR}/kind_template.cpp
     ${KINDS_FILES}
@@ -135,6 +137,7 @@
 add_custom_command(
   OUTPUT type_properties.h
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkkind_script}
     ${CMAKE_CURRENT_LIST_DIR}/type_properties_template.h
     ${KINDS_FILES}
@@ -145,6 +148,7 @@
 add_custom_command(
   OUTPUT metakind.h
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkmetakind_script}
     ${CMAKE_CURRENT_LIST_DIR}/metakind_template.h
     ${KINDS_FILES}
@@ -155,6 +159,7 @@
 add_custom_command(
   OUTPUT metakind.cpp
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkmetakind_script}
     ${CMAKE_CURRENT_LIST_DIR}/metakind_template.cpp
     ${KINDS_FILES}
@@ -165,6 +170,7 @@
 add_custom_command(
   OUTPUT expr.h
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkexpr_script}
     ${CMAKE_CURRENT_LIST_DIR}/expr_template.h
     ${KINDS_FILES}
@@ -175,6 +181,7 @@
 add_custom_command(
   OUTPUT expr.cpp
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkexpr_script}
     ${CMAKE_CURRENT_LIST_DIR}/expr_template.cpp
     ${KINDS_FILES}
@@ -185,6 +192,7 @@
 add_custom_command(
   OUTPUT expr_manager.h
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkexpr_script}
     ${CMAKE_CURRENT_LIST_DIR}/expr_manager_template.h
     ${KINDS_FILES}
@@ -195,6 +203,7 @@
 add_custom_command(
   OUTPUT expr_manager.cpp
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkexpr_script}
     ${CMAKE_CURRENT_LIST_DIR}/expr_manager_template.cpp
     ${KINDS_FILES}
@@ -205,6 +214,7 @@
 add_custom_command(
   OUTPUT type_checker.cpp
   COMMAND
+    ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
     ${mkexpr_script}
     ${CMAKE_CURRENT_LIST_DIR}/type_checker_template.cpp
     ${KINDS_FILES}
--- a/src/expr/expr_template.cpp
+++ b/src/expr/expr_template.cpp
@@ -33,7 +33,7 @@
 // compiler directs the user to the template file instead of the
 // generated one.  We don't want the user to modify the generated one,
 // since it'll get overwritten on a later build.
-#line 37 "${template}"
+#line 37 "${template_rel}"
 
 using namespace CVC4::kind;
 using namespace std;
--- a/src/expr/expr_template.h
+++ b/src/expr/expr_template.h
@@ -43,7 +43,7 @@
 // compiler directs the user to the template file instead of the
 // generated one.  We don't want the user to modify the generated one,
 // since it'll get overwritten on a later build.
-#line 47 "${template}"
+#line 47 "${template_rel}"
 
 namespace CVC4 {
 
@@ -621,7 +621,7 @@
 
 ${getConst_instantiations}
 
-#line 625 "${template}"
+#line 625 "${template_rel}"
 
 inline size_t ExprHashFunction::operator()(CVC4::Expr e) const {
   return (size_t) e.getId();
--- a/src/expr/expr_manager_template.cpp
+++ b/src/expr/expr_manager_template.cpp
@@ -30,7 +30,7 @@
 // compiler directs the user to the template file instead of the
 // generated one.  We don't want the user to modify the generated one,
 // since it'll get overwritten on a later build.
-#line 34 "${template}"
+#line 34 "${template_rel}"
 
 #ifdef CVC4_STATISTICS_ON
   #define INC_STAT(kind) \
--- a/src/expr/expr_manager_template.h
+++ b/src/expr/expr_manager_template.h
@@ -32,7 +32,7 @@
 // compiler directs the user to the template file instead of the
 // generated one.  We don't want the user to modify the generated one,
 // since it'll get overwritten on a later build.
-#line 36 "${template}"
+#line 36 "${template_rel}"
 
 namespace CVC4 {
 
--- a/src/expr/kind_template.cpp
+++ b/src/expr/kind_template.cpp
@@ -69,7 +69,7 @@
 std::ostream& operator<<(std::ostream& out, TypeConstant typeConstant) {
   switch(typeConstant) {
 ${type_constant_descriptions}
-#line 73 "${template}"
+#line 73 "${template_rel}"
   default:
     out << "UNKNOWN_TYPE_CONSTANT";
     break;
@@ -85,7 +85,7 @@
   case kind::NULL_EXPR:
     break;
 ${kind_to_theory_id}
-#line 89 "${template}"
+#line 89 "${template_rel}"
   case kind::LAST_KIND:
     break;
   }
@@ -97,7 +97,7 @@
   switch (typeConstant)
   {
 ${type_constant_to_theory_id}
-#line 101 "${template}"
+#line 101 "${template_rel}"
     case LAST_TYPE: break;
   }
   throw IllegalArgumentException(
--- a/src/expr/kind_template.h
+++ b/src/expr/kind_template.h
@@ -63,7 +63,7 @@
  */
 std::ostream& operator<<(std::ostream&, CVC4::Kind) CVC4_PUBLIC;
 
-#line 67 "${template}"
+#line 67 "${template_rel}"
 
 /** Returns true if the given kind is associative. This is used by ExprManager to
  * decide whether it's safe to modify big expressions by changing the grouping of
@@ -86,7 +86,7 @@
 enum CVC4_PUBLIC TypeConstant
 {
   ${type_constant_list}
-#line 90 "${template}"
+#line 90 "${template_rel}"
   LAST_TYPE
 }; /* enum TypeConstant */
 
--- a/src/expr/metakind_template.h
+++ b/src/expr/metakind_template.h
@@ -201,7 +201,7 @@
 
 }/* CVC4::kind namespace */
 
-#line 205 "${template}"
+#line 205 "${template_rel}"
 
 }/* CVC4 namespace */
 
--- a/src/expr/type_checker_template.cpp
+++ b/src/expr/type_checker_template.cpp
@@ -14,7 +14,7 @@
  ** TypeChecker implementation.
  **/
 
-#line 18 "${template}"
+#line 18 "${template_rel}"
 
 #include "expr/node_manager.h"
 #include "expr/node_manager_attributes.h"
@@ -23,7 +23,7 @@
 
 ${typechecker_includes}
 
-#line 27 "${template}"
+#line 27 "${template_rel}"
 
 namespace CVC4 {
 namespace expr {
@@ -44,7 +44,7 @@
 
 ${typerules}
 
-#line 48 "${template}"
+#line 48 "${template_rel}"
 
   default:
     Debug("getType") << "FAILURE" << std::endl;
@@ -68,7 +68,7 @@
   switch(n.getKind()) {
 ${construles}
 
-#line 72 "${template}"
+#line 72 "${template_rel}"
 
     default:;
   }
--- a/src/expr/type_properties_template.h
+++ b/src/expr/type_properties_template.h
@@ -19,7 +19,7 @@
 #ifndef CVC4__TYPE_PROPERTIES_H
 #define CVC4__TYPE_PROPERTIES_H
 
-#line 23 "${template}"
+#line 23 "${template_rel}"
 
 #include <sstream>
 
@@ -31,7 +31,7 @@
 
 ${type_properties_includes}
 
-#line 35 "${template}"
+#line 35 "${template_rel}"
 
 namespace CVC4 {
 namespace kind {
@@ -47,7 +47,7 @@
   switch (tc)
   {
 ${type_constant_cardinalities}
-#line 51 "${template}"
+#line 51 "${template_rel}"
     default: InternalError() << "No cardinality known for type constant " << tc;
   }
 } /* getCardinality(TypeConstant) */
@@ -64,7 +64,7 @@
   case TYPE_CONSTANT:
     return getCardinality(typeNode.getConst<TypeConstant>());
 ${type_cardinalities}
-#line 68 "${template}"
+#line 68 "${template_rel}"
   default:
     InternalError() << "A theory kinds file did not provide a cardinality "
                     << "or cardinality computer for type:\n"
@@ -75,7 +75,7 @@
 inline bool isWellFounded(TypeConstant tc) {
   switch(tc) {
 ${type_constant_wellfoundednesses}
-#line 79 "${template}"
+#line 79 "${template_rel}"
 default:
   InternalError() << "No well-foundedness status known for type constant: "
                   << tc;
@@ -88,7 +88,7 @@
   case TYPE_CONSTANT:
     return isWellFounded(typeNode.getConst<TypeConstant>());
 ${type_wellfoundednesses}
-#line 92 "${template}"
+#line 92 "${template_rel}"
   default:
     InternalError() << "A theory kinds file did not provide a well-foundedness "
                     << "or well-foundedness computer for type:\n"
@@ -101,7 +101,7 @@
   switch (tc)
   {
 ${type_constant_groundterms}
-#line 105 "${template}"
+#line 105 "${template_rel}"
     default:
       InternalError() << "No ground term known for type constant: " << tc;
   }
@@ -115,7 +115,7 @@
     case TYPE_CONSTANT:
       return mkGroundTerm(typeNode.getConst<TypeConstant>());
 ${type_groundterms}
-#line 119 "${template}"
+#line 119 "${template_rel}"
     default:
       InternalError() << "A theory kinds file did not provide a ground term "
                       << "or ground term computer for type:\n"
