summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoeycastillo <joeycastillo@utexas.edu>2022-11-22 08:37:33 -0600
committerGitHub <noreply@github.com>2022-11-22 08:37:33 -0600
commit8dbc00c56d8e2cc6618031d0c2a023d07a637cd3 (patch)
treeada5182417d8bd4628abb4231a99af1fbf83883c
parent2455a922c6c62dcb94106cef7214cf3f28c3ce55 (diff)
parentc5776781e0ed11ca9cfe3d72d5534d5209fcccac (diff)
downloadSensor-Watch-8dbc00c56d8e2cc6618031d0c2a023d07a637cd3.tar.gz
Sensor-Watch-8dbc00c56d8e2cc6618031d0c2a023d07a637cd3.tar.bz2
Sensor-Watch-8dbc00c56d8e2cc6618031d0c2a023d07a637cd3.zip
Merge pull request #118 from wryun/separate-emscripten-build-dir
Separate emscripten build directory
-rw-r--r--.github/workflows/build.yml4
-rw-r--r--.gitignore1
-rw-r--r--README.md2
-rw-r--r--make.mk4
-rwxr-xr-xmovement/make/make_alternate_fw.sh6
5 files changed, 11 insertions, 6 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3ed1ff26..b150afb1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -44,7 +44,7 @@ jobs:
run: emmake make
working-directory: 'movement/make'
- name: Archive simulator build
- working-directory: 'movement/make/build'
+ working-directory: 'movement/make/build-sim'
run: |
cp watch.html index.html
tar -czf simulator.tar.gz index.html watch.wasm watch.js
@@ -52,4 +52,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: simulator.tar.gz
- path: movement/make/build/simulator.tar.gz
+ path: movement/make/build-sim/simulator.tar.gz
diff --git a/.gitignore b/.gitignore
index 1100e911..06256b71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
**/build/
+**/build-sim/
*.b#*
*.bin
*.d
diff --git a/README.md b/README.md
index 90ce5119..b2601da3 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ You may want to test out changes in the emulator first. To do this, you'll need
```
cd movement/make
emmake make
-python3 -m http.server 8000 -d build
+python3 -m http.server -d build-sim
```
Finally, visit [watch.html](http://localhost:8000/watch.html) to see your work.
diff --git a/make.mk b/make.mk
index 2fe89d75..446ad6fe 100644
--- a/make.mk
+++ b/make.mk
@@ -1,5 +1,9 @@
##############################################################################
+ifndef EMSCRIPTEN
BUILD = ./build
+else
+BUILD = ./build-sim
+endif
BIN = watch
ifndef BOARD
diff --git a/movement/make/make_alternate_fw.sh b/movement/make/make_alternate_fw.sh
index 575c9e52..739c8557 100755
--- a/movement/make/make_alternate_fw.sh
+++ b/movement/make/make_alternate_fw.sh
@@ -28,9 +28,9 @@ do
make clean
emmake make FIRMWARE=$VARIANT
mkdir "$sim_dir/$variant/"
- mv "build/watch.wasm" "$sim_dir/$variant/"
- mv "build/watch.js" "$sim_dir/$variant/"
- mv "build/watch.html" "$sim_dir/$variant/index.html"
+ mv "build-sim/watch.wasm" "$sim_dir/$variant/"
+ mv "build-sim/watch.js" "$sim_dir/$variant/"
+ mv "build-sim/watch.html" "$sim_dir/$variant/index.html"
done
echo "Done."
/span> # 1. This LICENSE AGREEMENT is between the Python Software Foundation # ("PSF"), and the Individual or Organization ("Licensee") accessing and # otherwise using Python 2.3 software in source or binary form and its # associated documentation. # # 2. Subject to the terms and conditions of this License Agreement, PSF # hereby grants Licensee a nonexclusive, royalty-free, world-wide # license to reproduce, analyze, test, perform and/or display publicly, # prepare derivative works, distribute, and otherwise use Python 2.3 # alone or in any derivative version, provided, however, that PSF's # License Agreement and PSF's notice of copyright, i.e., "Copyright (c) # 2001, 2002, 2003, 2004 Python Software Foundation; All Rights Reserved" are # retained in Python 2.3 alone or in any derivative version prepared by # Licensee. # # 3. In the event Licensee prepares a derivative work that is based on # or incorporates Python 2.3 or any part thereof, and wants to make # the derivative work available to others as provided herein, then # Licensee hereby agrees to include in any such work a brief summary of # the changes made to Python 2.3. # # 4. PSF is making Python 2.3 available to Licensee on an "AS IS" # basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR # IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND # DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS # FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.3 WILL NOT # INFRINGE ANY THIRD PARTY RIGHTS. # # 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON # 2.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS # A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.3, # OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. # # 6. This License Agreement will automatically terminate upon a material # breach of its terms and conditions. # # 7. Nothing in this License Agreement shall be deemed to create any # relationship of agency, partnership, or joint venture between PSF and # Licensee. This License Agreement does not grant permission to use PSF # trademarks or trade name in a trademark sense to endorse or promote # products or services of Licensee, or any third party. # # 8. By copying, installing or otherwise using Python 2.3, Licensee # agrees to be bound by the terms and conditions of this License # Agreement. # # Modifications: Copyright (c) 2005 Christian Limpach <Christian.Limpach@cl.cam.ac.uk> # - add support for excluding a list of file descriptors from being # closed, allowing access to those file descriptors from the command. # """Spawn a command with pipes to its stdin, stdout, and optionally stderr. The normal os.popen(cmd, mode) call spawns a shell command and provides a file interface to just the input or output of the process depending on whether mode is 'r' or 'w'. This module provides the functions xpopen2(cmd) and xpopen3(cmd) which return two or three pipes to the spawned command. Optionally exclude a list of file descriptors from being closed, allowing access to those file descriptors from the command. """ import os import sys try: MAXFD = os.sysconf('SC_OPEN_MAX') except (AttributeError, ValueError): MAXFD = 256 _active = [] def _cleanup(): for inst in _active[:]: inst.poll() class xPopen3: """Class representing a child process. Normally instances are created by the factory functions popen2() and popen3().""" sts = -1 # Child not completed yet def __init__(self, cmd, capturestderr=False, bufsize=-1, passfd=()): """The parameter 'cmd' is the shell command to execute in a sub-process. The 'capturestderr' flag, if true, specifies that the object should capture standard error output of the child process. The default is false. If the 'bufsize' parameter is specified, it specifies the size of the I/O buffers to/from the child process.""" _cleanup() self.passfd = passfd p2cread, p2cwrite = os.pipe() c2pread, c2pwrite = os.pipe() if capturestderr: errout, errin = os.pipe() self.pid = os.fork() if self.pid == 0: # Child os.dup2(p2cread, 0) os.dup2(c2pwrite, 1) if capturestderr: os.dup2(errin, 2) self._run_child(cmd) os.close(p2cread) self.tochild = os.fdopen(p2cwrite, 'w', bufsize) os.close(c2pwrite) self.fromchild = os.fdopen(c2pread, 'r', bufsize) if capturestderr: os.close(errin) self.childerr = os.fdopen(errout, 'r', bufsize) else: self.childerr = None _active.append(self) def _run_child(self, cmd): if isinstance(cmd, basestring): cmd = ['/bin/sh', '-c', cmd] for i in range(3, MAXFD): if i in self.passfd: continue try: os.close(i) except OSError: pass try: os.execvp(cmd[0], cmd) finally: os._exit(127) def poll(self): """Return the exit status of the child process if it has finished, or -1 if it hasn't finished yet.""" if self.sts < 0: try: pid, sts = os.waitpid(self.pid, os.WNOHANG) if pid == self.pid: self.sts = sts _active.remove(self) except os.error: pass return self.sts def wait(self): """Wait for and return the exit status of the child process.""" if self.sts < 0: pid, sts = os.waitpid(self.pid, 0) if pid == self.pid: self.sts = sts _active.remove(self) return self.sts def xpopen2(cmd, bufsize=-1, mode='t', passfd=[]): """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout, child_stdin) are returned.""" inst = xPopen3(cmd, False, bufsize, passfd) return inst.fromchild, inst.tochild def xpopen3(cmd, bufsize=-1, mode='t', passfd=[]): """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout, child_stdin, child_stderr) are returned.""" inst = xPopen3(cmd, True, bufsize, passfd) return inst.fromchild, inst.tochild, inst.childerr