Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

using STL string/container to replace QT code #67

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
libdiff_match_patch.a
objs/
.d/
test_diff_match_patch
46 changes: 46 additions & 0 deletions cpp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
SOURCES := diff_match_patch.cpp diff_match_patch_util.cpp

OBJDIR := objs

OBJECTS := $(addprefix $(OBJDIR)/, $(notdir $(patsubst %.cpp,%.o,$(SOURCES))))
OUT_LIB := libdiff_match_patch.a

CXXFLAGS := -std=c++17 \
-g -O0

TEST_SRC := diff_match_patch_test.cpp
TEST_OBJECTS := $(addprefix $(OBJDIR)/, $(notdir $(patsubst %.cpp,%.o,$(TEST_SRC))))
TEST_EXEC := test_diff_match_patch

DEPDIR := .d
DEPFLAGS = -MT $@ -MMD -MP -MF$(DEPDIR)/$*.Td

POSTCOMPILE = @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@

ALL_SRC := $(SOURCES) $(TEST_SRC)

.PHONY: all clean init

all: init $(OUT_LIB) $(TEST_EXEC)

$(OBJDIR)/%.o : %.cpp %.h $(DEPDIR)/%.d
$(CXX) $(DEPFLAGS) $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -o "$@" "$<"
$(POSTCOMPILE)

$(OUT_LIB) : $(OBJECTS)
$(AR) -rv "$@" $(OBJECTS)

$(TEST_EXEC) : $(TEST_OBJECTS) $(OUT_LIB)
$(CXX) $(LDFLAGS) -o "$@" "$<" $(OUT_LIB)

init:
mkdir -p $(OBJDIR) $(DEPDIR)

clean:
$(RM) -r $(OUT_LIB) $(OBJDIR) $(TEST_EXEC) $(DEPDIR)

$(DEPDIR)/%.d: ;
.PRECIOUS: $(DEPDIR)/%.d


include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(ALL_SRC))))
Loading