Skip to content

Commit

Permalink
build: Exclude RabbitMQ when BUILD_REMOTE is off
Browse files Browse the repository at this point in the history
When the build option BUILD_REMOTE is off, the RabbitMQ should not be
compiled and included in the generated files.
Makefile modification:
- Extract the steps of submodule initialization and update
- Combine and create the submodule related variables

Close DLTcollab#169.
  • Loading branch information
marktwtn committed Jul 17, 2019
1 parent a59c65a commit 0f6e37a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ LIBS := $(addprefix $(OUT)/, $(LIBS))
JARS := dcurljni-$(VERSION).jar
JARS := $(addprefix $(OUT)/, $(JARS))

PREQ := config $(TESTS) $(LIBS)
PREQ := $(SUBS) config $(TESTS) $(LIBS)
ifeq ("$(BUILD_JNI)","1")
PREQ += $(JARS)
endif
Expand Down Expand Up @@ -162,19 +162,19 @@ endif

OBJS := $(addprefix $(OUT)/, $(OBJS))

$(OUT)/test-%.o: tests/test-%.c $(LIBTUV_PATH)/include
$(OUT)/test-%.o: tests/test-%.c
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) $(LIBTUV_INCLUDE) -c -MMD -MF $@.d $<
$(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) $(SUB_INCLUDE) -c -MMD -MF $@.d $<

$(OUT)/%.o: $(SRC)/%.c $(LIBTUV_PATH)/include $(LIBRABBITMQ_PATH)/build/include
$(OUT)/%.o: $(SRC)/%.c $(SUB_OBJS)
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) $(LIBTUV_INCLUDE) $(LIBRABBITMQ_INCLUDE) -c -MMD -MF $@.d $<
$(Q)$(CC) -o $@ $(CFLAGS) $(SUB_INCLUDE) -c -MMD -MF $@.d $<

$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS)
$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(SUB_OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -o $@ $^ $(LDFLAGS)

$(OUT)/libdcurl.so: $(OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS)
$(OUT)/libdcurl.so: $(OBJS) $(SUB_OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -shared -o $@ $^ $(LDFLAGS)

Expand Down
2 changes: 1 addition & 1 deletion mk/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ NO_COLOR = \e[0m
$(OUT)/test-%.done: $(OUT)/test-%
$(Q)$(PRINTF) "*** Validating $< ***\n"
$(Q)./$< && $(PRINTF) "\t$(PASS_COLOR)[ Verified ]$(NO_COLOR)\n"
check: $(addsuffix .done, $(TESTS))
check: $(SUBS) $(addsuffix .done, $(TESTS))

config: $(OUT)/config-timestamp

Expand Down
26 changes: 21 additions & 5 deletions mk/submodule.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LIBTUV_BOARD := $(BOARD)
# PIC (Position-Independent-Code) object file
LIBTUV_OBJS := $(LIBTUV_PATH)/build/$(LIBTUV_PLATFORM)/release/lib/libtuv.o

$(LIBTUV_PATH)/include:
$(LIBTUV_PATH)/.git:
git submodule update --init $(LIBTUV_PATH)

$(LIBTUV_OBJS):
Expand All @@ -36,9 +36,11 @@ ifeq ($(UNAME_S),darwin)
LDFLAGS += -L$(OPENSSL_PATH)/lib -lcrypto -lssl
endif

$(LIBRABBITMQ_PATH)/build/include:
$(LIBRABBITMQ_PATH)/.git:
git submodule update --init $(LIBRABBITMQ_PATH)
mkdir $(LIBRABBITMQ_PATH)/build
mkdir -p $(LIBRABBITMQ_PATH)/build

$(LIBRABBITMQ_OBJS):
ifeq ($(UNAME_S),darwin)
# macOS
cd $(LIBRABBITMQ_PATH)/build && \
Expand All @@ -49,7 +51,21 @@ else
cmake -DCMAKE_INSTALL_PREFIX=. .. && \
cmake --build . --target install
endif

$(LIBRABBITMQ_OBJS):
cd $(LIBRABBITMQ_PATH)/build && \
cmake --build .

# Submodules
SUBS := $(LIBTUV_PATH)/.git
ifeq ($(BUILD_REMOTE),1)
SUBS += $(LIBRABBITMQ_PATH)/.git
endif
# Submodule related objects
SUB_OBJS := $(LIBTUV_OBJS)
ifeq ($(BUILD_REMOTE),1)
SUB_OBJS += $(LIBRABBITMQ_OBJS)
endif
# Submodule C flags for including header files
SUB_INCLUDE := $(LIBTUV_INCLUDE)
ifeq ($(BUILD_REMOTE),1)
SUB_INCLUDE += $(LIBRABBITMQ_INCLUDE)
endif

0 comments on commit 0f6e37a

Please sign in to comment.