[config] Add HB_NO_OT_SHAPE / HB_NO_OT

Part of https://github.com/harfbuzz/harfbuzz/issues/1652
diff --git a/src/gen-indic-table.py b/src/gen-indic-table.py
index eedf420..cdf81fe 100755
--- a/src/gen-indic-table.py
+++ b/src/gen-indic-table.py
@@ -98,6 +98,10 @@
 		print (" * %s" % (l.strip()))
 print (" */")
 print ()
+print ('#include "hb.hh"')
+print ()
+print ('#ifndef HB_NO_OT_SHAPE')
+print ()
 print ('#include "hb-ot-shape-complex-indic.hh"')
 print ()
 
@@ -251,6 +255,8 @@
 		print ("#undef %s_%s" %
 			(what_short[i], short[i][v]))
 print ()
+print ()
+print ('#endif')
 print ("/* == End of generated table == */")
 
 # Maintain at least 30% occupancy in the table */
diff --git a/src/gen-use-table.py b/src/gen-use-table.py
index 820838c..a8a03a7 100755
--- a/src/gen-use-table.py
+++ b/src/gen-use-table.py
@@ -419,6 +419,10 @@
 		print (" * %s" % (l.strip()))
 print (" */")
 print ()
+print ('#include "hb.hh"')
+print ()
+print ('#ifndef HB_NO_OT_SHAPE')
+print ()
 print ('#include "hb-ot-shape-complex-use.hh"')
 print ()
 
@@ -533,6 +537,8 @@
 		tag = k + suf
 		print ("#undef %s" % tag)
 print ()
+print ()
+print ('#endif')
 print ("/* == End of generated table == */")
 
 # Maintain at least 50% occupancy in the table */
diff --git a/src/gen-vowel-constraints.py b/src/gen-vowel-constraints.py
index 1340d97..8ca90c8 100755
--- a/src/gen-vowel-constraints.py
+++ b/src/gen-vowel-constraints.py
@@ -157,6 +157,11 @@
 for line in scripts_header:
 	print (' * %s' % line.strip ())
 print (' */')
+
+print ()
+print ('#include "hb.hh"')
+print ()
+print ('#ifndef HB_NO_OT_SHAPE')
 print ()
 print ('#include "hb-ot-shape-complex-vowel-constraints.hh"')
 print ()
@@ -223,4 +228,6 @@
 print ('}')
 
 print ()
+print ()
+print ('#endif')
 print ('/* == End of generated functions == */')
diff --git a/src/hb-config.hh b/src/hb-config.hh
index f9e4699..c6a4080 100644
--- a/src/hb-config.hh
+++ b/src/hb-config.hh
@@ -121,6 +121,10 @@
 #define HB_NO_OT_NAME_LANGUAGE
 #endif
 
+#ifdef HB_NO_OT
+#define HB_NO_OT_SHAPE
+#endif
+
 #ifdef HB_NO_OT_SHAPE_FALLBACK
 #define HB_NO_OT_SHAPE_COMPLEX_ARABIC_FALLBACK
 #define HB_NO_OT_SHAPE_COMPLEX_HEBREW_FALLBACK
diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index 3212e0c..b24833b 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -25,6 +25,9 @@
  */
 
 #include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex-arabic.hh"
 #include "hb-ot-shape.hh"
 
@@ -710,3 +713,6 @@
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   true, /* fallback_position */
 };
+
+
+#endif
diff --git a/src/hb-ot-shape-complex-default.cc b/src/hb-ot-shape-complex-default.cc
index 97923ec..a921f16 100644
--- a/src/hb-ot-shape-complex-default.cc
+++ b/src/hb-ot-shape-complex-default.cc
@@ -24,6 +24,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex.hh"
 
 
@@ -44,3 +48,6 @@
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   true, /* fallback_position */
 };
+
+
+#endif
diff --git a/src/hb-ot-shape-complex-hangul.cc b/src/hb-ot-shape-complex-hangul.cc
index f084f6a..32e0e66 100644
--- a/src/hb-ot-shape-complex-hangul.cc
+++ b/src/hb-ot-shape-complex-hangul.cc
@@ -24,6 +24,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex.hh"
 
 
@@ -430,3 +434,6 @@
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
   false, /* fallback_position */
 };
+
+
+#endif
diff --git a/src/hb-ot-shape-complex-hebrew.cc b/src/hb-ot-shape-complex-hebrew.cc
index 1498973..334d3de 100644
--- a/src/hb-ot-shape-complex-hebrew.cc
+++ b/src/hb-ot-shape-complex-hebrew.cc
@@ -24,6 +24,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex.hh"
 
 
@@ -176,3 +180,6 @@
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   true, /* fallback_position */
 };
+
+
+#endif
diff --git a/src/hb-ot-shape-complex-indic-table.cc b/src/hb-ot-shape-complex-indic-table.cc
index d26bbb8..419aae1 100644
--- a/src/hb-ot-shape-complex-indic-table.cc
+++ b/src/hb-ot-shape-complex-indic-table.cc
@@ -14,6 +14,10 @@
  * # Date: 2018-07-30, 19:40:00 GMT [KW]
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex-indic.hh"
 
 #pragma GCC diagnostic push
@@ -487,4 +491,6 @@
 #undef IMC_TR
 #undef IMC_VOL
 
+
+#endif
 /* == End of generated table == */
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index f8cb574..6405d9c 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -24,6 +24,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex-indic.hh"
 #include "hb-ot-shape-complex-vowel-constraints.hh"
 #include "hb-ot-layout.hh"
@@ -1648,3 +1652,6 @@
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
   false, /* fallback_position */
 };
+
+
+#endif
diff --git a/src/hb-ot-shape-complex-khmer.cc b/src/hb-ot-shape-complex-khmer.cc
index 4c88477..eba7d86 100644
--- a/src/hb-ot-shape-complex-khmer.cc
+++ b/src/hb-ot-shape-complex-khmer.cc
@@ -24,6 +24,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex-khmer.hh"
 #include "hb-ot-layout.hh"
 
@@ -502,3 +506,6 @@
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
   false, /* fallback_position */
 };
+
+
+#endif
diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc
index b1f6b65..5b819cf 100644
--- a/src/hb-ot-shape-complex-myanmar.cc
+++ b/src/hb-ot-shape-complex-myanmar.cc
@@ -24,6 +24,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex-myanmar.hh"
 
 
@@ -415,3 +419,6 @@
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
   false, /* fallback_position */
 };
+
+
+#endif
diff --git a/src/hb-ot-shape-complex-thai.cc b/src/hb-ot-shape-complex-thai.cc
index 22d4aa3..347ea2e 100644
--- a/src/hb-ot-shape-complex-thai.cc
+++ b/src/hb-ot-shape-complex-thai.cc
@@ -24,6 +24,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex.hh"
 
 
@@ -385,3 +389,6 @@
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   false,/* fallback_position */
 };
+
+
+#endif
diff --git a/src/hb-ot-shape-complex-use-table.cc b/src/hb-ot-shape-complex-use-table.cc
index 0247469..4c5d687 100644
--- a/src/hb-ot-shape-complex-use-table.cc
+++ b/src/hb-ot-shape-complex-use-table.cc
@@ -15,6 +15,10 @@
  * UnicodeData.txt does not have a header.
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex-use.hh"
 
 #pragma GCC diagnostic push
@@ -851,4 +855,6 @@
 #undef VMPst
 #undef VMAbv
 
+
+#endif
 /* == End of generated table == */
diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc
index 2cc5ea2..91c0b8c 100644
--- a/src/hb-ot-shape-complex-use.cc
+++ b/src/hb-ot-shape-complex-use.cc
@@ -26,6 +26,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex-use.hh"
 #include "hb-ot-shape-complex-arabic.hh"
 #include "hb-ot-shape-complex-vowel-constraints.hh"
@@ -643,3 +647,6 @@
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY,
   false, /* fallback_position */
 };
+
+
+#endif
diff --git a/src/hb-ot-shape-complex-vowel-constraints.cc b/src/hb-ot-shape-complex-vowel-constraints.cc
index 912ee35..2f80413 100644
--- a/src/hb-ot-shape-complex-vowel-constraints.cc
+++ b/src/hb-ot-shape-complex-vowel-constraints.cc
@@ -13,6 +13,10 @@
  * # Date: 2019-01-28, 22:16:47 GMT
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-complex-vowel-constraints.hh"
 
 static void
@@ -440,4 +444,6 @@
   }
 }
 
+
+#endif
 /* == End of generated functions == */
diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc
index 573af8e..03a42df 100644
--- a/src/hb-ot-shape-fallback.cc
+++ b/src/hb-ot-shape-fallback.cc
@@ -24,6 +24,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-fallback.hh"
 #include "hb-kern.hh"
 
@@ -587,3 +591,6 @@
       }
     }
 }
+
+
+#endif
diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index 82bb24b..14c5bd4 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -24,6 +24,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-ot-shape-normalize.hh"
 #include "hb-ot-shape-complex.hh"
 #include "hb-ot-shape.hh"
@@ -469,3 +473,6 @@
     buffer->swap_buffers ();
   }
 }
+
+
+#endif
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 7690c22..499b1be 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -26,6 +26,10 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include "hb.hh"
+
+#ifndef HB_NO_OT_SHAPE
+
 #include "hb-shaper-impl.hh"
 
 #include "hb-ot-shape.hh"
@@ -1146,3 +1150,6 @@
 
   hb_shape_plan_destroy (shape_plan);
 }
+
+
+#endif
diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc
index 61ea8d0..2b23dee 100644
--- a/src/hb-shape-plan.cc
+++ b/src/hb-shape-plan.cc
@@ -79,7 +79,9 @@
   }
   this->shaper_func = nullptr;
   this->shaper_name = nullptr;
+#ifndef HB_NO_OT_SHAPE
   this->ot.init (face, coords, num_coords);
+#endif
 
   /*
    * Choose shaper.
@@ -148,7 +150,9 @@
 {
   return hb_segment_properties_equal (&this->props, &other->props) &&
 	 this->user_features_match (other) &&
+#ifndef HB_NO_OT_SHAPE
 	 this->ot.equal (&other->ot) &&
+#endif
 	 this->shaper_func == other->shaper_func;
 }
 
@@ -224,12 +228,16 @@
 				       num_coords,
 				       shaper_list)))
     goto bail2;
+#ifndef HB_NO_OT_SHAPE
   if (unlikely (!shape_plan->ot.init0 (face, &shape_plan->key)))
     goto bail3;
+#endif
 
   return shape_plan;
 
+#ifndef HB_NO_OT_SHAPE
 bail3:
+#endif
   shape_plan->key.free ();
 bail2:
   free (shape_plan);
@@ -281,7 +289,9 @@
 {
   if (!hb_object_destroy (shape_plan)) return;
 
+#ifndef HB_NO_OT_SHAPE
   shape_plan->ot.fini ();
+#endif
   shape_plan->key.free ();
   free (shape_plan);
 }
diff --git a/src/hb-shape-plan.hh b/src/hb-shape-plan.hh
index 3a057fd..8e8d763 100644
--- a/src/hb-shape-plan.hh
+++ b/src/hb-shape-plan.hh
@@ -39,7 +39,9 @@
   const hb_feature_t      *user_features;
   unsigned int             num_user_features;
 
+#ifndef HB_NO_OT_SHAPE
   hb_ot_shape_plan_key_t   ot;
+#endif
 
   hb_shape_func_t         *shaper_func;
   const char              *shaper_name;
@@ -65,7 +67,9 @@
   hb_object_header_t header;
   hb_face_t *face_unsafe; /* We don't carry a reference to face. */
   hb_shape_plan_key_t key;
+#ifndef HB_NO_OT_SHAPE
   hb_ot_shape_plan_t ot;
+#endif
 };
 
 
diff --git a/src/hb-shaper-list.hh b/src/hb-shaper-list.hh
index 4108e7a..c864af6 100644
--- a/src/hb-shaper-list.hh
+++ b/src/hb-shaper-list.hh
@@ -35,7 +35,9 @@
 HB_SHAPER_IMPLEMENT (graphite2)
 #endif
 
+#ifndef HB_NO_OT_SHAPE
 HB_SHAPER_IMPLEMENT (ot) /* <--- This is our main OpenType shaper. */
+#endif
 
 #ifdef HAVE_UNISCRIBE
 HB_SHAPER_IMPLEMENT (uniscribe)