Skip to content

Commit

Permalink
Add install libgit script (#86)
Browse files Browse the repository at this point in the history
* Improving compiling for mac

* Add install libgit script
  • Loading branch information
filhodanuvem authored Oct 11, 2019
1 parent 6555324 commit d377fd7
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 25 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ jobs:
env:
TARGET_OS_ARCH: darwin/amd64
run: |
brew install pkg-config gcc
brew install pkg-config
export PKG_CONFIG_PATH=${PWD}/libgit2/install/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(PWD)/libgit2/install/lib
echo ${PKG_CONFIG_PATH}
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(PWD)/libgit2/install/lib
make build-dynamic || true
pkg-config --version
openssl version
./gitql -v
17 changes: 4 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(PWD)/libgit2/install/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(PWD)/libgit2/install/lib
# export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
export C_INCLUDE_PATH=$C_INCLUDE_PATH:$(PWD)/libgit2/install/include
URL_BASE_GIT2GO=https://github.com/libgit2/git2go/archive
GIT2GO_VERSION=master
export LD_LIBRARY_PATH=$(PWD)/libgit2/install/lib
export DYLD_LIBRARY_PATH=$(PWD)/libgit2/install/lib
export PKG_CONFIG_PATH=${PWD}/libgit2/install/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig
export C_INCLUDE_PATH=$(PWD)/libgit2/install/include
GOPATH=$(shell go env GOPATH)

all: build
Expand All @@ -17,20 +15,13 @@ build:

clean:
@rm -rf ./libgit2
@rm -rf install-libgit2.sh

prepare-dynamic: clean
@echo "Preparing...\n"
@rm go.mod go.sum || echo 0
@curl https://raw.githubusercontent.com/cloudson/git2go/original_libgit2/script/install-libgit2.sh >> install-libgit2.sh
@chmod +x ./install-libgit2.sh
@bash ./install-libgit2.sh
@ls ${PWD}/libgit2/install/lib/pkgconfig
@echo $(PKG_CONFIG_PATH)

build-dynamic: prepare-dynamic
@pwd
@ls ${PWD}/libgit2/install/lib/pkgconfig
@echo $(PKG_CONFIG_PATH)
@go get -v -d .
@go build
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gitql [![Build Status](https://travis-ci.org/cloudson/gitql.png)](https://travis-ci.org/cloudson/gitql)
Gitql ![](https://github.com/cloudson/gitql/workflows/CI/badge.svg)
===============

Gitql is a Git query language.
Gitql is a Git query language.

In a repository path...

Expand All @@ -14,12 +14,26 @@ See more [here](https://asciinema.org/a/97094)
- cmake
- pkg-config

## Install
- `go get -u -d github.com/cloudson/gitql`
- `cd $GOPATH/src/github.com/cloudson/gitql`
- `make`
- `sudo make install`
## How to install
### linux/amd64

We support static compiling for linux architetures, so you can access the [releases page](https://github.com/cloudson/gitql/releases). If you want to compile itself, take a look in the dockerfile to
understand the whole process.

### darwin/amd64

We **do not** support yet static compiling. You need to have pkg-config as dependencies, so after install that, run

```bash
# Inside this repository folder
export PKG_CONFIG_PATH=${PWD}/libgit2/install/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(PWD)/libgit2/install/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(PWD)/libgit2/install/lib
make build-dynamic
```

You can always take a look in our [github actions file](./.github/workflows/ci.yml) to understand
how we build it in the ci server.

## Examples

Expand Down
39 changes: 39 additions & 0 deletions install-libgit2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -ex

git clone --depth 1 --branch v0.25.0 git://github.com/libgit2/libgit2 libgit2

cd libgit2
# Those files are temporary, should not be in git. To minimize
# impact, we'll delete them now
rm -rf CMakeCache.txt CMakeFiles

# There is no official way to specify a generator
# inside CMakeLists.txt, see
# https://stackoverflow.com/questions/11269833/cmake-selecting-a-generator-within-cmakelists-txt
# So we deriving the environment from uname and setting generator
# in the command line,
# https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac

# Passing an argument with a space is a trouble, so we switch from sh to bash
# https://stackoverflow.com/a/2249967/9469533
EXTRA_ARGS=( )
if [[ $machine == MinGw ]]
then
extra_args=( -G "MSYS Makefiles" )
fi

cmake -DTHREADSAFE=ON -DBUILD_CLAR=OFF -DCMAKE_INSTALL_PREFIX=$PWD/install "${extra_args[@]}" .

cmake --build .

cmake --build . --target install
2 changes: 1 addition & 1 deletion runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func proxyTableEntry(t string, f map[string]string) *proxyTable {
}

func openRepository(path *string) {
_repo, err := git.OpenRepositoryExtended(*path, git.RepositoryOpenBare, "")
_repo, err := git.OpenRepositoryExtended(*path, git.RepositoryOpenCrossFs, "")
if err != nil {
log.Fatalln(err)
}
Expand Down

0 comments on commit d377fd7

Please sign in to comment.