shithub: openh264

Download patch

ref: b38976944a479422b8f6135b07565bdc3073b667
parent: a8d549e343ec20dde85e4ca46327461cc56e89e8
author: Martin Storsjö <[email protected]>
date: Fri Jan 17 04:55:21 EST 2014

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

This simplifies updating all makefiles consistently.

--- 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,7 +83,7 @@
 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))
 
 if len(asm) > 0:
     f.write("ifeq ($(USE_ASM), Yes)\n");
--- 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)