fastled 1.2.40__tar.gz → 1.2.41__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 (125) hide show
  1. {fastled-1.2.40 → fastled-1.2.41}/.github/workflows/build_multi_docker_image.yml +8 -22
  2. fastled-1.2.41/Dockerfile +205 -0
  3. {fastled-1.2.40 → fastled-1.2.41}/PKG-INFO +3 -1
  4. {fastled-1.2.40 → fastled-1.2.41}/README.md +2 -0
  5. fastled-1.2.41/compiler/.dockerignore +2 -0
  6. fastled-1.2.41/compiler/Arduino.cpp +11 -0
  7. fastled-1.2.41/compiler/Arduino.h +162 -0
  8. fastled-1.2.41/compiler/CMakeLists.txt +139 -0
  9. fastled-1.2.41/compiler/arduino-pre-process.sh +3 -0
  10. fastled-1.2.41/compiler/build.sh +3 -0
  11. fastled-1.2.41/compiler/build_archive.sh +28 -0
  12. fastled-1.2.41/compiler/build_fast.sh +54 -0
  13. fastled-1.2.41/compiler/code_sync.py +76 -0
  14. fastled-1.2.41/compiler/compile.py +683 -0
  15. fastled-1.2.41/compiler/compile_lock.py +3 -0
  16. fastled-1.2.41/compiler/entrypoint.sh +7 -0
  17. fastled-1.2.41/compiler/extra/100dots.html +186 -0
  18. fastled-1.2.41/compiler/extra/demo_threejs.html +216 -0
  19. fastled-1.2.41/compiler/extra/webgl_postprocessing_unreal_bloom.html +191 -0
  20. fastled-1.2.41/compiler/final_prewarm.sh +26 -0
  21. fastled-1.2.41/compiler/index.css +288 -0
  22. fastled-1.2.41/compiler/index.html +191 -0
  23. fastled-1.2.41/compiler/index.js +492 -0
  24. fastled-1.2.41/compiler/init_runtime.py +63 -0
  25. fastled-1.2.41/compiler/install-arduino-cli.sh +41 -0
  26. fastled-1.2.41/compiler/modules/graphics_manager.js +279 -0
  27. fastled-1.2.41/compiler/modules/graphics_manager_threejs.js +375 -0
  28. fastled-1.2.41/compiler/modules/ui_manager.js +252 -0
  29. fastled-1.2.41/compiler/platformio.ini +19 -0
  30. fastled-1.2.41/compiler/pre-process.sh +27 -0
  31. fastled-1.2.41/compiler/prewarm.sh +43 -0
  32. fastled-1.2.41/compiler/process-ino.py +124 -0
  33. fastled-1.2.41/compiler/requirements.txt +12 -0
  34. fastled-1.2.41/compiler/run.py +125 -0
  35. fastled-1.2.41/compiler/server.py +773 -0
  36. fastled-1.2.41/compiler/sketch_hasher.py +254 -0
  37. fastled-1.2.41/compiler/wasm_compiler_flags.py +154 -0
  38. fastled-1.2.41/docker-compose.yml +9 -0
  39. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/__init__.py +63 -40
  40. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/compile_server_impl.py +0 -1
  41. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/docker_manager.py +3 -1
  42. fastled-1.2.41/src/fastled/interactive_srcs.py +5 -0
  43. {fastled-1.2.40 → fastled-1.2.41}/src/fastled.egg-info/PKG-INFO +3 -1
  44. {fastled-1.2.40 → fastled-1.2.41}/src/fastled.egg-info/SOURCES.txt +36 -0
  45. fastled-1.2.41/tests/test_ino/embedded/data/bigdata.dat +0 -0
  46. fastled-1.2.40/src/fastled/interactive_srcs.py +0 -5
  47. {fastled-1.2.40 → fastled-1.2.41}/.aiderignore +0 -0
  48. {fastled-1.2.40 → fastled-1.2.41}/.github/workflows/build_webpage.yml +0 -0
  49. {fastled-1.2.40 → fastled-1.2.41}/.github/workflows/lint.yml +0 -0
  50. {fastled-1.2.40 → fastled-1.2.41}/.github/workflows/publish_release.yml +0 -0
  51. {fastled-1.2.40 → fastled-1.2.41}/.github/workflows/test_build_exe.yml +0 -0
  52. {fastled-1.2.40 → fastled-1.2.41}/.github/workflows/test_macos.yml +0 -0
  53. {fastled-1.2.40 → fastled-1.2.41}/.github/workflows/test_ubuntu.yml +0 -0
  54. {fastled-1.2.40 → fastled-1.2.41}/.github/workflows/test_win.yml +0 -0
  55. {fastled-1.2.40 → fastled-1.2.41}/.gitignore +0 -0
  56. {fastled-1.2.40 → fastled-1.2.41}/.pylintrc +0 -0
  57. {fastled-1.2.40 → fastled-1.2.41}/.vscode/launch.json +0 -0
  58. {fastled-1.2.40 → fastled-1.2.41}/.vscode/settings.json +0 -0
  59. {fastled-1.2.40 → fastled-1.2.41}/.vscode/tasks.json +0 -0
  60. {fastled-1.2.40 → fastled-1.2.41}/LICENSE +0 -0
  61. {fastled-1.2.40 → fastled-1.2.41}/MANIFEST.in +0 -0
  62. {fastled-1.2.40 → fastled-1.2.41}/RELEASE.md +0 -0
  63. {fastled-1.2.40 → fastled-1.2.41}/TODO.md +0 -0
  64. {fastled-1.2.40 → fastled-1.2.41}/build_exe.py +0 -0
  65. {fastled-1.2.40 → fastled-1.2.41}/build_site.py +0 -0
  66. {fastled-1.2.40 → fastled-1.2.41}/clean +0 -0
  67. /fastled-1.2.40/tests/test_ino/embedded/data/bigdata.dat → /fastled-1.2.41/compiler/__init__.py +0 -0
  68. {fastled-1.2.40 → fastled-1.2.41}/install +0 -0
  69. {fastled-1.2.40 → fastled-1.2.41}/install_linux.sh +0 -0
  70. {fastled-1.2.40 → fastled-1.2.41}/lint +0 -0
  71. {fastled-1.2.40 → fastled-1.2.41}/pyproject.toml +0 -0
  72. {fastled-1.2.40 → fastled-1.2.41}/requirements.testing.txt +0 -0
  73. {fastled-1.2.40 → fastled-1.2.41}/setup.cfg +0 -0
  74. {fastled-1.2.40 → fastled-1.2.41}/setup.py +0 -0
  75. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/app.py +0 -0
  76. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/assets/example.txt +0 -0
  77. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/cli.py +0 -0
  78. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/client_server.py +0 -0
  79. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/compile_server.py +0 -0
  80. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/filewatcher.py +0 -0
  81. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/keyboard.py +0 -0
  82. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/live_client.py +0 -0
  83. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/open_browser.py +0 -0
  84. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/open_browser2.py +0 -0
  85. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/parse_args.py +0 -0
  86. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/paths.py +0 -0
  87. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/project_init.py +0 -0
  88. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/select_sketch_directory.py +0 -0
  89. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/settings.py +0 -0
  90. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/site/build.py +0 -0
  91. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/sketch.py +0 -0
  92. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/spinner.py +0 -0
  93. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/string_diff.py +0 -0
  94. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/test/can_run_local_docker_tests.py +0 -0
  95. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/test/examples.py +0 -0
  96. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/types.py +0 -0
  97. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/util.py +0 -0
  98. {fastled-1.2.40 → fastled-1.2.41}/src/fastled/web_compile.py +0 -0
  99. {fastled-1.2.40 → fastled-1.2.41}/src/fastled.egg-info/dependency_links.txt +0 -0
  100. {fastled-1.2.40 → fastled-1.2.41}/src/fastled.egg-info/entry_points.txt +0 -0
  101. {fastled-1.2.40 → fastled-1.2.41}/src/fastled.egg-info/requires.txt +0 -0
  102. {fastled-1.2.40 → fastled-1.2.41}/src/fastled.egg-info/top_level.txt +0 -0
  103. {fastled-1.2.40 → fastled-1.2.41}/test +0 -0
  104. {fastled-1.2.40 → fastled-1.2.41}/tests/html/index.html +0 -0
  105. {fastled-1.2.40 → fastled-1.2.41}/tests/test_api.py +0 -0
  106. {fastled-1.2.40 → fastled-1.2.41}/tests/test_bad_ino.py +0 -0
  107. {fastled-1.2.40 → fastled-1.2.41}/tests/test_build_examples.py +0 -0
  108. {fastled-1.2.40 → fastled-1.2.41}/tests/test_build_from_docker.py +0 -0
  109. {fastled-1.2.40 → fastled-1.2.41}/tests/test_build_from_github.py +0 -0
  110. {fastled-1.2.40 → fastled-1.2.41}/tests/test_cli.py +0 -0
  111. {fastled-1.2.40 → fastled-1.2.41}/tests/test_compile_server.py +0 -0
  112. {fastled-1.2.40 → fastled-1.2.41}/tests/test_docker_linux_on_windows.py +0 -0
  113. {fastled-1.2.40 → fastled-1.2.41}/tests/test_embedded_data.py +0 -0
  114. {fastled-1.2.40 → fastled-1.2.41}/tests/test_examples.py +0 -0
  115. {fastled-1.2.40 → fastled-1.2.41}/tests/test_filechanger.py +0 -0
  116. {fastled-1.2.40 → fastled-1.2.41}/tests/test_http_server.py +0 -0
  117. {fastled-1.2.40 → fastled-1.2.41}/tests/test_ino/bad/bad.ino +0 -0
  118. {fastled-1.2.40 → fastled-1.2.41}/tests/test_ino/bad_platformio/bad_platformio.ino +0 -0
  119. {fastled-1.2.40 → fastled-1.2.41}/tests/test_ino/bad_platformio/platformio.ini +0 -0
  120. {fastled-1.2.40 → fastled-1.2.41}/tests/test_ino/embedded/wasm.ino +0 -0
  121. {fastled-1.2.40 → fastled-1.2.41}/tests/test_ino/wasm/wasm.ino +0 -0
  122. {fastled-1.2.40 → fastled-1.2.41}/tests/test_project_init.py +0 -0
  123. {fastled-1.2.40 → fastled-1.2.41}/tests/test_server_and_client_seperatly.py +0 -0
  124. {fastled-1.2.40 → fastled-1.2.41}/tests/test_webcompile.py +0 -0
  125. {fastled-1.2.40 → fastled-1.2.41}/upload_package.sh +0 -0
@@ -20,27 +20,13 @@ jobs:
20
20
  uses: actions/checkout@v4
21
21
  with:
22
22
  fetch-depth: 2
23
- - name: Check FastLED repo
24
- uses: actions/checkout@v4
25
- with:
26
- repository: fastled/fastled
27
- path: fastled
28
23
  - id: check
29
24
  run: |
30
25
  # Check if there are any changes in workflow repository
31
- WORKFLOW_CHANGED=$(git diff --quiet HEAD^1 HEAD || echo "changed")
32
-
33
- # Check FastLED repo for changes in last 24 hours
34
- cd fastled
35
- FASTLED_CHANGED=$(git log --since="24 hours ago" --oneline | wc -l)
36
-
37
- if [[ -n "$WORKFLOW_CHANGED" ]] || [[ "$FASTLED_CHANGED" -gt 0 ]]; then
38
- echo "Changes detected in workflow repository or FastLED in last 24h"
39
- echo "should_run=true" >> $GITHUB_OUTPUT
40
- else
41
- echo "No recent changes detected"
42
- echo "should_run=false" >> $GITHUB_OUTPUT
43
- fi
26
+ # At this point always run, this used to trigger on changes to fastled repo (mostly for the compiler stuff)
27
+ # but that has been moved to this repo.
28
+ echo "should_run=true" >> $GITHUB_OUTPUT
29
+
44
30
 
45
31
  build-amd64:
46
32
  needs: check-if-changed
@@ -73,8 +59,8 @@ jobs:
73
59
  uses: docker/build-push-action@v6
74
60
  with:
75
61
  platforms: ${{ matrix.platform }}
76
- context: https://github.com/fastled/fastled.git
77
- file: src/platforms/wasm/compiler/Dockerfile
62
+ context: https://github.com/zackees/fastled-wasm.git
63
+ file: Dockerfile
78
64
  labels: ${{ steps.meta.outputs.labels }}
79
65
  outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
80
66
  build-args: |
@@ -125,8 +111,8 @@ jobs:
125
111
  uses: docker/build-push-action@v6
126
112
  with:
127
113
  platforms: ${{ matrix.platform }}
128
- context: https://github.com/fastled/fastled.git
129
- file: src/platforms/wasm/compiler/Dockerfile
114
+ context: https://github.com/zackees/fastled-wasm.git
115
+ file: Dockerfile
130
116
  labels: ${{ steps.meta.outputs.labels }}
131
117
  outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
132
118
  build-args: |
@@ -0,0 +1,205 @@
1
+ # Overview of this docker file
2
+ # This is a emscripten docker file that is used to compile FastLED for the web assembly platform.
3
+ # The goals of this docker are:
4
+ # * Compile the inputs as quickly as possible.
5
+ # * Be very fast to rebuild
6
+ # Container size is important, but not the primary goal.
7
+ #
8
+ # The emscripten build is based on emscripten. We create a custom `wasm_compiler_flags.py``
9
+ # that performs the necessary transformations to make this work.
10
+ #
11
+ # Maximizing compiler speed
12
+ # First let's talk about why platformio is typically slow
13
+ # * Network checking to see if the repo's are up to date
14
+ # * Unnecessary recompilation of cpp files that haven't changed.
15
+ #
16
+ # We address these slow compiler speeds via a few tricks
17
+ # * The emscripten compiler is wrapped in ccache so that identical compilations are cached.
18
+ # * We prewarm the ccache with a pre-compile of an example
19
+ # * This will generate the initial cache and also install the necessary tools.
20
+ #
21
+ # Pre-warming the cache
22
+ # * We have two pre-warm cycles. We do this for speed reasons.
23
+ # * The first pre-warm is done with a copy of fastled downloaded from the github repo
24
+ # * Docker is very relaxed on invalidating a cache layer for statements cloning a github repo. We want this.
25
+ # * So we clone the repo early in the docker image build cycle. Then we run a pre-warm compile.
26
+ # * This is the slowest pre-warm, and once built, tends to always be cached. However, it tends to go out of date
27
+ # quickly, which will make the cache be less effective.
28
+ # * The second pre-warm is done with a fresh copy of the fastled repo from the host machine that is copied over the
29
+ # git hub repo. We copy directories piece by piece to maximize the cache hit rate. Core files then platform files.
30
+ # * During developement when many files are changed, this second pre-warm will almost always be invalidated, however
31
+ # it is very fast to rebuild because the initial tool download of platformio has already been done with the first pre-warm.
32
+ # * After this second pre-warm, the ccache will have the exact state of the repo in it's cache.
33
+ #
34
+ # Final state
35
+ # * The final state of the docker image is a pre-warmed cached with the entire instance ready to compile.
36
+ # * The calling code is expected to provide volume mapped directory that will be inserted into the docker image when it runs.
37
+ # * However, this is not true when using this in server mode (see server.py) where the code to be compiled is injected into the
38
+ # container instance via a FastAPI route, the compilation is performed. Typically the web compiler is much better at holding
39
+ # on the cached files. Server.py will also periodically git pull the fastled repo to keep in sync with the latest changes.
40
+
41
+
42
+ # This will be set to arm64 to support MacOS M1+ devices (and Linux-based arm64 devices)
43
+ ARG PLATFORM_TAG=""
44
+
45
+ # Use only Emscripten base image
46
+ FROM emscripten/emsdk:3.1.70${PLATFORM_TAG}
47
+
48
+
49
+ ENV DEBIAN_FRONTEND=noninteractive
50
+
51
+ # Update the apt-get package list. This takes a long time, so we do it first to maximize cache hits.
52
+ # Also install apt-fast first
53
+ RUN apt-get update
54
+
55
+ RUN apt-get install -y software-properties-common
56
+
57
+ RUN add-apt-repository ppa:apt-fast/stable -y && \
58
+ apt-get update && \
59
+ apt-get -y install apt-fast
60
+
61
+ # Update apt and install required packages
62
+ RUN apt-fast install -y \
63
+ git \
64
+ gawk \
65
+ nano \
66
+ ca-certificates \
67
+ python3 \
68
+ python3-pip \
69
+ dos2unix \
70
+ tar \
71
+ wget \
72
+ unzip \
73
+ make \
74
+ cmake \
75
+ ninja-build \
76
+ ccache \
77
+ zlib1g \
78
+ zlib1g-dev \
79
+ gcc \
80
+ g++ \
81
+ rsync \
82
+ && rm -rf /var/lib/apt/lists/*
83
+
84
+
85
+ # /container/bin contains symbolic links to python3 and pip3 as python and pip that we use for the compiler.
86
+ RUN mkdir -p /container/bin && \
87
+ ln -s /usr/bin/python3 /container/bin/python && \
88
+ ln -s /usr/bin/pip3 /container/bin/pip
89
+
90
+
91
+ # Add Python and Emscripten to PATH
92
+ ENV PATH="/container/bin:/usr/local/bin:/usr/bin:/emsdk:/emsdk/upstream/emscripten:${PATH}"
93
+ ENV CCACHE_DIR=/ccache
94
+ ENV CCACHE_MAXSIZE=1G
95
+
96
+ # Create a custom print script
97
+ RUN echo '#!/bin/sh' > /usr/bin/print && \
98
+ echo 'echo "$@"' >> /usr/bin/print && \
99
+ chmod +x /usr/bin/print
100
+
101
+ # Add print function (which seems to be missing, strangly) and PATH modifications to /etc/profile
102
+ RUN echo 'print() { echo "$@"; }' >> /etc/profile && \
103
+ echo 'export -f print' >> /etc/profile && \
104
+ echo 'export PATH="/container/bin:/usr/bin:/emsdk:/emsdk/upstream/emscripten:$PATH"' >> /etc/profile && \
105
+ echo 'source /emsdk/emsdk_env.sh' >> /etc/profile
106
+
107
+ # This was added to try and fix formatting issues. It didn't fix it but it's better to force everything to use
108
+ # utf-8, as god intended it.
109
+ ENV LANG=en_US.UTF-8
110
+ ENV LC_CTYPE=UTF-8
111
+ RUN echo 'export LANG=en_US.UTF-8' >> /etc/profile && \
112
+ echo 'export LC_CTYPE=UTF-8' >> /etc/profile
113
+
114
+ # This is disabled code to try and use the arduino-cli to transform an *.ino file into a cpp file
115
+ # to enable the auto-predeclaration of missing functions. However, Arduino-cli is absolutely gigantic
116
+ # and requires that we compile it against one of the platforms. This doesn't work for us because
117
+ # we don't want a compile failure because of something weird in the platform we are compiling against, which
118
+ # isn't wasm.
119
+ #COPY compiler/install-arduino-cli.sh /install-arduino-cli.sh
120
+ #RUN chmod +x /install-arduino-cli.sh && /install-arduino-cli.sh || echo "Failed to install Arduino CLI"
121
+
122
+ RUN pip install uv==0.5.6
123
+
124
+ # Get the compiler requirements and install them.
125
+ COPY compiler/requirements.txt /install/requirements.txt
126
+ RUN uv pip install --system -r /install/requirements.txt
127
+
128
+ RUN pio settings set check_platformio_interval 9999
129
+ RUN pio settings set enable_telemetry 0
130
+
131
+ # FIRST PRE-WARM CYCLE and initial setup: Download the fastled repo from the github and pre-warm the cache with a compilation.
132
+ # This is by far the most expensive part of the build, because platformio needs to download initial tools. This
133
+ # pre-warm cycle is "sticky" and tends to stay in the cache for a long time since docker is very relaxed about
134
+ # invalidating cache layers that clone a github repo.
135
+
136
+ ARG FASTLED_BUILD_DAY=echo $(date +'%Y-%m-%d')
137
+ ENV FASTLED_BUILD_DAY=${FASTLED_BUILD_DAY}
138
+
139
+ ARG FASTLED_VERSION=master
140
+ ENV FASTLED_VERSION=${FASTLED_VERSION}
141
+ RUN git clone -b ${FASTLED_VERSION} https://github.com/fastled/FastLED.git --depth 1 /git/fastled && \
142
+ mkdir -p /js/fastled && \
143
+ rsync -a /git/fastled/ /js/fastled/ --exclude='.git'
144
+
145
+ # Create symlinks for wasm platform files.
146
+ COPY compiler/init_runtime.py /js/init_runtime.py
147
+ COPY compiler/prewarm.sh /js/prewarm.sh
148
+
149
+ WORKDIR /js
150
+
151
+ ARG NO_PREWARM=0
152
+ ENV NO_PREWARM=${NO_PREWARM}
153
+
154
+ RUN python /js/init_runtime.py || true
155
+
156
+
157
+ # First pre-warm cycle - always do it as part of the build.
158
+ RUN mkdir -p /logs
159
+
160
+ # Force a build if the compiler flags change.
161
+ COPY compiler/wasm_compiler_flags.py /trash/wasm_compiler_flags.py
162
+ COPY compiler/CMakeLists.txt /trash/CMakeLists.txt
163
+ RUN rm -rf /trash
164
+
165
+ RUN chmod +x /js/prewarm.sh && \
166
+ cat /js/prewarm.sh >> /logs/prewarm.log.0
167
+ RUN /js/prewarm.sh --force >> /logs/prewarm.log.1 || true
168
+
169
+
170
+ # # Copy the fastled repo from the host machine and prepare for pre-warm
171
+ # # Make sure and delete files that have been removed so that we don't get
172
+ # # duplicate symbols from stale files.
173
+ # COPY *.json /host/fastled/
174
+ # COPY src/*.* /host/fastled/src/
175
+ # COPY examples /host/fastled/examples
176
+ # COPY src/fx /host/fastled/src/fx
177
+ # COPY src/fl /host/fastled/src/fl
178
+ # COPY src/lib8tion /host/fastled/src/lib8tion
179
+ # COPY src/third_party /host/fastled/src/third_party
180
+ # COPY src/sensors /host/fastled/src/sensors
181
+ # COPY src/platforms /host/fastled/src/platforms
182
+
183
+ COPY compiler /js/compiler
184
+
185
+ COPY compiler/entrypoint.sh /entrypoint.sh
186
+ RUN chmod +x /entrypoint.sh && dos2unix /entrypoint.sh
187
+
188
+ # RSYNC DISABLED FOR NOW
189
+ # now sync local to the source directory.
190
+ # RUN rsync -av /host/fastled/ /js/fastled/ && rm -rf /host/fastled
191
+
192
+ RUN python /js/init_runtime.py || true
193
+
194
+
195
+ # SECOND PRE-WARM CYCLE: Copy the fastled repo from the host machine and pre-warm the cache with that compilation. This will
196
+ # be much quicker than the first pre-warm cycle.
197
+ RUN /js/prewarm.sh --force > /logs/prewarm.log.2 || true
198
+
199
+ # Now timestamp the image and store it at the end of the build.
200
+ RUN date > /image_timestamp.txt
201
+
202
+ ENTRYPOINT ["/entrypoint.sh"]
203
+ CMD ["python", "/js/run.py", "server"]
204
+
205
+ # CMD ["/bin/bash", "/entrypoint.sh"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fastled
3
- Version: 1.2.40
3
+ Version: 1.2.41
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -294,6 +294,8 @@ 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
299
  # Revisions
298
300
 
299
301
  * 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
@@ -268,6 +268,8 @@ 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
273
  # Revisions
272
274
 
273
275
  * 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
@@ -0,0 +1,2 @@
1
+ **/.mypy_cache/
2
+ **/.ruff_cache/
@@ -0,0 +1,11 @@
1
+
2
+ #ifdef __EMSCRIPTEN__
3
+
4
+ #include "./Arduino.h"
5
+
6
+ SerialEmulation Serial;
7
+ SerialEmulation Serial1;
8
+ SerialEmulation Serial2;
9
+ SerialEmulation Serial3;
10
+
11
+ #endif
@@ -0,0 +1,162 @@
1
+ // Arduino.h emulation for the WebAssembly platform.
2
+ // This allows us to compile sketches as is for the WebAssembly platform.
3
+
4
+ #pragma once
5
+
6
+ #include "fl/str.h"
7
+ #include <algorithm>
8
+ #include <random>
9
+ #include <stdint.h>
10
+ #include <stdio.h>
11
+ #include <string>
12
+
13
+ #include "fl/namespace.h"
14
+
15
+ FASTLED_USING_NAMESPACE
16
+
17
+ using std::max;
18
+ using std::min;
19
+
20
+
21
+ namespace fl {
22
+ class Str;
23
+ inline long map(long x, long in_min, long in_max, long out_min, long out_max) {
24
+ const long run = in_max - in_min;
25
+ if (run == 0) {
26
+ return 0; // AVR returns -1, SAM returns 0
27
+ }
28
+ const long rise = out_max - out_min;
29
+ const long delta = x - in_min;
30
+ return (delta * rise) / run + out_min;
31
+ }
32
+
33
+ // constrain
34
+ template <typename T> T constrain(T x, T a, T b) {
35
+ return x < a ? a : (x > b ? b : x);
36
+ }
37
+ } // namespace fl
38
+
39
+
40
+ using fl::map;
41
+ using fl::constrain;
42
+
43
+
44
+ inline long random(long min, long max) {
45
+ std::random_device rd;
46
+ std::mt19937 gen(rd());
47
+ // Arduino random is exclusive of the max value, but
48
+ // std::uniform_int_distribution is inclusive. So we subtract 1 from the max
49
+ // value.
50
+ std::uniform_int_distribution<> dis(min, max - 1);
51
+ return dis(gen);
52
+ }
53
+
54
+
55
+ inline int analogRead(int) { return random(0, 1023); }
56
+
57
+ inline long random(long max) { return random(0, max); }
58
+
59
+ template <typename T> struct PrintHelper {};
60
+
61
+ #define DEFINE_PRINT_HELPER(type, format) \
62
+ template <> struct PrintHelper<type> { \
63
+ static void print(type val) { printf(format, val); } \
64
+ static void println(type val) { \
65
+ printf(format, val); \
66
+ printf("\n"); \
67
+ } \
68
+ }
69
+
70
+ #define DEFINE_PRINT_HELPER_EXT(type, format, val_opp) \
71
+ template <> struct PrintHelper<type> { \
72
+ static void print(type val) { printf(format, val_opp); } \
73
+ static void println(type val) { \
74
+ printf(format, val_opp); \
75
+ printf("\n"); \
76
+ } \
77
+ }
78
+
79
+ // gcc push options
80
+ #pragma GCC diagnostic push
81
+ #pragma GCC diagnostic ignored "-Wformat"
82
+
83
+ DEFINE_PRINT_HELPER(double, "%f");
84
+ DEFINE_PRINT_HELPER(float, "%f");
85
+ DEFINE_PRINT_HELPER(const char *, "%s");
86
+ DEFINE_PRINT_HELPER(uint64_t, "%lu");
87
+ DEFINE_PRINT_HELPER(uint32_t, "%u");
88
+ DEFINE_PRINT_HELPER(uint16_t, "%u");
89
+ DEFINE_PRINT_HELPER(uint8_t, "%u");
90
+ DEFINE_PRINT_HELPER(int64_t, "%ld");
91
+ DEFINE_PRINT_HELPER(int32_t, "%d");
92
+ DEFINE_PRINT_HELPER(int16_t, "%d");
93
+ DEFINE_PRINT_HELPER(int8_t, "%d");
94
+ DEFINE_PRINT_HELPER(bool, "%d");
95
+ DEFINE_PRINT_HELPER_EXT(std::string, "%s", val.c_str());
96
+ DEFINE_PRINT_HELPER_EXT(fl::Str, "%s", val.c_str());
97
+
98
+ #ifdef __EMSCRIPTEN__
99
+ DEFINE_PRINT_HELPER(unsigned long, "%lu"); // Not sure why this is needed in emscripten
100
+ #endif
101
+
102
+ #define A0 0
103
+ #define A1 1
104
+ #define A2 2
105
+ #define A3 3
106
+ #define A4 4
107
+ #define A5 5
108
+
109
+
110
+ // gcc pop options
111
+ #pragma GCC diagnostic pop
112
+
113
+ struct SerialEmulation {
114
+ void begin(int) {}
115
+ template <typename T> void print(T val) { PrintHelper<T>::print(val); }
116
+ template <typename T> void println(T val) { PrintHelper<T>::println(val); }
117
+ void println() { printf("\n"); }
118
+ int available() { return 0; }
119
+ int read() { return 0; }
120
+ void write(uint8_t) {}
121
+ void write(const char *s) { printf("%s", s); }
122
+ void write(const uint8_t *s, size_t n) { fwrite(s, 1, n, stdout); }
123
+ void write(const char *s, size_t n) { fwrite(s, 1, n, stdout); }
124
+ void flush() {}
125
+ void end() {}
126
+ uint8_t peek() { return 0; }
127
+ };
128
+
129
+ #define LED_BUILTIN 13
130
+ #define HIGH 1
131
+ #define LOW 0
132
+ #define INPUT 0
133
+ #define OUTPUT 1
134
+ #define INPUT_PULLUP 2
135
+
136
+
137
+ inline void digitalWrite(int, int) {}
138
+ inline void analogWrite(int, int) {}
139
+ inline int digitalRead(int) { return LOW; }
140
+ inline void pinMode(int, int) {}
141
+
142
+ // avr flash memory macro is disabled.
143
+ #ifdef F
144
+ #undef F
145
+ #endif
146
+
147
+ #define F(x) x
148
+
149
+ // Found in the wild for scintillating example
150
+ #ifdef FL_PGM_READ_PTR_NEAR
151
+ #undef FL_PGM_READ_PTR_NEAR
152
+ #endif
153
+
154
+ #define FL_PGM_READ_PTR_NEAR(addr) (*(addr))
155
+ typedef unsigned char byte;
156
+
157
+ extern SerialEmulation Serial;
158
+ extern SerialEmulation Serial1;
159
+ extern SerialEmulation Serial2;
160
+ extern SerialEmulation Serial3;
161
+ typedef SerialEmulation HardwareSerial;
162
+ typedef SerialEmulation SoftwareSerial;
@@ -0,0 +1,139 @@
1
+ cmake_minimum_required(VERSION 3.10)
2
+ project(FastLED_WASM)
3
+
4
+ # Enable verbose makefile output for all compiled sources
5
+ set(CMAKE_VERBOSE_MAKEFILE ON)
6
+
7
+ # --- Set Emscripten as the Compiler ---
8
+ set(CMAKE_C_COMPILER "emcc")
9
+ set(CMAKE_CXX_COMPILER "em++")
10
+ set(CMAKE_AR "emar")
11
+ set(CMAKE_RANLIB "emranlib")
12
+
13
+ # Use ccache as a compiler launcher (requires CMake 3.4 or newer)
14
+ set(CMAKE_C_COMPILER_LAUNCHER "ccache")
15
+ set(CMAKE_CXX_COMPILER_LAUNCHER "ccache")
16
+
17
+ # --- Build Mode and Optimization Level ---
18
+ if(NOT DEFINED ENV{BUILD_MODE})
19
+ set(BUILD_MODE "QUICK")
20
+ else()
21
+ set(BUILD_MODE $ENV{BUILD_MODE})
22
+ endif()
23
+
24
+ if(BUILD_MODE STREQUAL "QUICK")
25
+ set(OPT_LEVEL "-O0")
26
+ elseif(BUILD_MODE STREQUAL "DEBUG")
27
+ set(OPT_LEVEL "-Og")
28
+ else() # RELEASE
29
+ set(OPT_LEVEL "-Oz")
30
+ endif()
31
+
32
+ # --- Common Compiler and Linker Flags ---
33
+ set(COMMON_COMPILE_FLAGS
34
+ -DFASTLED_ENGINE_EVENTS_MAX_LISTENERS=50
35
+ -DFASTLED_FORCE_NAMESPACE=1
36
+ -DFASTLED_NO_FORCE_INLINE
37
+ -DFASTLED_USE_PROGMEM=0
38
+ -DDISABLE_EXCEPTION_CATCHING=1
39
+ -fno-exceptions
40
+ -fno-rtti
41
+ -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0
42
+ -std=gnu++17
43
+ -fpermissive
44
+ -fno-inline
45
+ -Wno-constant-logical-operand
46
+ -Wnon-c-typedef-for-linkage
47
+ -Werror=bad-function-cast
48
+ -Werror=cast-function-type
49
+ -sUSE_PTHREADS=0 # Disable threading support
50
+ ${OPT_LEVEL}
51
+ )
52
+
53
+ # (Optional: PROFILE flags can be added here if needed)
54
+
55
+ set(COMMON_LINK_FLAGS
56
+ -sALLOW_MEMORY_GROWTH=0
57
+ -sDISABLE_EXCEPTION_CATCHING=1
58
+ -sDISABLE_EXCEPTION_THROWING=0
59
+ -sWASM_BIGINT
60
+ --bind
61
+ -DUSE_OFFSET_CONVERTER=0
62
+ -sINITIAL_MEMORY=134217728
63
+ -fuse-ld=lld
64
+ --no-entry
65
+ -sMODULARIZE=1
66
+ )
67
+
68
+ set(LIBRARY_LINK_FLAGS
69
+ ${COMMON_LINK_FLAGS}
70
+ )
71
+
72
+ set(SKETCH_LINK_FLAGS
73
+ ${COMMON_LINK_FLAGS}
74
+ -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap','stringToUTF8','lengthBytesUTF8']
75
+ -sEXPORTED_FUNCTIONS=['_malloc','_free','_extern_setup','_extern_loop','_fastled_declare_files']
76
+ -sEXPORT_NAME=fastled
77
+ -o fastled.js
78
+ )
79
+
80
+ if(BUILD_MODE STREQUAL "DEBUG")
81
+ list(APPEND COMMON_COMPILE_FLAGS
82
+ -g3
83
+ -fsanitize=address
84
+ -fsanitize=undefined
85
+ )
86
+ set(DEBUG_LINK_FLAGS
87
+ -gsource-map
88
+ --emit-symbol-map
89
+ -sSTACK_OVERFLOW_CHECK=2
90
+ -ASSERTIONS=1
91
+ )
92
+ list(APPEND LIBRARY_LINK_FLAGS ${DEBUG_LINK_FLAGS})
93
+ list(APPEND SKETCH_LINK_FLAGS ${DEBUG_LINK_FLAGS})
94
+ endif()
95
+
96
+ # --- FASTLED LIBRARY SETUP ---
97
+ set(LIBFASTLED_PATH /precompiled/libfastled.a)
98
+
99
+ if(EXISTS ${LIBFASTLED_PATH})
100
+ message(STATUS "Found prebuilt libfastled.a at ${LIBFASTLED_PATH}, skipping build of FastLED library.")
101
+ add_library(fastled STATIC IMPORTED)
102
+ set_target_properties(fastled PROPERTIES IMPORTED_LOCATION ${LIBFASTLED_PATH})
103
+ else()
104
+ message(FATAL_ERROR "Did not find precompiled libfastled.a at ${LIBFASTLED_PATH}. Please build the library first.")
105
+ endif()
106
+
107
+ if(TARGET fastled)
108
+ set_target_properties(fastled PROPERTIES
109
+ CXX_STANDARD 17
110
+ CXX_STANDARD_REQUIRED ON
111
+ POSITION_INDEPENDENT_CODE ON
112
+ )
113
+ endif()
114
+
115
+ # --- LIBRARY TARGET: sketch_lib ---
116
+ file(GLOB_RECURSE ALL_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
117
+ message(STATUS "All sources: ${ALL_SOURCES}")
118
+
119
+ add_library(sketch_lib STATIC ${ALL_SOURCES})
120
+
121
+ target_compile_options(sketch_lib PRIVATE ${COMMON_COMPILE_FLAGS})
122
+ target_compile_definitions(sketch_lib PRIVATE SKETCH_COMPILE)
123
+ target_include_directories(sketch_lib PRIVATE
124
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
125
+ "/precompiled/include"
126
+ )
127
+ set_target_properties(sketch_lib PROPERTIES
128
+ CXX_STANDARD 17
129
+ CXX_STANDARD_REQUIRED ON
130
+ )
131
+
132
+ # ── FINAL LINKING STEP: Produce fastled.js ──
133
+ # This custom target invokes em++ to link the static library (sketch_lib)
134
+ # with the precompiled libfastled.a into the final binary fastled.js.
135
+ add_custom_target(final_wasm ALL
136
+ COMMAND em++ ${SKETCH_LINK_FLAGS} -Wl,--whole-archive $<TARGET_FILE:sketch_lib> -Wl,--no-whole-archive /precompiled/libfastled.a
137
+ DEPENDS sketch_lib fastled
138
+ COMMENT "Linking final wasm binary to fastled.js"
139
+ )
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ arduino-cli compile --preprocess --fqbn arduino:avr:uno /pre-warm/Blink/Blink.ino
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ python compile.py --no-platformio
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+ set -e # Exit immediately if a command exits with a non-zero status
3
+ set -x
4
+
5
+ # if /include does not exist
6
+ if [ ! -d "/precompiled/include" ]; then
7
+ echo "include directory does not exist, copying header include tree"
8
+ # echo "include directory does not exist, copying header include tree"
9
+ # copy *.h,*.hpp files from fastled/src/** to /include
10
+ mkdir -p /precompiled/include
11
+ cd fastled/src
12
+ find . -name "*.h*" -exec cp --parents {} /precompiled/include \;
13
+ cd ../../
14
+ fi
15
+
16
+ # if /precompiled/libfastled.a does not exist
17
+ if [ ! -f "/precompiled/libfastled.a" ]; then
18
+ # echo "libfastled.a does not exist, compiling static library"
19
+ echo "libfastled.a does not exist, compiling static library"
20
+ cd fastled/src/platforms/wasm/compiler/lib
21
+ mkdir -p build
22
+ cd build
23
+ emcmake cmake -DCMAKE_VERBOSE_MAKEFILE=ON ..
24
+ emmake cmake --build . -v -j
25
+ cp fastled/libfastled.a /precompiled/libfastled.a
26
+ cd ../../../../../
27
+ fi
28
+