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]: allow single src file to build multiple independent debian p… #349

Merged
merged 2 commits into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 2 additions & 4 deletions platform/broadcom/platform-modules-dell.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ DELL_Z9100_PLATFORM_MODULE = platform-modules-z9100_$(DELL_Z9100_PLATFORM_MODULE
$(DELL_Z9100_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-dell
$(DELL_Z9100_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
$(DELL_Z9100_PLATFORM_MODULE)_PLATFORM = x86_64-dell_z9100_c2538-r0
SONIC_DPKG_DEBS += $(DELL_Z9100_PLATFORM_MODULE)

DELL_S6100_PLATFORM_MODULE = platform-modules-s6100_$(DELL_S6100_PLATFORM_MODULE_VERSION)_amd64.deb
$(DELL_S6100_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-dell
$(DELL_S6100_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
$(DELL_S6100_PLATFORM_MODULE)_PLATFORM = x86_64-dell_s6100_c2538-r0

SONIC_DPKG_DEBS += $(DELL_Z9100_PLATFORM_MODULE) $(DELL_S6100_PLATFORM_MODULE)
$(eval $(call add_peer_package,$(DELL_Z9100_PLATFORM_MODULE),$(DELL_S6100_PLATFORM_MODULE)))
8 changes: 8 additions & 0 deletions rules/functions
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ $(2)_SRC_PATH = $($(1)_SRC_PATH)
SONIC_DERIVED_DEBS += $(2)
endef

# call:
# add_peer_package some_deb.deb, some_peer_deb
define add_peer_package
$(2)_MAIN_DEB = $(1)
$(1)_PEER_DEBS += $(2)
SONIC_PEER_DEBS += $(2)
endef

###############################################################################
## Utility functions
###############################################################################
Expand Down
25 changes: 22 additions & 3 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_ONLINE_FILES)) : $(DEBS_PATH)/% : .platform
$(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) : $(DEBS_PATH)/% : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS)))
$(HEADER)
# remove target to force rebuild
rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS))
rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS) $($*_PEER_DEBS))
# build project and take package
make DEST=$(shell pwd)/$(DEBS_PATH) -C $($*_SRC_PATH) $(shell pwd)/$(DEBS_PATH)/$* $(LOG)
$(FOOTER)
Expand All @@ -159,7 +159,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a
[ ! -f ./autogen.sh ] || ./autogen.sh $(LOG)
dpkg-buildpackage -rfakeroot -b -us -uc $(LOG)
popd $(LOG)
mv $(addprefix $($*_SRC_PATH)/../, $* $($*_DERIVED_DEBS)) $(DEBS_PATH) $(LOG)
mv $(addprefix $($*_SRC_PATH)/../, $* $($*_DERIVED_DEBS) $($*_PEER_DEBS)) $(DEBS_PATH) $(LOG)
$(FOOTER)

# Build project with python setup.py --command-packages=stdeb.command
Expand Down Expand Up @@ -190,6 +190,19 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DERIVED_DEBS)) : $(DEBS_PATH)/% : .platform $
[ -f $@ ] && touch $@
$(FOOTER)

# Rules for peer debian packages
# All noise takes place in main deb recipe, so we are just telling that
# we depend on it and move our deb to other targets
# Add new dev package:
# $(eval $(call add_derived_package,$(ORIGINAL_DEB),derived_deb_file.deb))
$(addprefix $(DEBS_PATH)/, $(SONIC_PEER_DEBS)) : $(DEBS_PATH)/% : .platform $$(addprefix $(DEBS_PATH)/,$$($$*_MAIN_DEB))
$(HEADER)
# All noise takes place in main deb recipe, so we are just telling that
# we depend on it
# Put newer timestamp
[ -f $@ ] && touch $@
$(FOOTER)

# Targets for installing debian packages prior to build one that depends on them
SONIC_INSTALL_TARGETS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \
$(SONIC_ONLINE_DEBS) \
Expand Down Expand Up @@ -351,12 +364,18 @@ SONIC_CLEAN_DEBS = $(addsuffix -clean,$(addprefix $(DEBS_PATH)/, \
$(SONIC_MAKE_DEBS) \
$(SONIC_DPKG_DEBS) \
$(SONIC_PYTHON_STDEB_DEBS) \
$(SONIC_DERIVED_DEBS)))
$(SONIC_DERIVED_DEBS) \
$(SONIC_PEER_DEBS)))
$(SONIC_CLEAN_DEBS) : $(DEBS_PATH)/%-clean : .platform $$(addsuffix -clean,$$(addprefix $(DEBS_PATH)/,$$($$*_DERIVED_FROM)))
@# remove derived targets if main one is removed, because we treat them
@# as part of one package
@rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS))

$(SONIC_CLEAN_DEBS) : $(DEBS_PATH)/%-clean : .platform $$(addsuffix -clean,$$(addprefix $(DEBS_PATH)/,$$($$*_MAIN_DEB)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for separate pattern rule
Just extend rule above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@# remove derived targets if main one is removed, because we treat them
@# as part of one package
@rm -f $(addprefix $(DEBS_PATH)/, $* $($*_PEER_DEBS))

SONIC_CLEAN_TARGETS += $(addsuffix -clean,$(addprefix $(TARGET_PATH)/, \
$(SONIC_DOCKER_IMAGES) \
$(SONIC_SIMPLE_DOCKER_IMAGES)))
Expand Down