Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build as .a, remove make type build path #630

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ defines=standard
cxxstd=c++11
# set cxxstd=any to disable use of -std=...

BUILD=build/make-$(firstword $(CXX))-$(config)-$(defines)-$(cxxstd)
BUILD=build

SOURCES=src/pugixml.cpp $(filter-out tests/fuzz_%,$(wildcard tests/*.cpp))
EXECUTABLE=$(BUILD)/test
LIBRARY=$(BUILD)/libpugixml.a

VERSION=$(shell sed -n 's/.*version \(.*\).*/\1/p' src/pugiconfig.hpp)
RELEASE=$(filter-out scripts/archive.py docs/%.adoc,$(shell git ls-files docs scripts src CMakeLists.txt LICENSE.md readme.txt))
Expand Down Expand Up @@ -50,17 +50,21 @@ endif

OBJECTS=$(SOURCES:%=$(BUILD)/%.o)

all: $(EXECUTABLE)
all: $(LIBRARY)

$(LIBRARY): $(OBJECTS)
@mkdir -p $(dir $@)
$(AR) $(ARFLAGS) $@ $(OBJECTS)

ifeq ($(config),coverage)
test: $(EXECUTABLE)
test: $(LIBRARY)
-@find $(BUILD) -name '*.gcda' -exec rm {} +
./$(EXECUTABLE)
@gcov -b -o $(BUILD)/src/ pugixml.cpp.gcda | sed -e '/./{H;$!d;}' -e 'x;/pugixml.cpp/!d;'
@find . -name '*.gcov' -and -not -name 'pugixml.cpp.gcov' -exec rm {} +
@sed -i -e "s/#####\(.*\)\(\/\/ unreachable.*\)/ 1\1\2/" pugixml.cpp.gcov
else
test: $(EXECUTABLE)
test: $(LIBRARY)
./$(EXECUTABLE)
endif

Expand All @@ -79,9 +83,6 @@ build/pugixml-%: .FORCE | $(RELEASE)
@mkdir -p $(BUILD)
TIMESTAMP=`git show v$(VERSION) -s --format=%ct` && python3 scripts/archive.py $@ pugixml-$(VERSION) $$TIMESTAMP $|

$(EXECUTABLE): $(OBJECTS)
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@

$(BUILD)/fuzz_%: tests/fuzz_%.cpp src/pugixml.cpp
@mkdir -p $(BUILD)
$(CXX) $(CXXFLAGS) -fsanitize=address,fuzzer $^ -o $@
Expand Down
Loading