fix(bazel): use param file for compile (#1373)

* fixes issues on windows when dealing with many dependencies causing a
  'command line too long' error
diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl
index 835255a..745e27d 100644
--- a/bazel/emscripten_toolchain/toolchain.bzl
+++ b/bazel/emscripten_toolchain/toolchain.bzl
@@ -346,6 +346,16 @@
             provides = ["variant:crosstool_build_mode"],
         ),
 
+        # Feature to prevent 'command line too long' issues
+        feature(
+            name = "archive_param_file",
+            enabled = True,
+        ),
+        feature(
+            name = "compiler_param_file",
+            enabled = True,
+        ),
+
         #### User-settable features
 
         # Set if enabling exceptions.
diff --git a/bazel/test_external/long_command_line/BUILD.bazel b/bazel/test_external/long_command_line/BUILD.bazel
new file mode 100644
index 0000000..4ffe247
--- /dev/null
+++ b/bazel/test_external/long_command_line/BUILD.bazel
@@ -0,0 +1,61 @@
+load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
+
+_TEST_TARGETS = [
+    "long_command_line_file01",
+    "long_command_line_file02",
+    "long_command_line_file03",
+    "long_command_line_file04",
+    "long_command_line_file05",
+    "long_command_line_file06",
+    "long_command_line_file07",
+    "long_command_line_file08",
+    "long_command_line_file09",
+    "long_command_line_file10",
+    "long_command_line_file11",
+    "long_command_line_file12",
+    "long_command_line_file13",
+    "long_command_line_file14",
+    "long_command_line_file15",
+    "long_command_line_file16",
+    "long_command_line_file17",
+    "long_command_line_file18",
+    "long_command_line_file19",
+    "long_command_line_file20",
+]
+
+_TEST_TARGET_SUFFIXES = [
+    "a",
+    "b",
+    "c",
+    "d",
+    "e",
+    "f",
+    "g",
+    "h",
+    "i",
+    "j",
+]
+
+[cc_library(
+    name = "{}_{}".format(target, suffix),
+    hdrs = ["include/{}.hh".format(target)],
+    # stripping include prefix to create more flags passed to emcc
+    strip_include_prefix = "include",
+    srcs = ["{}.cc".format(target)],
+) for target in _TEST_TARGETS for suffix in _TEST_TARGET_SUFFIXES]
+
+cc_binary(
+    name = "long_command_line",
+    linkshared = True,
+    srcs = ["long_command_line.cc"],
+    deps = [":{}_{}".format(target, suffix) for target in _TEST_TARGETS for suffix in _TEST_TARGET_SUFFIXES],
+)
+
+wasm_cc_binary(
+    name = "long_command_line_wasm",
+    cc_target = ":long_command_line",
+    outputs = [
+        "long_command_line.js",
+        "long_command_line.wasm",
+    ],
+)
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file01.hh b/bazel/test_external/long_command_line/include/long_command_line_file01.hh
new file mode 100644
index 0000000..8dd06ba
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file01.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f1();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file02.hh b/bazel/test_external/long_command_line/include/long_command_line_file02.hh
new file mode 100644
index 0000000..7a3a0ff
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file02.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f2();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file03.hh b/bazel/test_external/long_command_line/include/long_command_line_file03.hh
new file mode 100644
index 0000000..1688055
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file03.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f3();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file04.hh b/bazel/test_external/long_command_line/include/long_command_line_file04.hh
new file mode 100644
index 0000000..45ef1fc
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file04.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f4();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file05.hh b/bazel/test_external/long_command_line/include/long_command_line_file05.hh
new file mode 100644
index 0000000..707ad50
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file05.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f5();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file06.hh b/bazel/test_external/long_command_line/include/long_command_line_file06.hh
new file mode 100644
index 0000000..5d91450
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file06.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f6();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file07.hh b/bazel/test_external/long_command_line/include/long_command_line_file07.hh
new file mode 100644
index 0000000..b0bf811
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file07.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f7();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file08.hh b/bazel/test_external/long_command_line/include/long_command_line_file08.hh
new file mode 100644
index 0000000..994b7ea
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file08.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f8();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file09.hh b/bazel/test_external/long_command_line/include/long_command_line_file09.hh
new file mode 100644
index 0000000..90c1958
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file09.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f9();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file10.hh b/bazel/test_external/long_command_line/include/long_command_line_file10.hh
new file mode 100644
index 0000000..6a43881
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file10.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f10();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file11.hh b/bazel/test_external/long_command_line/include/long_command_line_file11.hh
new file mode 100644
index 0000000..878c939
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file11.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f11();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file12.hh b/bazel/test_external/long_command_line/include/long_command_line_file12.hh
new file mode 100644
index 0000000..b5e0bc3
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file12.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f12();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file13.hh b/bazel/test_external/long_command_line/include/long_command_line_file13.hh
new file mode 100644
index 0000000..634dcef
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file13.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f13();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file14.hh b/bazel/test_external/long_command_line/include/long_command_line_file14.hh
new file mode 100644
index 0000000..8fa9666
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file14.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f14();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file15.hh b/bazel/test_external/long_command_line/include/long_command_line_file15.hh
new file mode 100644
index 0000000..1f7b770
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file15.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f15();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file16.hh b/bazel/test_external/long_command_line/include/long_command_line_file16.hh
new file mode 100644
index 0000000..c9fa2fc
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file16.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f16();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file17.hh b/bazel/test_external/long_command_line/include/long_command_line_file17.hh
new file mode 100644
index 0000000..b959207
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file17.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f17();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file18.hh b/bazel/test_external/long_command_line/include/long_command_line_file18.hh
new file mode 100644
index 0000000..af0bacf
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file18.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f18();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file19.hh b/bazel/test_external/long_command_line/include/long_command_line_file19.hh
new file mode 100644
index 0000000..0ac9b4b
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file19.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f19();
diff --git a/bazel/test_external/long_command_line/include/long_command_line_file20.hh b/bazel/test_external/long_command_line/include/long_command_line_file20.hh
new file mode 100644
index 0000000..0f10c73
--- /dev/null
+++ b/bazel/test_external/long_command_line/include/long_command_line_file20.hh
@@ -0,0 +1,3 @@
+#pragma once
+
+void f20();
diff --git a/bazel/test_external/long_command_line/long_command_line.cc b/bazel/test_external/long_command_line/long_command_line.cc
new file mode 100644
index 0000000..1ae13ab
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line.cc
@@ -0,0 +1,43 @@
+#include "long_command_line_file01.hh"
+#include "long_command_line_file02.hh"
+#include "long_command_line_file03.hh"
+#include "long_command_line_file04.hh"
+#include "long_command_line_file05.hh"
+#include "long_command_line_file06.hh"
+#include "long_command_line_file07.hh"
+#include "long_command_line_file08.hh"
+#include "long_command_line_file09.hh"
+#include "long_command_line_file10.hh"
+#include "long_command_line_file11.hh"
+#include "long_command_line_file12.hh"
+#include "long_command_line_file13.hh"
+#include "long_command_line_file14.hh"
+#include "long_command_line_file15.hh"
+#include "long_command_line_file16.hh"
+#include "long_command_line_file17.hh"
+#include "long_command_line_file18.hh"
+#include "long_command_line_file19.hh"
+#include "long_command_line_file20.hh"
+
+int main() {
+  f1();
+  f2();
+  f3();
+  f4();
+  f5();
+  f6();
+  f7();
+  f8();
+  f9();
+  f10();
+  f11();
+  f12();
+  f13();
+  f14();
+  f15();
+  f16();
+  f17();
+  f18();
+  f19();
+  f20();
+}
diff --git a/bazel/test_external/long_command_line/long_command_line_file01.cc b/bazel/test_external/long_command_line/long_command_line_file01.cc
new file mode 100644
index 0000000..3bf8d4a
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file01.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file01.hh"
+
+#include <iostream>
+
+void f1() { std::cout << "hello from f1()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file02.cc b/bazel/test_external/long_command_line/long_command_line_file02.cc
new file mode 100644
index 0000000..b8ac814
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file02.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file02.hh"
+
+#include <iostream>
+
+void f2() { std::cout << "hello from f2()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file03.cc b/bazel/test_external/long_command_line/long_command_line_file03.cc
new file mode 100644
index 0000000..294e777
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file03.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file03.hh"
+
+#include <iostream>
+
+void f3() { std::cout << "hello from f3()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file04.cc b/bazel/test_external/long_command_line/long_command_line_file04.cc
new file mode 100644
index 0000000..c0d537d
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file04.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file04.hh"
+
+#include <iostream>
+
+void f4() { std::cout << "hello from f4()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file05.cc b/bazel/test_external/long_command_line/long_command_line_file05.cc
new file mode 100644
index 0000000..310e3e0
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file05.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file05.hh"
+
+#include <iostream>
+
+void f5() { std::cout << "hello from f5()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file06.cc b/bazel/test_external/long_command_line/long_command_line_file06.cc
new file mode 100644
index 0000000..2c218fd
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file06.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file06.hh"
+
+#include <iostream>
+
+void f6() { std::cout << "hello from f6()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file07.cc b/bazel/test_external/long_command_line/long_command_line_file07.cc
new file mode 100644
index 0000000..c78dc40
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file07.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file07.hh"
+
+#include <iostream>
+
+void f7() { std::cout << "hello from f7()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file08.cc b/bazel/test_external/long_command_line/long_command_line_file08.cc
new file mode 100644
index 0000000..1c2e10f
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file08.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file08.hh"
+
+#include <iostream>
+
+void f8() { std::cout << "hello from f8()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file09.cc b/bazel/test_external/long_command_line/long_command_line_file09.cc
new file mode 100644
index 0000000..6c0028d
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file09.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file09.hh"
+
+#include <iostream>
+
+void f9() { std::cout << "hello from f9()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file10.cc b/bazel/test_external/long_command_line/long_command_line_file10.cc
new file mode 100644
index 0000000..9f0be9c
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file10.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file10.hh"
+
+#include <iostream>
+
+void f10() { std::cout << "hello from f10()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file11.cc b/bazel/test_external/long_command_line/long_command_line_file11.cc
new file mode 100644
index 0000000..2ef8f96
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file11.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file11.hh"
+
+#include <iostream>
+
+void f11() { std::cout << "hello from f11()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file12.cc b/bazel/test_external/long_command_line/long_command_line_file12.cc
new file mode 100644
index 0000000..7634996
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file12.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file12.hh"
+
+#include <iostream>
+
+void f12() { std::cout << "hello from f12()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file13.cc b/bazel/test_external/long_command_line/long_command_line_file13.cc
new file mode 100644
index 0000000..bca66d0
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file13.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file13.hh"
+
+#include <iostream>
+
+void f13() { std::cout << "hello from f13()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file14.cc b/bazel/test_external/long_command_line/long_command_line_file14.cc
new file mode 100644
index 0000000..543179f
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file14.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file14.hh"
+
+#include <iostream>
+
+void f14() { std::cout << "hello from f14()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file15.cc b/bazel/test_external/long_command_line/long_command_line_file15.cc
new file mode 100644
index 0000000..28767ef
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file15.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file15.hh"
+
+#include <iostream>
+
+void f15() { std::cout << "hello from f15()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file16.cc b/bazel/test_external/long_command_line/long_command_line_file16.cc
new file mode 100644
index 0000000..ca7ff99
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file16.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file16.hh"
+
+#include <iostream>
+
+void f16() { std::cout << "hello from f16()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file17.cc b/bazel/test_external/long_command_line/long_command_line_file17.cc
new file mode 100644
index 0000000..2230d36
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file17.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file17.hh"
+
+#include <iostream>
+
+void f17() { std::cout << "hello from f17()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file18.cc b/bazel/test_external/long_command_line/long_command_line_file18.cc
new file mode 100644
index 0000000..822cd14
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file18.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file18.hh"
+
+#include <iostream>
+
+void f18() { std::cout << "hello from f18()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file19.cc b/bazel/test_external/long_command_line/long_command_line_file19.cc
new file mode 100644
index 0000000..b864064
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file19.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file19.hh"
+
+#include <iostream>
+
+void f19() { std::cout << "hello from f19()\n"; }
diff --git a/bazel/test_external/long_command_line/long_command_line_file20.cc b/bazel/test_external/long_command_line/long_command_line_file20.cc
new file mode 100644
index 0000000..0562be6
--- /dev/null
+++ b/bazel/test_external/long_command_line/long_command_line_file20.cc
@@ -0,0 +1,5 @@
+#include "long_command_line_file20.hh"
+
+#include <iostream>
+
+void f20() { std::cout << "hello from f20()\n"; }
diff --git a/test/test_bazel.ps1 b/test/test_bazel.ps1
index 3fd269c..b417262 100644
--- a/test/test_bazel.ps1
+++ b/test/test_bazel.ps1
@@ -13,6 +13,9 @@
 bazel build //:hello-world-wasm
 if (-not $?) { Exit $LastExitCode }
 
+bazel build //long_command_line:long_command_line_wasm
+if (-not $?) { Exit $LastExitCode }
+
 bazel build //:hello-embind-wasm --compilation_mode dbg # debug
 if (-not $?) { Exit $LastExitCode }
 
diff --git a/test/test_bazel.sh b/test/test_bazel.sh
index bc53fcd..d8d40e1 100755
--- a/test/test_bazel.sh
+++ b/test/test_bazel.sh
@@ -26,9 +26,10 @@
 
 cd test_external
 bazel build //:hello-world-wasm
+bazel build //long_command_line:long_command_line_wasm
 bazel build //:hello-embind-wasm --compilation_mode dbg # debug
 
 # Test use of the closure compiler
 bazel build //:hello-embind-wasm --compilation_mode opt # release
 # This function should not be minified if the externs file is loaded correctly.
-grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js
\ No newline at end of file
+grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js
diff --git a/test/test_bazel_mac.sh b/test/test_bazel_mac.sh
index 58aa9f0..4b58b50 100755
--- a/test/test_bazel_mac.sh
+++ b/test/test_bazel_mac.sh
@@ -25,4 +25,5 @@
 bazel build //hello-world:hello-world-wasm-simd
 
 cd test_external
+bazel build //long_command_line:long_command_line_wasm
 bazel build //:hello-world-wasm