diff --git a/ccdgen/__main__.py b/ccdgen/__main__.py index fae9819..aea239e 100644 --- a/ccdgen/__main__.py +++ b/ccdgen/__main__.py @@ -167,12 +167,16 @@ def replace_relative_paths(command: str) -> str: Command with relative paths replaced """ + # capture does not include the -I matches = re.findall(r'-I([^\s]+)', command) for m in matches: - relative_path = m # capture does not include the -I + # space in replacement ensures that include paths which are a subset of + # another include path are not replaced in that path + # TODO: regex replace might remove need for this^ + relative_path = m absolute_path = os.path.abspath(relative_path) - command = command.replace(m, absolute_path) + command = command.replace(m + ' ', absolute_path + ' ') return command diff --git a/test/Makefile b/test/Makefile index 715a89f..135ec1b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -2,7 +2,7 @@ BUILD_DIR = build C_SOURCES = src/test.c src/foo/foo.c C_FLAGS = -Wall -Werror -std=c11 -O3 -C_INCLUDES = -Isrc/foo +C_INCLUDES = -Isrc/foo -Isrc/bar CC = gcc EXE = $(BUILD_DIR)/test diff --git a/test/src/bar/bar.h b/test/src/bar/bar.h new file mode 100644 index 0000000..fbc76e3 --- /dev/null +++ b/test/src/bar/bar.h @@ -0,0 +1 @@ +#define BAR \ No newline at end of file diff --git a/test/src/foo/foo.c b/test/src/foo/foo.c index bf91185..e713b96 100644 --- a/test/src/foo/foo.c +++ b/test/src/foo/foo.c @@ -1,4 +1,5 @@ #include +#include "bar.h" void foo() {