mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Add Escargot version configuration
* Escargot version is calculated based on commit id * If git is not available, RELEASE_VERSION is used instead * Escargot version is used to identify the version of code cache Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
parent
8821b0e275
commit
10ca04ae35
6 changed files with 75 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -37,3 +37,4 @@ CMakeFiles
|
|||
cmake_install.cmake
|
||||
#etc
|
||||
.vscode
|
||||
EscargotInfo.h
|
||||
|
|
|
|||
1
RELEASE_VERSION
Normal file
1
RELEASE_VERSION
Normal file
|
|
@ -0,0 +1 @@
|
|||
v3.0.0
|
||||
|
|
@ -9,6 +9,22 @@ ELSE()
|
|||
MESSAGE (FATAL_ERROR "Error: unsupported target")
|
||||
ENDIF()
|
||||
|
||||
# CONFIGURE ESCARGOT VERSION
|
||||
FIND_PACKAGE(Git)
|
||||
IF (GIT_FOUND)
|
||||
EXECUTE_PROCESS (
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE ESCARGOT_BUILD_VERSION
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
ENDIF()
|
||||
IF ((NOT DEFINED ESCARGOT_BUILD_VERSION) OR (ESCARGOT_BUILD_VERSION STREQUAL ""))
|
||||
FILE (STRINGS "${PROJECT_SOURCE_DIR}/RELEASE_VERSION" ESCARGOT_BUILD_VERSION)
|
||||
ENDIF()
|
||||
MESSAGE(STATUS "Escargot Build Version: ${ESCARGOT_BUILD_VERSION}")
|
||||
CONFIGURE_FILE (${PROJECT_SOURCE_DIR}/src/EscargotInfo.h.in ${PROJECT_SOURCE_DIR}/src/EscargotInfo.h @ONLY)
|
||||
|
||||
#######################################################
|
||||
# PATH
|
||||
#######################################################
|
||||
|
|
|
|||
|
|
@ -452,6 +452,7 @@ typedef uint16_t LexicalBlockIndex;
|
|||
#define ROPE_STRING_MIN_LENGTH 24
|
||||
#endif
|
||||
|
||||
#include "EscargotInfo.h"
|
||||
#include "heap/Heap.h"
|
||||
#include "CheckedArithmetic.h"
|
||||
#include "runtime/String.h"
|
||||
|
|
|
|||
27
src/EscargotInfo.h.in
Normal file
27
src/EscargotInfo.h.in
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2020-present Samsung Electronics Co., Ltd
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*/
|
||||
|
||||
#ifndef __EscargotInfo__
|
||||
#define __EscargotInfo__
|
||||
|
||||
#ifndef ESCARGOT_VERSION
|
||||
#define ESCARGOT_VERSION "@ESCARGOT_BUILD_VERSION@"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -152,13 +152,30 @@ bool CodeCache::tryInitCacheList()
|
|||
return false;
|
||||
}
|
||||
|
||||
// load list entries from file
|
||||
// open list file
|
||||
FILE* listFile = fopen(listFilePath.data(), "rb");
|
||||
if (!listFile) {
|
||||
ESCARGOT_LOG_ERROR("[CodeCache] can't open the cache list file %s\n", listFilePath.data());
|
||||
return false;
|
||||
}
|
||||
|
||||
// check Escargot version
|
||||
size_t cacheVerHash;
|
||||
if (UNLIKELY(fread(&cacheVerHash, sizeof(size_t), 1, listFile) != 1)) {
|
||||
ESCARGOT_LOG_ERROR("[CodeCache] fread of %s failed\n", listFilePath.data());
|
||||
fclose(listFile);
|
||||
return false;
|
||||
}
|
||||
std::string currentVer = ESCARGOT_VERSION;
|
||||
ASSERT(currentVer.length() > 0);
|
||||
size_t currentVerHash = std::hash<std::string>{}(currentVer);
|
||||
if (UNLIKELY(currentVerHash != cacheVerHash)) {
|
||||
ESCARGOT_LOG_ERROR("[CodeCache] Different Escargot version (current: %zu / cache: %zu), clear cache\n", currentVerHash, cacheVerHash);
|
||||
fclose(listFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// load list entries from file
|
||||
size_t listSize;
|
||||
if (UNLIKELY(fread(&listSize, sizeof(size_t), 1, listFile) != 1)) {
|
||||
ESCARGOT_LOG_ERROR("[CodeCache] fread of %s failed\n", listFilePath.data());
|
||||
|
|
@ -646,8 +663,18 @@ bool CodeCache::writeCacheList()
|
|||
return false;
|
||||
}
|
||||
|
||||
// first write Escargot version
|
||||
std::string version = ESCARGOT_VERSION;
|
||||
ASSERT(version.length() > 0);
|
||||
size_t versionHash = std::hash<std::string>{}(version);
|
||||
if (UNLIKELY(fwrite(&versionHash, sizeof(size_t), 1, listFile) != 1)) {
|
||||
ESCARGOT_LOG_ERROR("[CodeCache] fwrite of %s failed\n", cacheListFilePath.data());
|
||||
fclose(listFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t listSize = m_cacheList.size();
|
||||
// first write the number of cache entries
|
||||
// write the number of cache entries
|
||||
if (UNLIKELY(fwrite(&listSize, sizeof(size_t), 1, listFile) != 1)) {
|
||||
ESCARGOT_LOG_ERROR("[CodeCache] fwrite of %s failed\n", cacheListFilePath.data());
|
||||
fclose(listFile);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue