fastled 1.2.46__tar.gz → 1.2.47__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.
- {fastled-1.2.46 → fastled-1.2.47}/PKG-INFO +1 -2
- {fastled-1.2.46 → fastled-1.2.47}/README.md +0 -1
- {fastled-1.2.46 → fastled-1.2.47}/compiler/code_sync.py +37 -13
- {fastled-1.2.46 → fastled-1.2.47}/compiler/compile.py +101 -188
- {fastled-1.2.46 → fastled-1.2.47}/compiler/init_runtime.py +7 -8
- fastled-1.2.47/compiler/libcompile/CMakeLists.txt +152 -0
- fastled-1.2.47/compiler/paths.py +18 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/run.py +8 -21
- {fastled-1.2.46 → fastled-1.2.47}/compiler/server.py +42 -36
- {fastled-1.2.46 → fastled-1.2.47}/lint +5 -0
- {fastled-1.2.46 → fastled-1.2.47}/requirements.testing.txt +2 -1
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/__init__.py +1 -2
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/docker_manager.py +15 -13
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled.egg-info/PKG-INFO +1 -2
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled.egg-info/SOURCES.txt +2 -7
- fastled-1.2.46/compiler/index.css +0 -288
- fastled-1.2.46/compiler/index.html +0 -191
- fastled-1.2.46/compiler/index.js +0 -492
- fastled-1.2.46/compiler/modules/graphics_manager.js +0 -279
- fastled-1.2.46/compiler/modules/graphics_manager_threejs.js +0 -385
- fastled-1.2.46/compiler/modules/ui_manager.js +0 -252
- fastled-1.2.46/compiler/platformio.ini +0 -21
- {fastled-1.2.46 → fastled-1.2.47}/.aiderignore +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.dockerignore +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.github/workflows/build_multi_docker_image.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.github/workflows/build_webpage.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.github/workflows/lint.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.github/workflows/publish_release.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.github/workflows/template_build_docker_image.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.github/workflows/test_build_exe.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.github/workflows/test_macos.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.github/workflows/test_ubuntu.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.github/workflows/test_win.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.gitignore +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.pylintrc +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.vscode/launch.json +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.vscode/settings.json +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/.vscode/tasks.json +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/Dockerfile +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/LICENSE +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/MANIFEST.in +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/RELEASE.md +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/TODO.md +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/build_exe.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/build_site.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/clean +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/CMakeLists.txt +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/__init__.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/arduino-pre-process.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/build.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/build_archive.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/build_fast.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/compile_lock.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/entrypoint.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/extra/100dots.html +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/extra/demo_threejs.html +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/extra/webgl_postprocessing_unreal_bloom.html +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/final_prewarm.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/install-arduino-cli.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/pre-process.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/prewarm.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/process-ino.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/requirements.txt +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/sketch_hasher.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/compiler/wasm_compiler_flags.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/docker-compose.yml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/install +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/install_linux.sh +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/pyproject.toml +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/setup.cfg +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/setup.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/app.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/assets/example.txt +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/cli.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/client_server.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/compile_server.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/compile_server_impl.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/filewatcher.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/interactive_srcs.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/keyboard.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/live_client.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/open_browser.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/open_browser2.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/parse_args.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/paths.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/project_init.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/select_sketch_directory.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/settings.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/site/build.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/sketch.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/spinner.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/string_diff.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/test/can_run_local_docker_tests.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/test/examples.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/types.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/util.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled/web_compile.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled.egg-info/dependency_links.txt +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled.egg-info/entry_points.txt +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled.egg-info/requires.txt +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/src/fastled.egg-info/top_level.txt +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/test +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/html/index.html +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_api.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_bad_ino.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_build_examples.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_cli.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_compile_server.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_docker_linux_on_windows.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_embedded_data.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_examples.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_filechanger.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_http_server.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_ino/bad/bad.ino +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_ino/bad_platformio/bad_platformio.ino +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_ino/bad_platformio/platformio.ini +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_ino/embedded/data/bigdata.dat +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_ino/embedded/wasm.ino +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_ino/wasm/wasm.ino +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_project_init.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_server_and_client_seperatly.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/tests/test_webcompile.py +0 -0
- {fastled-1.2.46 → fastled-1.2.47}/upload_package.sh +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: fastled
|
3
|
-
Version: 1.2.
|
3
|
+
Version: 1.2.47
|
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
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
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
|
-
"
|
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=
|
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
|
-
|
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
|
-
|
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
|
-
|
363
|
+
js_dir: Path, build_mode: BuildMode, auto_clean: bool, no_platformio: bool
|
424
364
|
) -> None:
|
425
365
|
print("Starting compilation...")
|
426
|
-
rtn = compile(
|
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:
|
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
|
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
|
-
|
392
|
+
COMPILER_ROOT,
|
470
393
|
_INDEX_HTML_SRC,
|
471
394
|
_INDEX_CSS_SRC,
|
472
395
|
_INDEX_JS_SRC,
|
473
396
|
_WASM_COMPILER_SETTTINGS,
|
474
|
-
|
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
|
-
|
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,
|
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(
|
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
|
-
|
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
|
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 {
|
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
|
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
|
-
|
574
|
-
|
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 =
|
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,
|
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,
|
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(
|
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,
|
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,
|
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,
|
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,
|
518
|
+
shutil.copy2(_INDEX_JS_SRC, out_dir / "index.js")
|
610
519
|
optional_input_data_dir = src_dir / "data"
|
611
|
-
output_data_dir =
|
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(
|
569
|
+
with open(out_dir / "files.json", "w") as f:
|
661
570
|
f.write(manifest_json_str)
|
662
|
-
cleanup(args,
|
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
|
-
|
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
|
-
|
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 =
|
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(
|
58
|
+
files.extend(glob.glob(str(COMPILER_DIR / pattern)))
|
60
59
|
|
61
60
|
for pattern in patterns:
|
62
|
-
files.extend(glob.glob(str(
|
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:
|