Show a version number in the UI. Automate things so that the version number originates from the Makefile. Get ready for 0.0.8.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4330 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-06-28 23:00:34 +00:00
parent 6022001d66
commit 8f5201b2bc
6 changed files with 27 additions and 13 deletions

View File

@ -4,6 +4,8 @@ MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
PROJECT = tildefriends
VERSION_NUMBER := 0.0.8
VERSION_NAME := The secret ingredient is love.
BUILD_DIR ?= out
BUILD_TYPES := debug release windebug winrelease androiddebug androidrelease androiddebug-x86_64 androidrelease-x86_64
UNAME_M := $(shell uname -m)
@ -432,6 +434,10 @@ endef
$(foreach build_type,$(BUILD_TYPES),$(eval $(call build_rules,$(build_type))))
src/version.h : $(firstword $(MAKEFILE_LIST))
@echo [version] $@
@echo "#define VERSION_NUMBER \"$(VERSION_NUMBER)\"\n#define VERSION_NAME \"$(VERSION_NAME)\"\n" > $@
# Android support.
out/res/layout_activity_main.xml.flat: src/android/res/layout/activity_main.xml
@mkdir -p $(dir $@)

View File

@ -52,6 +52,8 @@ class TfNavigationElement extends LitElement {
show_permissions: {type: Boolean},
status: {type: Object},
spark_lines: {type: Object},
version: {type: Object},
show_version: {type: Boolean},
};
}
@ -128,7 +130,8 @@ class TfNavigationElement extends LitElement {
${k_global_style}
</style>
<div style="margin: 4px; display: flex; flex-direction: row; flex-wrap: nowrap; gap: 3px">
<span>😎</span>
<span style="cursor: pointer" @click=${() => this.show_version = !this.show_version}>😎</span>
<span ?hidden=${!this.show_version} style="flex: 0 0; white-space: nowrap" title=${this.version?.name}>${this.version?.number}</span>
<a accesskey="h" data-tip="Open home app." href="/" style="color: #fff; white-space: nowrap">TF</a>
<a accesskey="a" data-tip="Open apps list." href="/~core/apps/">apps</a>
<a accesskey="e" data-tip="Toggle the app editor." href="#" @click=${this.toggle_edit}>edit</a>
@ -768,6 +771,7 @@ function _receive_websocket_message(message) {
if (window.location.hash) {
send({event: "hashChange", hash: window.location.hash});
}
document.getElementsByTagName('tf-navigation')[0].version = message.version;
send({action: 'enableStats', enabled: true});
} else if (message && message.action == "ping") {
send({action: "pong"});

View File

@ -456,7 +456,7 @@ async function getProcessBlob(blobId, key, options) {
}
broadcastEvent('onSessionBegin', [getUser(process, process)]);
if (process.app) {
process.app.send({action: "ready"});
process.app.send({action: "ready", version: version()});
process.sendPermissions();
}
await process.task.execute({name: appSourceName, source: appSource});

View File

@ -14,6 +14,7 @@
#include "tlscontext.js.h"
#include "trace.h"
#include "util.js.h"
#include "version.h"
#include "backtrace.h"
#include "quickjs.h"
@ -35,8 +36,6 @@
#define _countof(a) ((int)(sizeof((a)) / sizeof(*(a))))
#endif
static const char* k_version = "1.0";
static JSClassID _import_class_id;
static int _count;
@ -675,9 +674,11 @@ static JSValue _tf_task_version(JSContext* context, JSValueConst this_val, int a
{
tf_task_t* task = JS_GetContextOpaque(context);
tf_trace_begin(task->_trace, __func__);
JSValue result = JS_NewString(task->_context, k_version);
JSValue version = JS_NewObject(context);
JS_SetPropertyStr(context, version, "number", JS_NewString(context, VERSION_NUMBER));
JS_SetPropertyStr(context, version, "name", JS_NewString(context, VERSION_NAME));
tf_trace_end(task->_trace);
return result;
return version;
}
exportid_t tf_task_export_function(tf_task_t* task, tf_taskstub_t* to, JSValue function)

3
src/version.h Normal file
View File

@ -0,0 +1,3 @@
#define VERSION_NUMBER "0.0.8"
#define VERSION_NAME "The secret ingredient is love."

View File

@ -1,10 +1,10 @@
#!/bin/bash
VERSION=$1
NICKNAME=$2
rm -rfv tildefriends-$VERSION
svn export . tildefriends-$VERSION
echo "tildefriends-$VERSION: $NICKNAME" > tildefriends-$VERSION/VERSION
VERSION_NUMBER=`sed -n -e 's/^VERSION_NUMBER := //p' Makefile`
VERSION_NAME=`sed -n -e 's/^VERSION_NAME := //p' Makefile`
rm -rfv tildefriends-$VERSION_NUMBER
svn export . tildefriends-$VERSION_NUMBER
echo "tildefriends-$VERSION_NUMBER: $VERSION_NAME" > tildefriends-$VERSION_NUMBER/VERSION
tar \
--exclude=deps/libbacktrace/Isaac.Newton-Opticks.txt \
--exclude=deps/libsodium/builds \
@ -17,5 +17,5 @@ tar \
--exclude=deps/sqlite/shell.c \
--exclude=deps/zlib/contrib/vstudio \
--exclude=deps/zlib/doc \
-caf tildefriends-$VERSION.tar.xz tildefriends-$VERSION
rm -rfv tildefriends-$VERSION
-caf tildefriends-$VERSION_NUMBER.tar.xz tildefriends-$VERSION_NUMBER
rm -rfv tildefriends-$VERSION_NUMBER