splash include git sha1

This commit is contained in:
James Cherry 2019-07-07 09:58:47 -07:00
parent d7248abcab
commit db6b650a52
11 changed files with 249 additions and 37 deletions

View File

@ -27,6 +27,11 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(STA_HOME ${PROJECT_SOURCE_DIR}) set(STA_HOME ${PROJECT_SOURCE_DIR})
message(STATUS "STA version: ${PROJECT_VERSION}") message(STATUS "STA version: ${PROJECT_VERSION}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC STA_GIT_SHA1)
message(STATUS "STA git sha: ${STA_GIT_SHA1}")
# Default to bulding optimnized/release executable. # Default to bulding optimnized/release executable.
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE) set(CMAKE_BUILD_TYPE RELEASE)

View File

@ -0,0 +1,168 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# git_local_changes(<var>)
#
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
# Uses the return code of "git diff-index --quiet HEAD --".
# Does not regard untracked files.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
# check if this is a submodule
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_local_changes _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
execute_process(COMMAND
"${GIT_EXECUTABLE}"
diff-index --quiet HEAD --
WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(res EQUAL 0)
set(${_var} "CLEAN" PARENT_SCOPE)
else()
set(${_var} "DIRTY" PARENT_SCOPE)
endif()
endfunction()

View File

@ -0,0 +1,41 @@
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
set(HEAD_HASH)
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()

View File

@ -51,7 +51,6 @@ Graph::Graph(StaState *sta,
slew_tr_count_(slew_tr_count), slew_tr_count_(slew_tr_count),
have_arc_delays_(have_arc_delays), have_arc_delays_(have_arc_delays),
ap_count_(ap_count), ap_count_(ap_count),
float_pool_(nullptr),
width_check_annotations_(nullptr), width_check_annotations_(nullptr),
period_check_annotations_(nullptr) period_check_annotations_(nullptr)
{ {
@ -63,9 +62,8 @@ Graph::~Graph()
delete edges_; delete edges_;
deleteSlewPools(); deleteSlewPools();
deleteArcDelayPools(); deleteArcDelayPools();
delete width_check_annotations_; removeWidthCheckAnnotations();
delete period_check_annotations_; removePeriodCheckAnnotations();
delete float_pool_;
} }
void void
@ -1010,7 +1008,7 @@ Graph::setWidthCheckAnnotation(const Pin *pin,
float *widths = width_check_annotations_->findKey(pin); float *widths = width_check_annotations_->findKey(pin);
if (widths == nullptr) { if (widths == nullptr) {
int width_count = TransRiseFall::index_count * ap_count_; int width_count = TransRiseFall::index_count * ap_count_;
widths = makeFloats(width_count); widths = new float[width_count];
// Use negative (illegal) width values to indicate unannotated checks. // Use negative (illegal) width values to indicate unannotated checks.
for (int i = 0; i < width_count; i++) for (int i = 0; i < width_count; i++)
widths[i] = -1; widths[i] = -1;
@ -1024,11 +1022,10 @@ void
Graph::removeWidthCheckAnnotations() Graph::removeWidthCheckAnnotations()
{ {
if (width_check_annotations_) { if (width_check_annotations_) {
int width_count = TransRiseFall::index_count * ap_count_;
WidthCheckAnnotations::Iterator check_iter(width_check_annotations_); WidthCheckAnnotations::Iterator check_iter(width_check_annotations_);
while (check_iter.hasNext()) { while (check_iter.hasNext()) {
float *widths = check_iter.next(); float *widths = check_iter.next();
deleteFloats(widths, width_count); delete [] widths;
} }
delete width_check_annotations_; delete width_check_annotations_;
width_check_annotations_ = nullptr; width_check_annotations_ = nullptr;
@ -1064,9 +1061,9 @@ Graph::setPeriodCheckAnnotation(const Pin *pin,
period_check_annotations_ = new PeriodCheckAnnotations; period_check_annotations_ = new PeriodCheckAnnotations;
float *periods = period_check_annotations_->findKey(pin); float *periods = period_check_annotations_->findKey(pin);
if (periods == nullptr) { if (periods == nullptr) {
periods = makeFloats(ap_count_); periods = new float[ap_count_];
// Use negative (illegal) period values to indicate unannotated checks. // Use negative (illegal) period values to indicate unannotated checks.
for (DcalcAPIndex i = 0; i < ap_count_; i++) for (int i = 0; i < ap_count_; i++)
periods[i] = -1; periods[i] = -1;
(*period_check_annotations_)[pin] = periods; (*period_check_annotations_)[pin] = periods;
} }
@ -1079,7 +1076,7 @@ Graph::removePeriodCheckAnnotations()
if (period_check_annotations_) { if (period_check_annotations_) {
for (auto pin_floats : *period_check_annotations_) { for (auto pin_floats : *period_check_annotations_) {
float *periods = pin_floats.second; float *periods = pin_floats.second;
deleteFloats(periods, ap_count_); delete [] periods;
} }
delete period_check_annotations_; delete period_check_annotations_;
period_check_annotations_ = nullptr; period_check_annotations_ = nullptr;
@ -1103,20 +1100,6 @@ Graph::removeDelaySlewAnnotations()
removePeriodCheckAnnotations(); removePeriodCheckAnnotations();
} }
float *
Graph::makeFloats(ObjectIndex count)
{
if (float_pool_ == nullptr)
float_pool_ = new Pool<float>(100);
return float_pool_->makeObjects(count);
}
void
Graph::deleteFloats(float *floats, ObjectIndex count)
{
float_pool_->deleteObjects(floats, count);
}
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// //
// Vertex // Vertex

View File

@ -216,9 +216,6 @@ protected:
void deleteOutEdge(Vertex *vertex, void deleteOutEdge(Vertex *vertex,
Edge *edge); Edge *edge);
void removeDelays(); void removeDelays();
float *makeFloats(ObjectIndex count);
void deleteFloats(float *floats,
ObjectIndex count);
void removeDelayAnnotated(Edge *edge); void removeDelayAnnotated(Edge *edge);
// User defined predicate to filter graph edges for liberty timing arcs. // User defined predicate to filter graph edges for liberty timing arcs.
virtual bool filterEdge(TimingArcSet *) const { return true; } virtual bool filterEdge(TimingArcSet *) const { return true; }
@ -240,7 +237,6 @@ protected:
DelayPoolSeq slew_pools_; // [ap_index][tr_index][vertex_index] DelayPoolSeq slew_pools_; // [ap_index][tr_index][vertex_index]
VertexIndex slew_count_; VertexIndex slew_count_;
DelayPoolSeq arc_delays_; // [ap_index][edge_arc_index] DelayPoolSeq arc_delays_; // [ap_index][edge_arc_index]
Pool<float> *float_pool_;
// Sdf width check annotations. // Sdf width check annotations.
WidthCheckAnnotations *width_check_annotations_; WidthCheckAnnotations *width_check_annotations_;
// Sdf period check annotations. // Sdf period check annotations.

View File

@ -1167,7 +1167,9 @@ ConcreteNetwork::replaceCell(Instance *inst,
int port_count = ccell->portBitCount(); int port_count = ccell->portBitCount();
ConcreteInstance *cinst = reinterpret_cast<ConcreteInstance*>(inst); ConcreteInstance *cinst = reinterpret_cast<ConcreteInstance*>(inst);
ConcretePin **pins = cinst->pins_; ConcretePin **pins = cinst->pins_;
ConcretePin **rpins = new ConcretePin*[port_count]{nullptr}; ConcretePin **rpins = new ConcretePin*[port_count];
for (int i = 0; i < port_count; i++)
rpins[i] = nullptr;
for (int i = 0; i < port_count; i++) { for (int i = 0; i < port_count; i++) {
ConcretePin *cpin = pins[i]; ConcretePin *cpin = pins[i];
if (cpin) { if (cpin) {
@ -1489,8 +1491,11 @@ void
ConcreteInstance::initPins() ConcreteInstance::initPins()
{ {
int pin_count = reinterpret_cast<ConcreteCell*>(cell_)->portBitCount(); int pin_count = reinterpret_cast<ConcreteCell*>(cell_)->portBitCount();
if (pin_count) if (pin_count) {
pins_ = new ConcretePin*[pin_count]{nullptr}; pins_ = new ConcretePin*[pin_count];
for (int i = 0; i < pin_count; i++)
pins_[i] = nullptr;
}
else else
pins_ = nullptr; pins_ = nullptr;
} }

View File

@ -1071,7 +1071,9 @@ ConcreteParasitics::makePiElmore(const Pin *drvr_pin,
if (parasitics == nullptr) { if (parasitics == nullptr) {
int ap_count = corners_->parasiticAnalysisPtCount(); int ap_count = corners_->parasiticAnalysisPtCount();
int ap_tr_count = ap_count * TransRiseFall::index_count; int ap_tr_count = ap_count * TransRiseFall::index_count;
parasitics = new ConcreteParasitic*[ap_tr_count]{nullptr}; parasitics = new ConcreteParasitic*[ap_tr_count];
for (int i = 0; i < ap_tr_count; i++)
parasitics[i] = nullptr;
drvr_parasitic_map_[drvr_pin] = parasitics; drvr_parasitic_map_[drvr_pin] = parasitics;
} }
int ap_tr_index = parasiticAnalysisPtIndex(ap, tr); int ap_tr_index = parasiticAnalysisPtIndex(ap, tr);
@ -1189,7 +1191,9 @@ ConcreteParasitics::makePiPoleResidue(const Pin *drvr_pin,
if (parasitics == nullptr) { if (parasitics == nullptr) {
int ap_count = corners_->parasiticAnalysisPtCount(); int ap_count = corners_->parasiticAnalysisPtCount();
int ap_tr_count = ap_count * TransRiseFall::index_count; int ap_tr_count = ap_count * TransRiseFall::index_count;
parasitics = new ConcreteParasitic*[ap_tr_count]{nullptr}; parasitics = new ConcreteParasitic*[ap_tr_count];
for (int i = 0; i < ap_tr_count; i++)
parasitics[i] = nullptr;
drvr_parasitic_map_[drvr_pin] = parasitics; drvr_parasitic_map_[drvr_pin] = parasitics;
} }
int ap_tr_index = parasiticAnalysisPtIndex(ap, tr); int ap_tr_index = parasiticAnalysisPtIndex(ap, tr);
@ -1312,7 +1316,9 @@ ConcreteParasitics::makeParasiticNetwork(const Net *net,
ConcreteParasiticNetwork **parasitics = parasitic_network_map_.findKey(net); ConcreteParasiticNetwork **parasitics = parasitic_network_map_.findKey(net);
if (parasitics == nullptr) { if (parasitics == nullptr) {
int ap_count = corners_->parasiticAnalysisPtCount(); int ap_count = corners_->parasiticAnalysisPtCount();
parasitics = new ConcreteParasiticNetwork*[ap_count]{nullptr}; parasitics = new ConcreteParasiticNetwork*[ap_count];
for (int i = 0; i < ap_count; i++)
parasitics[i] = nullptr;
parasitic_network_map_[net] = parasitics; parasitic_network_map_[net] = parasitics;
} }
int ap_index = ap->index(); int ap_index = ap->index();

View File

@ -197,7 +197,7 @@ define_cmd_args "set_units" \
# It merely checks that the library units are the same as the # It merely checks that the library units are the same as the
# units in the set_units command. # units in the set_units command.
proc set_units { args } { proc set_units { args } {
parse_key_args "set_cmd_units" args \ parse_key_args "set_units" args \
keys {-capacitance -resistance -time -voltage -current -power} flags {} keys {-capacitance -resistance -time -voltage -current -power} flags {}
if { [llength $args] != 0 } { if { [llength $args] != 0 } {
cmd_usage_error "set_units" cmd_usage_error "set_units"

View File

@ -25,12 +25,12 @@ namespace eval sta {
define_cmd_args show_splash {} define_cmd_args show_splash {}
proc show_splash {} { proc show_splash {} {
puts {OpenSTA Copyright (c) 2018, Parallax Software, Inc. puts "OpenSTA [sta::version] [string range [sta::git_sha1] 0 9] Copyright (c) 2019, Parallax Software, Inc.
License GPLv3: GNU GPL version 3 <http://gnu.org/licenses/gpl.html> License GPLv3: GNU GPL version 3 <http://gnu.org/licenses/gpl.html>
This is free software, and you are free to change and redistribute it This is free software, and you are free to change and redistribute it
under certain conditions; type `show_copying' for details. under certain conditions; type `show_copying' for details.
This program comes with ABSOLUTELY NO WARRANTY; for details type `show_warranty'.} This program comes with ABSOLUTELY NO WARRANTY; for details type `show_warranty'."
} }
define_cmd_args show_warranty {} define_cmd_args show_warranty {}

View File

@ -1909,6 +1909,12 @@ version()
return STA_VERSION; return STA_VERSION;
} }
const char *
git_sha1()
{
return STA_GIT_SHA1;
}
void void
redirect_file_begin(const char *filename) redirect_file_begin(const char *filename)
{ {

View File

@ -1,5 +1,7 @@
#define STA_VERSION "${STA_VERSION}" #define STA_VERSION "${STA_VERSION}"
#define STA_GIT_SHA1 "${STA_GIT_SHA1}"
#define ZLIB ${ZLIB} #define ZLIB ${ZLIB}
#define CUDD ${CUDD} #define CUDD ${CUDD}