Skip to content

Commit 0ab8574

Browse files
authored
Merge pull request #2 from vkottler/dev/plotting
Initial sync
2 parents ec331ba + bfecc23 commit 0ab8574

File tree

12 files changed

+170
-25
lines changed

12 files changed

+170
-25
lines changed

.eslintrc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
root: true
3+
parserOptions:
4+
ecmaVersion: 2020

.github/workflows/yambs-project.yml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ on:
99

1010
env:
1111
GITHUB_API_TOKEN: ${{secrets.API_TOKEN}}
12+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
1213

1314
jobs:
1415
build:
15-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-24.04
1617
strategy:
1718
matrix:
18-
python-version: [3.11]
19+
python-version: [3.12]
20+
1921
env:
2022
PYTHON_VERSION: ${{matrix.python-version}}
2123

@@ -40,12 +42,12 @@ jobs:
4042

4143
- run: mk yaml python-lint python-sa
4244

43-
- name: setup clang 17
44-
run: |
45-
wget https://apt.llvm.org/llvm.sh
46-
chmod +x ./llvm.sh
47-
sudo ./llvm.sh 17
48-
rm llvm.sh
45+
# - name: setup clang 17
46+
# run: |
47+
# wget https://apt.llvm.org/llvm.sh
48+
# chmod +x ./llvm.sh
49+
# sudo ./llvm.sh 17
50+
# rm llvm.sh
4951

5052
- run: sudo apt-get install emscripten
5153
- run: emcc --version
@@ -58,24 +60,11 @@ jobs:
5860
- run: clang-17 --version
5961
- run: clang++-17 --version
6062

61-
- run: mk t variant=clang coverage=false
63+
- run: mk g
6264
- run: ninja all format-check
6365
- run: mk dist docs
6466
if: github.ref_name != 'master'
6567

66-
# Need to clean because codecov is not finding coverage otherwise.
67-
- run: mk c keep=debug
68-
- run: mk t variant=debug
69-
70-
- uses: codecov/codecov-action@v3
71-
with:
72-
gcov: true
73-
gcov_include: build/debug
74-
gcov_ignore: .mypy_cache
75-
gcov_executable: gcov-13
76-
fail_ci_if_error: true
77-
verbose: true
78-
7968
- run: mk release
8069
if: |
8170
env.GITHUB_API_TOKEN != ''

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ venv*
88
.*cache
99
*-out
1010
__pycache__
11-
tasks
1211
tags
1312
dev_requirements.txt
1413
mklocal

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Vaughn Kottler
3+
Copyright (c) 2024 Vaughn Kottler
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

local/yambs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ includes:
44
- package://yambs/includes/wasm.yaml
55

66
default_target: wasm
7+
8+
variants:
9+
debug: &debug
10+
enabled: false
11+
opt: *debug
12+
clang: *debug
13+
clang-opt: *debug

src/apps/audio.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <emscripten/val.h>
2+
#include <math.h>
3+
#include <stdio.h>
4+
5+
using namespace emscripten;
6+
7+
int main()
8+
{
9+
val AudioContext = val::global("AudioContext");
10+
if (!AudioContext.as<bool>())
11+
{
12+
printf("No global AudioContext, trying webkitAudioContext\n");
13+
AudioContext = val::global("webkitAudioContext");
14+
}
15+
16+
printf("Got an AudioContext\n");
17+
val context = AudioContext.new_();
18+
val oscillator = context.call<val>("createOscillator");
19+
20+
printf("Configuring oscillator\n");
21+
oscillator.set("type", val("triangle"));
22+
oscillator["frequency"].set("value", val(261.63)); // Middle C
23+
24+
printf("Playing\n");
25+
oscillator.call<void>("connect", context["destination"]);
26+
oscillator.call<void>("start", 0);
27+
28+
printf("All done!\n");
29+
}

tasks/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
conf.py
2+
mklocal

tasks/app.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
"""
2+
A module implementing a simple web application.
3+
"""
4+
5+
# built-in
6+
from pathlib import Path
7+
from typing import Optional
8+
9+
# third-party
10+
from runtimepy.net.arbiter.info import AppInfo
11+
from runtimepy.net.html import append_kind
12+
from runtimepy.net.http.header import RequestHeader
13+
from runtimepy.net.http.response import ResponseHeader
14+
from runtimepy.net.server import RuntimepyServerConnection
15+
from svgen.element import Element
16+
from svgen.element.html import Html, div
17+
from vcorelib.asyncio.cli import run_command
18+
19+
20+
def script(path: Path | str, is_async: bool = True) -> Element:
21+
"""Create a script element."""
22+
23+
elem = Element(tag="script", src=str(path), text="/* null */")
24+
if is_async:
25+
elem.booleans.add("async")
26+
return elem
27+
28+
29+
async def build_app(app: AppInfo, is_async: bool = True) -> Element:
30+
"""Build the application."""
31+
32+
app_path = Path(
33+
"build", "wasm", "apps", app.config_param("wasm_app", "", strict=True)
34+
)
35+
36+
# Run ninja to re-build.
37+
await run_command(app.logger, "ninja", str(app_path.with_suffix(".html")))
38+
39+
return script(app_path.with_suffix(".js"), is_async=is_async)
40+
41+
42+
async def setup(app: AppInfo) -> int:
43+
"""Perform server application setup steps."""
44+
45+
del app
46+
47+
async def main(
48+
document: Html,
49+
request: RequestHeader,
50+
response: ResponseHeader,
51+
request_data: Optional[bytes],
52+
) -> Html:
53+
"""A simple 'Hello, world!' application."""
54+
55+
# Not currently used.
56+
del request
57+
del response
58+
del request_data
59+
60+
# Create the application.
61+
append_kind(document.head, "main", kind="css", tag="style")
62+
63+
# Remove at some point.
64+
div(text="Hello, world!", parent=document.body)
65+
66+
# Add WebAssembly application.
67+
# document.body.children.append(await build_app(app))
68+
69+
document.body.children.append(script("tasks/test.js"))
70+
71+
return document
72+
73+
# Set default application.
74+
RuntimepyServerConnection.default_app = main
75+
return 0

tasks/default.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
includes:
3+
- package://runtimepy/server_base.yaml
4+
5+
port_overrides:
6+
runtimepy_http_server: 8000
7+
8+
config:
9+
wasm_app: test_file
10+
11+
app:
12+
- tasks.app.setup
13+
- runtimepy.net.apps.wait_for_stop

0 commit comments

Comments
 (0)