fastled 1.2.46__tar.gz → 1.2.49__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. {fastled-1.2.46 → fastled-1.2.49}/PKG-INFO +1 -2
  2. {fastled-1.2.46 → fastled-1.2.49}/README.md +0 -1
  3. {fastled-1.2.46 → fastled-1.2.49}/compiler/code_sync.py +37 -13
  4. {fastled-1.2.46 → fastled-1.2.49}/compiler/compile.py +101 -188
  5. {fastled-1.2.46 → fastled-1.2.49}/compiler/init_runtime.py +7 -8
  6. fastled-1.2.49/compiler/libcompile/CMakeLists.txt +152 -0
  7. fastled-1.2.49/compiler/paths.py +18 -0
  8. {fastled-1.2.46 → fastled-1.2.49}/compiler/run.py +8 -21
  9. {fastled-1.2.46 → fastled-1.2.49}/compiler/server.py +42 -36
  10. {fastled-1.2.46 → fastled-1.2.49}/lint +2 -0
  11. {fastled-1.2.46 → fastled-1.2.49}/requirements.testing.txt +2 -1
  12. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/__init__.py +1 -2
  13. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/client_server.py +6 -2
  14. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/docker_manager.py +63 -29
  15. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/filewatcher.py +16 -4
  16. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/web_compile.py +2 -1
  17. {fastled-1.2.46 → fastled-1.2.49}/src/fastled.egg-info/PKG-INFO +1 -2
  18. {fastled-1.2.46 → fastled-1.2.49}/src/fastled.egg-info/SOURCES.txt +2 -7
  19. {fastled-1.2.46 → fastled-1.2.49}/tests/test_http_server.py +4 -1
  20. fastled-1.2.46/compiler/index.css +0 -288
  21. fastled-1.2.46/compiler/index.html +0 -191
  22. fastled-1.2.46/compiler/index.js +0 -492
  23. fastled-1.2.46/compiler/modules/graphics_manager.js +0 -279
  24. fastled-1.2.46/compiler/modules/graphics_manager_threejs.js +0 -385
  25. fastled-1.2.46/compiler/modules/ui_manager.js +0 -252
  26. fastled-1.2.46/compiler/platformio.ini +0 -21
  27. {fastled-1.2.46 → fastled-1.2.49}/.aiderignore +0 -0
  28. {fastled-1.2.46 → fastled-1.2.49}/.dockerignore +0 -0
  29. {fastled-1.2.46 → fastled-1.2.49}/.github/workflows/build_multi_docker_image.yml +0 -0
  30. {fastled-1.2.46 → fastled-1.2.49}/.github/workflows/build_webpage.yml +0 -0
  31. {fastled-1.2.46 → fastled-1.2.49}/.github/workflows/lint.yml +0 -0
  32. {fastled-1.2.46 → fastled-1.2.49}/.github/workflows/publish_release.yml +0 -0
  33. {fastled-1.2.46 → fastled-1.2.49}/.github/workflows/template_build_docker_image.yml +0 -0
  34. {fastled-1.2.46 → fastled-1.2.49}/.github/workflows/test_build_exe.yml +0 -0
  35. {fastled-1.2.46 → fastled-1.2.49}/.github/workflows/test_macos.yml +0 -0
  36. {fastled-1.2.46 → fastled-1.2.49}/.github/workflows/test_ubuntu.yml +0 -0
  37. {fastled-1.2.46 → fastled-1.2.49}/.github/workflows/test_win.yml +0 -0
  38. {fastled-1.2.46 → fastled-1.2.49}/.gitignore +0 -0
  39. {fastled-1.2.46 → fastled-1.2.49}/.pylintrc +0 -0
  40. {fastled-1.2.46 → fastled-1.2.49}/.vscode/launch.json +0 -0
  41. {fastled-1.2.46 → fastled-1.2.49}/.vscode/settings.json +0 -0
  42. {fastled-1.2.46 → fastled-1.2.49}/.vscode/tasks.json +0 -0
  43. {fastled-1.2.46 → fastled-1.2.49}/Dockerfile +0 -0
  44. {fastled-1.2.46 → fastled-1.2.49}/LICENSE +0 -0
  45. {fastled-1.2.46 → fastled-1.2.49}/MANIFEST.in +0 -0
  46. {fastled-1.2.46 → fastled-1.2.49}/RELEASE.md +0 -0
  47. {fastled-1.2.46 → fastled-1.2.49}/TODO.md +0 -0
  48. {fastled-1.2.46 → fastled-1.2.49}/build_exe.py +0 -0
  49. {fastled-1.2.46 → fastled-1.2.49}/build_site.py +0 -0
  50. {fastled-1.2.46 → fastled-1.2.49}/clean +0 -0
  51. {fastled-1.2.46 → fastled-1.2.49}/compiler/CMakeLists.txt +0 -0
  52. {fastled-1.2.46 → fastled-1.2.49}/compiler/__init__.py +0 -0
  53. {fastled-1.2.46 → fastled-1.2.49}/compiler/arduino-pre-process.sh +0 -0
  54. {fastled-1.2.46 → fastled-1.2.49}/compiler/build.sh +0 -0
  55. {fastled-1.2.46 → fastled-1.2.49}/compiler/build_archive.sh +0 -0
  56. {fastled-1.2.46 → fastled-1.2.49}/compiler/build_fast.sh +0 -0
  57. {fastled-1.2.46 → fastled-1.2.49}/compiler/compile_lock.py +0 -0
  58. {fastled-1.2.46 → fastled-1.2.49}/compiler/entrypoint.sh +0 -0
  59. {fastled-1.2.46 → fastled-1.2.49}/compiler/extra/100dots.html +0 -0
  60. {fastled-1.2.46 → fastled-1.2.49}/compiler/extra/demo_threejs.html +0 -0
  61. {fastled-1.2.46 → fastled-1.2.49}/compiler/extra/webgl_postprocessing_unreal_bloom.html +0 -0
  62. {fastled-1.2.46 → fastled-1.2.49}/compiler/final_prewarm.sh +0 -0
  63. {fastled-1.2.46 → fastled-1.2.49}/compiler/install-arduino-cli.sh +0 -0
  64. {fastled-1.2.46 → fastled-1.2.49}/compiler/pre-process.sh +0 -0
  65. {fastled-1.2.46 → fastled-1.2.49}/compiler/prewarm.sh +0 -0
  66. {fastled-1.2.46 → fastled-1.2.49}/compiler/process-ino.py +0 -0
  67. {fastled-1.2.46 → fastled-1.2.49}/compiler/requirements.txt +0 -0
  68. {fastled-1.2.46 → fastled-1.2.49}/compiler/sketch_hasher.py +0 -0
  69. {fastled-1.2.46 → fastled-1.2.49}/compiler/wasm_compiler_flags.py +0 -0
  70. {fastled-1.2.46 → fastled-1.2.49}/docker-compose.yml +0 -0
  71. {fastled-1.2.46 → fastled-1.2.49}/install +0 -0
  72. {fastled-1.2.46 → fastled-1.2.49}/install_linux.sh +0 -0
  73. {fastled-1.2.46 → fastled-1.2.49}/pyproject.toml +0 -0
  74. {fastled-1.2.46 → fastled-1.2.49}/setup.cfg +0 -0
  75. {fastled-1.2.46 → fastled-1.2.49}/setup.py +0 -0
  76. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/app.py +0 -0
  77. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/assets/example.txt +0 -0
  78. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/cli.py +0 -0
  79. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/compile_server.py +0 -0
  80. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/compile_server_impl.py +0 -0
  81. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/interactive_srcs.py +0 -0
  82. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/keyboard.py +0 -0
  83. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/live_client.py +0 -0
  84. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/open_browser.py +0 -0
  85. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/open_browser2.py +0 -0
  86. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/parse_args.py +0 -0
  87. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/paths.py +0 -0
  88. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/project_init.py +0 -0
  89. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/select_sketch_directory.py +0 -0
  90. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/settings.py +0 -0
  91. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/site/build.py +0 -0
  92. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/sketch.py +0 -0
  93. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/spinner.py +0 -0
  94. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/string_diff.py +0 -0
  95. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/test/can_run_local_docker_tests.py +0 -0
  96. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/test/examples.py +0 -0
  97. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/types.py +0 -0
  98. {fastled-1.2.46 → fastled-1.2.49}/src/fastled/util.py +0 -0
  99. {fastled-1.2.46 → fastled-1.2.49}/src/fastled.egg-info/dependency_links.txt +0 -0
  100. {fastled-1.2.46 → fastled-1.2.49}/src/fastled.egg-info/entry_points.txt +0 -0
  101. {fastled-1.2.46 → fastled-1.2.49}/src/fastled.egg-info/requires.txt +0 -0
  102. {fastled-1.2.46 → fastled-1.2.49}/src/fastled.egg-info/top_level.txt +0 -0
  103. {fastled-1.2.46 → fastled-1.2.49}/test +0 -0
  104. {fastled-1.2.46 → fastled-1.2.49}/tests/html/index.html +0 -0
  105. {fastled-1.2.46 → fastled-1.2.49}/tests/test_api.py +0 -0
  106. {fastled-1.2.46 → fastled-1.2.49}/tests/test_bad_ino.py +0 -0
  107. {fastled-1.2.46 → fastled-1.2.49}/tests/test_build_examples.py +0 -0
  108. {fastled-1.2.46 → fastled-1.2.49}/tests/test_cli.py +0 -0
  109. {fastled-1.2.46 → fastled-1.2.49}/tests/test_compile_server.py +0 -0
  110. {fastled-1.2.46 → fastled-1.2.49}/tests/test_docker_linux_on_windows.py +0 -0
  111. {fastled-1.2.46 → fastled-1.2.49}/tests/test_embedded_data.py +0 -0
  112. {fastled-1.2.46 → fastled-1.2.49}/tests/test_examples.py +0 -0
  113. {fastled-1.2.46 → fastled-1.2.49}/tests/test_filechanger.py +0 -0
  114. {fastled-1.2.46 → fastled-1.2.49}/tests/test_ino/bad/bad.ino +0 -0
  115. {fastled-1.2.46 → fastled-1.2.49}/tests/test_ino/bad_platformio/bad_platformio.ino +0 -0
  116. {fastled-1.2.46 → fastled-1.2.49}/tests/test_ino/bad_platformio/platformio.ini +0 -0
  117. {fastled-1.2.46 → fastled-1.2.49}/tests/test_ino/embedded/data/bigdata.dat +0 -0
  118. {fastled-1.2.46 → fastled-1.2.49}/tests/test_ino/embedded/wasm.ino +0 -0
  119. {fastled-1.2.46 → fastled-1.2.49}/tests/test_ino/wasm/wasm.ino +0 -0
  120. {fastled-1.2.46 → fastled-1.2.49}/tests/test_project_init.py +0 -0
  121. {fastled-1.2.46 → fastled-1.2.49}/tests/test_server_and_client_seperatly.py +0 -0
  122. {fastled-1.2.46 → fastled-1.2.49}/tests/test_webcompile.py +0 -0
  123. {fastled-1.2.46 → fastled-1.2.49}/upload_package.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fastled
3
- Version: 1.2.46
3
+ Version: 1.2.49
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -294,7 +294,6 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
294
294
  Q: How can I get the compiled size of my FastLED sketch smaller?
295
295
  A: A big chunk of space is being used by unnecessary javascript `emscripten` bundling. The wasm_compiler_settings.py file in the FastLED repo can tweak this.
296
296
 
297
-
298
297
  # Revisions
299
298
 
300
299
  * 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
@@ -268,7 +268,6 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
268
268
  Q: How can I get the compiled size of my FastLED sketch smaller?
269
269
  A: A big chunk of space is being used by unnecessary javascript `emscripten` bundling. The wasm_compiler_settings.py file in the FastLED repo can tweak this.
270
270
 
271
-
272
271
  # Revisions
273
272
 
274
273
  * 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
@@ -5,12 +5,10 @@ from typing import Callable
5
5
 
6
6
  from compile_lock import COMPILE_LOCK
7
7
 
8
- VOLUME_MAPPED_SRC = Path("/host/fastled/src")
9
- RSYNC_DEST = Path("/js/fastled/src")
10
8
  TIME_START = time.time()
11
9
 
12
10
 
13
- def sync_src_to_target(
11
+ def _sync_src_to_target(
14
12
  src: Path, dst: Path, callback: Callable[[], None] | None = None
15
13
  ) -> bool:
16
14
  """Sync the volume mapped source directory to the FastLED source directory."""
@@ -70,13 +68,39 @@ def sync_src_to_target(
70
68
  return False
71
69
 
72
70
 
73
- def sync_source_directory_if_volume_is_mapped(
74
- callback: Callable[[], None] | None = None,
75
- ) -> bool:
76
- """Sync the volume mapped source directory to the FastLED source directory."""
77
- if not VOLUME_MAPPED_SRC.exists():
78
- # Volume is not mapped in so we don't rsync it.
79
- print("Skipping rsync, as fastled src volume not mapped")
80
- return False
81
- print("Syncing source directories because host is mapped in")
82
- return sync_src_to_target(VOLUME_MAPPED_SRC, RSYNC_DEST, callback=callback)
71
+ class CodeSync:
72
+
73
+ def __init__(self, volume_mapped_src: Path, rsync_dest: Path):
74
+ self.volume_mapped_src = volume_mapped_src
75
+ self.rsync_dest = rsync_dest
76
+
77
+ def sync_src_to_target(
78
+ self,
79
+ volume_mapped_src: Path | None = None,
80
+ rsync_dest: Path | None = None,
81
+ callback: Callable[[], None] | None = None,
82
+ ) -> bool:
83
+ """Sync the volume mapped source directory to the FastLED source directory."""
84
+
85
+ if volume_mapped_src is None or rsync_dest is None:
86
+ assert (
87
+ volume_mapped_src is None and rsync_dest is None
88
+ ), f"Both must be None: {volume_mapped_src} {rsync_dest}"
89
+ volume_mapped_src = volume_mapped_src or self.volume_mapped_src
90
+ rsync_dest = rsync_dest or self.rsync_dest
91
+ return _sync_src_to_target(
92
+ self.volume_mapped_src, self.rsync_dest, callback=callback
93
+ )
94
+
95
+ def sync_source_directory_if_volume_is_mapped(
96
+ self,
97
+ callback: Callable[[], None] | None = None,
98
+ ) -> bool:
99
+ """Sync the volume mapped source directory to the FastLED source directory."""
100
+ if not self.volume_mapped_src.exists():
101
+ # Volume is not mapped in so we don't rsync it.
102
+ print("Skipping rsync, as fastled src volume not mapped")
103
+ return False
104
+ print("Syncing source directories because host is mapped in")
105
+ out: bool = self.sync_src_to_target(callback=callback)
106
+ return out
@@ -17,12 +17,28 @@ import re
17
17
  import shutil
18
18
  import subprocess
19
19
  import sys
20
+ import traceback
20
21
  from dataclasses import dataclass
21
22
  from datetime import datetime
22
23
  from enum import Enum
23
24
  from pathlib import Path
24
25
  from typing import List
25
26
 
27
+ from paths import COMPILER_ROOT, FASTLED_COMPILER_DIR, PIO_BUILD_DIR, SKETCH_SRC
28
+
29
+ _FASTLED_MODULES_DIR = FASTLED_COMPILER_DIR / "modules"
30
+ _INDEX_HTML_SRC = FASTLED_COMPILER_DIR / "index.html"
31
+ _INDEX_CSS_SRC = FASTLED_COMPILER_DIR / "index.css"
32
+ _INDEX_JS_SRC = FASTLED_COMPILER_DIR / "index.js"
33
+
34
+
35
+ _WASM_COMPILER_SETTTINGS = FASTLED_COMPILER_DIR / "wasm_compiler_flags.py"
36
+ # _OUTPUT_FILES = ["fastled.js", "fastled.wasm"]
37
+ _HEADERS_TO_INSERT = ["#include <Arduino.h>", '#include "platforms/wasm/js.h"']
38
+ _FILE_EXTENSIONS = [".ino", ".h", ".hpp", ".cpp"]
39
+ # _MAX_COMPILE_ATTEMPTS = 1 # Occasionally the compiler fails for unknown reasons, but disabled because it increases the build time on failure.
40
+ _FASTLED_OUTPUT_DIR_NAME = "fastled_js"
41
+
26
42
 
27
43
  @dataclass
28
44
  class DateLine:
@@ -51,41 +67,6 @@ class SyntaxCheckResult:
51
67
  message: str
52
68
 
53
69
 
54
- _CHECK_SYNTAX = False
55
- _COMPILER_PATH = "em++"
56
-
57
- _JS_DIR = Path("/js")
58
- _FASTLED_DIR = _JS_DIR / "fastled"
59
- _FASTLED_SRC = _FASTLED_DIR / "src"
60
- # FASTLED_SRC_PLATFORMS = _FASTLED_SRC / "platforms"
61
- # FASTLED_SRC_PLATFORMS_WASM = FASTLED_SRC_PLATFORMS / "wasm"
62
- # _FASTLED_SRC_PLATFORMS_WASM_COMPILER = FASTLED_SRC_PLATFORMS_WASM / "compiler"
63
- _FASTLED_SRC_PLATFORMS_WASM_COMPILER = _JS_DIR / "compiler"
64
-
65
-
66
- _JS_SRC = _JS_DIR / "src"
67
-
68
- _FASTLED_DIR = _JS_DIR / "fastled"
69
- # FASTLED_SRC_DIR = _FASTLED_DIR / "src"
70
- # FASTLED_PLATFORMS_DIR = FASTLED_SRC_DIR / "platforms"
71
- # FASTLED_WASM_DIR = FASTLED_PLATFORMS_DIR / "wasm"
72
- _FASTLED_COMPILER_DIR = _JS_DIR / "compiler"
73
- _FASTLED_MODULES_DIR = _FASTLED_COMPILER_DIR / "modules"
74
-
75
- _PIO_BUILD_DIR = _JS_DIR / ".pio/build"
76
- _INDEX_HTML_SRC = _FASTLED_COMPILER_DIR / "index.html"
77
- _INDEX_CSS_SRC = _FASTLED_COMPILER_DIR / "index.css"
78
- _INDEX_JS_SRC = _FASTLED_COMPILER_DIR / "index.js"
79
-
80
-
81
- _WASM_COMPILER_SETTTINGS = _JS_DIR / "wasm_compiler_flags.py"
82
- _OUTPUT_FILES = ["fastled.js", "fastled.wasm"]
83
- _HEADERS_TO_INSERT = ["#include <Arduino.h>", '#include "platforms/wasm/js.h"']
84
- _FILE_EXTENSIONS = [".ino", ".h", ".hpp", ".cpp"]
85
- _MAX_COMPILE_ATTEMPTS = 1 # Occasionally the compiler fails for unknown reasons, but disabled because it increases the build time on failure.
86
- _FASTLED_OUTPUT_DIR_NAME = "fastled_js"
87
-
88
-
89
70
  def copy_files(src_dir: Path, js_src: Path) -> None:
90
71
  print("Copying files from mapped directory to container...")
91
72
  for item in src_dir.iterdir():
@@ -98,7 +79,7 @@ def copy_files(src_dir: Path, js_src: Path) -> None:
98
79
 
99
80
 
100
81
  def compile(
101
- _JS_DIR: Path, build_mode: BuildMode, auto_clean: bool, no_platformio: bool
82
+ compiler_root: Path, build_mode: BuildMode, auto_clean: bool, no_platformio: bool
102
83
  ) -> int:
103
84
  print("Starting compilation process...")
104
85
  max_attempts = 1
@@ -111,7 +92,7 @@ def compile(
111
92
  cmd_list = [
112
93
  "/bin/bash",
113
94
  "-c",
114
- "/js/build_fast.sh",
95
+ (compiler_root / "build_fast.sh").as_posix(),
115
96
  ]
116
97
  else:
117
98
  cmd_list.extend(["pio", "run"])
@@ -121,7 +102,7 @@ def compile(
121
102
  def _open_process(cmd_list: list[str] = cmd_list) -> subprocess.Popen:
122
103
  out = subprocess.Popen(
123
104
  cmd_list,
124
- cwd=_JS_DIR,
105
+ cwd=compiler_root,
125
106
  stdout=subprocess.PIPE,
126
107
  stderr=subprocess.STDOUT,
127
108
  universal_newlines=True,
@@ -135,6 +116,7 @@ def compile(
135
116
  print(f"Attempting compilation (attempt {attempt}/{max_attempts})...")
136
117
  process = _open_process()
137
118
  assert process.stdout is not None
119
+ line: str
138
120
  for line in process.stdout:
139
121
  processed_line = line.replace("fastled/src", "src")
140
122
  timestamped_line = _timestamp_output(processed_line)
@@ -221,89 +203,6 @@ def process_ino_files(src_dir: Path) -> None:
221
203
  print("Transform to cpp and insert header operations completed.")
222
204
 
223
205
 
224
- def check_syntax_with_gcc(file_path, gcc_path="gcc"):
225
- """
226
- Perform syntax checking on a C or C++ source file using GCC.
227
-
228
- Parameters:
229
- file_path (str): Path to the source file to check.
230
- gcc_path (str): Path to the GCC executable (default is 'gcc').
231
-
232
- Returns:
233
- bool: True if syntax is correct, False otherwise.
234
- str: Output or error message from GCC.
235
- """
236
- try:
237
- # Run GCC with -fsyntax-only flag for syntax checking
238
- cmd_list = [
239
- gcc_path,
240
- "-fsyntax-only",
241
- "-std=gnu++20",
242
- "-fpermissive",
243
- "-Wno-everything", # Suppress all warnings
244
- "-I",
245
- "/js/src/", # Add /js/src/ to the include path
246
- "-I",
247
- "/js/fastled/src/", # Add /js/fastled/src/ to the include path
248
- "-I",
249
- "/emsdk/upstream/emscripten/system/include",
250
- "-I",
251
- "/js/fastled/src/platforms/wasm/compiler", # Arduino.h and Arduino.cpp
252
- file_path,
253
- ]
254
- cmd_str = subprocess.list2cmdline(cmd_list)
255
- print(f"Running command: {cmd_str}")
256
- result = subprocess.run(
257
- cmd_list,
258
- stdout=subprocess.PIPE,
259
- stderr=subprocess.PIPE,
260
- text=True,
261
- )
262
-
263
- # Check the return code to determine if syntax is valid
264
- if result.returncode == 0:
265
- return True, "Syntax check passed successfully."
266
- else:
267
- return False, result.stderr
268
- except FileNotFoundError:
269
- return False, f"GCC not found at {gcc_path}."
270
- except Exception as e:
271
- return False, str(e)
272
-
273
-
274
- def check_syntax(
275
- directory_path: Path, gcc_path: str = "gcc"
276
- ) -> list[SyntaxCheckResult]:
277
- # os walk
278
- out: list[SyntaxCheckResult] = []
279
- exclusion_list = set("fastled_js")
280
- for root, dirs, files in os.walk(directory_path):
281
- # if sub directory is in exclusion list, skip
282
- dirs[:] = [d for d in dirs if d not in exclusion_list]
283
- for file in files:
284
- if file.endswith(".cpp") or file.endswith(".ino"):
285
- file_path = os.path.join(root, file)
286
- is_valid, message = check_syntax_with_gcc(file_path, gcc_path)
287
- if not is_valid:
288
- print(f"Syntax check failed for file: {file_path}")
289
- print(f"Error message: {message}")
290
- out.append(
291
- SyntaxCheckResult(
292
- file_path=Path(file_path), is_valid=False, message=message
293
- )
294
- )
295
- else:
296
- print(f"Syntax check passed for file: {file_path}")
297
- out.append(
298
- SyntaxCheckResult(
299
- file_path=Path(file_path),
300
- is_valid=True,
301
- message="Syntax check passed successfully.",
302
- )
303
- )
304
- return out
305
-
306
-
307
206
  def _make_timestamps_relative(stdout: str) -> str:
308
207
  def parse(line: str) -> DateLine:
309
208
  parts = line.split(" ")
@@ -351,7 +250,35 @@ def _timestamp_output(line: str) -> str:
351
250
  return f"{timestamp} {line.rstrip()}"
352
251
 
353
252
 
354
- def parse_args() -> argparse.Namespace:
253
+ @dataclass
254
+ class Args:
255
+ mapped_dir: Path
256
+ keep_files: bool
257
+ only_copy: bool
258
+ only_insert_header: bool
259
+ only_compile: bool
260
+ profile: bool
261
+ disable_auto_clean: bool
262
+ no_platformio: bool
263
+ debug: bool
264
+ quick: bool
265
+ release: bool
266
+
267
+ def __post_init__(self):
268
+ assert isinstance(self.mapped_dir, Path)
269
+ assert isinstance(self.keep_files, bool)
270
+ assert isinstance(self.only_copy, bool)
271
+ assert isinstance(self.only_insert_header, bool)
272
+ assert isinstance(self.only_compile, bool)
273
+ assert isinstance(self.profile, bool)
274
+ assert isinstance(self.disable_auto_clean, bool)
275
+ assert isinstance(self.no_platformio, bool)
276
+ assert isinstance(self.debug, bool)
277
+ assert isinstance(self.quick, bool)
278
+ assert isinstance(self.release, bool)
279
+
280
+
281
+ def parse_args() -> Args:
355
282
  parser = argparse.ArgumentParser(description="Compile FastLED for WASM")
356
283
  parser.add_argument(
357
284
  "--mapped-dir",
@@ -405,7 +332,20 @@ def parse_args() -> argparse.Namespace:
405
332
  "--release", action="store_true", help="Build in release mode"
406
333
  )
407
334
 
408
- return parser.parse_args()
335
+ tmp = parser.parse_args()
336
+ return Args(
337
+ mapped_dir=tmp.mapped_dir,
338
+ keep_files=tmp.keep_files,
339
+ only_copy=tmp.only_copy,
340
+ only_insert_header=tmp.only_insert_header,
341
+ only_compile=tmp.only_compile,
342
+ profile=tmp.profile,
343
+ disable_auto_clean=tmp.disable_auto_clean,
344
+ no_platformio=tmp.no_platformio,
345
+ debug=tmp.debug,
346
+ quick=tmp.quick,
347
+ release=tmp.release,
348
+ )
409
349
 
410
350
 
411
351
  def find_project_dir(mapped_dir: Path) -> Path:
@@ -420,10 +360,10 @@ def find_project_dir(mapped_dir: Path) -> Path:
420
360
 
421
361
 
422
362
  def process_compile(
423
- _JS_DIR: Path, build_mode: BuildMode, auto_clean: bool, no_platformio: bool
363
+ js_dir: Path, build_mode: BuildMode, auto_clean: bool, no_platformio: bool
424
364
  ) -> None:
425
365
  print("Starting compilation...")
426
- rtn = compile(_JS_DIR, build_mode, auto_clean, no_platformio=no_platformio)
366
+ rtn = compile(js_dir, build_mode, auto_clean, no_platformio=no_platformio)
427
367
  print(f"Compilation return code: {rtn}")
428
368
  if rtn != 0:
429
369
  print("Compilation failed.")
@@ -431,7 +371,7 @@ def process_compile(
431
371
  print("Compilation successful.")
432
372
 
433
373
 
434
- def cleanup(args: argparse.Namespace, js_src: Path) -> None:
374
+ def cleanup(args: Args, js_src: Path) -> None:
435
375
  if not args.keep_files and not (args.only_copy or args.only_insert_header):
436
376
  print("Removing temporary source files")
437
377
  shutil.rmtree(js_src)
@@ -447,33 +387,15 @@ def hash_file(file_path: Path) -> str:
447
387
  return hasher.hexdigest()
448
388
 
449
389
 
450
- def main() -> int:
451
-
452
- # assert _JS_DIR.exists()
453
- # assert ARDUINO_H_SRC.exists()
454
- # assert _INDEX_HTML_SRC.exists()
455
- # assert _INDEX_CSS_SRC.exists(), f"Index CSS not found at {_INDEX_CSS_SRC}"
456
- # assert _INDEX_JS_SRC.exists()
457
- # assert _WASM_COMPILER_SETTTINGS.exists()
458
- # assert _FASTLED_SRC_PLATFORMS_WASM_COMPILER.exists()
459
- # assert _JS_DIR.exists(), f"_JS_DIR does not exist: {_JS_DIR}"
460
- # assert ARDUINO_H_SRC.exists(), f"ARDUINO_H_SRC does not exist: {ARDUINO_H_SRC}"
461
- # assert _INDEX_HTML_SRC.exists(), f"_INDEX_HTML_SRC does not exist: {_INDEX_HTML_SRC}"
462
- # assert _INDEX_CSS_SRC.exists(), f"_INDEX_CSS_SRC does not exist: {_INDEX_CSS_SRC}"
463
- # assert _INDEX_JS_SRC.exists(), f"_INDEX_JS_SRC does not exist: {_INDEX_JS_SRC}"
464
- # assert (
465
- # _WASM_COMPILER_SETTTINGS.exists()
466
- # ), f"_WASM_COMPILER_SETTTINGS does not exist: {_WASM_COMPILER_SETTTINGS}"
467
-
390
+ def run(args: Args) -> int:
468
391
  check_paths: list[Path] = [
469
- _JS_DIR,
392
+ COMPILER_ROOT,
470
393
  _INDEX_HTML_SRC,
471
394
  _INDEX_CSS_SRC,
472
395
  _INDEX_JS_SRC,
473
396
  _WASM_COMPILER_SETTTINGS,
474
- _FASTLED_SRC_PLATFORMS_WASM_COMPILER,
397
+ FASTLED_COMPILER_DIR,
475
398
  ]
476
-
477
399
  missing_paths = [p for p in check_paths if not p.exists()]
478
400
  if missing_paths:
479
401
  print("The following paths are missing:")
@@ -483,7 +405,6 @@ def main() -> int:
483
405
  raise FileNotFoundError(f"Missing required paths: {missing_paths_str}")
484
406
 
485
407
  print("Starting FastLED WASM compilation script...")
486
- args = parse_args()
487
408
  print(f"Keep files flag: {args.keep_files}")
488
409
  print(f"Using mapped directory: {args.mapped_dir}")
489
410
 
@@ -493,9 +414,7 @@ def main() -> int:
493
414
  os.environ["EMPROFILE"] = "2"
494
415
 
495
416
  try:
496
- if _JS_SRC.exists():
497
- shutil.rmtree(_JS_SRC)
498
- _JS_SRC.mkdir(parents=True, exist_ok=True)
417
+
499
418
  src_dir = find_project_dir(args.mapped_dir)
500
419
 
501
420
  any_only_flags = args.only_copy or args.only_insert_header or args.only_compile
@@ -504,31 +423,23 @@ def main() -> int:
504
423
  do_insert_header = not any_only_flags or args.only_insert_header
505
424
  do_compile = not any_only_flags or args.only_compile
506
425
 
426
+ if not any_only_flags:
427
+ if SKETCH_SRC.exists():
428
+ shutil.rmtree(SKETCH_SRC)
429
+
430
+ SKETCH_SRC.mkdir(parents=True, exist_ok=True)
431
+
507
432
  if do_copy:
508
- copy_files(src_dir, _JS_SRC)
433
+ copy_files(src_dir, SKETCH_SRC)
509
434
  if args.only_copy:
510
435
  return 0
511
436
 
512
437
  if do_insert_header:
513
- process_ino_files(_JS_SRC)
438
+ process_ino_files(SKETCH_SRC)
514
439
  if args.only_insert_header:
515
440
  print("Transform to cpp and insert header operations completed.")
516
441
  return 0
517
442
 
518
- if _CHECK_SYNTAX:
519
- print("Performing syntax check...")
520
- syntax_results = check_syntax(
521
- directory_path=_JS_SRC, gcc_path=_COMPILER_PATH
522
- )
523
- failed_checks = [r for r in syntax_results if not r.is_valid]
524
- if failed_checks:
525
- print("\nSyntax check failed!")
526
- for result in failed_checks:
527
- print(f"\nFile: {result.file_path}")
528
- print(f"Error: {result.message}")
529
- return 1
530
- print("Syntax check passed for all files.")
531
-
532
443
  no_platformio: bool = args.no_platformio
533
444
 
534
445
  if do_compile:
@@ -543,7 +454,7 @@ def main() -> int:
543
454
  build_mode = BuildMode.QUICK
544
455
 
545
456
  process_compile(
546
- _JS_DIR=_JS_DIR,
457
+ js_dir=COMPILER_ROOT,
547
458
  build_mode=build_mode,
548
459
  auto_clean=not args.disable_auto_clean,
549
460
  no_platformio=no_platformio,
@@ -553,16 +464,16 @@ def main() -> int:
553
464
  return 1
554
465
 
555
466
  def _get_build_dir_platformio() -> Path:
556
- build_dirs = [d for d in _PIO_BUILD_DIR.iterdir() if d.is_dir()]
467
+ build_dirs = [d for d in PIO_BUILD_DIR.iterdir() if d.is_dir()]
557
468
  if len(build_dirs) != 1:
558
469
  raise RuntimeError(
559
- f"Expected exactly one build directory in {_PIO_BUILD_DIR}, found {len(build_dirs)}: {build_dirs}"
470
+ f"Expected exactly one build directory in {PIO_BUILD_DIR}, found {len(build_dirs)}: {build_dirs}"
560
471
  )
561
472
  build_dir: Path = build_dirs[0]
562
473
  return build_dir
563
474
 
564
475
  def _get_build_dir_cmake() -> Path:
565
- return _JS_DIR / "build"
476
+ return COMPILER_ROOT / "build"
566
477
 
567
478
  if no_platformio:
568
479
  build_dir = _get_build_dir_cmake()
@@ -570,45 +481,43 @@ def main() -> int:
570
481
  build_dir = _get_build_dir_platformio()
571
482
 
572
483
  print("Copying output files...")
573
- fastled__JS_DIR: Path = src_dir / _FASTLED_OUTPUT_DIR_NAME
574
- fastled__JS_DIR.mkdir(parents=True, exist_ok=True)
484
+ out_dir: Path = src_dir / _FASTLED_OUTPUT_DIR_NAME
485
+ out_dir.mkdir(parents=True, exist_ok=True)
575
486
 
576
487
  for file in ["fastled.js", "fastled.wasm"]:
577
488
  _src = build_dir / file
578
- _dst = fastled__JS_DIR / file
489
+ _dst = out_dir / file
579
490
  print(f"Copying {_src} to {_dst}")
580
491
  shutil.copy2(_src, _dst)
581
492
 
582
493
  print(f"Copying {_INDEX_HTML_SRC} to output directory")
583
- shutil.copy2(_INDEX_HTML_SRC, fastled__JS_DIR / "index.html")
494
+ shutil.copy2(_INDEX_HTML_SRC, out_dir / "index.html")
584
495
  print(f"Copying {_INDEX_CSS_SRC} to output directory")
585
- shutil.copy2(_INDEX_CSS_SRC, fastled__JS_DIR / "index.css")
496
+ shutil.copy2(_INDEX_CSS_SRC, out_dir / "index.css")
586
497
 
587
498
  # copy all js files in _FASTLED_COMPILER_DIR to output directory
588
- Path(fastled__JS_DIR / "modules").mkdir(parents=True, exist_ok=True)
499
+ Path(out_dir / "modules").mkdir(parents=True, exist_ok=True)
589
500
  for _file in _FASTLED_MODULES_DIR.iterdir():
590
501
  if _file.suffix == ".js":
591
502
  print(f"Copying {_file} to output directory")
592
- shutil.copy2(_file, fastled__JS_DIR / "modules" / _file.name)
503
+ shutil.copy2(_file, out_dir / "modules" / _file.name)
593
504
 
594
505
  fastled_js_mem = build_dir / "fastled.js.mem"
595
506
  fastled_wasm_map = build_dir / "fastled.wasm.map"
596
507
  fastled_js_symbols = build_dir / "fastled.js.symbols"
597
508
  if fastled_js_mem.exists():
598
509
  print(f"Copying {fastled_js_mem} to output directory")
599
- shutil.copy2(fastled_js_mem, fastled__JS_DIR / fastled_js_mem.name)
510
+ shutil.copy2(fastled_js_mem, out_dir / fastled_js_mem.name)
600
511
  if fastled_wasm_map.exists():
601
512
  print(f"Copying {fastled_wasm_map} to output directory")
602
- shutil.copy2(fastled_wasm_map, fastled__JS_DIR / fastled_wasm_map.name)
513
+ shutil.copy2(fastled_wasm_map, out_dir / fastled_wasm_map.name)
603
514
  if fastled_js_symbols.exists():
604
515
  print(f"Copying {fastled_js_symbols} to output directory")
605
- shutil.copy2(
606
- fastled_js_symbols, fastled__JS_DIR / fastled_js_symbols.name
607
- )
516
+ shutil.copy2(fastled_js_symbols, out_dir / fastled_js_symbols.name)
608
517
  print("Copying index.js to output directory")
609
- shutil.copy2(_INDEX_JS_SRC, fastled__JS_DIR / "index.js")
518
+ shutil.copy2(_INDEX_JS_SRC, out_dir / "index.js")
610
519
  optional_input_data_dir = src_dir / "data"
611
- output_data_dir = fastled__JS_DIR / optional_input_data_dir.name
520
+ output_data_dir = out_dir / optional_input_data_dir.name
612
521
 
613
522
  # Handle data directory if it exists
614
523
  manifest: list[dict] = []
@@ -657,15 +566,14 @@ def main() -> int:
657
566
  # Write manifest file even if empty
658
567
  print("Writing manifest files.json")
659
568
  manifest_json_str = json.dumps(manifest, indent=2, sort_keys=True)
660
- with open(fastled__JS_DIR / "files.json", "w") as f:
569
+ with open(out_dir / "files.json", "w") as f:
661
570
  f.write(manifest_json_str)
662
- cleanup(args, _JS_SRC)
571
+ cleanup(args, SKETCH_SRC)
663
572
 
664
573
  print("Compilation process completed successfully")
665
574
  return 0
666
575
 
667
576
  except Exception as e:
668
- import traceback
669
577
 
670
578
  stacktrace = traceback.format_exc()
671
579
  print(stacktrace)
@@ -673,5 +581,10 @@ def main() -> int:
673
581
  return 1
674
582
 
675
583
 
584
+ def main() -> int:
585
+ args = parse_args()
586
+ return run(args)
587
+
588
+
676
589
  if __name__ == "__main__":
677
590
  sys.exit(main())
@@ -4,18 +4,18 @@ import warnings
4
4
  from concurrent.futures import ThreadPoolExecutor
5
5
  from pathlib import Path
6
6
 
7
- HERE = Path(__file__).parent
8
-
7
+ COMPILER_ROOT = Path("/js")
8
+ COMPILER_DIR = COMPILER_ROOT / "compiler"
9
+ FASTLED_COMPILER_DIR = COMPILER_ROOT / "fastled/src/platforms/wasm/compiler"
9
10
 
10
- _COMPILER_DIR = Path("/js/compiler")
11
- _FASTLED_COMPILER_DIR = Path("/js/fastled/src/platforms/wasm/compiler")
11
+ HERE = Path(__file__).parent
12
12
 
13
13
 
14
14
  def copy_task(src: str | Path) -> None:
15
15
  src = Path(src)
16
16
  if "entrypoint.sh" in str(src):
17
17
  return
18
- link_dst = Path("/js") / src.name
18
+ link_dst = COMPILER_ROOT / src.name
19
19
 
20
20
  # Handle shell scripts
21
21
  if src.suffix == ".sh":
@@ -46,7 +46,6 @@ def make_links() -> None:
46
46
  "*.hpp",
47
47
  "*.cpp",
48
48
  "*.py",
49
- "*.css",
50
49
  "*.sh",
51
50
  "*.ino",
52
51
  "*.ini",
@@ -56,10 +55,10 @@ def make_links() -> None:
56
55
  # Get all matching files in compiler directory
57
56
  files = []
58
57
  for pattern in patterns:
59
- files.extend(glob.glob(str(_COMPILER_DIR / pattern)))
58
+ files.extend(glob.glob(str(COMPILER_DIR / pattern)))
60
59
 
61
60
  for pattern in patterns:
62
- files.extend(glob.glob(str(_FASTLED_COMPILER_DIR / pattern)))
61
+ files.extend(glob.glob(str(FASTLED_COMPILER_DIR / pattern)))
63
62
 
64
63
  # Process files in parallel using ThreadPoolExecutor
65
64
  with ThreadPoolExecutor(max_workers=16) as executor: