Skip to content

Commit

Permalink
Fix gh #154 : Fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kanjoe24 committed Dec 16, 2024
1 parent 6baa470 commit f89d8dd
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ TOP_DIR ?= $(UT_CORE_DIR)
BIN_DIR ?= $(TOP_DIR)/build/bin
LIB_DIR ?= $(TOP_DIR)/build/$(TARGET)/lib
BUILD_DIR ?= $(TOP_DIR)/build/$(TARGET)/obj
LIBRARY_DIR = $(LIB_DIR)

# Non-Moveable Directories
FRAMEWORK_DIR = $(UT_CORE_DIR)/framework
Expand Down Expand Up @@ -76,6 +75,16 @@ else # GTEST case
SRCS := $(shell find $(SRC_DIRS) -type f \( -name '*.cpp' -o -name '*.c' \) | grep -v "$(EXCLUDE_DIRS)")
endif

# Check if BUILD_WEAK_STUBS_SRC is defined
ifdef BUILD_WEAK_STUBS_SRC

# Define variables for the static library and its source files
WEAK_STUBS_LIB := $(LIB_DIR)/libweak_stubs_libs.a
WEAK_STUBS_SRC := $(wildcard $(BUILD_WEAK_STUBS_SRC)/*.c)

XLDFLAGS := -L$(LIB_DIR) -lweak_stubs_libs $(XLDFLAGS)
endif

VARIANT_FILE := .variant

ifeq ($(TARGET),arm)
Expand Down Expand Up @@ -119,7 +128,7 @@ VPATH += $(UT_CORE_DIR) $(TOP_DIR)
# Default target
.PHONY: clean list arm linux framework test createdirs all printenv

all: framework $(OBJS) $(if $(LIBRARY_NAME),$(LIBRARY_DIR)/$(LIBRARY_NAME)$(LIBRARY_EXTENSION))
all: framework $(OBJS) $(if $(BUILD_WEAK_STUBS_SRC),$(WEAK_STUBS_LIB))

# Build framework
# Recursive make is needed as src files are not available during the first iteration
Expand All @@ -140,7 +149,7 @@ download_and_build:
@${MAKE} -C $(UT_CONTROL) TARGET=${TARGET}

# Build the test binary
test: $(OBJS) createdirs $(if $(LIBRARY_NAME),$(LIBRARY_DIR)/$(LIBRARY_NAME)$(LIBRARY_EXTENSION))
test: $(OBJS) createdirs $(if $(BUILD_WEAK_STUBS_SRC),$(WEAK_STUBS_LIB))
@${ECHOE} ${GREEN}Linking $@ $(BUILD_DIR)/$(TARGET_EXEC)${NC}
@$(COMPILER) $(OBJS) -o $(BUILD_DIR)/$(TARGET_EXEC) $(XCFLAGS) $(XLDFLAGS)
@cp $(BUILD_DIR)/$(TARGET_EXEC) $(BIN_DIR)/
Expand Down Expand Up @@ -178,21 +187,10 @@ checkvariantchange:
fi \
fi

# Create the library (shared or static)
$(LIBRARY_DIR)/$(LIBRARY_NAME)$(LIBRARY_EXTENSION): $(LIBRARY_OBJS) createdirs
@if [ "${LIBRARY_TYPE}" = "shared" ]; then \
${ECHOE} ${GREEN}Building shared library $(LIBRARY_NAME)$(LIBRARY_EXTENSION)${NC}; \
$(CC) $(LIBRARY_OBJS) $(LIBRARY_FLAGS) -o $@; \
else \
${ECHOE} ${GREEN}Building static library $(LIBRARY_NAME)$(LIBRARY_EXTENSION)${NC}; \
$(AR) rcs $@ $(LIBRARY_OBJS); \
fi

# Create object files for the library
$(LIBRARY_DIR)/%.o: $(SRC_DIR)/%.c
@${ECHOE} ${GREEN}Building [${YELLOW}$<${GREEN}] for library${NC}
@$(MKDIR_P) $(dir $@)
@$(CC) $(XCFLAGS) $(CFLAGS) -I$(LIBRARY_INC) -c $< -o $@
# Create the library weak_stubs_libs
$(WEAK_STUBS_LIB): $(WEAK_STUBS_SRC)
@${ECHOE} ${GREEN}Building weak_stubs_libs...${NC}
$(AR) rcs $@ $^

arm:
make TARGET=arm
Expand Down Expand Up @@ -263,14 +261,6 @@ list:
@${ECHOE}
@${ECHOE} ${YELLOW}INC_FLAGS:${NC} $(INC_FLAGS)
@${ECHOE}
@${ECHOE} ${YELLOW}LIBRARY_DIR:${NC} $(LIBRARY_DIR)
@${ECHOE}
@${ECHOE} ${YELLOW}LIBRARY_NAME:${NC} $(LIBRARY_NAME)
@${ECHOE}
@${ECHOE} ${YELLOW}LIBRARY_EXTENSION:${NC} $(LIBRARY_EXTENSION)
@${ECHOE}
@${ECHOE} ${YELLOW}LIBRARY_TYPE:${NC} $(LIBRARY_TYPE)
@${ECHOE}
@${ECHOE} ${YELLOW}DEPS:${NC} $(DEPS)
@${ECHOE}
@${ECHOE} --------- ut_control ----------------
Expand Down

0 comments on commit f89d8dd

Please sign in to comment.