tf_fuzz: refactor includes to only include what is needed

* Refactor Makefile to automatically gather prerequisites.

* Change the includes (using include-what-you-need) so that files only
  include the specific headers they need. Many includes are also now
  inside the .hpp files instead of the .cpp files.

  This improves editor support: previously, external symbols in .hpp
  files would not be resolved by clangd due to .hpp files not having any
  imports.

Change-Id: Iece03f81c35aa43ac026aaeb49b87d2c4acf07cd
Signed-off-by: Nik Dewally <Nik.Dewally@arm.com>
diff --git a/tf_fuzz/tfz-cpp/utility/compute.cpp b/tf_fuzz/tfz-cpp/utility/compute.cpp
index 708a1f3..f898be2 100644
--- a/tf_fuzz/tfz-cpp/utility/compute.cpp
+++ b/tf_fuzz/tfz-cpp/utility/compute.cpp
@@ -1,11 +1,10 @@
 /*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
-#include <cstdint>  // for uint32_t
 #include "compute.hpp"
 
 
diff --git a/tf_fuzz/tfz-cpp/utility/compute.hpp b/tf_fuzz/tfz-cpp/utility/compute.hpp
index c6ece6c..86cb48f 100644
--- a/tf_fuzz/tfz-cpp/utility/compute.hpp
+++ b/tf_fuzz/tfz-cpp/utility/compute.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -8,6 +8,7 @@
 #ifndef COMPUTE_HPP
 #define COMPUTE_HPP
 
+#include <stdint.h>
 #include <cstdlib>
 
 using namespace std;
diff --git a/tf_fuzz/tfz-cpp/utility/data_blocks.cpp b/tf_fuzz/tfz-cpp/utility/data_blocks.cpp
index c84d4d2..21b7f50 100644
--- a/tf_fuzz/tfz-cpp/utility/data_blocks.cpp
+++ b/tf_fuzz/tfz-cpp/utility/data_blocks.cpp
@@ -9,24 +9,16 @@
    associated methods (most importantly their constructors) used in template_
    line, psa_call, psa_asset (etc.). */
 
+#include <stdlib.h>
 #include <string>
 #include <vector>
-#include <cstdint>
+#include <iostream>
 
-#include "class_forwards.hpp"
-
-#include "boilerplate.hpp"
 #include "randomization.hpp"
 #include "gibberish.hpp"
-#include "compute.hpp"
-#include "string_ops.hpp"
 #include "data_blocks.hpp"
-#include "psa_asset.hpp"
-#include "crypto_asset.hpp"
 #include "find_or_create_asset.hpp"
 #include "psa_call.hpp"
-#include "template_line.hpp"
-#include "tf_fuzz.hpp"
 
 
 
diff --git a/tf_fuzz/tfz-cpp/utility/data_blocks.hpp b/tf_fuzz/tfz-cpp/utility/data_blocks.hpp
index 5b26e1b..1e56836 100644
--- a/tf_fuzz/tfz-cpp/utility/data_blocks.hpp
+++ b/tf_fuzz/tfz-cpp/utility/data_blocks.hpp
@@ -5,7 +5,17 @@
  *
  */
 
+#include <stdint.h>
 #include <string>
+#include <vector>
+#include <iosfwd>
+
+class psa_asset;
+
+enum class psa_asset_type;
+class psa_call;
+
+enum class asset_search;
 
 /* These classes "cut down the clutter" by grouping together related data and
    associated methods (most importantly their constructors) used in template_
@@ -14,12 +24,6 @@
 #ifndef DATA_BLOCKS_HPP
 #define DATA_BLOCKS_HPP
 
-/* This project's header files #including other project headers quickly becomes
-   unrealistically complicated.  The only solution is for each .cpp to include
-   the headers it needs.  However these in particular are mostly axiomatic:  Not
-   dependent upon other classes. */
-
-
 using namespace std;
 
 
diff --git a/tf_fuzz/tfz-cpp/utility/find_or_create_asset.hpp b/tf_fuzz/tfz-cpp/utility/find_or_create_asset.hpp
index c2e7853..92b1323 100644
--- a/tf_fuzz/tfz-cpp/utility/find_or_create_asset.hpp
+++ b/tf_fuzz/tfz-cpp/utility/find_or_create_asset.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019-2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -8,6 +8,16 @@
 #ifndef FIND_OR_CREATE_ASSET_HPP
 #define FIND_OR_CREATE_ASSET_HPP
 
+#include <stdint.h>
+#include <iostream>
+#include <iterator>
+#include <new>
+#include <string>
+#include <vector>
+
+#include "psa_asset.hpp"
+#include "data_blocks.hpp"
+
 using namespace std;
 
 /* This enum defines possible results when asked to find an existing, or create a
diff --git a/tf_fuzz/tfz-cpp/utility/gibberish.cpp b/tf_fuzz/tfz-cpp/utility/gibberish.cpp
index 6de56f0..436ace4 100644
--- a/tf_fuzz/tfz-cpp/utility/gibberish.cpp
+++ b/tf_fuzz/tfz-cpp/utility/gibberish.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019-2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -14,6 +14,7 @@
  */
 
 #include <string>
+#include <cstdlib>
 
 #include "gibberish.hpp"  // shouldn't need any other project headers
 
diff --git a/tf_fuzz/tfz-cpp/utility/gibberish.hpp b/tf_fuzz/tfz-cpp/utility/gibberish.hpp
index c5692e3..533f239 100644
--- a/tf_fuzz/tfz-cpp/utility/gibberish.hpp
+++ b/tf_fuzz/tfz-cpp/utility/gibberish.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -15,6 +15,7 @@
 #define GIBBERISH_HPP
 
 #include <cstdlib>
+#include <string>
 
 using namespace std;
 
diff --git a/tf_fuzz/tfz-cpp/utility/randomization.cpp b/tf_fuzz/tfz-cpp/utility/randomization.cpp
index c8cdd38..ded87bb 100644
--- a/tf_fuzz/tfz-cpp/utility/randomization.cpp
+++ b/tf_fuzz/tfz-cpp/utility/randomization.cpp
@@ -15,6 +15,8 @@
 
 #include "randomization.hpp"
 
+#include <stdlib.h>
+
 /**
  * \brief Selects and returns a random key_usage_t value.
  *
diff --git a/tf_fuzz/tfz-cpp/utility/randomization.hpp b/tf_fuzz/tfz-cpp/utility/randomization.hpp
index 2eb72f6..b47742a 100644
--- a/tf_fuzz/tfz-cpp/utility/randomization.hpp
+++ b/tf_fuzz/tfz-cpp/utility/randomization.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
diff --git a/tf_fuzz/tfz-cpp/utility/string_ops.cpp b/tf_fuzz/tfz-cpp/utility/string_ops.cpp
index 9c14140..98a4a0f 100644
--- a/tf_fuzz/tfz-cpp/utility/string_ops.cpp
+++ b/tf_fuzz/tfz-cpp/utility/string_ops.cpp
@@ -1,14 +1,19 @@
 /*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include "string_ops.hpp"
+
+#include <ctype.h>
+#include <stdint.h>
+#include <stdlib.h>
 #include <iostream>
-#include <sstream>
 #include <iomanip>
+#include <stdexcept>
+#include <sstream>
 
 using namespace std;
 
diff --git a/tf_fuzz/tfz-cpp/utility/variables.cpp b/tf_fuzz/tfz-cpp/utility/variables.cpp
index ab2a823..7209074 100644
--- a/tf_fuzz/tfz-cpp/utility/variables.cpp
+++ b/tf_fuzz/tfz-cpp/utility/variables.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -8,28 +8,13 @@
 /* This file defines information to track regarding variables in the generated test
    code. */
 
+#include <stdlib.h>
 #include <string>
-#include <vector>
-#include <list>
-#include <iostream>
-#include <fstream>
 
-#include "class_forwards.hpp"
-
-#include "data_blocks.hpp"
-#include "psa_asset.hpp"
-#include "crypto_asset.hpp"
-#include "psa_call.hpp"
 #include "find_or_create_asset.hpp"
 #include "variables.hpp"
 #include "gibberish.hpp"
 
-/* This project's header files #including other project headers quickly becomes
-   unrealistically complicated.  The only solution is for each .cpp to include
-   the headers it needs.  However these in particular are mostly axiomatic:  Not
-   dependent upon other classes. */
-
-
 using namespace std;
 
 
diff --git a/tf_fuzz/tfz-cpp/utility/variables.hpp b/tf_fuzz/tfz-cpp/utility/variables.hpp
index 886acc3..2c679ef 100644
--- a/tf_fuzz/tfz-cpp/utility/variables.hpp
+++ b/tf_fuzz/tfz-cpp/utility/variables.hpp
@@ -1,12 +1,13 @@
 /*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include <string>
-#include <vector>
+
+#include "find_or_create_asset.hpp"
 
 /* This file defines information to track regarding variables in the generated test
    code. */
@@ -14,12 +15,6 @@
 #ifndef VARIABLES_HPP
 #define VARIABLES_HPP
 
-/* This project's header files #including other project headers quickly becomes
-   unrealistically complicated.  The only solution is for each .cpp to include
-   the headers it needs.  However these in particular are mostly axiomatic:  Not
-   dependent upon other classes. */
-
-
 using namespace std;
 
 
@@ -56,4 +51,3 @@
 
 
 #endif // VARIABLES_HPP
-