From 05e0cd7c4f21f10ee62010f80d20486e9b16b7af Mon Sep 17 00:00:00 2001 From: angiebird Date: Wed, 15 Jul 2020 14:52:02 -0700 Subject: [PATCH] Build libsimple_encode.a separately BUG=webm:1689 Change-Id: Id920816315c6586cd652ba6cd1b3a76dfc1f12b7 (cherry picked from commit 56345d256ae191e6de042ad82ccf458de3102b8a) --- libs.mk | 59 ++++++++++++++++++++++++++++++++++---- test/simple_encode_test.cc | 5 ++++ test/test.mk | 5 +++- vp9/vp9cx.mk | 3 -- 4 files changed, 63 insertions(+), 9 deletions(-) diff --git a/libs.mk b/libs.mk index d73578be9..39f11d4bc 100644 --- a/libs.mk +++ b/libs.mk @@ -173,7 +173,18 @@ INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a endif +ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_RATE_CTRL),yesyes) + SIMPLE_ENCODE_SRCS := $(call enabled,CODEC_SRCS) + SIMPLE_ENCODE_SRCS += $(VP9_PREFIX)simple_encode.cc + SIMPLE_ENCODE_SRCS += $(VP9_PREFIX)simple_encode.h + SIMPLE_ENCODE_SRCS += ivfenc.h + SIMPLE_ENCODE_SRCS += ivfenc.c + INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)simple_encode.cc + INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)simple_encode.h +endif + CODEC_SRCS=$(call enabled,CODEC_SRCS) + INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS) INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS) @@ -263,8 +274,8 @@ PROJECTS-yes += vp9rc.$(VCPROJ_SFX) vp9rc.$(VCPROJ_SFX): vpx_config.asm vp9rc.$(VCPROJ_SFX): $(RTCD) -endif -else +endif # ifeq ($(CONFIG_MSVS),yes) +else # ifeq ($(CONFIG_EXTERNAL_BUILD),yes) LIBVPX_OBJS=$(call objs, $(filter-out $(ASM_INCLUDES), $(CODEC_SRCS))) OBJS-yes += $(LIBVPX_OBJS) LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a @@ -377,8 +388,15 @@ ifeq ($(CONFIG_VP9_ENCODER),yes) $(BUILD_PFX)libvp9rc_g.a: $(RC_RTC_OBJS) endif +ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_RATE_CTRL),yesyes) + SIMPLE_ENCODE_OBJS=$(call objs,$(SIMPLE_ENCODE_SRCS)) + OBJS-yes += $(SIMPLE_ENCODE_OBJS) + LIBS-yes += $(BUILD_PFX)libsimple_encode.a $(BUILD_PFX)libsimple_encode_g.a + $(BUILD_PFX)libsimple_encode_g.a: $(SIMPLE_ENCODE_OBJS) endif +endif # ifeq ($(CONFIG_EXTERNAL_BUILD),yes) + libvpx.ver: $(call enabled,CODEC_EXPORTS) @echo " [CREATE] $@" $(qexec)echo "{ global:" > $@ @@ -434,20 +452,39 @@ ifeq ($(CONFIG_UNIT_TESTS),yes) LIBVPX_TEST_DATA_PATH ?= . include $(SRC_PATH_BARE)/test/test.mk -LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS)) + +# addprefix_clean behaves like addprefix if the target doesn't start with "../" +# However, if the target starts with "../", instead of adding prefix, +# it will remove "../". +# Using addprefix_clean, we can avoid two different targets building the +# same file, i.e. +# test/../ivfenc.c.d: ivfenc.o +# ivfenc.c.d: ivfenc.o +# Note that the other way to solve this problem is using "realpath". +# The "realpath" is supported by make 3.81 or later. +addprefix_clean=$(patsubst $(1)../%,%,$(addprefix $(1), $(2))) +LIBVPX_TEST_SRCS=$(call addprefix_clean,test/,$(call enabled,LIBVPX_TEST_SRCS)) + LIBVPX_TEST_BIN=./test_libvpx$(EXE_SFX) LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\ $(call enabled,LIBVPX_TEST_DATA)) libvpx_test_data_url=https://storage.googleapis.com/downloads.webmproject.org/test_data/libvpx/$(1) TEST_INTRA_PRED_SPEED_BIN=./test_intra_pred_speed$(EXE_SFX) -TEST_INTRA_PRED_SPEED_SRCS=$(addprefix test/,$(call enabled,TEST_INTRA_PRED_SPEED_SRCS)) +TEST_INTRA_PRED_SPEED_SRCS=$(call addprefix_clean,test/,\ + $(call enabled,TEST_INTRA_PRED_SPEED_SRCS)) TEST_INTRA_PRED_SPEED_OBJS := $(sort $(call objs,$(TEST_INTRA_PRED_SPEED_SRCS))) RC_INTERFACE_TEST_BIN=./test_rc_interface$(EXE_SFX) -RC_INTERFACE_TEST_SRCS=$(addprefix test/,$(call enabled,RC_INTERFACE_TEST_SRCS)) +RC_INTERFACE_TEST_SRCS=$(call addprefix_clean,test/,\ + $(call enabled,RC_INTERFACE_TEST_SRCS)) RC_INTERFACE_TEST_OBJS := $(sort $(call objs,$(RC_INTERFACE_TEST_SRCS))) +SIMPLE_ENCODE_TEST_BIN=./test_simple_encode$(EXE_SFX) +SIMPLE_ENCODE_TEST_SRCS=$(call addprefix_clean,test/,\ + $(call enabled,SIMPLE_ENCODE_TEST_SRCS)) +SIMPLE_ENCODE_TEST_OBJS := $(sort $(call objs,$(SIMPLE_ENCODE_TEST_SRCS))) + libvpx_test_srcs.txt: @echo " [CREATE] $@" @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@ @@ -609,6 +646,18 @@ $(eval $(call linkerxx_template,$(RC_INTERFACE_TEST_BIN), \ -L. -lvpx -lgtest -lvp9rc $(extralibs) -lm)) endif # RC_INTERFACE_TEST +ifneq ($(strip $(SIMPLE_ENCODE_TEST_OBJS)),) +$(SIMPLE_ENCODE_TEST_OBJS) $(SIMPLE_ENCODE_TEST_OBJS:.o=.d): \ + CXXFLAGS += $(GTEST_INCLUDES) +OBJS-yes += $(SIMPLE_ENCODE_TEST_OBJS) +BINS-yes += $(SIMPLE_ENCODE_TEST_BIN) + +$(SIMPLE_ENCODE_TEST_BIN): $(TEST_LIBS) libsimple_encode.a +$(eval $(call linkerxx_template,$(SIMPLE_ENCODE_TEST_BIN), \ + $(SIMPLE_ENCODE_TEST_OBJS) \ + -L. -lsimple_encode -lvpx -lgtest $(extralibs) -lm)) +endif # SIMPLE_ENCODE_TEST + endif # CONFIG_UNIT_TESTS # Install test sources only if codec source is included diff --git a/test/simple_encode_test.cc b/test/simple_encode_test.cc index eddd1c59b..f37a6d076 100644 --- a/test/simple_encode_test.cc +++ b/test/simple_encode_test.cc @@ -473,3 +473,8 @@ TEST(SimpleEncode, GetFramePixelCount) { } // namespace } // namespace vp9 + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/test.mk b/test/test.mk index e289a7853..5aecb013f 100644 --- a/test/test.mk +++ b/test/test.mk @@ -58,7 +58,6 @@ LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += svc_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += svc_test.h LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += svc_end_to_end_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += timestamp_test.cc -LIBVPX_TEST_SRCS-$(CONFIG_RATE_CTRL) += simple_encode_test.cc LIBVPX_TEST_SRCS-yes += decode_test_driver.cc LIBVPX_TEST_SRCS-yes += decode_test_driver.h @@ -193,6 +192,10 @@ LIBVPX_TEST_SRCS-yes += vp9_denoiser_test.cc endif LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_arf_freq_test.cc +ifeq ($(CONFIG_VP9_ENCODER),yes) +SIMPLE_ENCODE_TEST_SRCS-$(CONFIG_RATE_CTRL) := simple_encode_test.cc +endif + endif # VP9 ## Multi-codec / unconditional whitebox tests. diff --git a/vp9/vp9cx.mk b/vp9/vp9cx.mk index ad774505c..666f22882 100644 --- a/vp9/vp9cx.mk +++ b/vp9/vp9cx.mk @@ -18,9 +18,6 @@ VP9_CX_SRCS_REMOVE-no += $(VP9_COMMON_SRCS_REMOVE-no) VP9_CX_SRCS-yes += vp9_cx_iface.c VP9_CX_SRCS-yes += vp9_cx_iface.h -VP9_CX_SRCS-$(CONFIG_RATE_CTRL) += simple_encode.cc -VP9_CX_SRCS-$(CONFIG_RATE_CTRL) += simple_encode.h - VP9_CX_SRCS-yes += encoder/vp9_bitstream.c VP9_CX_SRCS-yes += encoder/vp9_context_tree.c VP9_CX_SRCS-yes += encoder/vp9_context_tree.h -- 2.40.0