diff --git a/build.bat b/build.bat index 504d51e..f395b9e 100644 --- a/build.bat +++ b/build.bat @@ -6,6 +6,11 @@ set script_dir=%script_dir_backslash:~0,-1% set build_dir=%script_dir%\Build 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 mkdir %build_dir% 2>nul pushd %build_dir% diff --git a/feely_pona_build.cpp b/feely_pona_build.cpp index 799de73..5fa24d2 100644 --- a/feely_pona_build.cpp +++ b/feely_pona_build.cpp @@ -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(); 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 ============================================================= Dqn_CPPBuildContext build_context = {}; 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("-o"), Dqn_String8_InitF(scratch.allocator, "%.*s.html", DQN_STRING_FMT(output_name)), 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_STRING8("-s"), DQN_STRING8("USE_GLFW=3"), DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=512MB"), diff --git a/feely_pona_emscripten_shell.html b/feely_pona_emscripten_shell.html index 50f1a62..5b3d4dc 100644 --- a/feely_pona_emscripten_shell.html +++ b/feely_pona_emscripten_shell.html @@ -19,10 +19,14 @@ } #header { + font-weight: bold; + color: white; height: 30px; + text-align: center; padding-left: 5px; padding-right: 5px; padding-top: 5px; + padding-bottom: 10px; } .emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; } @@ -37,47 +41,12 @@ 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 { display: inline-block; vertical-align: top; - margin-top: 5px; - margin-left: 5px; - font-weight: bold; - color: white; + font-weight: normal; + font-size: 0.8em; + color: darkgray; } #progress { @@ -119,13 +88,8 @@