Skip to content

Commit

Permalink
common: fallback to C GNU regex for compilers with limited std::regex…
Browse files Browse the repository at this point in the history
… support

This change replaces fallback to boost::regex with fallback to GNU C
regex if the compiler lacks complete support for std::regex.
See recent commit for the same.
  • Loading branch information
AlexBlago authored and ogalbxela committed Nov 8, 2023
1 parent 9954a58 commit fdc4ed9
Show file tree
Hide file tree
Showing 15 changed files with 1,411 additions and 116 deletions.
2 changes: 1 addition & 1 deletion adb_parser/adb_condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <stdlib.h>
#include "adb_condition.h"

#include "common/regex.h"
#include "common/tools_regex.h"

AdbCondition::AdbCondition() {}

Expand Down
2 changes: 1 addition & 1 deletion adb_parser/adb_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include <list>

#include "common/algorithm.h"
#include "common/regex.h"
#include "common/tools_regex.h"

// Constants
const char AdbInstance::path_seperator{'.'};
Expand Down
2 changes: 1 addition & 1 deletion adb_parser/adb_xml_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include "common/algorithm.h"
#include "common/filesystem.h"
#include "common/regex.h"
#include "common/tools_regex.h"

bool AdbParser::allowMultipleExceptions = false;
const string AdbParser::TAG_NODES_DEFINITION = "NodesDefinition";
Expand Down
124 changes: 123 additions & 1 deletion common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ cc_binary(
defines = ["USE_BOOST"],
deps = [
":filesystem",
"@com_google_googletest//:gtest_main",
"@boost//:filesystem",
"@com_google_googletest//:gtest_main",
],
)

Expand Down Expand Up @@ -158,3 +158,125 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)

genrule(
name = "gen-config-h",
outs = ["config.h"],
cmd = "touch $@",
)

cc_library(
name = "config-h",
hdrs = [
":gen-config-h",
],
include_prefix = ".",
)

cc_library(
name = "regex",
srcs = [
"tools_regex.cpp",
],
hdrs = [
"tools_regex.h",
],
copts = [
"-Wall",
"-Wextra",
"-Wpedantic",
],
deps = [
":config-h",
],
)

cc_library(
name = "stdlib-regex",
srcs = [
"tools_regex.cpp",
],
hdrs = [
"tools_regex.h",
],
copts = [
"-Wall",
"-Wextra",
"-Wpedantic",
],
defines = ["USE_STDLIB_REGEX"],
deps = [
":config-h",
],
)

cc_library(
name = "boost-regex",
srcs = [
"tools_regex.cpp",
],
hdrs = [
"tools_regex.h",
],
copts = [
"-Wall",
"-Wextra",
"-Wpedantic",
],
defines = ["USE_BOOST_REGEX"],
deps = [
":config-h",
"@boost//:regex",
],
)

cc_test(
name = "regex-test",
size = "small",
srcs = [
"tools_regex-test.cpp",
],
copts = [
"-Wall",
"-Wextra",
"-Wpedantic",
],
deps = [
":regex",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "stdlib-regex-test",
size = "small",
srcs = [
"tools_regex-test.cpp",
],
copts = [
"-Wall",
"-Wextra",
"-Wpedantic",
],
deps = [
":stdlib-regex",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "boost-regex-test",
size = "small",
srcs = [
"tools_regex-test.cpp",
],
copts = [
"-Wall",
"-Wextra",
"-Wpedantic",
],
deps = [
":boost-regex",
"@com_google_googletest//:gtest_main",
],
)
10 changes: 5 additions & 5 deletions common/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#--
# Copyright (c) 2004-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# This software is available to you under a choice of one of two
# licenses. You may choose to be licensed under the terms of the GNU
Expand Down Expand Up @@ -28,14 +27,15 @@
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#--

# Makefile.am -- Process this file with automake to produce Makefile.in

noinst_HEADERS = compatibility.h bit_slice.h tools_utils.h tools_utils.h tools_version.h filesystem.h regex.h algorithm.h
noinst_HEADERS = compatibility.h bit_slice.h tools_utils.h tools_utils.h tools_version.h filesystem.h tools_regex.h algorithm.h

noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = filesystem.cpp
libcommon_la_SOURCES = \
filesystem.cpp \
tools_regex.cpp

commonincludedir = $(includedir)/mstflint/common/
commoninclude_HEADERS = compatibility.h
Expand Down
69 changes: 0 additions & 69 deletions common/regex.h

This file was deleted.

Loading

0 comments on commit fdc4ed9

Please sign in to comment.