Add generation of libaom_test_srcs.gni

Export additional sources necessary to build libaom unittests using
the gn build system.

The unit tests also depend on the sources

aom_common_app_util_sources
aom_decoder_app_util_sources
aom_encoder_app_util_sources
aom_libwebm_sources

which are used to build other binaries in the project. Becuase of this
they have been placed into libaom_srcs.txt/gni

Change-Id: I02011810ff5c50d7342a7ff856d979884fcb1b7c
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50c4efd..2416887 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -944,7 +944,7 @@
 get_cmake_property(all_cmake_vars VARIABLES)
 foreach(var ${all_cmake_vars})
   if("${var}" MATCHES "SOURCES$\|_INTRIN_\|_ASM_"
-     AND NOT "${var}" MATCHES "_APP_\|DOXYGEN\|LIBWEBM\|LIBYUV\|_PKG_\|TEST")
+     AND NOT "${var}" MATCHES "DOXYGEN\|LIBYUV\|_PKG_\|TEST")
     list(APPEND aom_source_vars ${var})
   endif()
 endforeach()
diff --git a/test/test.cmake b/test/test.cmake
index 685d0e3..8e5cb87 100644
--- a/test/test.cmake
+++ b/test/test.cmake
@@ -608,6 +608,27 @@
     set(last_aom_test_source_var ${aom_test_source_var})
   endforeach()
 
+  # libaom_test_srcs.gni generation
+  set(libaom_test_srcs_gni_file "${AOM_CONFIG_DIR}/libaom_test_srcs.gni")
+  file(WRITE "${libaom_test_srcs_gni_file}"
+       "# This file is generated. DO NOT EDIT.\n")
+
+  foreach(aom_test_source_var ${AOM_TEST_SOURCE_VARS})
+    string(TOLOWER "${aom_test_source_var}" aom_test_source_var_lowercase)
+    file(APPEND "${libaom_test_srcs_gni_file}"
+         "\n${aom_test_source_var_lowercase} = [\n")
+
+    foreach(file ${${aom_test_source_var}})
+      if(NOT "${file}" MATCHES "${AOM_CONFIG_DIR}")
+        string(REPLACE "${AOM_ROOT}/" "//third_party/libaom/source/libaom/" file
+                       "${file}")
+        file(APPEND "${libaom_test_srcs_gni_file}" "  \"${file}\",\n")
+      endif()
+    endforeach()
+
+    file(APPEND "${libaom_test_srcs_gni_file}" "]\n")
+  endforeach()
+
   # Set up test for rc interface
   if(CONFIG_AV1_ENCODER
      AND ENABLE_TESTS