Embed rrcc git version on binary
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
93382e0815
commit
06051ec67d
|
@ -63,4 +63,8 @@ ADD_RESOURCES(embeddedResources
|
|||
asm/stdlib.asm
|
||||
)
|
||||
|
||||
add_executable(rrc-as src/rrcas.cpp ${SOURCE_FILES} ${embeddedResources})
|
||||
|
||||
execute_process(COMMAND git describe --tags --always OUTPUT_VARIABLE GIT_REPO_VERSION)
|
||||
|
||||
add_executable(rrc-as src/rrcas.cpp ${SOURCE_FILES} ${embeddedResources})
|
||||
target_compile_definitions(rrc-as PRIVATE "RRCC_VERSION=${GIT_REPO_VERSION}")
|
|
@ -3,13 +3,21 @@
|
|||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#include "Parser.h"
|
||||
#include "Assembler.h"
|
||||
#include "instructions/virtual/Stack.h"
|
||||
#include "EmbeddedResource.h"
|
||||
|
||||
#define xstr(s) __str(s)
|
||||
#define __str(s) #s
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 3) {
|
||||
if (argc == 2 && strcmp(argv[1], "version") == 0){
|
||||
std::cout << xstr(RRCC_VERSION) << "\n";
|
||||
return 0;
|
||||
} else if (argc < 3) {
|
||||
std::cout << "rrc-as " << xstr(RRCC_VERSION) << "\n";
|
||||
std::cout << "Usage: " << argv[0] << " code.asm [code2.asm ...] output.bin\n";
|
||||
return 1;
|
||||
}
|
||||
|
@ -82,7 +90,7 @@ int main(int argc, char *argv[]) {
|
|||
config.buildVersion = linker.getIntegerConstant("rrcc_IMAGE_VERSION", 0, false);
|
||||
|
||||
std::stringstream s;
|
||||
s << "Image generated with rrc-as. EEPROM Image Version: 0x" << std::hex << std::setw(4) << std::setfill('0') << config.buildVersion;
|
||||
s << "Image generated with rrc-as " << xstr(RRCC_VERSION) << ". EEPROM Image Version: 0x" << std::hex << std::setw(4) << std::setfill('0') << config.buildVersion;
|
||||
config.buildSignature = s.str();
|
||||
|
||||
auto entrypointName = linker.getTextConstant("rrcc_ENTRYPOINT", "", true);
|
||||
|
|
Loading…
Reference in a new issue