From 0eae96293b4d2da6b6b23ae80ac132fb49f90915 Mon Sep 17 00:00:00 2001
From: Blaine Bublitz <blaine@aztecprotocol.com>
Date: Thu, 2 Mar 2023 08:59:21 -0700
Subject: [PATCH] fix: Wrap each use of filesystem library in ifndef __wasm__
 (#181)

---
 .../join_split_example/proofs/compute_circuit_data.hpp     | 7 +++++++
 .../aztec/proof_system/proving_key/proving_key.test.cpp    | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/cpp/src/aztec/join_split_example/proofs/compute_circuit_data.hpp b/cpp/src/aztec/join_split_example/proofs/compute_circuit_data.hpp
index d76acf99a0..e9fed596b3 100644
--- a/cpp/src/aztec/join_split_example/proofs/compute_circuit_data.hpp
+++ b/cpp/src/aztec/join_split_example/proofs/compute_circuit_data.hpp
@@ -6,7 +6,10 @@
 #include <sys/stat.h>
 #include <common/timer.hpp>
 #include <proof_system/proving_key/serialize.hpp>
+
+#ifndef __wasm__
 #include <filesystem>
+#endif
 
 namespace join_split_example {
 namespace proofs {
@@ -91,11 +94,13 @@ circuit_data get_circuit_data(std::string const& name,
         }
     }
 
+#ifndef __wasm__
     // If we're saving data, create the circuit data directory.
     if (save) {
         std::filesystem::create_directories(key_path.c_str());
         std::filesystem::create_directories(circuit_key_path.c_str());
     }
+#endif
 
     if (pk) {
         auto pk_dir = circuit_key_path + "/proving_key";
@@ -145,6 +150,7 @@ circuit_data get_circuit_data(std::string const& name,
                                                        name + name_suffix_for_benchmarks,
                                                        "Proving key computed in",
                                                        timer.toString());
+#ifndef __wasm__
             if (save) {
                 info(name, ": Saving proving key...");
                 std::filesystem::create_directories(pk_dir.c_str());
@@ -156,6 +162,7 @@ circuit_data get_circuit_data(std::string const& name,
                 }
                 info(name, ": Saved in ", write_timer.toString(), "s");
             }
+#endif
         }
     }
 
diff --git a/cpp/src/aztec/proof_system/proving_key/proving_key.test.cpp b/cpp/src/aztec/proof_system/proving_key/proving_key.test.cpp
index fe07b31026..871d5a8597 100644
--- a/cpp/src/aztec/proof_system/proving_key/proving_key.test.cpp
+++ b/cpp/src/aztec/proof_system/proving_key/proving_key.test.cpp
@@ -3,7 +3,10 @@
 #include "proving_key.hpp"
 #include "serialize.hpp"
 #include "plonk/composer/standard_composer.hpp"
+
+#ifndef __wasm__
 #include <filesystem>
+#endif
 
 using namespace barretenberg;
 using namespace bonk;
@@ -45,6 +48,7 @@ TEST(proving_key, proving_key_from_serialized_key)
 }
 
 // Test that a proving key can be serialized/deserialized using mmap
+#ifndef __wasm__
 TEST(proving_key, proving_key_from_mmaped_key)
 {
     plonk::StandardComposer composer = plonk::StandardComposer();
@@ -108,4 +112,5 @@ TEST(proving_key, proving_key_from_mmaped_key)
     EXPECT_EQ(p_key.circuit_size, pk_data.circuit_size);
     EXPECT_EQ(p_key.num_public_inputs, pk_data.num_public_inputs);
     EXPECT_EQ(p_key.contains_recursive_proof, pk_data.contains_recursive_proof);
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file