diff --git a/.bazelrc b/.bazelrc index c5b23138aa..9a1b5663ec 100644 --- a/.bazelrc +++ b/.bazelrc @@ -261,6 +261,7 @@ test:linux --test_env LD_LIBRARY_PATH=/opt/opencv/lib/:/opt/intel/openvino/runti # genai hardcodes path during build time so without this so is not visible test:linux --test_env OPENVINO_TOKENIZERS_PATH_GENAI=/opt/intel/openvino/runtime/lib/intel64/libopenvino_tokenizers.so test:linux --test_env PYTHONPATH=/opt/intel/openvino/python:/ovms/bazel-bin/src/python/binding +test:linux --test_env no_proxy=localhost # Bazelrc imports ############################################################################################################################ # file below should contain sth like diff --git a/Dockerfile.redhat b/Dockerfile.redhat index ee12466597..8b219d12e0 100644 --- a/Dockerfile.redhat +++ b/Dockerfile.redhat @@ -118,6 +118,10 @@ RUN dnf install -y https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os libicu-devel && \ dnf clean all +WORKDIR /lfs +RUN wget -q --content-disposition "https://packagecloud.io/github/git-lfs/packages/el/9/git-lfs-3.6.1-1.el9.x86_64.rpm/download.rpm?distro_version_id=240" +RUN dnf install -y git-lfs-3.6.1-1.el9.x86_64.rpm && dnf clean all + RUN python3 --version && python3 -m pip install numpy==1.21.0 --no-cache-dir ARG INSTALL_DRIVER_VERSION="23.22.26516" diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 1c0c529a7b..2037850775 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -44,7 +44,8 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ patch \ pkg-config \ wget \ - zlib1g-dev && \ + zlib1g-dev \ + git-lfs && \ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 && \ update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9 && \ apt-get clean && \ diff --git a/WORKSPACE b/WORKSPACE index 20b36dae26..2778be8dc0 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -472,6 +472,10 @@ aws_sdk_cpp() load("@//third_party/llm_engine:llm_engine.bzl", "llm_engine") llm_engine() +### Libgit2 +load("@//third_party/libgt2:libgt2_engine.bzl", "libgt2_engine") +libgt2_engine() + load("@//third_party/drogon:drogon.bzl", "drogon_cpp") drogon_cpp() diff --git a/ci/build_test_OnCommit.groovy b/ci/build_test_OnCommit.groovy index 84e251d08c..24f90c20f9 100644 --- a/ci/build_test_OnCommit.groovy +++ b/ci/build_test_OnCommit.groovy @@ -91,6 +91,7 @@ pipeline { when { expression { image_build_needed == "true" } } steps { sh "echo build --remote_cache=${env.OVMS_BAZEL_REMOTE_CACHE_URL} > .user.bazelrc" + sh "echo test:linux --test_env https_proxy=${env.HTTPS_PROXY} >> .user.bazelrc" sh "make ovms_builder_image RUN_TESTS=0 OPTIMIZE_BUILDING_TESTS=1 OV_USE_BINARY=1 BASE_OS=redhat OVMS_CPP_IMAGE_TAG=${shortCommit} BUILD_IMAGE=openvino/model_server-build:${shortCommit}" } } diff --git a/create_package.sh b/create_package.sh index a9b72bc6e4..6a1309bf29 100755 --- a/create_package.sh +++ b/create_package.sh @@ -85,6 +85,8 @@ patchelf --debug --set-rpath '$ORIGIN' /ovms_release/lib/libopenvino.so patchelf --debug --set-rpath '$ORIGIN' /ovms_release/lib/lib*plugin.so if [ -f /ovms_release/lib/libopenvino_nvidia_gpu_plugin.so ] && [ "$BASE_OS" != "redhat" ]; then patchelf --replace-needed libcutensor.so.1 /usr/lib/x86_64-linux-gnu/libcutensor/11/libcutensor.so.1 /ovms_release/lib/libopenvino_nvidia_gpu_plugin.so ; fi +cp -P /usr/bin/git-lfs . + cd /ovms cp -v /ovms/release_files/LICENSE /ovms_release/ cp -v /ovms/release_files/metadata.json /ovms_release/ diff --git a/external/lfs.patch b/external/lfs.patch new file mode 100644 index 0000000000..e50f8cbd95 --- /dev/null +++ b/external/lfs.patch @@ -0,0 +1,389 @@ +commit aef9047d67d08027afe0417d6c681bfdc4666f5e +Author: rasapala +Date: Fri Mar 14 09:23:35 2025 +0100 + + Lfs + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 31da49a88..d61c9735e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -121,11 +121,6 @@ include(ExperimentalFeatures) + + add_subdirectory(src) + +-if(BUILD_TESTS) +- enable_testing() +- add_subdirectory(tests) +-endif() +- + if(BUILD_EXAMPLES) + add_subdirectory(examples) + endif() +diff --git a/include/git2/sys/filter.h b/include/git2/sys/filter.h +index 60466d173..a35ad5f98 100644 +--- a/include/git2/sys/filter.h ++++ b/include/git2/sys/filter.h +@@ -32,11 +32,19 @@ GIT_EXTERN(git_filter *) git_filter_lookup(const char *name); + /** The "ident" filter */ + #define GIT_FILTER_IDENT "ident" + ++/** The "lfs" filter */ ++#define GIT_FILTER_LFS "lfs" ++ + /** + * This is priority that the internal CRLF filter will be registered with + */ + #define GIT_FILTER_CRLF_PRIORITY 0 + ++/** ++ * This is priority that the internal CRLF filter will be registered with ++ */ ++#define GIT_FILTER_LFS_PRIORITY 199 ++ + /** + * This is priority that the internal ident filter will be registered with + */ +diff --git a/src/cli/cmd_clone.c b/src/cli/cmd_clone.c +index c18cb28d4..286fa7153 100644 +--- a/src/cli/cmd_clone.c ++++ b/src/cli/cmd_clone.c +@@ -146,6 +146,7 @@ int cmd_clone(int argc, char **argv) + clone_opts.bare = !!bare; + clone_opts.checkout_branch = branch; + clone_opts.fetch_opts.depth = compute_depth(depth); ++ clone_opts.fetch_opts.proxy_opts.type = GIT_PROXY_AUTO; + + if (!checkout) + clone_opts.checkout_opts.checkout_strategy = GIT_CHECKOUT_NONE; +diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt +index a7d3c7ca4..f78a25e35 100644 +--- a/src/libgit2/CMakeLists.txt ++++ b/src/libgit2/CMakeLists.txt +@@ -69,8 +69,6 @@ set_target_properties(libgit2package PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJE + ide_split_sources(libgit2package) + + if(SONAME) +- set_target_properties(libgit2package PROPERTIES VERSION ${libgit2_VERSION}) +- set_target_properties(libgit2package PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}") + if(LIBGIT2_FILENAME) + target_compile_definitions(libgit2package PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\") + set_target_properties(libgit2package PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME}) +diff --git a/src/libgit2/checkout.c b/src/libgit2/checkout.c +index f4b1ea96f..d8d4dee35 100644 +--- a/src/libgit2/checkout.c ++++ b/src/libgit2/checkout.c +@@ -1529,6 +1529,7 @@ static int blob_content_to_file( + mode_t file_mode = data->opts.file_mode ? + data->opts.file_mode : entry_filemode; + git_filter_session filter_session = GIT_FILTER_SESSION_INIT; ++ + struct checkout_stream writer; + mode_t mode; + git_filter_list *fl = NULL; +diff --git a/src/libgit2/filter.c b/src/libgit2/filter.c +index 9e0910c8c..a27b55340 100644 +--- a/src/libgit2/filter.c ++++ b/src/libgit2/filter.c +@@ -190,7 +190,7 @@ static int filter_registry_insert( + + int git_filter_global_init(void) + { +- git_filter *crlf = NULL, *ident = NULL; ++ git_filter *crlf = NULL, *ident = NULL, *lfs = NULL; + int error = 0; + + if (git_rwlock_init(&filter_registry.lock) < 0) +@@ -205,7 +205,11 @@ int git_filter_global_init(void) + GIT_FILTER_CRLF, crlf, GIT_FILTER_CRLF_PRIORITY) < 0 || + (ident = git_ident_filter_new()) == NULL || + filter_registry_insert( +- GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0) ++ GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0 || ++ (lfs = git_lfs_filter_new()) == NULL || ++ filter_registry_insert( ++ GIT_FILTER_LFS, lfs, GIT_FILTER_LFS_PRIORITY) < 0 ++ ) + error = -1; + + if (!error) +@@ -215,6 +219,7 @@ done: + if (error) { + git_filter_free(crlf); + git_filter_free(ident); ++ git_filter_free(lfs); + } + + return error; +diff --git a/src/libgit2/filter.h b/src/libgit2/filter.h +index 58cb4b424..00ddee9f3 100644 +--- a/src/libgit2/filter.h ++++ b/src/libgit2/filter.h +@@ -72,6 +72,7 @@ extern int git_filter_list__apply_to_file( + + extern git_filter *git_crlf_filter_new(void); + extern git_filter *git_ident_filter_new(void); ++extern git_filter *git_lfs_filter_new(void); + + extern int git_filter_buffered_stream_new( + git_writestream **out, +diff --git a/src/libgit2/lfs_filter.c b/src/libgit2/lfs_filter.c +new file mode 100644 +index 000000000..aac0d6dda +--- /dev/null ++++ b/src/libgit2/lfs_filter.c +@@ -0,0 +1,254 @@ ++/* ++/ Copyright 2025 Intel Corporation ++/ ++/ Licensed 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. ++*/ ++ ++#include "common.h" ++ ++#include "git2/sys/filter.h" ++#include "filter.h" ++#include "str.h" ++#include "process.h" ++#include "repository.h" ++ ++#ifndef GIT_WIN32 ++#include ++#endif ++ ++typedef struct lfs_attrs ++{ ++ const char *path; ++ const char* full_path; ++ const char* workdir; ++} lfs_attrs; ++ ++char *appendCharToBuffer(char *existingBuffer, char additionalChar) ++{ ++ size_t existingLength = strlen(existingBuffer); ++ char *newBuffer = (char *)malloc((existingLength + 2) * sizeof(char)); ++ if (newBuffer == NULL) { ++ return NULL; ++ } ++ strcpy(newBuffer, existingBuffer); ++ newBuffer[existingLength] = additionalChar; ++ newBuffer[existingLength + 1] = '\0'; ++ return newBuffer; ++} ++ ++static int lfs_insert_id( ++ git_str *to, const git_str *from, const git_filter_source *src, void** payload) ++{ ++ git_repository *repo = git_filter_source_repo(src); ++ const char *path = git_filter_source_path(src); ++ ++ git_str full_path = GIT_STR_INIT; ++ if (git_repository_workdir_path(&full_path, repo, path) < 0) ++ return -1; ++ ++ size_t workdir_size = strlen(git_repository_workdir(repo)); ++ ++ const char *workdir = git_repository_workdir(repo); ++ struct lfs_attrs la = { path, full_path.ptr, workdir }; ++ ++ *payload = git__malloc(sizeof(la)); ++ GIT_ERROR_CHECK_ALLOC(*payload); ++ memcpy(*payload, &la, sizeof(la)); ++ ++ /*Just write the oryginal lfs file contents */ ++ return git_str_set(to, from->ptr, from->size); ++} ++ ++static int lfs_apply( ++ git_filter *self, ++ void **payload, ++ git_str *to, ++ const git_str *from, ++ const git_filter_source *src) ++{ ++ GIT_UNUSED(self); GIT_UNUSED(payload); ++ ++ if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE) ++ return lfs_insert_id(to, from, src, payload); ++ /*else ++ * PATH for upload lfs files not needed ++ return lfs_remove_id(to, from); ++ */ ++ return 0; ++} ++ ++static int lfs_check( ++ git_filter *self, ++ void **payload, /* points to NULL ptr on entry, may be set */ ++ const git_filter_source *src, ++ const char **attr_values) ++{ ++ const char *value; ++ ++ git_repository *repo = git_filter_source_repo(src); ++ const char *path = git_filter_source_path(src); ++ ++ git_attr_get( ++ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM, path, "filter"); ++ ++ if (value && *value) { ++ if (strcmp(value, "lfs") == 0) { ++ return 0; ++ } ++ } else { ++ return GIT_PASSTHROUGH; ++ } ++ ++ GIT_UNUSED(self); ++ ++ return 0; ++} ++ ++static int lfs_stream( ++ git_writestream **out, ++ git_filter *self, ++ void **payload, ++ const git_filter_source *src, ++ git_writestream *next) ++{ ++ return git_filter_buffered_stream_new(out, ++ self, lfs_apply, NULL, payload, src, next); ++} ++ ++static void lfs_download(git_filter *self, void *payload) ++{ ++ GIT_UNUSED(self); ++ struct lfs_attrs *la = (struct lfs_attrs *)payload; ++ char *tmp_out_file = appendCharToBuffer(la->full_path, '2'); ++ ++ git_process *process; ++ git_process_options opts = GIT_PROCESS_OPTIONS_INIT; ++ opts.cwd = la->workdir; ++ git_process_result result = GIT_PROCESS_RESULT_INIT; ++#if defined(GIT_WIN32) ++ const char *args_array[] = { "C:\\Windows\\System32\\cmd.exe", ++ "/c", ++ "git-lfs.exe", ++ "smudge", ++ la->path, ++ "<", ++ la->full_path, ++ ">", ++ tmp_out_file }; ++ if (git_process_new( ++ &process, args_array, ARRAY_SIZE(args_array), NULL, 0, ++ &opts) < 0) { ++ fprintf(stderr, "failed to create git-lfs process for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++#elif defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) || \ ++ defined(__MidnightBSD__) || defined(__DragonFly__) ++ git_str cmd_line = GIT_STR_INIT; ++ ++ if (git_str_printf(&cmd_line, "git-lfs smudge %s < %s > %s", la->path, la->full_path, tmp_out_file) < 0) { ++ fprintf(stderr, ++ "failed to create git-lfs command for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++ if (git_process_new_from_cmdline( ++ &process, cmd_line.ptr, NULL, 0, &opts) < 0) { ++ fprintf(stderr, "failed to create git-lfs process for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++#else ++ git_str cmd_line = GIT_STR_INIT; ++ if (git_str_printf( ++ &cmd_line, "git-lfs smudge %s < %s > %s", la->path, ++ la->full_path, tmp_out_file) < 0) { ++ fprintf(stderr, "failed to create git-lfs command for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++ if (git_process_new_from_cmdline( ++ &process, cmd_line.ptr, NULL, 0, &opts) < 0) { ++ fprintf(stderr, "failed to create git-lfs process for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++#endif ++ if (git_process_start(process) < 0) { ++ fprintf(stderr, "failed to start git-lfs process for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++ if (git_process_wait(&result, process) < 0) { ++ fprintf(stderr, "failed to wait for git-lfs process for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++ ++ if (GIT_PROCESS_STATUS_NORMAL != result.status) { ++ fprintf(stderr, ++ "abnormal process status for git-lfs process for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++ ++ if (0 != result.exitcode) { ++ fprintf(stderr, ++ "abnormal exitcode signal for git-lfs process for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++ if (0 != result.signal) { ++ fprintf(stderr, ++ "abnormal process signal for git-lfs process for '%s'\n", ++ la->full_path); ++ goto on_error; ++ } ++ ++ /* Remove lfs file and rename downloaded file to oryginal lfs filename ++ */ ++ if (p_unlink(la->full_path) < 0) { ++ fprintf(stderr, "failed to delete file '%s'", la->full_path); ++ goto on_error; ++ } ++ ++ if (p_rename(tmp_out_file, la->full_path) < 0) { ++ fprintf(stderr, "failed to rename file to '%s'", la->full_path); ++ goto on_error; ++ } ++ ++ git_process_free(process); ++ git__free(payload); ++ return; ++ ++on_error: ++ git_process_free(process); ++ git__free(payload); ++ return; ++} ++ ++git_filter *git_lfs_filter_new(void) ++{ ++ git_filter *f = git__calloc(1, sizeof(git_filter)); ++ if (f == NULL) ++ return NULL; ++ ++ f->version = GIT_FILTER_VERSION; ++ f->attributes = "lfs"; ++ f->shutdown = git_filter_free; ++ f->stream = lfs_stream; ++ f->check = lfs_check; ++ f->cleanup = lfs_download; ++ ++ return f; ++} diff --git a/release_files/thirdparty-licenses/libgt2.LICENSE.txt b/release_files/thirdparty-licenses/libgt2.LICENSE.txt new file mode 100644 index 0000000000..701792e9ac --- /dev/null +++ b/release_files/thirdparty-licenses/libgt2.LICENSE.txt @@ -0,0 +1,1410 @@ + libgit2 is Copyright (C) the libgit2 contributors, + unless otherwise stated. See the AUTHORS file for details. + + Note that the only valid version of the GPL as far as this project + is concerned is _this_ particular version of the license (ie v2, not + v2.2 or v3.x or whatever), unless explicitly otherwise stated. + +---------------------------------------------------------------------- + + LINKING EXCEPTION + + In addition to the permissions in the GNU General Public License, + the authors give you unlimited permission to link the compiled + version of this library into combinations with other programs, + and to distribute those combinations without any restriction + coming from the use of this file. (The General Public License + restrictions do apply in other respects; for example, they cover + modification of the file, and distribution when not linked into + a combined executable.) + +---------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + +---------------------------------------------------------------------- + +The bundled ZLib code is licensed under the ZLib license: + + (C) 1995-2022 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +---------------------------------------------------------------------- + +The Clar framework is licensed under the ISC license: + +Copyright (c) 2011-2015 Vicent Marti + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +---------------------------------------------------------------------- + +The bundled PCRE implementation (deps/pcre/) is licensed under the BSD +license. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the name of Google + Inc. nor the names of their contributors may be used to endorse or + promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------- + +The bundled winhttp definition files (deps/winhttp/) are licensed under +the GNU LGPL (available at the end of this file). + +Copyright (C) 2007 Francois Gouget + +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 St, Fifth Floor, Boston, MA 02110-1301, USA + +---------------------------------------------------------------------- + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + +---------------------------------------------------------------------- + +The bundled SHA1 collision detection code is licensed under the MIT license: + +MIT License + +Copyright (c) 2017: + Marc Stevens + Cryptology Group + Centrum Wiskunde & Informatica + P.O. Box 94079, 1090 GB Amsterdam, Netherlands + marc@marc-stevens.nl + + Dan Shumow + Microsoft Research + danshu@microsoft.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +---------------------------------------------------------------------- + +The bundled wildmatch code is licensed under the BSD license: + +Copyright Rich Salz. +All rights reserved. + +Redistribution and use in any form are permitted provided that the +following restrictions are are met: + +1. Source distributions must retain this entire copyright notice + and comment. +2. Binary distributions must include the acknowledgement ``This + product includes software developed by Rich Salz'' in the + documentation or other materials provided with the + distribution. This must not be represented as an endorsement + or promotion without specific prior written permission. +3. The origin of this software must not be misrepresented, either + by explicit claim or by omission. Credits must appear in the + source and documentation. +4. Altered versions must be plainly marked as such in the source + and documentation and must not be misrepresented as being the + original software. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +---------------------------------------------------------------------- + +Portions of the OpenSSL headers are included under the OpenSSL license: + +Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) +All rights reserved. + +This package is an SSL implementation written +by Eric Young (eay@cryptsoft.com). +The implementation was written so as to conform with Netscapes SSL. + +This library is free for commercial and non-commercial use as long as +the following conditions are aheared to. The following conditions +apply to all code found in this distribution, be it the RC4, RSA, +lhash, DES, etc., code; not just the SSL code. The SSL documentation +included with this distribution is covered by the same copyright terms +except that the holder is Tim Hudson (tjh@cryptsoft.com). + +Copyright remains Eric Young's, and as such any Copyright notices in +the code are not to be removed. +If this package is used in a product, Eric Young should be given attribution +as the author of the parts of the library used. +This can be in the form of a textual message at program startup or +in documentation (online or textual) provided with the package. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + "This product includes cryptographic software written by + Eric Young (eay@cryptsoft.com)" + The word 'cryptographic' can be left out if the rouines from the library + being used are not cryptographic related :-). +4. If you include any Windows specific code (or a derivative thereof) from + the apps directory (application code) you must include an acknowledgement: + "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + +THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +The licence and distribution terms for any publically available version or +derivative of this code cannot be changed. i.e. this code cannot simply be +copied and put under another distribution licence +[including the GNU Public Licence.] + +==================================================================== +Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + "This product includes software developed by the OpenSSL Project + for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + +4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + endorse or promote products derived from this software without + prior written permission. For written permission, please contact + openssl-core@openssl.org. + +5. Products derived from this software may not be called "OpenSSL" + nor may "OpenSSL" appear in their names without prior written + permission of the OpenSSL Project. + +6. Redistributions of any form whatsoever must retain the following + acknowledgment: + "This product includes software developed by the OpenSSL Project + for use in the OpenSSL Toolkit (http://www.openssl.org/)" + +THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY +EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------- + +The xoroshiro256** implementation is licensed in the public domain: + +Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org) + +To the extent possible under law, the author has dedicated all copyright +and related and neighboring rights to this software to the public domain +worldwide. This software is distributed without any warranty. + +See . + +---------------------------------------------------------------------- + +The built-in SHA256 support (src/hash/rfc6234) is taken from RFC 6234 +under the following license: + +Copyright (c) 2011 IETF Trust and the persons identified as +authors of the code. All rights reserved. + +Redistribution and use in source and binary forms, with or +without modification, are permitted provided that the following +conditions are met: + +- Redistributions of source code must retain the above + copyright notice, this list of conditions and + the following disclaimer. + +- Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + +- Neither the name of Internet Society, IETF or IETF Trust, nor + the names of specific contributors, may be used to endorse or + promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------- + +The built-in git_fs_path_basename_r() function is based on the +Android implementation, BSD licensed: + +Copyright (C) 2008 The Android Open Source Project +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +---------------------------------------------------------------------- + +The bundled ntlmclient code is licensed under the MIT license: + +Copyright (c) Edward Thomson. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +---------------------------------------------------------------------- + +Portions of this software derived from Team Explorer Everywhere: + +Copyright (c) Microsoft Corporation + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------------------------------------------- + +Portions of this software derived from the LLVM Compiler Infrastructure: + +Copyright (c) 2003-2016 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +--------------------------------------------------------------------------- + +Portions of this software derived from Unicode, Inc: + +Copyright 2001-2004 Unicode, Inc. + +Disclaimer + +This source code is provided as is by Unicode, Inc. No claims are +made as to fitness for any particular purpose. No warranties of any +kind are expressed or implied. The recipient agrees to determine +applicability of information provided. If this file has been +purchased on magnetic or optical media from Unicode, Inc., the +sole remedy for any claim will be exchange of defective media +within 90 days of receipt. + +Limitations on Rights to Redistribute This Code + +Unicode, Inc. hereby grants the right to freely use the information +supplied in this file in the creation of products supporting the +Unicode Standard, and to make copies of this file in any form +for internal or external distribution as long as this notice +remains attached. + +--------------------------------------------------------------------------- + +Portions of this software derived from sheredom/utf8.h: + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to + +--------------------------------------------------------------------------- + +Portions of this software derived from RFC 1320: + +Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD4 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD4 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + +---------------------------------------------------------------------- + +The bundled llhttp dependency is licensed under the MIT license: + +Copyright Fedor Indutny, 2018. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/spelling-whitelist.txt b/spelling-whitelist.txt index 6bb52f64c4..d6b81c0c06 100644 --- a/spelling-whitelist.txt +++ b/spelling-whitelist.txt @@ -22,3 +22,6 @@ WORKSPACE:98: thirdparty demos/classification_using_paddlepaddle_model/python/utils/imagenet_class_index.json release_files/thirdparty-licenses/icu.LICENSE.txt:146: TaBE ==> table, tab release_files/thirdparty-licenses/icu.LICENSE.txt:160: TaBE ==> table, tab +release_files/thirdparty-licenses/libgt2.LICENSE.txt:1040: aheared ==> adhered +release_files/thirdparty-licenses/libgt2.LICENSE.txt:1065: rouines ==> routines +release_files/thirdparty-licenses/libgt2.LICENSE.txt:1083: publically ==> publicly diff --git a/src/BUILD b/src/BUILD index 80088630ff..83c9ae0320 100644 --- a/src/BUILD +++ b/src/BUILD @@ -695,6 +695,7 @@ cc_library( "//:ovms_dependencies", # TODO dispose or replace "//src/kfserving_api:kfserving_api_cpp", "capimodule", + "//src/libgt2:hf_pull_model_module", "predict_request_validation_utils", # to be removed when capi has its own lib and added there @atobisze "kfs_backend_impl", "tfs_backend_impl", @@ -2910,6 +2911,7 @@ cc_test( ":network_utils_test", "//src:custom_nodes_common_buffersqueue", "@com_google_googletest//:gtest", + ":pull_hf_model_test", ] + select({ "//conditions:default": [ ":openvino_remote_tensors_tests", @@ -3010,6 +3012,22 @@ cc_library( ], copts = COPTS_TESTS, ) +cc_library( + name = "pull_hf_model_test", + linkstatic = 1, + alwayslink = True, + srcs = ["test/pull_hf_model_test.cpp"], + linkopts = [], + deps = [ + ":test_utils", + "//src/libgt2:libgt2", + "//src/libgt2:hf_pull_model_module", + "//src:ovms_lib", + "@com_google_googletest//:gtest", + ], + local_defines = COMMON_LOCAL_DEFINES, + copts = COPTS_TESTS, +) cc_library( name = "openvino_remote_tensors_tests", linkstatic = 1, diff --git a/src/capi_frontend/server_settings.hpp b/src/capi_frontend/server_settings.hpp index c5c9dce0a8..b16645df67 100644 --- a/src/capi_frontend/server_settings.hpp +++ b/src/capi_frontend/server_settings.hpp @@ -21,6 +21,12 @@ namespace ovms { +struct HFSettingsImpl { + std::string sourceModel = ""; + std::string downloadPath = ""; + bool pullHfModelMode = false; +}; + struct ServerSettingsImpl { uint32_t grpcPort = 0; uint32_t restPort = 0; @@ -45,6 +51,7 @@ struct ServerSettingsImpl { std::string cacheDir; bool withPython = false; bool startedWithCLI = false; + HFSettingsImpl hfSettings; }; struct ModelsSettingsImpl { diff --git a/src/cli_parser.cpp b/src/cli_parser.cpp index c6db68c5af..c5a611c909 100644 --- a/src/cli_parser.cpp +++ b/src/cli_parser.cpp @@ -126,6 +126,20 @@ void CLIParser::parse(int argc, char** argv) { "Absolute path to json configuration file", cxxopts::value(), "CONFIG_PATH"); + options->add_options("pull hf model") + ("pull", + "Pull model from HF", + cxxopts::value()->default_value("false"), + "PULL_HF") + ("source_model", + "HF source model path", + cxxopts::value(), + "HF_SOURCE") + ("download_path", + "HF model destination download path", + cxxopts::value(), + "DOWNLOAD_PATH"); + options->add_options("single model") ("model_name", "Name of the model", @@ -232,6 +246,19 @@ void CLIParser::prepare(ServerSettingsImpl* serverSettings, ModelsSettingsImpl* if (nullptr == result) { throw std::logic_error("Tried to prepare server and model settings without parse result"); } + + // Ovms Pull models mode + if (result->count("pull")) { + serverSettings->hfSettings.pullHfModelMode = result->operator[]("pull").as(); + if (result->count("source_model")) + serverSettings->hfSettings.sourceModel = result->operator[]("source_model").as(); + if (result->count("download_path")) + serverSettings->hfSettings.downloadPath = result->operator[]("download_path").as(); + return; + } else { + serverSettings->hfSettings.pullHfModelMode = false; + } + serverSettings->grpcPort = result->operator[]("port").as(); serverSettings->restPort = result->operator[]("rest_port").as(); diff --git a/src/config.cpp b/src/config.cpp index 4a6439c096..2a0c4b9add 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -93,6 +93,10 @@ bool Config::check_hostname_or_ip(const std::string& input) { } bool Config::validate() { + // TODO: Add validation of all parameters once the CLI model export flags will be implemented + if (this->serverSettings.hfSettings.pullHfModelMode) { + return true; + } if (!configPath().empty() && (!modelName().empty() || !modelPath().empty())) { std::cerr << "Use either config_path or model_path with model_name" << std::endl; return false; diff --git a/src/config.hpp b/src/config.hpp index e6376dd694..a08901867d 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -48,7 +48,7 @@ class Config { ServerSettingsImpl serverSettings; public: - ServerSettingsImpl getServerSettings() { + const ServerSettingsImpl& getServerSettings() const { return serverSettings; } ModelsSettingsImpl& getModelSettings() { diff --git a/src/libgt2/BUILD b/src/libgt2/BUILD new file mode 100644 index 0000000000..0bfbef2919 --- /dev/null +++ b/src/libgt2/BUILD @@ -0,0 +1,64 @@ +# +# Copyright (c) 2025 Intel Corporation +# +# Licensed 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. +# + +load("//:common_settings.bzl", + "COMMON_STATIC_LIBS_COPTS", "COMMON_STATIC_LIBS_LINKOPTS", "COMMON_FUZZER_COPTS", "COMMON_FUZZER_LINKOPTS", "COMMON_LOCAL_DEFINES", "PYBIND_DEPS") + +COPTS_ADJUSTED = COMMON_STATIC_LIBS_COPTS + select({ + "//conditions:default": [], + "//:fuzzer_build" : COMMON_FUZZER_COPTS, +}) + +LINKOPTS_ADJUSTED = COMMON_STATIC_LIBS_LINKOPTS + select({ + "//conditions:default": [], + "//:fuzzer_build" : COMMON_FUZZER_LINKOPTS, +}) + +cc_library( + name = "libgt2", + srcs = ["libgt2.cpp"], + hdrs = ["libgt2.hpp"], + deps = [ + "@libgt2_engine//:libgt2_engine", + "@ovms//src:libovmslogging", + "@ovms//src:libovmsstatus", + "@ovms//src:libovmsstring_utils", + ], + visibility = ["//visibility:public"], + copts = COPTS_ADJUSTED, + linkopts = LINKOPTS_ADJUSTED, + alwayslink = 1, + local_defines = COMMON_LOCAL_DEFINES, +) + +cc_library( + name = "hf_pull_model_module", + srcs = ["hf_pull_model_module.cpp"], + hdrs = ["hf_pull_model_module.hpp"], + deps = [ + ":libgt2", + "@ovms//src:cpp_headers", + "@ovms//src:libovmsstring_utils", + "@ovms//src:libovmslogging", + "@ovms//src:libovms_server_settings", + "@ovms//src:libovms_module", + ], + visibility = ["//visibility:public"], + copts = COPTS_ADJUSTED, + linkopts = LINKOPTS_ADJUSTED, + alwayslink = 1, + local_defines = COMMON_LOCAL_DEFINES, +) \ No newline at end of file diff --git a/src/libgt2/hf_pull_model_module.cpp b/src/libgt2/hf_pull_model_module.cpp new file mode 100644 index 0000000000..494f2dc7da --- /dev/null +++ b/src/libgt2/hf_pull_model_module.cpp @@ -0,0 +1,111 @@ +//*************************************************************************** +// Copyright 2025 Intel Corporation +// +// Licensed 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. +//***************************************************************************** +#include "hf_pull_model_module.hpp" + +#include +#include + +#include "../config.hpp" +#include "libgt2.hpp" +#include "../logging.hpp" +#include "../module_names.hpp" +#include "../status.hpp" +#include "../stringutils.hpp" + +namespace ovms { + +HfPullModelModule::HfPullModelModule() {} + +Status HfPullModelModule::start(const ovms::Config& config) { + state = ModuleState::STARTED_INITIALIZE; + SPDLOG_INFO("{} starting", HF_MODEL_PULL_MODULE_NAME); + + std::unique_ptr initGuard = std::make_unique(); + if (initGuard->status < 0) { + SPDLOG_ERROR("Failed to init libgit2 {}", initGuard->errMsg.c_str()); + return StatusCode::HF_FAILED_TO_INIT_LIBGIT2; + } + + this->hfSettings = config.getServerSettings().hfSettings; + + state = ModuleState::INITIALIZED; + SPDLOG_INFO("{} started", HF_MODEL_PULL_MODULE_NAME); + + return StatusCode::OK; +} + +Status HfPullModelModule::clone() const { + std::unique_ptr initGuard = std::make_unique(); + if (initGuard->status < 0) { + SPDLOG_ERROR("Failed to init libgit2 {}", initGuard->errMsg.c_str()); + return StatusCode::HF_FAILED_TO_INIT_LIBGIT2; + } + std::unique_ptr hfDownloader = std::make_unique(this->hfSettings.sourceModel, this->hfSettings.downloadPath, this->GetHfEndpoint(), this->GetHfToken(), this->GetProxy()); + // TODO: CVS-166568 Do we want to set timeout for this operation ? + auto status = hfDownloader->cloneRepository(); + if (!status.ok()) { + return status; + } + + return StatusCode::OK; +} + +const std::string HfPullModelModule::GetProxy() const { + std::string proxy = ""; + const char* envCred = std::getenv("https_proxy"); + if (envCred) + proxy = std::string(envCred); + return proxy; +} + +const std::string HfPullModelModule::GetHfToken() const { + std::string token = ""; + const char* envCred = std::getenv("HF_TOKEN"); + if (envCred) + token = std::string(envCred); + return token; +} + +const std::string HfPullModelModule::GetHfEndpoint() const { + const char* envCred = std::getenv("HF_ENDPOINT"); + std::string hfEndpoint = "huggingface.co"; + if (envCred) { + hfEndpoint = std::string(envCred); + } else { + SPDLOG_DEBUG("HF_ENDPOINT environment variable not set"); + } + + if (!endsWith(hfEndpoint, "/")) { + hfEndpoint.append("/"); + } + + return hfEndpoint; +} + +void HfPullModelModule::shutdown() { + if (state == ModuleState::SHUTDOWN) + return; + state = ModuleState::STARTED_SHUTDOWN; + SPDLOG_INFO("{} shutting down", HF_MODEL_PULL_MODULE_NAME); + state = ModuleState::SHUTDOWN; + SPDLOG_INFO("{} shutdown", HF_MODEL_PULL_MODULE_NAME); +} + +HfPullModelModule::~HfPullModelModule() { + this->shutdown(); +} + +} // namespace ovms diff --git a/src/libgt2/hf_pull_model_module.hpp b/src/libgt2/hf_pull_model_module.hpp new file mode 100644 index 0000000000..fe0061b1d4 --- /dev/null +++ b/src/libgt2/hf_pull_model_module.hpp @@ -0,0 +1,40 @@ +//**************************************************************************** +// Copyright 2025 Intel Corporation +// +// Licensed 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. +//***************************************************************************** +#pragma once +#include +#include + +#include "../module.hpp" +#include "../capi_frontend/server_settings.hpp" + +namespace ovms { + +class HfPullModelModule : public Module { +protected: + HFSettingsImpl hfSettings; + const std::string GetProxy() const; + const std::string GetHfToken() const; + const std::string GetHfEndpoint() const; + +public: + HfPullModelModule(); + ~HfPullModelModule(); + Status start(const ovms::Config& config) override; + void shutdown() override; + + Status clone() const; +}; +} // namespace ovms diff --git a/src/libgt2/libgt2.cpp b/src/libgt2/libgt2.cpp new file mode 100644 index 0000000000..07ac742933 --- /dev/null +++ b/src/libgt2/libgt2.cpp @@ -0,0 +1,240 @@ +//***************************************************************************** +// Copyright 2025 Intel Corporation +// +// Licensed 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. +//***************************************************************************** +#include "libgt2.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../stringutils.hpp" +#include "../logging.hpp" +#include "../status.hpp" + +#ifndef PRIuZ +/* Define the printf format specifier to use for size_t output */ +#if defined(_MSC_VER) || defined(__MINGW32__) +#define PRIuZ "Iu" +#else +#define PRIuZ "zu" +#endif +#endif +#ifdef __cplusplus +extern "C" { +#endif + +namespace ovms { + +// C-style callback functions section used in libgt2 library STARTS ******************************** +typedef struct progress_data { + git_indexer_progress fetch_progress; + size_t completed_steps; + size_t total_steps; + const char* path; +} progress_data; + +static void print_progress(const progress_data* pd) { + int network_percent = pd->fetch_progress.total_objects > 0 ? (100 * pd->fetch_progress.received_objects) / pd->fetch_progress.total_objects : 0; + int index_percent = pd->fetch_progress.total_objects > 0 ? (100 * pd->fetch_progress.indexed_objects) / pd->fetch_progress.total_objects : 0; + + int checkout_percent = pd->total_steps > 0 + ? (int)((100 * pd->completed_steps) / pd->total_steps) + : 0; + size_t kbytes = pd->fetch_progress.received_bytes / 1024; + + if (pd->fetch_progress.total_objects && + pd->fetch_progress.received_objects == pd->fetch_progress.total_objects) { + printf("Resolving deltas %u/%u\r", + pd->fetch_progress.indexed_deltas, + pd->fetch_progress.total_deltas); + } else { + printf("net %3d%% (%4" PRIuZ " kb, %5u/%5u) / idx %3d%% (%5u/%5u) / chk %3d%% (%4" PRIuZ "/%4" PRIuZ ")%s\n", + network_percent, kbytes, + pd->fetch_progress.received_objects, pd->fetch_progress.total_objects, + index_percent, pd->fetch_progress.indexed_objects, pd->fetch_progress.total_objects, + checkout_percent, + pd->completed_steps, pd->total_steps, + pd->path); + } +} + +static int sideband_progress(const char* str, int len, void* payload) { + (void)payload; /* unused */ + + printf("remote: %.*s", len, str); + fflush(stdout); + return 0; +} + +static int fetch_progress(const git_indexer_progress* stats, void* payload) { + progress_data* pd = (progress_data*)payload; + pd->fetch_progress = *stats; + print_progress(pd); + return 0; +} + +static void checkout_progress(const char* path, size_t cur, size_t tot, void* payload) { + progress_data* pd = (progress_data*)payload; + pd->completed_steps = cur; + pd->total_steps = tot; + pd->path = path; + print_progress(pd); +} + +// Callback for clone authentication - will be used when password is not set in repo_url +// Does not work with LFS download as it requires additional authentication when password is not set in repository url +int cred_acquire_cb(git_credential** out, + const char* url, + const char* username_from_url, + unsigned int allowed_types, + void* payload) { + char *username = NULL, *password = NULL; + int error = -1; + + fprintf(stdout, "Authentication is required for repository clone.\n"); + if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) { + const char* env_cred = std::getenv("HF_TOKEN"); +#ifdef __linux__ + if (env_cred) { + username = strdup(env_cred); + password = strdup(username); + } else { + fprintf(stderr, "HF_TOKEN env variable is not set.\n"); + return -1; + } +#elif _WIN32 + if (env_cred) { + username = _strdup(env_cred); + password = _strdup(username); + } else { + fprintf(stderr, "HF_TOKEN env variable is not set.\n"); + return -1; + } +#endif + error = git_credential_userpass_plaintext_new(out, username, password); + if (error < 0) { + fprintf(stderr, "Creating credentials failed.\n"); + error = -1; + } + } else { + fprintf(stderr, "Only USERPASS_PLAINTEXT supported in OVMS.\n"); + return 1; + } + + free(username); + free(password); + return error; +} + +// C-style callback functions section used in libgt2 library ENDS ******************************** +bool HfDownloader::CheckIfProxySet() { + if (this->httpProxy != "") + return true; + return false; +} + +std::string HfDownloader::GetRepositoryUrlWithPassword() { + std::string passRepoUrl = "https://"; + if (this->hfToken != "") { + passRepoUrl += this->hfToken + ":" + this->hfToken + "@"; + } else { + SPDLOG_DEBUG("HF_TOKEN environment variable not set"); + } + + passRepoUrl += this->hfEndpoint + this->sourceModel; + + return passRepoUrl; +} + +std::string HfDownloader::GetRepoUrl() { + std::string repoUrl = "https://"; + repoUrl += this->hfEndpoint + this->sourceModel; + return repoUrl; +} + +HfDownloader::HfDownloader() { + this->sourceModel = ""; + this->downloadPath = ""; + this->hfEndpoint = ""; + this->hfToken = ""; + this->httpProxy = ""; +} + +HfDownloader::HfDownloader(const std::string& sourceModel, const std::string& downloadPath, const std::string& hfEndpoint, const std::string& hfToken, const std::string& httpProxy) { + this->sourceModel = sourceModel; + this->downloadPath = downloadPath; + this->hfEndpoint = hfEndpoint; + this->hfToken = hfToken; + this->httpProxy = httpProxy; +} + +Status HfDownloader::cloneRepository() { + progress_data pd = {{0}}; + git_repository* cloned_repo = NULL; + git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; + git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; + + /* Set up options */ + checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE; + checkout_opts.progress_cb = checkout_progress; + checkout_opts.progress_payload = &pd; + clone_opts.checkout_opts = checkout_opts; + clone_opts.fetch_opts.callbacks.sideband_progress = sideband_progress; + clone_opts.fetch_opts.callbacks.transfer_progress = &fetch_progress; + clone_opts.fetch_opts.callbacks.credentials = cred_acquire_cb; + clone_opts.fetch_opts.callbacks.payload = &pd; + + // Use proxy + if (CheckIfProxySet()) { + clone_opts.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED; + clone_opts.fetch_opts.proxy_opts.url = this->httpProxy.c_str(); + SPDLOG_DEBUG("Download using https_proxy settings"); + } else { + SPDLOG_DEBUG("Download with https_proxy not set"); + } + + std::string repoUrl = GetRepoUrl(); + SPDLOG_DEBUG("Downloading from url: {}", repoUrl.c_str()); + std::string passRepoUrl = GetRepositoryUrlWithPassword(); + const char* url = passRepoUrl.c_str(); + const char* path = this->downloadPath.c_str(); + int error = git_clone(&cloned_repo, url, path, &clone_opts); + if (error != 0) { + const git_error* err = git_error_last(); + if (err) + SPDLOG_ERROR("Libgit2 clone error: {} message: {}", err->klass, err->message); + else + SPDLOG_ERROR("Libgit2 clone error: {}", error); + + return StatusCode::HF_GIT_CLONE_FAILED; + } else if (cloned_repo) { + git_repository_free(cloned_repo); + } + + return StatusCode::OK; +} + +} // namespace ovms +#ifdef __cplusplus +} +#endif diff --git a/src/libgt2/libgt2.hpp b/src/libgt2/libgt2.hpp new file mode 100644 index 0000000000..8ffa2ff8ce --- /dev/null +++ b/src/libgt2/libgt2.hpp @@ -0,0 +1,78 @@ +//***************************************************************************** +// Copyright 2025 Intel Corporation +// +// Licensed 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 SRC_LIBGT2_LIBGT2_HPP_ +#define SRC_LIBGT2_LIBGT2_HPP_ +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +namespace ovms { +class Status; + +class Libgt2InitGuard { +public: + int status; + std::string errMsg; + Libgt2InitGuard() { + this->status = git_libgit2_init(); + if (this->status < 0) { + const git_error* err = git_error_last(); + const char* msg = err ? err->message : "unknown failure"; + errMsg = std::string(msg); + } else { + errMsg = ""; + } + } + ~Libgt2InitGuard() { + git_libgit2_shutdown(); + } +}; + +class HfDownloader { +public: + HfDownloader(const std::string& sourceModel, const std::string& downloadPath, const std::string& hfEndpoint, const std::string& hfToken, const std::string& httpProxy); + Status cloneRepository(); + +protected: + std::string sourceModel; + std::string downloadPath; + std::string hfEndpoint; + std::string hfToken; + std::string httpProxy; + + HfDownloader(); + std::string GetRepoUrl(); + std::string GetRepositoryUrlWithPassword(); + bool CheckIfProxySet(); +}; + +} // namespace ovms +#ifdef __cplusplus +} +#endif +#endif // SRC_LIBGT2_LIBGT2_HPP_ diff --git a/src/module_names.cpp b/src/module_names.cpp index a6e3930f7e..0aad521ada 100644 --- a/src/module_names.cpp +++ b/src/module_names.cpp @@ -20,6 +20,7 @@ const std::string PROFILER_MODULE_NAME = "ProfilerModule"; const std::string GRPC_SERVER_MODULE_NAME = "GRPCServerModule"; const std::string HTTP_SERVER_MODULE_NAME = "HTTPServerModule"; const std::string SERVABLE_MANAGER_MODULE_NAME = "ServableManagerModule"; +const std::string HF_MODEL_PULL_MODULE_NAME = "HfModelPullModule"; const std::string METRICS_MODULE_NAME = "MetricsModule"; const std::string PYTHON_INTERPRETER_MODULE_NAME = "PythonInterpreterModule"; const std::string CAPI_MODULE_NAME = "C-APIModule"; diff --git a/src/module_names.hpp b/src/module_names.hpp index 06d345513c..a975f78fa3 100644 --- a/src/module_names.hpp +++ b/src/module_names.hpp @@ -21,6 +21,7 @@ extern const std::string PROFILER_MODULE_NAME; extern const std::string GRPC_SERVER_MODULE_NAME; extern const std::string HTTP_SERVER_MODULE_NAME; extern const std::string SERVABLE_MANAGER_MODULE_NAME; +extern const std::string HF_MODEL_PULL_MODULE_NAME; extern const std::string METRICS_MODULE_NAME; extern const std::string PYTHON_INTERPRETER_MODULE_NAME; extern const std::string CAPI_MODULE_NAME; diff --git a/src/server.cpp b/src/server.cpp index 092fe39ffc..a271c16d5e 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -31,7 +31,6 @@ #include #include -#include "ovms_exit_codes.hpp" #ifdef __linux__ #include #include @@ -53,13 +52,16 @@ #include "cli_parser.hpp" #include "config.hpp" #include "grpcservermodule.hpp" +#include "libgt2/hf_pull_model_module.hpp" #include "http_server.hpp" #include "httpservermodule.hpp" #include "kfs_frontend/kfs_grpc_inference_service.hpp" +#include "libgt2/libgt2.hpp" #include "logging.hpp" #include "metric_module.hpp" #include "model_service.hpp" #include "modelmanager.hpp" +#include "ovms_exit_codes.hpp" #include "prediction_service.hpp" #include "profiler.hpp" #include "profilermodule.hpp" @@ -89,6 +91,11 @@ static void logConfig(const Config& config) { SPDLOG_INFO(project_name + " " + project_version); SPDLOG_INFO("OpenVINO backend {}", OPENVINO_NAME); SPDLOG_DEBUG("CLI parameters passed to ovms server"); + if (config.getServerSettings().hfSettings.pullHfModelMode) { + SPDLOG_DEBUG("source_model: {}", config.getServerSettings().hfSettings.sourceModel); + SPDLOG_DEBUG("download_path: {}", config.getServerSettings().hfSettings.downloadPath); + return; + } if (config.configPath().empty()) { SPDLOG_DEBUG("model_path: {}", config.modelPath()); SPDLOG_DEBUG("model_name: {}", config.modelName()); @@ -250,6 +257,8 @@ std::unique_ptr Server::createModule(const std::string& name) { return std::make_unique(); if (name == CAPI_MODULE_NAME) return std::make_unique(*this); + if (name == HF_MODEL_PULL_MODULE_NAME) + return std::make_unique(); return nullptr; } @@ -292,6 +301,18 @@ Status Server::startModules(ovms::Config& config) { Status status; bool inserted = false; auto it = modules.end(); + + if (config.getServerSettings().hfSettings.pullHfModelMode) { + INSERT_MODULE(HF_MODEL_PULL_MODULE_NAME, it); + START_MODULE(it); + if (!status.ok()) { + return status; + } + auto hfModule = dynamic_cast(it->second.get()); + status = hfModule->clone(); + return status; + } + #if (PYTHON_DISABLE == 0) if (config.getServerSettings().withPython) { INSERT_MODULE(PYTHON_INTERPRETER_MODULE_NAME, it); @@ -351,6 +372,7 @@ class ModulesShutdownGuard { void Server::shutdownModules() { // we want very precise order of modules shutdown // first we should stop incoming new requests + ensureModuleShutdown(HF_MODEL_PULL_MODULE_NAME); ensureModuleShutdown(GRPC_SERVER_MODULE_NAME); ensureModuleShutdown(HTTP_SERVER_MODULE_NAME); ensureModuleShutdown(SERVABLE_MANAGER_MODULE_NAME); @@ -385,12 +407,13 @@ int Server::start(int argc, char** argv) { ModelsSettingsImpl modelsSettings; parser.parse(argc, argv); parser.prepare(&serverSettings, &modelsSettings); + Status ret = start(&serverSettings, &modelsSettings); ModulesShutdownGuard shutdownGuard(*this); if (!ret.ok()) { return statusToExitCode(ret); } - while (!shutdown_request) { + while (!shutdown_request && !serverSettings.hfSettings.pullHfModelMode) { std::this_thread::sleep_for(std::chrono::milliseconds(200)); } if (shutdown_request == 2) { diff --git a/src/status.cpp b/src/status.cpp index 9e43681f12..1ef3de3e68 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -333,6 +333,10 @@ const std::unordered_map Status::statusMessageMap = { {StatusCode::SERVER_ALREADY_STARTING, "Server is already starting"}, {StatusCode::MODULE_ALREADY_INSERTED, "Module already inserted"}, + // Huggingface model download errors for libgit2 + {StatusCode::HF_FAILED_TO_INIT_LIBGIT2, "Failed to initialize libgit2 library"}, + {StatusCode::HF_GIT_CLONE_FAILED, "Failed in libgit2 execution of clone method"}, + {StatusCode::PARTIAL_END, "Request has finished and no further communication is needed"}, }; } // namespace ovms diff --git a/src/status.hpp b/src/status.hpp index 4fddd853f3..3cf9d8b32c 100644 --- a/src/status.hpp +++ b/src/status.hpp @@ -344,6 +344,10 @@ enum class StatusCode { SERVER_ALREADY_STARTING, MODULE_ALREADY_INSERTED, + // Huggingface model download errors for libgit2 + HF_FAILED_TO_INIT_LIBGIT2, + HF_GIT_CLONE_FAILED, + PARTIAL_END, STATUS_CODE_END diff --git a/src/test/pull_hf_model_test.cpp b/src/test/pull_hf_model_test.cpp new file mode 100644 index 0000000000..7a2daf8878 --- /dev/null +++ b/src/test/pull_hf_model_test.cpp @@ -0,0 +1,137 @@ +//***************************************************************************** +// Copyright 2025 Intel Corporation +// +// Licensed 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. +//***************************************************************************** +#include +#include +#include + +#include +#include + +#include "test_utils.hpp" +#include "../filesystem.hpp" +#include "../libgt2/hf_pull_model_module.hpp" +#include "src/libgt2/libgt2.hpp" +#include "../server.hpp" + +class HfDownloaderPullHfModel : public TestWithTempDir { +protected: + ovms::Server& server = ovms::Server::instance(); + std::unique_ptr t; + + void ServerPullHfModel(std::string& sourceModel, std::string& downloadPath) { + ::SetUpServerForDownload(this->t, this->server, sourceModel, downloadPath); + } + void TearDown() { + server.setShutdownRequest(1); + t->join(); + server.setShutdownRequest(0); + // Clone sets readonly - need to remove it before we can delete on windows + RemoveReadonlyFileAttributeFromDir(this->directoryPath); + TestWithTempDir::TearDown(); + } +}; + +TEST_F(HfDownloaderPullHfModel, PositiveDownload) { + std::string modelName = "OpenVINO/Phi-3-mini-FastDraft-50M-int8-ov"; + std::string downloadPath = ovms::FileSystem::appendSlash(this->directoryPath) + "repository"; + this->ServerPullHfModel(modelName, downloadPath); + std::string modelPath = ovms::FileSystem::appendSlash(downloadPath) + "openvino_model.bin"; + ASSERT_EQ(std::filesystem::exists(modelPath), true); + ASSERT_EQ(std::filesystem::file_size(modelPath), 52417240); +} + +class TestHfDownloader : public ovms::HfDownloader { +public: + TestHfDownloader(const std::string& sourceModel, const std::string& downloadPath, const std::string& hfEndpoint, const std::string& hfToken, const std::string& httpProxy) : + HfDownloader(sourceModel, downloadPath, hfEndpoint, hfToken, httpProxy) {} + std::string GetRepoUrl() { return HfDownloader::GetRepoUrl(); } + std::string GetRepositoryUrlWithPassword() { return HfDownloader::GetRepositoryUrlWithPassword(); } + bool CheckIfProxySet() { return HfDownloader::CheckIfProxySet(); } + void setProxy(const std::string& proxy) { this->httpProxy = proxy; } + void setEndpoint(const std::string& endpoint) { this->hfEndpoint = endpoint; } + const std::string& getEndpoint() { return this->hfEndpoint; } + const std::string& getProxy() { return this->httpProxy; } +}; + +TEST(HfDownloaderClassTest, Methods) { + std::string modelName = "model/name"; + std::string downloadPath = "/path/to/Download"; + std::string hfEndpoint = "www.new_hf.com/"; + std::string hfToken = "123$$o_O123!AAbb"; + std::string httpProxy = "https://proxy_test1:123"; + std::unique_ptr hfDownloader = std::make_unique(modelName, downloadPath, hfEndpoint, hfToken, httpProxy); + ASSERT_EQ(hfDownloader->getProxy(), httpProxy); + ASSERT_EQ(hfDownloader->CheckIfProxySet(), true); + + EXPECT_EQ(TestHfDownloader(modelName, downloadPath, hfEndpoint, hfToken, "").CheckIfProxySet(), false); + ASSERT_EQ(hfDownloader->getEndpoint(), "www.new_hf.com/"); + ASSERT_EQ(hfDownloader->GetRepoUrl(), "https://www.new_hf.com/model/name"); + ASSERT_EQ(hfDownloader->GetRepositoryUrlWithPassword(), "https://123$$o_O123!AAbb:123$$o_O123!AAbb@www.new_hf.com/model/name"); +} + +class TestHfPullModelModule : public ovms::HfPullModelModule { +public: + const std::string GetHfToken() const { return HfPullModelModule::GetHfToken(); } + const std::string GetHfEndpoint() const { return HfPullModelModule::GetHfEndpoint(); } + const std::string GetProxy() const { return HfPullModelModule::GetProxy(); } +}; + +class HfDownloaderHfEnvTest : public ::testing::Test { +public: + std::string oldHfEndpoint = ""; + std::string oldHfToken = ""; + std::string oldHttpProxy = ""; + std::string proxy_env = "https_proxy"; + std::string token_env = "HF_TOKEN"; + std::string endpoint_env = "HF_ENDPOINT"; + void SetUp() { + this->oldHttpProxy = GetEnvVar(proxy_env); + this->oldHfToken = GetEnvVar(token_env); + this->oldHfEndpoint = GetEnvVar(endpoint_env); + } + + void TearDown() { + SetEnvironmentVar(proxy_env, oldHttpProxy); + SetEnvironmentVar(token_env, oldHfToken); + SetEnvironmentVar(endpoint_env, oldHfEndpoint); + } +}; + +TEST_F(HfDownloaderHfEnvTest, Methods) { + std::string modelName = "model/name"; + std::string downloadPath = "/path/to/Download"; + std::unique_ptr testHfPullModelModule = std::make_unique(); + + std::string proxy = "https://proxy_test1:123"; + UnSetEnvironmentVar(proxy_env); + ASSERT_EQ(testHfPullModelModule->GetProxy(), ""); + SetEnvironmentVar(proxy_env, proxy); + ASSERT_EQ(testHfPullModelModule->GetProxy(), proxy); + + std::string token = "123$$o_O123!AAbb"; + UnSetEnvironmentVar(token_env); + ASSERT_EQ(testHfPullModelModule->GetHfToken(), ""); + SetEnvironmentVar(token_env, token); + ASSERT_EQ(testHfPullModelModule->GetHfToken(), token); + + std::string endpoint = "www.new_hf.com"; + UnSetEnvironmentVar(endpoint_env); + ASSERT_EQ(testHfPullModelModule->GetHfEndpoint(), "huggingface.co/"); + SetEnvironmentVar(endpoint_env, endpoint); + + std::string hfEndpoint = testHfPullModelModule->GetHfEndpoint(); + ASSERT_EQ(hfEndpoint, "www.new_hf.com/"); +} diff --git a/src/test/test_utils.cpp b/src/test/test_utils.cpp index 6b89e8b880..7b7dd655ce 100644 --- a/src/test/test_utils.cpp +++ b/src/test/test_utils.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -306,6 +307,12 @@ void checkIncrement4DimShape(const std::string outputName, } } +void RemoveReadonlyFileAttributeFromDir(std::string& directoryPath) { + for (const std::filesystem::directory_entry& dir_entry : std::filesystem::recursive_directory_iterator(directoryPath)) { + std::filesystem::permissions(dir_entry, std::filesystem::perms::owner_read | std::filesystem::perms::owner_write | std::filesystem::perms::owner_exec | std::filesystem::perms::group_read | std::filesystem::perms::group_write | std::filesystem::perms::others_read, std::filesystem::perm_options::add); + } +} + bool isShapeTheSame(const tensorflow::TensorShapeProto& actual, const std::vector&& expected) { bool same = true; if (static_cast(actual.dim_size()) != expected.size()) { @@ -624,6 +631,28 @@ std::string* findKFSInferInputTensorContentInRawInputs(::KFSRequest& request, co return content; } +void SetEnvironmentVar(const std::string& var, const std::string& val) { +#ifdef _WIN32 + _putenv_s(var.c_str(), val.c_str()); +#elif __linux__ + ::setenv(var.c_str(), val.c_str(), 1); +#endif +} +void UnSetEnvironmentVar(const std::string& var) { +#ifdef _WIN32 + _putenv_s(var.c_str(), ""); +#elif __linux__ + ::unsetenv(var.c_str()); +#endif +} +const std::string GetEnvVar(const std::string& var) { + std::string val = ""; + const char* envCred = std::getenv(var.c_str()); + if (envCred) + val = std::string(envCred); + return val; +} + void prepareCAPIInferInputTensor(ovms::InferenceRequest& request, const std::string& name, const std::tuple& inputInfo, const std::vector& data, uint32_t decrementBufferSize, OVMS_BufferType bufferType, std::optional deviceId) { auto [shape, type] = inputInfo; @@ -696,6 +725,30 @@ void EnsureServerStartedWithTimeout(ovms::Server& server, int timeoutSeconds) { ASSERT_EQ(server.getModuleState(ovms::SERVABLE_MANAGER_MODULE_NAME), ovms::ModuleState::INITIALIZED) << "OVMS did not fully load until allowed time:" << timeoutSeconds << "s. Check machine load"; } +void EnsureServerModelDownloadFinishedWithTimeout(ovms::Server& server, int timeoutSeconds) { + auto start = std::chrono::high_resolution_clock::now(); + while ((server.getModuleState(ovms::HF_MODEL_PULL_MODULE_NAME) != ovms::ModuleState::SHUTDOWN) && + (std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - start).count() < timeoutSeconds)) { + } + ASSERT_EQ(server.getModuleState(ovms::HF_MODEL_PULL_MODULE_NAME), ovms::ModuleState::SHUTDOWN) << "OVMS did not download model in allowed time:" << timeoutSeconds << "s. Check machine load and network load"; +} + +// --pull --source_model OpenVINO/Phi-3-mini-FastDraft-50M-int8-ov --download_path c:\download +void SetUpServerForDownload(std::unique_ptr& t, ovms::Server& server, std::string& source_model, std::string& download_path, int timeoutSeconds) { + server.setShutdownRequest(0); + char* argv[] = {(char*)"ovms", + (char*)"--pull", + (char*)"--source_model", + (char*)source_model.c_str(), + (char*)"--download_path", + (char*)download_path.c_str()}; + int argc = 6; + t.reset(new std::thread([&argc, &argv, &server]() { + EXPECT_EQ(EXIT_SUCCESS, server.start(argc, argv)); + })); + + EnsureServerModelDownloadFinishedWithTimeout(server, timeoutSeconds); +} void SetUpServer(std::unique_ptr& t, ovms::Server& server, std::string& port, const char* configPath, int timeoutSeconds) { server.setShutdownRequest(0); randomizeAndEnsureFree(port); diff --git a/src/test/test_utils.hpp b/src/test/test_utils.hpp index 931f20848d..9af4424b7d 100644 --- a/src/test/test_utils.hpp +++ b/src/test/test_utils.hpp @@ -63,6 +63,10 @@ using inputs_info_t = std::map>; +void SetEnvironmentVar(const std::string& var, const std::string& val); +void UnSetEnvironmentVar(const std::string& var); +const std::string GetEnvVar(const std::string& var); + const std::string& getGenericFullPathForSrcTest(const std::string& linuxPath, bool logChange = true); const std::string& getGenericFullPathForSrcTest(const char* linuxPath, bool logChange = true); const std::string& getGenericFullPathForTmp(const std::string& linuxPath, bool logChange = true); @@ -779,6 +783,8 @@ class ResourcesAccessModelManager : public ConstructorEnabledModelManager { } }; +void RemoveReadonlyFileAttributeFromDir(std::string& directoryPath); + class TestWithTempDir : public ::testing::Test { protected: void SetUp() override { @@ -1029,6 +1035,15 @@ extern const int64_t SERVER_START_FROM_CONFIG_TIMEOUT_SECONDS; * Waits until server is ready */ void EnsureServerStartedWithTimeout(ovms::Server& server, int timeoutSeconds); +/* + * Waits until server downloads model + */ +void EnsureServerModelDownloadFinishedWithTimeout(ovms::Server& server, int timeoutSeconds); +/* + * starts loading OVMS on separate thread but waits until it is shutdowned or model is downloaded + * --pull --source_model OpenVINO/Phi-3-mini-FastDraft-50M-int8-ov --download_path c:\download + */ +void SetUpServerForDownload(std::unique_ptr& t, ovms::Server& server, std::string& source_model, std::string& download_path, int timeoutSeconds = SERVER_START_FROM_CONFIG_TIMEOUT_SECONDS); /* * starts loading OVMS on separate thread but waits until it is ready */ diff --git a/third_party/libgt2/BUILD b/third_party/libgt2/BUILD new file mode 100644 index 0000000000..a3354b20e4 --- /dev/null +++ b/third_party/libgt2/BUILD @@ -0,0 +1,15 @@ +# +# Copyright (c) 2025 Intel Corporation +# +# Licensed 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. +# diff --git a/third_party/libgt2/libgt2_engine.bzl b/third_party/libgt2/libgt2_engine.bzl new file mode 100644 index 0000000000..b7eb7e0321 --- /dev/null +++ b/third_party/libgt2/libgt2_engine.bzl @@ -0,0 +1,149 @@ +# +# Copyright (c) 2025 Intel Corporation +# +# Licensed 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. +# + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") + +def _is_windows(ctx): + return ctx.os.name.lower().find("windows") != -1 + +def libgt2_engine(): + libgt2_repository(name="_libgt2_engine") + new_git_repository( + name = "libgt2_engine", + remote = "https://github.com/libgit2/libgit2.git", + commit = "338e6fb681369ff0537719095e22ce9dc602dbf0", # Dec 28, 2024 - v1.9.0 + build_file = "@_libgt2_engine//:BUILD", + patch_args = ["-p1"], + # Patch implements git-lfs filter, required for HF models download + patches = ["lfs.patch"], + ) + + #native.new_local_repository( + # name = "libgt2_engine", + # path = "/libgt2_engine", + # build_file = "@_libgt2_engine//:BUILD", + #) + +def _impl(repository_ctx): + http_proxy = repository_ctx.os.environ.get("http_proxy", "") + if http_proxy == "": + http_proxy = repository_ctx.os.environ.get("HTTP_PROXY", "") + + https_proxy = repository_ctx.os.environ.get("https_proxy", "") + if https_proxy == "": + https_proxy = repository_ctx.os.environ.get("HTTPS_PROXY", "") + + if _is_windows(repository_ctx): + lib_name = "git2" + out_static = "out_interface_libs = [\"{lib_name}.lib\"],".format(lib_name=lib_name) + out_libs = "out_shared_libs = [\"{lib_name}.dll\"],".format(lib_name=lib_name) + cache_entries = """ + "CMAKE_POSITION_INDEPENDENT_CODE": "ON", + "CMAKE_CXX_FLAGS": " -s -D_GLIBCXX_USE_CXX11_ABI=1", + "CMAKE_LIBRARY_OUTPUT_DIRECTORY": "Debug", + "WIN32": "True", + "X86_64": "True", + "BUILD_EXAMPLES": "OFF", + "BUILD_TESTS": "OFF", + "BUILD_CLI": "OFF" + """ + else: + lib_name = "libgit2" + out_static = "" + out_libs = "out_shared_libs = [\"{lib_name}.so\"],".format(lib_name=lib_name) + cache_entries = """ + "CMAKE_POSITION_INDEPENDENT_CODE": "ON", + "CMAKE_CXX_FLAGS": " -s -D_GLIBCXX_USE_CXX11_ABI=1 -Wno-error=deprecated-declarations -Wuninitialized", + "CMAKE_ARCHIVE_OUTPUT_DIRECTORY": "lib", + "CMAKE_INSTALL_LIBDIR": "lib", + "BUILD_EXAMPLES": "OFF", + "BUILD_TESTS": "OFF", + "BUILD_CLI": "OFF", + """ + + # Note that we need to escape '{/}' by doubling them due to call to format + build_file_content = """ +load("@rules_foreign_cc//foreign_cc:cmake.bzl", "cmake") +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +visibility = ["//visibility:public"] + +config_setting( + name = "dbg", + values = {{"compilation_mode": "dbg"}}, +) + +config_setting( + name = "opt", + values = {{"compilation_mode": "opt"}}, +) + +filegroup( + name = "all_srcs", + srcs = glob(["**"], exclude = ["tests/**"]), + visibility = ["//visibility:public"], +) + +build_release = {{"CMAKE_BUILD_TYPE": "Release"}} +build_debug = {{"CMAKE_BUILD_TYPE": "Debug"}} + +cmake( + name = "libgt2_cmake", + build_args = [ + "--verbose", + "--", # <- Pass remaining options to the native tool. + # https://github.com/bazelbuild/rules_foreign_cc/issues/329 + # there is no elegant parallel compilation support + #"-j 32", + ], + cache_entries = {{ + {cache_entries} + }} | select({{ + "//conditions:default": dict( + build_release + ), + ":dbg": dict( + build_debug + ), + }}), + env = {{ + "http_proxy": "{http_proxy}", + "https_proxy": "{https_proxy}", + }}, + lib_source = ":all_srcs", + out_include_dir = "include", + {out_libs} + {out_static} + tags = ["requires-network"], + visibility = ["//visibility:public"], + lib_name = "{lib_name}", + deps = [] +) + +cc_library( + name = "libgt2_engine", + deps = [ + ":libgt2_cmake", + ], + visibility = ["//visibility:public"], +) +""" + repository_ctx.file("BUILD", build_file_content.format(http_proxy=http_proxy, https_proxy=https_proxy, + lib_name=lib_name, out_libs=out_libs, cache_entries=cache_entries, out_static=out_static)) + +libgt2_repository = repository_rule( + implementation = _impl, + local=True, +) diff --git a/windows_build.bat b/windows_build.bat index dc7f3bd08b..f4cfbc84a3 100644 --- a/windows_build.bat +++ b/windows_build.bat @@ -37,6 +37,7 @@ set "setOvmsVersionCmd=python windows_set_ovms_version.py" :: Setting PATH environment variable based on default windows node settings: Added ovms_windows specific python settings and c:/opt and removed unused Nvidia and OCL specific tools. :: When changing the values here you can print the node default PATH value and base your changes on it. set "setPath=C:\opt;C:\opt\Python312\;C:\opt\Python312\Scripts\;C:\opt\msys64\usr\bin\;%PATH%;" +set "PYTHONHOME=C:\opt\Python312" set "envPath=win_environment.log" set "setPythonPath=%cd%\bazel-out\x64_windows-opt\bin\src\python\binding" set "BAZEL_SH=C:\opt\msys64\usr\bin\bash.exe" diff --git a/windows_create_package.bat b/windows_create_package.bat index 32b3ba12fb..dc2174d328 100644 --- a/windows_create_package.bat +++ b/windows_create_package.bat @@ -76,6 +76,11 @@ copy /Y %cd%\bazel-out\x64_windows-opt\bin\src\openvino_genai.dll dist\windows\o if !errorlevel! neq 0 exit /b !errorlevel! copy /Y %cd%\bazel-out\x64_windows-opt\bin\src\openvino_tokenizers.dll dist\windows\ovms if !errorlevel! neq 0 exit /b !errorlevel! +copy /Y %cd%\bazel-out\x64_windows-opt\bin\src\git2.dll dist\windows\ovms +if !errorlevel! neq 0 exit /b !errorlevel! +copy /Y %dest_dir%\git-lfs.exe dist\windows\ovms +if !errorlevel! neq 0 exit /b !errorlevel! + :: Old package had core_tokenizers if exist %cd%\bazel-out\x64_windows-opt\bin\src\core_tokenizers.dll ( copy /Y %cd%\bazel-out\x64_windows-opt\bin\src\core_tokenizers.dll dist\windows\ovms diff --git a/windows_install_build_dependencies.bat b/windows_install_build_dependencies.bat index 3f4bfe11ac..915f78aaee 100644 --- a/windows_install_build_dependencies.bat +++ b/windows_install_build_dependencies.bat @@ -40,7 +40,7 @@ set "opt_install_dir=C:\opt" :: Python 312 needs to be first in the windows path, as well as MSYS tools set "setPath=C:\opt;C:\opt\Python312\;C:\opt\Python312\Scripts\;C:\opt\msys64\usr\bin\;c:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\;%PATH%;" - +set "PYTHONHOME=C:\opt\Python312" :: Set proper PATH environment variable: Remove other python paths and add c:\opt with bazel, wget to PATH set "PATH=%setPath%" @@ -247,6 +247,66 @@ IF /I EXIST %bazel_path% ( if !errorlevel! neq 0 exit /b !errorlevel! ) echo [INFO] Bazel installed: %bazel_file% + + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +::::::::::::::::::::::: git-lfs - reinstalled per worker +set "gitlfs_dir=git-lfs-3.6.1" +set "gitlfs_short_dir=" +set "gitlfs_ver=git-lfs-windows-amd64-v3.6.1.zip" +set "gitlfs_http=https://github.com/git-lfs/git-lfs/releases/download/v3.6.1/" + +set "gitlfs_zip=%opt_install_dir%\%gitlfs_ver%" + +echo [INFO] Installing git-lfs: %gitlfs_dir% ... +:: Download git-lfs +IF /I EXIST %gitlfs_zip% ( + if %expunge% EQU 1 ( + del /S /Q %gitlfs_zip% + if !errorlevel! neq 0 exit /b !errorlevel! + %wget_path% -P %opt_install_dir%\ %gitlfs_http%%gitlfs_ver% + if !errorlevel! neq 0 exit /b !errorlevel! + ) else ( echo [INFO] file exists %gitlfs_zip% ) + +) ELSE ( + %wget_path% -P %opt_install_dir%\ %gitlfs_http%%gitlfs_ver% + if !errorlevel! neq 0 exit /b !errorlevel! +) +:: Extract git-lfs +IF /I EXIST %opt_install_dir%\%gitlfs_dir% ( + if %expunge% EQU 1 ( + rmdir /S /Q %opt_install_dir%\%gitlfs_dir% + if !errorlevel! neq 0 exit /b !errorlevel! + C:\Windows\System32\tar.exe -xf "%gitlfs_zip%" -C %opt_install_dir% + if !errorlevel! neq 0 exit /b !errorlevel! + ) else ( echo [INFO] directory exists %opt_install_dir%\%gitlfs_dir% ) + +) ELSE ( + C:\Windows\System32\tar.exe -xf "%gitlfs_zip%" -C %opt_install_dir% + if !errorlevel! neq 0 exit /b !errorlevel! +) + +:: Check git-lfs.exe +IF /I EXIST %opt_install_dir%\%gitlfs_dir%\git-lfs.exe ( + if %expunge% EQU 1 ( + rmdir /S /Q %opt_install_dir%\%gitlfs_dir% + if !errorlevel! neq 0 exit /b !errorlevel! + C:\Windows\System32\tar.exe -xf "%gitlfs_zip%" -C %opt_install_dir% + if !errorlevel! neq 0 exit /b !errorlevel! + ) else ( echo [INFO] file exists %opt_install_dir%\%gitlfs_dir%\git-lfs.exe ) + +) ELSE ( + C:\Windows\System32\tar.exe -xf "%gitlfs_zip%" -C %opt_install_dir% + if !errorlevel! neq 0 exit /b !errorlevel! +) + +:: Create git-lfs link - always to make sure it points to latest version +IF /I EXIST %opt_install_dir%\git-lfs.exe ( + del /Q %opt_install_dir%\git-lfs.exe +) +mklink %opt_install_dir%\git-lfs.exe %opt_install_dir%\%gitlfs_dir%\git-lfs.exe +if !errorlevel! neq 0 exit /b !errorlevel! + ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: Python set "python_version=3.12.9"