mirror of
https://github.com/google/sentencepiece.git
synced 2024-12-29 11:11:58 +03:00
Fixed the issue of concatinating paths for pkg-config
This commit is contained in:
parent
de150504f8
commit
460d15b31d
@ -94,6 +94,30 @@ if (NOT DEFINED CMAKE_INSTALL_INCDIR)
|
||||
set(CMAKE_INSTALL_INCDIR include)
|
||||
endif()
|
||||
|
||||
# SPDX-License-Identifier: (MIT OR CC0-1.0)
|
||||
# Copyright 2020 Jan Tojnar
|
||||
# https://github.com/jtojnar/cmake-snips
|
||||
#
|
||||
# Modelled after Python’s os.path.join
|
||||
# https://docs.python.org/3.7/library/os.path.html#os.path.join
|
||||
# Windows not supported
|
||||
function(join_paths joined_path first_path_segment)
|
||||
set(temp_path "${first_path_segment}")
|
||||
foreach(current_segment IN LISTS ARGN)
|
||||
if(NOT ("${current_segment}" STREQUAL ""))
|
||||
if(IS_ABSOLUTE "${current_segment}")
|
||||
set(temp_path "${current_segment}")
|
||||
else()
|
||||
set(temp_path "${temp_path}/${current_segment}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${joined_path} "${temp_path}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
||||
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
configure_file("${PROJECT_SOURCE_DIR}/config.h.in" "config.h")
|
||||
configure_file("${PROJECT_SOURCE_DIR}/sentencepiece.pc.in" "sentencepiece.pc" @ONLY)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
libdir=@libdir_for_pc_file@
|
||||
includedir=@includedir_for_pc_file@
|
||||
|
||||
Name: @PROJECT_NAME@
|
||||
Description: Unsupervised text tokenizer and detokenizer for Neural Network-based text generation.
|
||||
|
20
third_party/absl/flags/flag.cc
vendored
20
third_party/absl/flags/flag.cc
vendored
@ -61,8 +61,8 @@ struct FlagFunc {
|
||||
|
||||
namespace {
|
||||
|
||||
using FlagMap = std::map<std::string, FlagFunc *>;
|
||||
using FlagList = std::vector<FlagFunc *>;
|
||||
using FlagMap = std::map<std::string, std::shared_ptr<FlagFunc>>;
|
||||
using FlagList = std::vector<std::shared_ptr<FlagFunc>>;
|
||||
|
||||
FlagMap *GetFlagMap() {
|
||||
static auto *flag_map = new FlagMap;
|
||||
@ -111,7 +111,7 @@ std::string PrintHelp(const char *programname) {
|
||||
os << PACKAGE_STRING << "\n\n";
|
||||
os << "Usage: " << programname << " [options] files\n\n";
|
||||
|
||||
for (const auto *func : *GetFlagList()) {
|
||||
for (auto func : *GetFlagList()) {
|
||||
os << " --" << func->name << " (" << func->help << ")";
|
||||
os << " type: " << func->type << " default: " << func->default_value
|
||||
<< '\n';
|
||||
@ -123,7 +123,7 @@ std::string PrintHelp(const char *programname) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void RegisterFlag(const std::string &name, FlagFunc *func) {
|
||||
void RegisterFlag(const std::string &name, std::shared_ptr<FlagFunc> func) {
|
||||
GetFlagList()->emplace_back(func);
|
||||
GetFlagMap()->emplace(name, func);
|
||||
}
|
||||
@ -140,7 +140,7 @@ Flag<T>::Flag(const char *name, const char *type, const char *help,
|
||||
func_->set_value = [this](const std::string &value) {
|
||||
this->set_value_as_str(value);
|
||||
};
|
||||
RegisterFlag(name, func_.get());
|
||||
RegisterFlag(name, func_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -219,4 +219,14 @@ std::vector<char *> ParseCommandLine(int argc, char *argv[]) {
|
||||
|
||||
return output_args;
|
||||
}
|
||||
|
||||
void CleanupFlags() {
|
||||
static bool is_shutdown = false;
|
||||
if (!is_shutdown) {
|
||||
delete internal::GetFlagList();
|
||||
delete internal::GetFlagMap();
|
||||
is_shutdown = true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace absl
|
||||
|
10
third_party/absl/flags/flag.h
vendored
10
third_party/absl/flags/flag.h
vendored
@ -24,7 +24,8 @@ namespace absl {
|
||||
namespace internal {
|
||||
struct FlagFunc;
|
||||
|
||||
void RegisterFlag(const std::string &name, FlagFunc *func);
|
||||
void RegisterFlag(const std::string &name, std::shared_ptr<FlagFunc> func);
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <typename T>
|
||||
@ -39,7 +40,7 @@ class Flag {
|
||||
|
||||
private:
|
||||
T value_;
|
||||
std::unique_ptr<internal::FlagFunc> func_;
|
||||
std::shared_ptr<internal::FlagFunc> func_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@ -52,6 +53,11 @@ void SetFlag(Flag<T> *flag, const V &v) {
|
||||
const T value(v);
|
||||
flag->set_value(value);
|
||||
}
|
||||
|
||||
#define HAS_ABSL_CLEANUP_FLAGS
|
||||
|
||||
void CleanupFlags();
|
||||
|
||||
} // namespace absl
|
||||
|
||||
#define ABSL_FLAG(Type, name, defautl_value, help) \
|
||||
|
Loading…
Reference in New Issue
Block a user