shithub: openh264

Download patch

ref: 0da712380b2474fcb8dcbde5307ff916ce2daace
parent: 16099cfd32f2d1a236d94545f6fd1feb17eeb863
parent: b38976944a479422b8f6135b07565bdc3073b667
author: Ethan Hugg <[email protected]>
date: Fri Jan 17 07:14:22 EST 2014

Merge pull request #155 from mstorsjo/update-gtest-makefile

Regenerate gtest-targets.mk using mktargets.sh/py

--- a/Makefile
+++ b/Makefile
@@ -76,6 +76,9 @@
     -Icodec/encoder/core/inc \
     -Icodec/encoder/plus/inc
 
+GTEST_INCLUDES = \
+    -Igtest
+
 H264DEC_INCLUDES = $(DECODER_INCLUDES) -Icodec/console/dec/inc
 H264DEC_LDFLAGS = -L. $(call LINK_LIB, decoder) $(call LINK_LIB, common)
 H264DEC_DEPS = $(LIBPREFIX)decoder.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX)
--- a/build/gtest-targets.mk
+++ b/build/gtest-targets.mk
@@ -1,19 +1,16 @@
 GTEST_PREFIX=GTEST
 GTEST_SRCDIR=gtest
 GTEST_CPP_SRCS=\
-	$(GTEST_SRCDIR)/src/gtest-all.cc
+	$(GTEST_SRCDIR)/./src/gtest-all.cc\
 
 GTEST_OBJS += $(GTEST_CPP_SRCS:.cc=.o)
-
 OBJS += $(GTEST_OBJS)
-GTEST_INCLUDES += -Igtest
+$(GTEST_SRCDIR)/%.o: $(GTEST_SRCDIR)/%.cc
+	$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(GTEST_CFLAGS) $(GTEST_INCLUDES) -c $(CXX_O) $<
 
-$(GTEST_SRCDIR)/src/gtest-all.o: $(GTEST_SRCDIR)/src/gtest-all.cc
-	$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(GTEST_CFLAGS) $(GTEST_INCLUDES) -c -o $@ $<
-
 $(LIBPREFIX)gtest.$(LIBSUFFIX): $(GTEST_OBJS)
 	rm -f $(LIBPREFIX)gtest.$(LIBSUFFIX)
-	$(AR) cr $@ $(GTEST_OBJS)
+	$(AR) $(AR_OPTS) $(GTEST_OBJS)
 
 libraries: $(LIBPREFIX)gtest.$(LIBSUFFIX)
 LIBRARIES += $(LIBPREFIX)gtest.$(LIBSUFFIX)
--- a/build/mktargets.py
+++ b/build/mktargets.py
@@ -8,16 +8,22 @@
 parser.add_argument("--library", dest="library", help="Make a library")
 parser.add_argument("--binary", dest="binary", help="Make a binary")
 parser.add_argument("--exclude", dest="exclude", help="Exclude file", action="append")
+parser.add_argument("--include", dest="include", help="Include file", action="append")
+parser.add_argument("--out", dest="out", help="Output file")
+parser.add_argument("--cpp-suffix", dest="cpp_suffix", help="C++ file suffix")
 PREFIX=None
 LIBRARY=None
 BINARY=None
 EXCLUDE=[]
+INCLUDE=[]
+OUTFILE="targets.mk"
+CPP_SUFFIX=".cpp"
 
 def make_o(x):
     return os.path.splitext(x)[0] + ".o"
 
 def write_cpp_rule_pattern(f):
-    src = "$(%s_SRCDIR)/%%.cpp"%(PREFIX)
+    src = "$(%s_SRCDIR)/%%%s"%(PREFIX, CPP_SUFFIX)
     dst = "$(%s_SRCDIR)/%%.o"%(PREFIX)
 
     f.write("%s: %s\n"%(dst, src))
@@ -39,8 +45,8 @@
     print EXCLUDE
     for dir in os.walk("."):
         for file in dir[2]:
-            if not file in EXCLUDE:
-                if os.path.splitext(file)[1] == '.cpp':
+            if (len(INCLUDE) == 0 and not file in EXCLUDE) or file in INCLUDE:
+                if os.path.splitext(file)[1] == CPP_SUFFIX:
                     cpp_files.append(os.path.join(dir[0], file))
                 if os.path.splitext(file)[1] == '.asm':
                     asm_files.append(os.path.join(dir[0], file))
@@ -59,11 +65,17 @@
 
 if args.exclude is not None:
     EXCLUDE = args.exclude
+if args.include is not None:
+    INCLUDE = args.include
+if args.out is not None:
+    OUTFILE = args.out
+if args.cpp_suffix is not None:
+    CPP_SUFFIX = args.cpp_suffix
 (cpp, asm) = find_sources()
 
 
 
-f = open("targets.mk", "w")
+f = open(OUTFILE, "w")
 f.write("%s_PREFIX=%s\n"%(PREFIX, PREFIX))
 f.write("%s_SRCDIR=%s\n"%(PREFIX, args.directory))
 
@@ -71,21 +83,23 @@
 for c in cpp:
     f.write("\t$(%s_SRCDIR)/%s\\\n"%(PREFIX, c))
 f.write("\n")
-f.write("%s_OBJS += $(%s_CPP_SRCS:.cpp=.o)\n"%(PREFIX, PREFIX))
+f.write("%s_OBJS += $(%s_CPP_SRCS:%s=.o)\n"%(PREFIX, PREFIX, CPP_SUFFIX))
 
-f.write("ifeq ($(USE_ASM), Yes)\n");
-f.write("%s_ASM_SRCS=\\\n"%(PREFIX))
-for c in asm:
-    f.write("\t$(%s_SRCDIR)/%s\\\n"%(PREFIX, c))
-f.write("\n")
-f.write("%s_OBJS += $(%s_ASM_SRCS:.asm=.o)\n"%(PREFIX, PREFIX))
-f.write("endif\n\n")
+if len(asm) > 0:
+    f.write("ifeq ($(USE_ASM), Yes)\n");
+    f.write("%s_ASM_SRCS=\\\n"%(PREFIX))
+    for c in asm:
+        f.write("\t$(%s_SRCDIR)/%s\\\n"%(PREFIX, c))
+    f.write("\n")
+    f.write("%s_OBJS += $(%s_ASM_SRCS:.asm=.o)\n"%(PREFIX, PREFIX))
+    f.write("endif\n\n")
 
 f.write("OBJS += $(%s_OBJS)\n"%PREFIX)
 
 write_cpp_rule_pattern(f)
 
-write_asm_rule_pattern(f)
+if len(asm) > 0:
+    write_asm_rule_pattern(f)
 
 if args.library is not None:
     f.write("$(LIBPREFIX)%s.$(LIBSUFFIX): $(%s_OBJS)\n"%(args.library, PREFIX));
--- a/build/mktargets.sh
+++ b/build/mktargets.sh
@@ -7,4 +7,5 @@
 (cd codec/console/dec; python ../../../build/mktargets.py --directory codec/console/dec --binary h264dec --exclude dec_console.h --exclude load_bundle_functions.cpp)
 (cd codec/console/enc; python ../../../build/mktargets.py --directory codec/console/enc --binary h264enc --exclude enc_console.h --exclude bundlewelsenc.cpp)
 (cd test; python ../build/mktargets.py --directory test --binary codec_unittest)
+(cd gtest; python ../build/mktargets.py --directory gtest --library gtest --out ../build/gtest-targets.mk --cpp-suffix .cc --include gtest-all.cc)
 
--- a/codec/console/dec/targets.mk
+++ b/codec/console/dec/targets.mk
@@ -6,18 +6,9 @@
 	$(H264DEC_SRCDIR)/./src/read_config.cpp\
 
 H264DEC_OBJS += $(H264DEC_CPP_SRCS:.cpp=.o)
-ifeq ($(USE_ASM), Yes)
-H264DEC_ASM_SRCS=\
-
-H264DEC_OBJS += $(H264DEC_ASM_SRCS:.asm=.o)
-endif
-
 OBJS += $(H264DEC_OBJS)
 $(H264DEC_SRCDIR)/%.o: $(H264DEC_SRCDIR)/%.cpp
 	$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(H264DEC_CFLAGS) $(H264DEC_INCLUDES) -c $(CXX_O) $<
-
-$(H264DEC_SRCDIR)/%.o: $(H264DEC_SRCDIR)/%.asm
-	$(ASM) $(ASMFLAGS) $(ASM_INCLUDES) $(H264DEC_ASMFLAGS) $(H264DEC_ASM_INCLUDES) -o $@ $<
 
 h264dec: $(H264DEC_OBJS) $(LIBS) $(H264DEC_LIBS) $(H264DEC_DEPS)
 	$(CXX) $(CXX_LINK_O)  $(H264DEC_OBJS) $(H264DEC_LDFLAGS) $(H264DEC_LIBS) $(LDFLAGS) $(LIBS)
--- a/codec/console/enc/targets.mk
+++ b/codec/console/enc/targets.mk
@@ -5,18 +5,9 @@
 	$(H264ENC_SRCDIR)/./src/welsenc.cpp\
 
 H264ENC_OBJS += $(H264ENC_CPP_SRCS:.cpp=.o)
-ifeq ($(USE_ASM), Yes)
-H264ENC_ASM_SRCS=\
-
-H264ENC_OBJS += $(H264ENC_ASM_SRCS:.asm=.o)
-endif
-
 OBJS += $(H264ENC_OBJS)
 $(H264ENC_SRCDIR)/%.o: $(H264ENC_SRCDIR)/%.cpp
 	$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(H264ENC_CFLAGS) $(H264ENC_INCLUDES) -c $(CXX_O) $<
-
-$(H264ENC_SRCDIR)/%.o: $(H264ENC_SRCDIR)/%.asm
-	$(ASM) $(ASMFLAGS) $(ASM_INCLUDES) $(H264ENC_ASMFLAGS) $(H264ENC_ASM_INCLUDES) -o $@ $<
 
 h264enc: $(H264ENC_OBJS) $(LIBS) $(H264ENC_LIBS) $(H264ENC_DEPS)
 	$(CXX) $(CXX_LINK_O)  $(H264ENC_OBJS) $(H264ENC_LDFLAGS) $(H264ENC_LIBS) $(LDFLAGS) $(LIBS)
--- a/test/targets.mk
+++ b/test/targets.mk
@@ -6,18 +6,9 @@
 	$(CODEC_UNITTEST_SRCDIR)/./simple_test.cpp\
 
 CODEC_UNITTEST_OBJS += $(CODEC_UNITTEST_CPP_SRCS:.cpp=.o)
-ifeq ($(USE_ASM), Yes)
-CODEC_UNITTEST_ASM_SRCS=\
-
-CODEC_UNITTEST_OBJS += $(CODEC_UNITTEST_ASM_SRCS:.asm=.o)
-endif
-
 OBJS += $(CODEC_UNITTEST_OBJS)
 $(CODEC_UNITTEST_SRCDIR)/%.o: $(CODEC_UNITTEST_SRCDIR)/%.cpp
 	$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(CODEC_UNITTEST_CFLAGS) $(CODEC_UNITTEST_INCLUDES) -c $(CXX_O) $<
-
-$(CODEC_UNITTEST_SRCDIR)/%.o: $(CODEC_UNITTEST_SRCDIR)/%.asm
-	$(ASM) $(ASMFLAGS) $(ASM_INCLUDES) $(CODEC_UNITTEST_ASMFLAGS) $(CODEC_UNITTEST_ASM_INCLUDES) -o $@ $<
 
 codec_unittest: $(CODEC_UNITTEST_OBJS) $(LIBS) $(CODEC_UNITTEST_LIBS) $(CODEC_UNITTEST_DEPS)
 	$(CXX) $(CXX_LINK_O)  $(CODEC_UNITTEST_OBJS) $(CODEC_UNITTEST_LDFLAGS) $(CODEC_UNITTEST_LIBS) $(LDFLAGS) $(LIBS)