forked from libgit2/libgit2sharp.nativebinaries
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix VC++ dependency requirement on windows hosts #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
31831ff
Add smoke test for windows to replicate the issue
eddymoulton d7f9593
Split build
eddymoulton 6a3127c
Build statically
eddymoulton f057b95
Fix build
eddymoulton 3c88df7
Set HAVE_LIBSSH2_MEMORY_CREDENTIALS
eddymoulton 7b41996
More smoke tests
eddymoulton ff78d88
Common cmake args var
eddymoulton e149b9c
Remove check for libssh2 non-existance
eddymoulton 1d10d42
Remove comment
eddymoulton fc35e77
More readable loaders
eddymoulton 2cf877e
Tidy comment
eddymoulton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| set(VCPKG_CRT_LINKAGE dynamic) | ||
| set(VCPKG_LIBRARY_LINKAGE dynamic) | ||
| set(VCPKG_CRT_LINKAGE static) | ||
| set(VCPKG_LIBRARY_LINKAGE static) | ||
| set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DENABLE_ECDSA_WINCNG=ON") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Build the loader on a full base, then run it in a slim runtime base that | ||
| # represents an intended target (matching OpenSSL present, no dev tooling). | ||
| ARG BUILD_BASE=debian:bookworm | ||
| ARG RUNTIME_BASE=debian:bookworm-slim | ||
| FROM ${BUILD_BASE} AS build | ||
| RUN apt-get update && apt-get install -y --no-install-recommends build-essential && rm -rf /var/lib/apt/lists/* | ||
| COPY loader.c /loader.c | ||
| RUN gcc -O2 -o /loader /loader.c -ldl | ||
|
|
||
| FROM ${RUNTIME_BASE} | ||
| ARG RUNTIME_PKGS="" | ||
| RUN if [ -n "$RUNTIME_PKGS" ]; then apt-get update && apt-get install -y --no-install-recommends $RUNTIME_PKGS && rm -rf /var/lib/apt/lists/*; fi | ||
| COPY --from=build /loader /usr/local/bin/loader | ||
| COPY native/ /native/ | ||
| ENTRYPOINT ["/usr/local/bin/loader"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* Minimal dlopen loader for the Linux libgit2 native binary smoke test. */ | ||
| #include <dlfcn.h> | ||
| #include <stdio.h> | ||
|
|
||
| typedef int (*git_libgit2_init_fn)(void); | ||
|
|
||
| int main(int argc, char **argv) { | ||
| if (argc < 2) { | ||
| fprintf(stderr, "usage: loader <path-to-libgit2.so>\n"); | ||
| return 2; | ||
| } | ||
|
|
||
| const char *libraryPath = argv[1]; | ||
|
|
||
| void *library = dlopen(libraryPath, RTLD_NOW | RTLD_GLOBAL); | ||
| if (!library) { | ||
| fprintf(stderr, "dlopen('%s') failed: %s\n", libraryPath, dlerror()); | ||
| return 1; | ||
| } | ||
|
|
||
| git_libgit2_init_fn git_libgit2_init = (git_libgit2_init_fn)dlsym(library, "git_libgit2_init"); | ||
| if (!git_libgit2_init) { | ||
| fprintf(stderr, "dlsym(git_libgit2_init) failed: %s\n", dlerror()); | ||
| return 1; | ||
| } | ||
|
|
||
| int initCount = git_libgit2_init(); | ||
| printf("git_libgit2_init() returned %d\n", initCount); | ||
|
|
||
| return initCount > 0 ? 0 : 1; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 | ||
| COPY native/ C:/native/ | ||
| COPY loader.exe C:/loader.exe | ||
| ENTRYPOINT ["C:\\loader.exe"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR makes the loader resolve git2's sibling DLLs | ||
| * from git2's own directory (where libssh2.dll/z.dll live in the broken build), | ||
| * so a missing transitive dep (VCRUNTIME140.dll) surfaces as ERROR_MOD_NOT_FOUND. | ||
| */ | ||
| #include <windows.h> | ||
| #include <stdio.h> | ||
|
|
||
| typedef int (*git_libgit2_init_fn)(void); | ||
|
|
||
| int main(int argc, char **argv) { | ||
| if (argc < 2) { | ||
| fprintf(stderr, "usage: loader <full-path-to-git2.dll>\n"); | ||
| return 2; | ||
| } | ||
|
|
||
| const char *dllPath = argv[1]; | ||
|
|
||
| HMODULE library = LoadLibraryExA(dllPath, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); | ||
| if (!library) { | ||
| DWORD error = GetLastError(); | ||
| fprintf(stderr, "LoadLibraryEx('%s') failed: error %lu (0x%08lX)\n", dllPath, error, error); | ||
| return 1; | ||
| } | ||
|
|
||
| git_libgit2_init_fn git_libgit2_init = (git_libgit2_init_fn)GetProcAddress(library, "git_libgit2_init"); | ||
| if (!git_libgit2_init) { | ||
| fprintf(stderr, "GetProcAddress(git_libgit2_init) failed: %lu\n", GetLastError()); | ||
| return 1; | ||
| } | ||
|
|
||
| int initCount = git_libgit2_init(); | ||
| printf("git_libgit2_init() returned %d\n", initCount); | ||
|
|
||
| /* git_libgit2_init returns the initialization count (>=1) on success. */ | ||
| return initCount > 0 ? 0 : 1; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two properties are new