Skip to content

Commit bbbf27f

Browse files
committed
vendor minshell
1 parent cdf68b0 commit bbbf27f

3 files changed

Lines changed: 97 additions & 5 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
c_*.c
33
pufferlib/extensions.c
44
pufferlib/puffernet.c
5+
src/libstatic*
56

67
# Build dir
78
build/
9+
build_web/
810

911
# hipified cuda extensions dir [HIP/ROCM]
1012
pufferlib/extensions/hip/
@@ -21,6 +23,7 @@ cy_*.c
2123

2224
# C extensions
2325
*.so
26+
*.o
2427

2528
# Distribution / packaging
2629
.Python

build.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ if [ "$MODE" = "local" ] || [ "$MODE" = "fast" ]; then
149149
echo "Built: ./$OUTPUT_NAME"
150150
exit 0
151151
elif [ "$MODE" = "web" ]; then
152-
if [ ! -f "minshell.html" ]; then
153-
curl -sL "https://raw.githubusercontent.com/raysan5/raylib/master/src/minshell.html" -o minshell.html
154-
fi
155152
mkdir -p "build_web/$ENV"
156153
echo "Compiling $ENV for web..."
157154
emcc \
@@ -163,7 +160,7 @@ elif [ "$MODE" = "web" ]; then
163160
-L. -L./$RAYLIB_NAME/lib \
164161
-sASSERTIONS=2 -gsource-map \
165162
-sUSE_GLFW=3 -sUSE_WEBGL2=1 -sASYNCIFY -sFILESYSTEM -sFORCE_FILESYSTEM=1 \
166-
--shell-file ./minshell.html \
163+
--shell-file vendor/minshell.html \
167164
-sINITIAL_MEMORY=512MB -sALLOW_MEMORY_GROWTH -sSTACK_SIZE=512KB \
168165
-DNDEBUG -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES3 \
169166
--preload-file resources/$ENV@resources/$ENV \
@@ -223,6 +220,7 @@ ${CC:-clang} -c "${CLANG_OPT[@]}" \
223220
"$BINDING_SRC" -o "$STATIC_OBJ"
224221
ar rcs "$STATIC_LIB" "$STATIC_OBJ"
225222

223+
# Brittle hack: have to extract the tensor type from the static lib to build trainer
226224
OBS_TENSOR_T=$(awk '/^#define OBS_TENSOR_T/{print $3}' "$BINDING_SRC")
227225
if [ -z "$OBS_TENSOR_T" ]; then
228226
echo "Error: Could not find OBS_TENSOR_T in $BINDING_SRC"
@@ -282,7 +280,7 @@ elif [ "$MODE" = "cpu" ]; then
282280
elif [ "$MODE" = "profile" ]; then
283281
echo "Compiling profile binary ($ARCH)..."
284282
$NVCC $NVCC_OPT -arch=$ARCH -std=c++17 \
285-
-I. -Isrc -I$SRC_DIR -I./vendor \
283+
-I. -Isrc -I$SRC_DIR \
286284
-I$CUDA_HOME/include $CUDNN_IFLAG -I$RAYLIB_NAME/include \
287285
-DOBS_TENSOR_T=$OBS_TENSOR_T \
288286
-DENV_NAME=$ENV \

vendor/minshell.html

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!doctype html>
2+
<html lang="EN-us">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6+
7+
<title>raylib web game</title>
8+
9+
<meta name="title" content="raylib web game">
10+
<meta name="description" content="New raylib web videogame, developed using raylib videogames library">
11+
<meta name="keywords" content="raylib, programming, examples, html5, C, C++, library, learn, games, videogames">
12+
<meta name="viewport" content="width=device-width">
13+
14+
<!-- Open Graph metatags for sharing -->
15+
<meta property="og:type" content="website" />
16+
<meta property="og:title" content="raylib web game">
17+
<meta property="og:image:type" content="image/png">
18+
<meta property="og:image" content="https://www.raylib.com/common/raylib_logo.png">
19+
<meta property="og:image:alt" content="New raylib web videogame, developed using raylib videogames library" />
20+
<meta property="og:site_name" content="raylib - example">
21+
<meta property="og:url" content="https://www.raylib.com/games.html">
22+
<meta property="og:description" content="New raylib web videogame, developed using raylib videogames library">
23+
24+
<!-- Twitter metatags for sharing -->
25+
<meta name="twitter:card" content="summary_large_image">
26+
<meta name="twitter:site" content="@raysan5">
27+
<meta name="twitter:title" content="raylib web game">
28+
<meta name="twitter:image" content="https://www.raylib.com/common/raylib_logo.png">
29+
<meta name="twitter:image:alt" content="New raylib web videogame, developed using raylib videogames library">
30+
<meta name="twitter:url" content="https://www.raylib.com/games.html">
31+
<meta name="twitter:description" content="New raylib web videogame, developed using raylib videogames library">
32+
33+
<!-- Favicon -->
34+
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
35+
36+
<style>
37+
body { margin: 0px; overflow: hidden; background-color: black; }
38+
canvas.emscripten { border: 0px none; background-color: black; }
39+
</style>
40+
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
41+
<script type='text/javascript'>
42+
function saveFileFromMEMFSToDisk(memoryFSname, localFSname) // This can be called by C/C++ code
43+
{
44+
var isSafari = false; // Not supported, navigator.userAgent access is being restricted
45+
//var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
46+
var data = FS.readFile(memoryFSname);
47+
var blob;
48+
49+
if (isSafari) blob = new Blob([data.buffer], { type: "application/octet-stream" });
50+
else blob = new Blob([data.buffer], { type: "application/octet-binary" });
51+
52+
// NOTE: SaveAsDialog is a browser setting. For example, in Google Chrome,
53+
// in Settings/Advanced/Downloads section you have a setting:
54+
// 'Ask where to save each file before downloading' - which you can set true/false.
55+
// If you enable this setting it would always ask you and bring the SaveAsDialog
56+
saveAs(blob, localFSname);
57+
58+
// Alternative implementation to avoid FileSaver.js
59+
//const link = document.createElement("a");
60+
//link.href = URL.createObjectURL(blob);
61+
//link.download = localFSname;
62+
//link.click();
63+
}
64+
</script>
65+
</head>
66+
<body>
67+
<canvas class=emscripten id=canvas oncontextmenu=event.preventDefault() tabindex=-1></canvas>
68+
<p id="output" />
69+
<script>
70+
var Module = {
71+
print: (function() {
72+
var element = document.getElementById('output');
73+
if (element) element.value = ''; // clear browser cache
74+
return function(text) {
75+
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
76+
console.log(text);
77+
if (element) {
78+
element.value += text + "\n";
79+
element.scrollTop = element.scrollHeight; // focus on bottom
80+
}
81+
};
82+
})(),
83+
canvas: (function() {
84+
var canvas = document.getElementById('canvas');
85+
return canvas;
86+
})()
87+
};
88+
</script>
89+
{{{ SCRIPT }}}
90+
</body>
91+
</html>

0 commit comments

Comments
 (0)