mirror of
https://github.com/arkorty/ExprEvalplusplus.git
synced 2026-03-18 00:57:18 +00:00
Update Makefile for build improvements and testing
Commit details: - Set optimization level to O3 and include pedantic warnings in CXXFLAGS. - Introduce separate build and source directories for better project organization. - Add a target to run tests with the ENABLE_TESTS macro. - Improve the 'all' target to create the build directory before building the executable. - Introduce a 'rebuild' target for cleaning and rebuilding the project. Changes made in Makefile: - Update CXXFLAGS with -O3 and -pedantic. - Introduce BUILD_DIR and SRC_DIR variables for better organization. - Modifie SOURCE to point to the source file within the source directory. - Update EXECUTABLE to exclude the file extension. - Update 'all' target to create the build directory. - Add 'test' target to run tests with the ENABLE_TESTS macro. - Add 'rebuild' target for cleaning and rebuilding the project.
This commit is contained in:
36
Makefile
36
Makefile
@@ -1,18 +1,30 @@
|
|||||||
CXX = clang++
|
CXX = clang++
|
||||||
CXXFLAGS = -std=c++17 -Wall -Wextra
|
CXXFLAGS = -O3 -std=c++17 -Wall -Wextra -pedantic
|
||||||
SOURCE = main.cxx
|
BUILD_DIR = build
|
||||||
EXECUTABLE = ast.out
|
SRC_DIR = src
|
||||||
|
SOURCE = ast.cxx
|
||||||
|
EXECUTABLE = ast
|
||||||
|
|
||||||
# Build target
|
all: $(BUILD_DIR) $(BUILD_DIR)/$(EXECUTABLE)
|
||||||
all: $(EXECUTABLE)
|
|
||||||
|
|
||||||
# Rule to build the executable
|
$(BUILD_DIR):
|
||||||
$(EXECUTABLE): $(SOURCE)
|
mkdir -p $@
|
||||||
@$(CXX) $(CXXFLAGS) -o $@ $<
|
|
||||||
|
|
||||||
run: $(EXECUTABLE)
|
$(BUILD_DIR)/$(EXECUTABLE): $(SRC_DIR)/$(SOURCE) $(BUILD_DIR)
|
||||||
@./$(EXECUTABLE)
|
$(CXX) $(CXXFLAGS) -o $@ $<
|
||||||
|
|
||||||
# Clean up generated files
|
.PHONY: run
|
||||||
|
run: $(BUILD_DIR)/$(EXECUTABLE)
|
||||||
|
./$<
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: CXXFLAGS += -DENABLE_TESTS
|
||||||
|
test: $(BUILD_DIR)/$(EXECUTABLE)
|
||||||
|
./$< --run-test
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
@rm -f $(EXECUTABLE)
|
rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
|
.PHONY: rebuild
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
Reference in New Issue
Block a user