Last active
August 29, 2015 14:26
-
-
Save tkelman/eeb68211b3a697a51026 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
set -e # stop on failure | |
# from libgit2 master at 723babd7124ae420f9afea65e25231d206ac1a20, or v0.23.0 | |
echo '#include "git2.h" | |
void main() { | |
git_repository* repo_ptr = NULL; | |
char* repo_url = "https://github.com/JuliaLang/Example.jl"; | |
char* repo_path = "Example.Bare"; | |
git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; | |
clone_opts.bare = 1; | |
git_libgit2_init(); | |
git_clone(&repo_ptr, repo_url, repo_path, &clone_opts); | |
git_libgit2_shutdown(); | |
}' > clonetest.c | |
CMAKE_ARGS_COMMON="-DBUILD_CLAR=OFF \ | |
-DUSE_SSH=OFF \ | |
-DCMAKE_SYSTEM_NAME=Windows \ | |
-DCMAKE_BUILD_TYPE=RelWithDebInfo" | |
if [ "$(uname -o)" = "Msys" ]; then | |
GENERATOR="MSYS Makefiles" | |
CC="gcc" | |
else # cross-compile from cygwin or linux | |
CMAKE_ARGS_COMMON="$CMAKE_ARGS_COMMON \ | |
-DCMAKE_C_COMPILER=i686-w64-mingw32-gcc \ | |
-DCMAKE_RC_COMPILER=$(which i686-w64-mingw32-windres) \ | |
-DDLLTOOL=$(which i686-w64-mingw32-dlltool) \ | |
-DCMAKE_FIND_ROOT_PATH=/usr/i686-w64-mingw32 \ | |
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY" | |
GENERATOR="Unix Makefiles" | |
CC="i686-w64-mingw32-gcc" | |
fi | |
rm -rf build_O1_works | |
mkdir build_O1_works | |
cd build_O1_works | |
cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/usr $CMAKE_ARGS_COMMON \ | |
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-O1 -g -D_DEBUG" -G"$GENERATOR" | |
make -j3 install | |
[ "$(uname -o)" = "Msys" ] || | |
cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc* usr/bin || | |
cp /usr/lib/gcc/i686-w64-mingw32/*/libgcc* usr/bin | |
$CC -Iusr/include -Lusr/bin -lgit2 ../clonetest.c -g -o usr/bin/clonetest.exe | |
usr/bin/clonetest.exe | |
ls -al Example.Bare | |
cd .. | |
rm -rf build_O2_segfaults | |
mkdir build_O2_segfaults | |
cd build_O2_segfaults | |
cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/usr $CMAKE_ARGS_COMMON \ | |
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-O2 -g -D_DEBUG" -G"$GENERATOR" | |
make -j3 install | |
[ "$(uname -o)" = "Msys" ] || | |
cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc* usr/bin || | |
cp /usr/lib/gcc/i686-w64-mingw32/*/libgcc* usr/bin | |
$CC -Iusr/include -Lusr/bin -lgit2 ../clonetest.c -g -o usr/bin/clonetest.exe | |
usr/bin/clonetest.exe | |
ls -al Example.Bare | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment