[glib/wip/pwithnall/962-drop-embedded-pcre: 2/4] build: Drop the internal_pcre option in favour of the subproject




commit 97e4a5c766feb4b741ce95d3a1b016ca2b6ea0dc
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Jun 9 12:26:30 2021 +0100

    build: Drop the internal_pcre option in favour of the subproject
    
    This should maintain equivalent functionality, apart from that now you
    have to pass `--force-fallback-for libpcre` to `meson configure` in
    order to use the subproject; rather than specifying
    `-Dinternal_pcre=true` to use the internal copy.
    
    This also fixes #642, as the wrapdb copy of libpcre is version 8.37.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #962
    Fixes: #642

 .gitlab-ci.yml                   |  4 +--
 docs/reference/glib/building.xml | 48 +++-------------------------------
 glib/gregex.c                    |  4 ---
 glib/meson.build                 |  9 ++-----
 glib/tests/regex.c               |  4 ---
 meson.build                      | 56 ++++++++++++++++++----------------------
 meson_options.txt                |  5 ----
 7 files changed, 32 insertions(+), 98 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3c8e7c834..636ae8217 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -270,7 +270,7 @@ cross-android_api21_arm64:
     # FIXME: add --werror
     # We use -Diconv=auto to test that we successfully detect that iconv is not
     # provided by android api 21, and detect the external iconv instead.
-    - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_21.txt -Diconv=auto 
-Dinternal_pcre=true _build
+    - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_21.txt -Diconv=auto _build
     - ninja -C _build
 
 cross-android_api28_arm64:
@@ -278,7 +278,7 @@ cross-android_api28_arm64:
   image: $ANDROID_IMAGE
   script:
     # FIXME: add --werror
-    - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_28.txt -Dinternal_pcre=true 
_build
+    - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_28.txt _build
     - ninja -C _build
 
 cross-mingw64:
diff --git a/docs/reference/glib/building.xml b/docs/reference/glib/building.xml
index 9ff2fbfe7..d165c5c23 100644
--- a/docs/reference/glib/building.xml
+++ b/docs/reference/glib/building.xml
@@ -153,12 +153,9 @@
       <listitem>
         <para>
           GRegex uses the <ulink url="http://www.pcre.org/";>PCRE library</ulink>
-          for regular expression matching. The default is to use the system
-          version of PCRE, to reduce the chances of security fixes going out
-          of sync. GLib additionally provides an internal copy of PCRE in case
-          the system version is too old, or does not support UTF-8; the internal
-          copy is patched to use GLib for memory management and to share the
-          same Unicode tables.
+          for regular expression matching. The system version of PCRE is used,
+          unless not available (which is the case on Android), in which case a
+          fallback subproject is used.
         </para>
       </listitem>
       <listitem>
@@ -235,45 +232,6 @@
       </para>
     </formalpara>
 
-    <formalpara>
-      <title><option>-Dinternal_pcre=true</option></title>
-
-      <para>
-        Normally, GLib will be configured to use the system-supplied PCRE
-        library if it is suitable, falling back to an internal version
-        otherwise. If this option is specified, the internal version will always
-        be used.
-      </para>
-      <para>
-        Using the internal PCRE is the preferred solution if:
-        <itemizedlist>
-          <listitem>
-            <para>
-              your system has strict resource constraints; the system-supplied
-              PCRE has a separated copy of the tables used for Unicode
-              handling, whereas the internal copy shares the Unicode tables
-              used by GLib.
-            </para>
-          </listitem>
-          <listitem>
-            <para>
-              your system has PCRE built without some needed features,
-              such as UTF-8 and Unicode support.
-            </para>
-          </listitem>
-          <listitem>
-            <para>
-              you are planning to use both GRegex and PCRE API at the same
-              time, either directly or indirectly through a dependency; PCRE
-              uses some global variables for memory management and
-              other features, and if both GLib and PCRE try to access them
-              at the same time, this could lead to undefined behavior.
-            </para>
-          </listitem>
-        </itemizedlist>
-      </para>
-    </formalpara>
-
     <formalpara>
       <title><option>-Dbsymbolic_functions=false</option> and
         <option>-Dbsymbolic_functions=true</option></title>
diff --git a/glib/gregex.c b/glib/gregex.c
index 5e6ddfb46..eeed2d8d0 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -22,11 +22,7 @@
 
 #include <string.h>
 
-#ifdef USE_SYSTEM_PCRE
 #include <pcre.h>
-#else
-#include "pcre/pcre.h"
-#endif
 
 #include "gtypes.h"
 #include "gregex.h"
diff --git a/glib/meson.build b/glib/meson.build
index 8c18e6de4..0c768128a 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -357,13 +357,8 @@ if use_pcre_static_flag
   pcre_static_args = ['-DPCRE_STATIC']
 endif
 
-if use_system_pcre
-  pcre_deps = [pcre]
-  pcre_objects = []
-else
-  pcre_deps = []
-  pcre_objects = [libpcre.extract_all_objects()]
-endif
+pcre_deps = [pcre]
+pcre_objects = []
 
 glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + 
glib_hidden_visibility_args
 libglib = library('glib-2.0',
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index 1a37177b3..80d18d985 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -25,11 +25,7 @@
 #include <locale.h>
 #include "glib.h"
 
-#ifdef USE_SYSTEM_PCRE
 #include <pcre.h>
-#else
-#include "glib/pcre/pcre.h"
-#endif
 
 /* U+20AC EURO SIGN (symbol, currency) */
 #define EURO "\xe2\x82\xac"
diff --git a/meson.build b/meson.build
index a0ee8b774..16f65cf3c 100644
--- a/meson.build
+++ b/meson.build
@@ -1979,45 +1979,39 @@ else
   endif
 endif
 
-if get_option('internal_pcre')
-  pcre = []
-  use_system_pcre = false
-else
-  pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, 
too. FIXME
-  if not pcre.found()
-    if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
-    # MSVC: Search for the PCRE library by the configuration, which corresponds
-    # to the output of CMake builds of PCRE.  Note that debugoptimized
-    # is really a Release build with .PDB files.
-      if vs_crt == 'debug'
-        pcre = cc.find_library('pcred', required : false)
-      else
-        pcre = cc.find_library('pcre', required : false)
-      endif
+pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, too. 
FIXME
+if not pcre.found()
+  if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
+  # MSVC: Search for the PCRE library by the configuration, which corresponds
+  # to the output of CMake builds of PCRE.  Note that debugoptimized
+  # is really a Release build with .PDB files.
+    if vs_crt == 'debug'
+      pcre = cc.find_library('pcred', required : false)
+    else
+      pcre = cc.find_library('pcre', required : false)
     endif
   endif
-  use_system_pcre = pcre.found()
 endif
-glib_conf.set('USE_SYSTEM_PCRE', use_system_pcre)
+
+# Try again with the fallback
+if not pcre.found()
+  pcre = dependency('libpcre', required : true, fallback : ['libpcre', 'pcre_dep'])
+endif
 
 use_pcre_static_flag = false
 
 if host_system == 'windows'
-  if not use_system_pcre
+  pcre_static = cc.links('''#define PCRE_STATIC
+                            #include <pcre.h>
+                            int main() {
+                              void *p = NULL;
+                              pcre_free(p);
+                              return 0;
+                            }''',
+                         dependencies: pcre,
+                         name : 'Windows system PCRE is a static build')
+  if pcre_static
     use_pcre_static_flag = true
-  else
-    pcre_static = cc.links('''#define PCRE_STATIC
-                              #include <pcre.h>
-                              int main() {
-                                void *p = NULL;
-                                pcre_free(p);
-                                return 0;
-                              }''',
-                           dependencies: pcre,
-                           name : 'Windows system PCRE is a static build')
-    if pcre_static
-      use_pcre_static_flag = true
-    endif
   endif
 endif
 
diff --git a/meson_options.txt b/meson_options.txt
index 072765361..6cd7bc90a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -34,11 +34,6 @@ option('libmount',
        value : 'auto',
        description : 'build with libmount support')
 
-option('internal_pcre',
-       type : 'boolean',
-       value : false,
-       description : 'whether to use internal PCRE')
-
 option('man',
        type : 'boolean',
        value : false,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]