build: Generate versioning information for the website
This commit is contained in:
parent
1bb1d71230
commit
c73e6e08a8
@ -6,6 +6,11 @@ set script_dir=%script_dir_backslash:~0,-1%
|
|||||||
set build_dir=%script_dir%\Build
|
set build_dir=%script_dir%\Build
|
||||||
set code_dir=%script_dir%
|
set code_dir=%script_dir%
|
||||||
|
|
||||||
|
REM Bootstrap a version
|
||||||
|
git show -s --date=format:%%Y-%%m-%%d --format=%%cd HEAD> feely_pona_version.txt
|
||||||
|
git rev-parse --short=8 HEAD>> feely_pona_version.txt
|
||||||
|
git rev-list --count HEAD>> feely_pona_version.txt
|
||||||
|
|
||||||
REM Bootstrap the build program
|
REM Bootstrap the build program
|
||||||
mkdir %build_dir% 2>nul
|
mkdir %build_dir% 2>nul
|
||||||
pushd %build_dir%
|
pushd %build_dir%
|
||||||
|
@ -465,11 +465,53 @@ int main(int argc, char const **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: feely pona emscripten =================================================================
|
// NOTE: feely pona emscripten =============================================================
|
||||||
{
|
{
|
||||||
feely_pona_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
|
feely_pona_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { feely_pona_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { feely_pona_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
|
// NOTE: feely pona emscripten shell =======================================================
|
||||||
|
Dqn_String8 html_shell_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_emscripten_shell.html", DQN_STRING_FMT(build_dir));
|
||||||
|
{
|
||||||
|
Dqn_String8 html_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_emscripten_shell.html", DQN_STRING_FMT(code_dir));
|
||||||
|
Dqn_String8 html_buffer = Dqn_Fs_Read(html_path, scratch.allocator);
|
||||||
|
if (!DQN_CHECKF(html_buffer.size,
|
||||||
|
"Failed to read Emscripten HTML shell file. The file at\n\n '%.*s'\n\ndoes not exist or is not readable",
|
||||||
|
DQN_STRING_FMT(html_path)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
Dqn_String8 version_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_version.txt", DQN_STRING_FMT(code_dir));
|
||||||
|
Dqn_String8 version_buffer = Dqn_Fs_Read(version_path, scratch.allocator);
|
||||||
|
Dqn_String8SplitAllocResult version_parts = Dqn_String8_SplitAlloc(scratch.allocator, version_buffer, DQN_STRING8("\n"));
|
||||||
|
|
||||||
|
if (!DQN_CHECKF(version_parts.size == 3,
|
||||||
|
"Version file '%.*s' must have 3 lines containing, date, commit hash and number of commits. The buffer we tried extracting information from was\n\n%.*s\n\n",
|
||||||
|
DQN_STRING_FMT(version_path),
|
||||||
|
DQN_STRING_FMT(version_buffer))) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dqn_String8 date = Dqn_String8_TrimWhitespaceAround(version_parts.data[0]);
|
||||||
|
Dqn_String8 commit_hash = Dqn_String8_TrimWhitespaceAround(version_parts.data[1]);
|
||||||
|
Dqn_String8 commit_count = Dqn_String8_TrimWhitespaceAround(version_parts.data[2]);
|
||||||
|
Dqn_String8 version_text = Dqn_String8_InitF(scratch.allocator,
|
||||||
|
"%.*s edition rev. %.*s-%.*s",
|
||||||
|
DQN_STRING_FMT(date),
|
||||||
|
DQN_STRING_FMT(commit_count),
|
||||||
|
DQN_STRING_FMT(commit_hash));
|
||||||
|
|
||||||
|
Dqn_String8 html_buffer_processed = Dqn_String8_Replace(html_buffer,
|
||||||
|
DQN_STRING8("@version@"),
|
||||||
|
version_text,
|
||||||
|
0 /*start_index*/,
|
||||||
|
scratch.allocator);
|
||||||
|
if (!DQN_CHECKF(Dqn_Fs_Write(html_shell_path,
|
||||||
|
html_buffer_processed),
|
||||||
|
"Failed to write Emscripten HTML shell with the project version inserted into it. We were unable to write to the target location\n\n '%.*s'\n",
|
||||||
|
DQN_STRING_FMT(html_shell_path)))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Compile with emcc =============================================================
|
// NOTE: Compile with emcc =============================================================
|
||||||
Dqn_CPPBuildContext build_context = {};
|
Dqn_CPPBuildContext build_context = {};
|
||||||
build_context.compile_file_obj_suffix = DQN_CPP_BUILD_OBJ_SUFFIX_O;
|
build_context.compile_file_obj_suffix = DQN_CPP_BUILD_OBJ_SUFFIX_O;
|
||||||
@ -482,7 +524,7 @@ int main(int argc, char const **argv)
|
|||||||
DQN_STRING8("cmd"), DQN_STRING8("/C"), DQN_STRING8("emcc.bat"),
|
DQN_STRING8("cmd"), DQN_STRING8("/C"), DQN_STRING8("emcc.bat"),
|
||||||
DQN_STRING8("-o"), Dqn_String8_InitF(scratch.allocator, "%.*s.html", DQN_STRING_FMT(output_name)),
|
DQN_STRING8("-o"), Dqn_String8_InitF(scratch.allocator, "%.*s.html", DQN_STRING_FMT(output_name)),
|
||||||
DQN_STRING8("-Wall"),
|
DQN_STRING8("-Wall"),
|
||||||
DQN_STRING8("--shell-file"), Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_emscripten_shell.html", DQN_STRING_FMT(code_dir)),
|
DQN_STRING8("--shell-file"), html_shell_path,
|
||||||
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STRING_FMT(build_dir), DQN_STRING_FMT(raylib_emscripten_lib_name)),
|
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STRING_FMT(build_dir), DQN_STRING_FMT(raylib_emscripten_lib_name)),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("USE_GLFW=3"),
|
DQN_STRING8("-s"), DQN_STRING8("USE_GLFW=3"),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=512MB"),
|
DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=512MB"),
|
||||||
|
@ -19,10 +19,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#header {
|
#header {
|
||||||
|
font-weight: bold;
|
||||||
|
color: white;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
|
text-align: center;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
||||||
@ -37,47 +41,12 @@
|
|||||||
width: 75vw;
|
width: 75vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spinner {
|
|
||||||
height: 15px;
|
|
||||||
width: 15px;
|
|
||||||
margin: 0;
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: top;
|
|
||||||
-webkit-animation: rotation .8s linear infinite;
|
|
||||||
-moz-animation: rotation .8s linear infinite;
|
|
||||||
-o-animation: rotation .8s linear infinite;
|
|
||||||
animation: rotation 0.8s linear infinite;
|
|
||||||
border-left: 5px solid black;
|
|
||||||
border-right: 5px solid black;
|
|
||||||
border-bottom: 5px solid black;
|
|
||||||
border-top: 5px solid red;
|
|
||||||
border-radius: 100%;
|
|
||||||
background-color: rgb(245, 245, 245);
|
|
||||||
}
|
|
||||||
@-webkit-keyframes rotation {
|
|
||||||
from {-webkit-transform: rotate(0deg);}
|
|
||||||
to {-webkit-transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
@-moz-keyframes rotation {
|
|
||||||
from {-moz-transform: rotate(0deg);}
|
|
||||||
to {-moz-transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
@-o-keyframes rotation {
|
|
||||||
from {-o-transform: rotate(0deg);}
|
|
||||||
to {-o-transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
@keyframes rotation {
|
|
||||||
from {transform: rotate(0deg);}
|
|
||||||
to {transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
|
|
||||||
#status {
|
#status {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
margin-top: 5px;
|
font-weight: normal;
|
||||||
margin-left: 5px;
|
font-size: 0.8em;
|
||||||
font-weight: bold;
|
color: darkgray;
|
||||||
color: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#progress {
|
#progress {
|
||||||
@ -119,13 +88,8 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<div class="spinner" id='spinner'></div>
|
<h1 style="font-size: 1em; text-align: center; margin-top: 0; margin-bottom: 0; padding-bottom: 3px">Terry Cherry</h1>
|
||||||
<div class="emscripten" id="status">Downloading...</div>
|
<div class="emscripten" id="status">Downloading...</div>
|
||||||
<span id='controls'>
|
|
||||||
<span><input type="button" value="🖵 FULLSCREEN" onclick="Module.requestFullscreen(false, false)"></span>
|
|
||||||
<span><input type="button" id="btn-audio" value="🔇 SUSPEND" onclick="toggleAudio()"></span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<div class="emscripten">
|
<div class="emscripten">
|
||||||
<progress value="0" max="100" id="progress" hidden=0></progress>
|
<progress value="0" max="100" id="progress" hidden=0></progress>
|
||||||
</div>
|
</div>
|
||||||
@ -135,11 +99,17 @@
|
|||||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
|
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div style="display: flex; justify-content: space-around;">
|
||||||
|
<span id='controls'>
|
||||||
|
<span><input type="button" value="🖵 FULLSCREEN" onclick="Module.requestFullscreen(false, false)"></span>
|
||||||
|
<span><input type="button" id="btn-audio" value="🔇 SUSPEND" onclick="toggleAudio()"></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<textarea id="output" rows="8"></textarea>
|
<textarea id="output" rows="8"></textarea>
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var statusElement = document.querySelector('#status');
|
var statusElement = document.querySelector('#status');
|
||||||
var progressElement = document.querySelector('#progress');
|
var progressElement = document.querySelector('#progress');
|
||||||
var spinnerElement = document.querySelector('#spinner');
|
|
||||||
var Module = {
|
var Module = {
|
||||||
preRun: [],
|
preRun: [],
|
||||||
postRun: [],
|
postRun: [],
|
||||||
@ -195,15 +165,17 @@
|
|||||||
progressElement.value = parseInt(m[2])*100;
|
progressElement.value = parseInt(m[2])*100;
|
||||||
progressElement.max = parseInt(m[4])*100;
|
progressElement.max = parseInt(m[4])*100;
|
||||||
progressElement.hidden = true;
|
progressElement.hidden = true;
|
||||||
spinnerElement.hidden = false;
|
|
||||||
} else {
|
} else {
|
||||||
progressElement.value = null;
|
progressElement.value = null;
|
||||||
progressElement.max = null;
|
progressElement.max = null;
|
||||||
progressElement.hidden = true;
|
progressElement.hidden = true;
|
||||||
if (!text) spinnerElement.style.display = 'none';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
statusElement.innerHTML = text;
|
if (text) {
|
||||||
|
statusElement.innerHTML = '@version@: ' + text;
|
||||||
|
} else {
|
||||||
|
statusElement.innerHTML = '@version@';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
totalDependencies: 0,
|
totalDependencies: 0,
|
||||||
monitorRunDependencies: function(left) {
|
monitorRunDependencies: function(left) {
|
||||||
@ -217,7 +189,6 @@
|
|||||||
|
|
||||||
window.onerror = function() {
|
window.onerror = function() {
|
||||||
Module.setStatus('Exception thrown, see JavaScript console');
|
Module.setStatus('Exception thrown, see JavaScript console');
|
||||||
spinnerElement.style.display = 'none';
|
|
||||||
Module.setStatus = function(text) { if (text) Module.printErr('[post-exception status] ' + text); };
|
Module.setStatus = function(text) { if (text) Module.printErr('[post-exception status] ' + text); };
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
3
feely_pona_version.txt
Normal file
3
feely_pona_version.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
2023-10-17
|
||||||
|
1bb1d712
|
||||||
|
190
|
Loading…
Reference in New Issue
Block a user