mirror of
https://gitlab.com/c3d/db48x.git
synced 2024-09-29 05:36:58 +02:00
Makefile: Generate version.h file
Instead of passing a -D on the command line, put the version in a version file. This is more correct, since it will cause a rebuild of parts that may depend on it. Also moved several of the commands out of line to reduce header dependencies. Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
parent
9686a70533
commit
bcfc62e9a7
4 changed files with 128 additions and 112 deletions
16
Makefile
16
Makefile
|
@ -33,7 +33,8 @@ CRCFIX = $(TOOLS)/forcecrc32/forcecrc32
|
|||
FLASH=$(BUILD)/$(TARGET)_flash.bin
|
||||
QSPI =$(BUILD)/$(TARGET)_qspi.bin
|
||||
|
||||
VERSION=$(shell git describe --dirty=Z | sed -e 's/^v//g')
|
||||
VERSION=$(shell git describe --dirty=Z --abbrev=5| sed -e 's/^v//g' -e 's/-g/-/g')
|
||||
VERSION_H=src/dm42/version.h
|
||||
|
||||
|
||||
#==============================================================================
|
||||
|
@ -43,7 +44,7 @@ VERSION=$(shell git describe --dirty=Z | sed -e 's/^v//g')
|
|||
#==============================================================================
|
||||
|
||||
# default action: build all
|
||||
all: $(TARGET).pgm help/$(TARGET).md
|
||||
all: $(TARGET).pgm help/$(TARGET).md $(VERSION_H)
|
||||
|
||||
# installation steps
|
||||
install: install-pgm install-qspi install-help
|
||||
|
@ -59,8 +60,8 @@ install-help: help/$(TARGET).md
|
|||
|
||||
sim: sim/simulator.mak sim/gcc111libbid.a recorder/config.h help/$(TARGET).md .ALWAYS
|
||||
cd sim; make -f $(<F)
|
||||
sim/simulator.mak: sim/simulator.pro Makefile
|
||||
cd sim; qmake $(<F) -o $(@F) CONFIG+=$(OPT) DEFINES+=DB48X_VERSION=\\\\\\\"$(VERSION)\\\\\\\"
|
||||
sim/simulator.mak: sim/simulator.pro Makefile $(VERSION_H)
|
||||
cd sim; qmake $(<F) -o $(@F) CONFIG+=$(OPT)
|
||||
|
||||
ttf2font: $(TOOLS)/ttf2fonts/ttf2fonts
|
||||
$(TOOLS)/ttf2fonts/ttf2fonts: $(TOOLS)/ttf2font/ttf2font.cpp $(TOOLS)/ttf2font/Makefile
|
||||
|
@ -72,6 +73,12 @@ dist: all
|
|||
mv build/release/$(TARGET)_qspi.bin .
|
||||
tar cvfz v$(VERSION).tgz $(TARGET).pgm $(TARGET)_qspi.bin help/ STATE/
|
||||
|
||||
$(VERSION_H): Makefile $(BUILD)/version-$(VERSION).h
|
||||
cp $(BUILD)/version-$(VERSION).h $@
|
||||
$(BUILD)/version-$(VERSION).h:
|
||||
echo "#define DB48X_VERSION \"$(VERSION)\"" > $@
|
||||
|
||||
|
||||
#BASE_FONT=fonts/C43StandardFont.ttf
|
||||
BASE_FONT=fonts/FogSans-ddd.ttf
|
||||
fonts/EditorFont.cc: ttf2font $(BASE_FONT)
|
||||
|
@ -167,7 +174,6 @@ DEFINES += \
|
|||
DECIMAL_GLOBAL_ROUNDING_ACCESS_FUNCTIONS \
|
||||
DECIMAL_GLOBAL_EXCEPTION_FLAGS \
|
||||
DECIMAL_GLOBAL_EXCEPTION_FLAGS_ACCESS_FUNCTIONS \
|
||||
DB48X_VERSION=\"$(VERSION)\" \
|
||||
$(DEFINES_$(OPT))
|
||||
DEFINES_debug=DEBUG
|
||||
DEFINES_release=RELEASE
|
||||
|
|
104
src/command.cc
104
src/command.cc
|
@ -40,6 +40,7 @@
|
|||
#include "settings.h"
|
||||
#include "symbol.h"
|
||||
#include "utf8.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
@ -317,6 +318,55 @@ bool command::stack(int32_t *result, uint level)
|
|||
}
|
||||
|
||||
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// Command implementations
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
COMMAND_BODY(Eval)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Evaluate an object
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (object_p x = RT.pop())
|
||||
return x->execute();
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
COMMAND_BODY(True)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Evaluate as self
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (RT.push(command::static_object(ID_True)))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
COMMAND_BODY(False)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Evaluate as self
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (RT.push(command::static_object(ID_False)))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
||||
COMMAND_BODY(ToText)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Convert an object to text
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (gcobj obj = RT.top())
|
||||
if (gcobj txt = obj->as_text(false, false))
|
||||
if (RT.top(txt))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
COMMAND_BODY(SelfInsert)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Find the label associated to the menu and enter it in the editor
|
||||
|
@ -346,3 +396,57 @@ COMMAND_BODY(Ticks)
|
|||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
COMMAND_BODY(Off)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Switch the calculator off
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
extern void power_off();
|
||||
power_off();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
COMMAND_BODY(SystemSetup)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Select the system menu
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
extern void system_setup();
|
||||
system_setup();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
COMMAND_BODY(HomeDirectory)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Return the home directory
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (gcobj dir = (object *) RT.variables(0))
|
||||
if (RT.push(dir))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
||||
COMMAND_BODY(Version)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Return a version string
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
const utf8 version_text = (utf8)
|
||||
"DB48X " DB48X_VERSION "\n"
|
||||
"A modern implementation of\n"
|
||||
"Reverse Polish Lisp (RPL)\n"
|
||||
"and a tribute to\n"
|
||||
"Bill Hewlett and Dave Packard\n"
|
||||
"© 2022-2023 Christophe de Dinechin";
|
||||
if (text_g version = text::make(version_text))
|
||||
if (RT.push(object_p(version)))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
|
|
118
src/command.h
118
src/command.h
|
@ -137,112 +137,16 @@ struct Unimplemented : command
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
COMMAND(Eval)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Evaluate an object
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (object_p x = RT.pop())
|
||||
return x->execute();
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
COMMAND(True)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Evaluate as self
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (RT.push(command::static_object(ID_True)))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
COMMAND(False)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Evaluate as self
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (RT.push(command::static_object(ID_False)))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
||||
COMMAND(ToText)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Convert an object to text
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (gcobj obj = RT.top())
|
||||
if (gcobj txt = obj->as_text(false, false))
|
||||
if (RT.top(txt))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
||||
COMMAND_DECLARE(SelfInsert);
|
||||
// ----------------------------------------------------------------------------
|
||||
// Insert the label associated to a menu
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
COMMAND_DECLARE(Ticks);
|
||||
// ----------------------------------------------------------------------------
|
||||
// Measure number of milliseconds
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
COMMAND(Off)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Switch the calculator off
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
extern void power_off();
|
||||
power_off();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
COMMAND(SystemSetup)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Select the system menu
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
extern void system_setup();
|
||||
system_setup();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
COMMAND(HomeDirectory)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Return the home directory
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (gcobj dir = (object *) RT.variables(0))
|
||||
if (RT.push(dir))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
||||
COMMAND(Version)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Return a version string
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
const utf8 version_text = (utf8)
|
||||
"DB48X " DB48X_VERSION "\n"
|
||||
"A modern implementation of\n"
|
||||
"Reverse Polish Lisp (RPL)\n"
|
||||
"and a tribute to\n"
|
||||
"Bill Hewlett and Dave Packard\n"
|
||||
"© 2022-2023 Christophe de Dinechin";
|
||||
if (text_g version = text::make(version_text))
|
||||
if (RT.push(object_p(version)))
|
||||
return OK;
|
||||
return ERROR;
|
||||
}
|
||||
// Various global commands
|
||||
COMMAND_DECLARE(Eval); // Evaluate an object
|
||||
COMMAND_DECLARE(True); // Evaluate as self
|
||||
COMMAND_DECLARE(False); // Evaluate as self
|
||||
COMMAND_DECLARE(ToText); // Convert an object to text
|
||||
COMMAND_DECLARE(SelfInsert); // Enter menu label in the editor
|
||||
COMMAND_DECLARE(Ticks); // Return number of ticks
|
||||
COMMAND_DECLARE(Off); // Switch the calculator off
|
||||
COMMAND_DECLARE(SystemSetup); // Select the system menu
|
||||
COMMAND_DECLARE(HomeDirectory); // Return the home directory
|
||||
COMMAND_DECLARE(Version); // Return a version string
|
||||
|
||||
#endif // COMMAND_H
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// ****************************************************************************
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#define PROGRAM_NAME "DB48X"
|
||||
#define PROGRAM_VERSION DB48X_VERSION
|
||||
|
||||
|
|
Loading…
Reference in a new issue