Skip to content

Commit

Permalink
[GLUTEN-6094][CH] Add gluten commit info in local engine
Browse files Browse the repository at this point in the history
  • Loading branch information
lwz9103 committed Jun 14, 2024
1 parent 8f21484 commit ba6cd07
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
25 changes: 25 additions & 0 deletions cpp-ch/local-engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ else()
add_definitions(-DENABLE_MULTITARGET_CODE=0)
endif()

get_filename_component(CURRENT_DIR ${CMAKE_CURRENT_LIST_DIR} ABSOLUTE)
if(IS_SYMLINK "${CURRENT_DIR}")
get_filename_component(REAL_DIR "${CURRENT_DIR}" REALPATH)
get_filename_component(PARENT_DIR "${REAL_DIR}" DIRECTORY)
else()
get_filename_component(PARENT_DIR "${CURRENT_DIR}" DIRECTORY)
endif()
execute_process(
COMMAND git log -n 1 --pretty=format:%h,%an,%ad -- "${PARENT_DIR}"
WORKING_DIRECTORY ${PARENT_DIR}
OUTPUT_VARIABLE LAST_CHANGE
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "," ";" CHANGE_PARTS ${LAST_CHANGE})
list(GET CHANGE_PARTS 0 COMMIT_HASH)
list(GET CHANGE_PARTS 1 COMMIT_AUTHOR)
list(GET CHANGE_PARTS 2 COMMIT_DATE)

message("Last change in gluten/cpp-ch directory:")
message("Commit: ${COMMIT_HASH}")
message("Author: ${COMMIT_AUTHOR}")
message("Date: ${COMMIT_DATE}")

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gluten_version.h.in
${CMAKE_CURRENT_SOURCE_DIR}/gluten_version.h)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -ffunction-sections -fdata-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -ffunction-sections -fdata-sections")
set(CMAKE_SHARED_LINKER_FLAGS
Expand Down
27 changes: 27 additions & 0 deletions cpp-ch/local-engine/gluten_version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef VERSION_H
#define VERSION_H

namespace local_engine {
constexpr const char* COMMIT_HASH = "@COMMIT_HASH@";
constexpr const char* COMMIT_AUTHOR = "@COMMIT_AUTHOR@";
constexpr const char* COMMIT_DATE = "@COMMIT_DATE@";
}

#endif // VERSION_H
7 changes: 6 additions & 1 deletion cpp-ch/local-engine/local_engine_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <numeric>
#include <string>
#include <jni.h>

#include <gluten_version.h>
#include <Builder/SerializedPlanBuilder.h>
#include <Compression/CompressedReadBuffer.h>
#include <DataTypes/DataTypeNullable.h>
Expand Down Expand Up @@ -130,6 +130,11 @@ JNIEXPORT jint JNI_OnLoad(JavaVM * vm, void * /*reserved*/)
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_8) != JNI_OK)
return JNI_ERR;

LOG_INFO(&Poco::Logger::get("jni"), "gluten version info:");
LOG_INFO(&Poco::Logger::get("jni"), "gluten commit hash: {}", local_engine::COMMIT_HASH);
LOG_INFO(&Poco::Logger::get("jni"), "gluten commit author: {}", local_engine::COMMIT_AUTHOR);
LOG_INFO(&Poco::Logger::get("jni"), "gluten commit date: {}", local_engine::COMMIT_DATE);

local_engine::JniErrorsGlobalState::instance().initialize(env);

spark_row_info_class = local_engine::CreateGlobalClassReference(env, "Lorg/apache/gluten/row/SparkRowInfo;");
Expand Down

0 comments on commit ba6cd07

Please sign in to comment.