]> granicus.if.org Git - libvpx/commitdiff
Build libsimple_encode.a separately
authorangiebird <angiebird@google.com>
Wed, 15 Jul 2020 21:52:02 +0000 (14:52 -0700)
committerJerome Jiang <jianj@google.com>
Mon, 20 Jul 2020 21:45:50 +0000 (14:45 -0700)
BUG=webm:1689

Change-Id: Id920816315c6586cd652ba6cd1b3a76dfc1f12b7
(cherry picked from commit 56345d256ae191e6de042ad82ccf458de3102b8a)

libs.mk
test/simple_encode_test.cc
test/test.mk
vp9/vp9cx.mk

diff --git a/libs.mk b/libs.mk
index d73578be92afa798db9eb5c428aca086be466e56..39f11d4bc8747b207886e4cb6747f88de6ca4388 100644 (file)
--- 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
index eddd1c59b617d17194c935ef30c1d96fc51d6de4..f37a6d0764c2acee61660b59f2cd1a386c0a9b36 100644 (file)
@@ -473,3 +473,8 @@ TEST(SimpleEncode, GetFramePixelCount) {
 
 }  // namespace
 }  // namespace vp9
+
+int main(int argc, char **argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
index e289a78535b4d348192593de6167a008581d31ca..5aecb013f34ab394550add698f8941e89cb766f6 100644 (file)
@@ -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.
index ad774505c60756b17d47accb731dea857401c6a3..666f228827fa34807cd3440488f036a450b84217 100644 (file)
@@ -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