Flatten a few more inner CMake files

This moves test_fips and modulewrapper up to the build directory like
most of our other targets. Also integrate modulewrapper's source list
into build.json since it has more than one file.

Change-Id: I45335630c9bfe4be8293ce03dd3aef5c4963e3bf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78609
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d849bec..4211db0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -507,9 +507,6 @@
   add_subdirectory(ssl/test)
 endif()
 
-add_subdirectory(util/fipstools)
-add_subdirectory(util/fipstools/acvp/modulewrapper)
-
 if(OPENSSL_ASM)
   set(CRYPTO_SOURCES_ASM_USED ${CRYPTO_SOURCES_ASM})
   set(BCM_SOURCES_ASM_USED ${BCM_SOURCES_ASM})
@@ -707,6 +704,14 @@
   target_link_libraries(pki_test test_support_lib boringssl_gtest pki crypto)
   target_compile_options(pki_test PRIVATE ${PKI_CXX_FLAGS})
   add_dependencies(all_tests pki_test)
+
+  add_executable(test_fips util/fipstools/test_fips.cc)
+  target_link_libraries(test_fips crypto)
+endif()
+
+if(FIPS)
+  add_executable(modulewrapper ${MODULEWRAPPER_SOURCES})
+  target_link_libraries(modulewrapper crypto)
 endif()
 
 add_executable(bssl ${BSSL_SOURCES})
diff --git a/build.json b/build.json
index 41d30db..67d3992 100644
--- a/build.json
+++ b/build.json
@@ -1056,5 +1056,14 @@
             "rust/bssl-crypto/src/*.rs",
             "rust/bssl-crypto/src/*/*.rs"
         ]
+    },
+    "modulewrapper": {
+        "srcs": [
+            "util/fipstools/acvp/modulewrapper/main.cc",
+            "util/fipstools/acvp/modulewrapper/modulewrapper.cc"
+        ],
+        "internal_hdrs": [
+            "util/fipstools/acvp/modulewrapper/modulewrapper.h"
+        ]
     }
 }
diff --git a/gen/sources.bzl b/gen/sources.bzl
index 390c651..758f8e7 100644
--- a/gen/sources.bzl
+++ b/gen/sources.bzl
@@ -1124,6 +1124,15 @@
     "fuzz/verify_name_match_verifynameinsubtree_fuzzer.cc",
 ]
 
+modulewrapper_sources = [
+    "util/fipstools/acvp/modulewrapper/main.cc",
+    "util/fipstools/acvp/modulewrapper/modulewrapper.cc",
+]
+
+modulewrapper_internal_headers = [
+    "util/fipstools/acvp/modulewrapper/modulewrapper.h",
+]
+
 pki_sources = [
     "pki/cert_error_id.cc",
     "pki/cert_error_params.cc",
diff --git a/gen/sources.cmake b/gen/sources.cmake
index ccdde32..32aaf2b 100644
--- a/gen/sources.cmake
+++ b/gen/sources.cmake
@@ -1159,6 +1159,19 @@
 )
 
 set(
+  MODULEWRAPPER_SOURCES
+
+  util/fipstools/acvp/modulewrapper/main.cc
+  util/fipstools/acvp/modulewrapper/modulewrapper.cc
+)
+
+set(
+  MODULEWRAPPER_INTERNAL_HEADERS
+
+  util/fipstools/acvp/modulewrapper/modulewrapper.h
+)
+
+set(
   PKI_SOURCES
 
   pki/cert_error_id.cc
diff --git a/gen/sources.gni b/gen/sources.gni
index 1b50f09..cd760e2 100644
--- a/gen/sources.gni
+++ b/gen/sources.gni
@@ -1124,6 +1124,15 @@
   "fuzz/verify_name_match_verifynameinsubtree_fuzzer.cc",
 ]
 
+modulewrapper_sources = [
+  "util/fipstools/acvp/modulewrapper/main.cc",
+  "util/fipstools/acvp/modulewrapper/modulewrapper.cc",
+]
+
+modulewrapper_internal_headers = [
+  "util/fipstools/acvp/modulewrapper/modulewrapper.h",
+]
+
 pki_sources = [
   "pki/cert_error_id.cc",
   "pki/cert_error_params.cc",
diff --git a/gen/sources.json b/gen/sources.json
index d4f4c2d..fb27719 100644
--- a/gen/sources.json
+++ b/gen/sources.json
@@ -1106,6 +1106,15 @@
       "fuzz/verify_name_match_verifynameinsubtree_fuzzer.cc"
     ]
   },
+  "modulewrapper": {
+    "srcs": [
+      "util/fipstools/acvp/modulewrapper/main.cc",
+      "util/fipstools/acvp/modulewrapper/modulewrapper.cc"
+    ],
+    "internal_hdrs": [
+      "util/fipstools/acvp/modulewrapper/modulewrapper.h"
+    ]
+  },
   "pki": {
     "srcs": [
       "pki/cert_error_id.cc",
diff --git a/gen/sources.mk b/gen/sources.mk
index 3c6285d..b6888fa 100644
--- a/gen/sources.mk
+++ b/gen/sources.mk
@@ -1107,6 +1107,13 @@
   fuzz/verify_name_match_normalizename_fuzzer.cc \
   fuzz/verify_name_match_verifynameinsubtree_fuzzer.cc
 
+boringssl_modulewrapper_sources := \
+  util/fipstools/acvp/modulewrapper/main.cc \
+  util/fipstools/acvp/modulewrapper/modulewrapper.cc
+
+boringssl_modulewrapper_internal_headers := \
+  util/fipstools/acvp/modulewrapper/modulewrapper.h
+
 boringssl_pki_sources := \
   pki/cert_error_id.cc \
   pki/cert_error_params.cc \
diff --git a/util/fipstools/CMakeLists.txt b/util/fipstools/CMakeLists.txt
deleted file mode 100644
index e2bcb19..0000000
--- a/util/fipstools/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-if(BUILD_TESTING)
-  add_executable(
-    test_fips
-
-    test_fips.cc
-  )
-  target_link_libraries(test_fips crypto)
-endif()
diff --git a/util/fipstools/acvp/acvptool/acvp.go b/util/fipstools/acvp/acvptool/acvp.go
index dcaf542..7a5c43c 100644
--- a/util/fipstools/acvp/acvptool/acvp.go
+++ b/util/fipstools/acvp/acvptool/acvp.go
@@ -51,7 +51,7 @@
 	runFlag         = flag.String("run", "", "Name of primitive to run tests for")
 	fetchFlag       = flag.String("fetch", "", "Name of primitive to fetch vectors for")
 	expectedOutFlag = flag.String("expected-out", "", "Name of a file to write the expected results to")
-	wrapperPath     = flag.String("wrapper", "../../../../build/util/fipstools/acvp/modulewrapper/modulewrapper", "Path to the wrapper binary")
+	wrapperPath     = flag.String("wrapper", "../../../../build/modulewrapper", "Path to the wrapper binary")
 )
 
 type Config struct {
diff --git a/util/fipstools/acvp/modulewrapper/CMakeLists.txt b/util/fipstools/acvp/modulewrapper/CMakeLists.txt
deleted file mode 100644
index 7938d39..0000000
--- a/util/fipstools/acvp/modulewrapper/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-if(FIPS)
-  add_executable(
-    modulewrapper
-
-    main.cc
-    modulewrapper.cc
-  )
-  target_link_libraries(modulewrapper crypto)
-endif()
diff --git a/util/fipstools/break-tests.sh b/util/fipstools/break-tests.sh
index e056e8f..111f120 100644
--- a/util/fipstools/break-tests.sh
+++ b/util/fipstools/break-tests.sh
@@ -128,7 +128,7 @@
 }
 
 if [ "$MODE" = "local" ]; then
-  TEST_FIPS_BIN=${TEST_FIPS_BIN:-build/util/fipstools/test_fips}
+  TEST_FIPS_BIN=${TEST_FIPS_BIN:-build/test_fips}
   TEST_FIPS_BREAK_BIN=${TEST_FIPS_BREAK_BIN:-./test_fips_break}
   check_file "$TEST_FIPS_BIN"
   check_file "$TEST_FIPS_BREAK_BIN"
diff --git a/util/fipstools/test-break-kat.sh b/util/fipstools/test-break-kat.sh
index b3b6283..01c13c3 100644
--- a/util/fipstools/test-break-kat.sh
+++ b/util/fipstools/test-break-kat.sh
@@ -18,7 +18,7 @@
 set -x
 set -e
 
-TEST_FIPS_BIN="build/util/fipstools/test_fips"
+TEST_FIPS_BIN="build/test_fips"
 
 if [ ! -f $TEST_FIPS_BIN ]; then
   echo "$TEST_FIPS_BIN is missing. Run this script from the top level of a"