diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 802891c..85736cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,14 +24,11 @@ jobs: - name: Run tests run: | - make test + go test -v ./... - name: Build linux - env: - GOPATH: /home/runner/work/cloudson/go - TARGET_OS_ARCH: linux/amd64 run: | - make build + go build . ./gitql -v - uses: actions/upload-artifact@master name: Generating artifact @@ -56,17 +53,11 @@ jobs: - name: Run tests run: | - make test + go test -v ./... - name: Build mac - env: - TARGET_OS_ARCH: darwin/amd64 run: | - 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 - export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(PWD)/libgit2/install/lib - make build-dynamic || true + go build . ./gitql -v - uses: actions/upload-artifact@master name: Generating artifact @@ -89,14 +80,11 @@ jobs: - name: Run tests run: | - make test + go test -v ./... - name: Build windows - env: - TARGET_OS_ARCH: windows/amd64 run: | - choco install ninja vcredist2017 - make build + go build . .\gitql.exe -v - uses: actions/upload-artifact@master diff --git a/Makefile b/Makefile deleted file mode 100644 index 7f28105..0000000 --- a/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -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 - -test: - @go test -count=1 -v ./parser/ ./lexical/ ./utilities/ ./semantical/ - -build: - @echo "Building..." - @bash install.sh - -clean: - @rm -rf ./libgit2 - -prepare-dynamic: clean - @echo "Preparing...\n" - @rm go.mod go.sum || echo 0 - @chmod +x ./install-libgit2.sh - @bash ./install-libgit2.sh - -build-dynamic: prepare-dynamic - @go get -v -d . - @go build \ No newline at end of file diff --git a/README.md b/README.md index d987706..b7a9e08 100644 --- a/README.md +++ b/README.md @@ -14,41 +14,10 @@ See more [here](https://asciinema.org/a/97094) ## Requirements - Go -- cmake -- pkg-config ## How to install -We support static compiling for linux and windows platform (amd64), so you can access the [releases page](https://github.com/cloudson/gitql/releases) and just grab the binary. If you want to compile itself follow the instructions below: - -### linux/amd64 - -Read 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 -``` - -### windows/amd64 - -You need a C compiler, Cmake and Ninja installed. Using chocolately it should be easy - -```bash -choco install cmake ninja vcredist2017 -set PATH=%HOMEDRIVE%\mingw64\bin;%PATH% -make build -``` - -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. If even after try [the binaries](https://github.com/cloudson/gitql/releases) or either compile yourself you couldn't use that. Open an issue. +You can access the [releases page](https://github.com/cloudson/gitql/releases) and just grab the binary. If you want to compile itself just run `go build .`. ## Examples diff --git a/cmd.go b/cmd.go index cd63721..621711d 100644 --- a/cmd.go +++ b/cmd.go @@ -16,7 +16,7 @@ import ( "github.com/pkg/errors" ) -const Version = "Gitql 2.0.0" +const Version = "Gitql 2.1.0" type Gitql struct { Path string `short:"p" default:"."` diff --git a/install-libgit2.sh b/install-libgit2.sh deleted file mode 100755 index ea2e4f8..0000000 --- a/install-libgit2.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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 diff --git a/install.sh b/install.sh deleted file mode 100755 index 3bbfcab..0000000 --- a/install.sh +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env bash - -set -ex -export GO111MODULE="on" -export GOFLAGS="-mod=vendor -tags=static" -export CGO_ENABLED=1 - -export GIT2GO_PATH="${PWD}/vendor/github.com/cloudson/git2go" -export LIBGIT2_PATH="${GIT2GO_PATH}/vendor/libgit2" -export LIBGIT2_BUILD="${GIT2GO_PATH}/static-build/${TARGET_OS_ARCH}" -export LIBGIT2_STATIC_PREFIX="${GIT2GO_PATH}/static-build/install" - -setup_vendor(){ - LIBGIT2_URL=https://github.com/libgit2/libgit2.git - LIBGIT2_VER=v0.28.2 - - go mod download - - if ! [[ -d vendor ]]; then - go mod vendor - fi - - git -c advice.detachedHead=false clone --quiet --depth 1 -b $LIBGIT2_VER $LIBGIT2_URL $LIBGIT2_PATH || : -} - -build_libgit2_generic(){ - cmake \ - -G Ninja \ - -DTHREADSAFE=ON \ - -DBUILD_CLAR=OFF \ - -DBUILD_SHARED_LIBS=OFF \ - -DUSE_EXT_HTTP_PARSER=OFF \ - -DUSE_BUNDLED_ZLIB=ON \ - -DUSE_HTTPS=OFF \ - -DUSE_SSH=OFF \ - -DUSE_ICONV=OFF \ - -DCMAKE_C_FLAGS=-fPIE \ - -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ - -DCMAKE_INSTALL_PREFIX="${LIBGIT2_STATIC_PREFIX}" \ - ${LIBGIT2_PATH} -} - -build_libgit2_linux(){ - cmake \ - -DTHREADSAFE=ON \ - -DBUILD_CLAR=OFF \ - -DBUILD_SHARED_LIBS=OFF \ - -DUSE_EXT_HTTP_PARSER=OFF \ - -DUSE_BUNDLED_ZLIB=ON \ - -DUSE_HTTPS=OFF \ - -DUSE_SSH=OFF \ - -DUSE_ICONV=OFF \ - -DCMAKE_SYSTEM_NAME=Linux \ - -DCMAKE_C_COMPILER=${CC} \ - -DCMAKE_C_FLAGS=-fPIE \ - -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ - -DCMAKE_INSTALL_PREFIX="${LIBGIT2_STATIC_PREFIX}" \ - ${LIBGIT2_PATH} -} - -build_libgit2_windows(){ - cmake \ - -G Ninja \ - -DTHREADSAFE=ON \ - -DBUILD_CLAR=OFF \ - -DBUILD_SHARED_LIBS=OFF \ - -DUSE_EXT_HTTP_PARSER=OFF \ - -DUSE_BUNDLED_ZLIB=ON \ - -DUSE_HTTPS=OFF \ - -DUSE_SSH=OFF \ - -DUSE_ICONV=OFF \ - -DWINHTTP=OFF \ - -DCMAKE_SYSTEM_NAME=Windows \ - -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ - -DCMAKE_INSTALL_PREFIX="${LIBGIT2_STATIC_PREFIX}" \ - -DWIN32=ON \ - -DMINGW=ON \ - -DCMAKE_SIZEOF_VOID_P=8 \ - ${LIBGIT2_PATH} -} - -build_libgit2_darwin(){ - cmake \ - -G "Ninja" \ - -DTHREADSAFE=ON \ - -DBUILD_CLAR=OFF \ - -DBUILD_SHARED_LIBS=OFF \ - -DUSE_EXT_HTTP_PARSER=OFF \ - -DUSE_BUNDLED_ZLIB=ON \ - -DUSE_HTTPS=OFF \ - -DUSE_SSH=OFF \ - -DUSE_ICONV=OFF \ - -DCMAKE_SYSTEM_NAME=Darwin \ - -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" \ - -DCMAKE_C_COMPILER=${CC} \ - -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ - -DCMAKE_INSTALL_PREFIX="${LIBGIT2_STATIC_PREFIX}" \ - -DCMAKE_OSX_SYSROOT="${OSX_SDK}" \ - ${LIBGIT2_PATH} -} - -build_libgit2(){ - mkdir -vp $LIBGIT2_BUILD - pushd $LIBGIT2_BUILD - - case "$TARGET_OS_ARCH" in - "") - FLAGS="" - export CGO_LDFLAGS="${LIBGIT2_STATIC_PREFIX}/lib/libgit2.a -L${LIBGIT2_STATIC_PREFIX}/include ${FLAGS}" - build_libgit2_generic - ;; - linux/amd64*) - export GOOS=linux GOARCH=amd64 CC=clang - FLAGS="" - export CGO_LDFLAGS="${LIBGIT2_STATIC_PREFIX}/lib/libgit2.a -L${LIBGIT2_STATIC_PREFIX}/include ${FLAGS}" - build_libgit2_linux - ;; - darwin/amd64*) - export GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin18-clang OSX_SDK=/opt/osxcross/SDK/MacOSX10.14.sdk/ - FLAGS="" - export CGO_LDFLAGS="${LIBGIT2_STATIC_PREFIX}/lib/libgit2.a -L${LIBGIT2_STATIC_PREFIX}/include ${FLAGS}" - build_libgit2_darwin - ;; - windows/amd64*) - export GOOS=windows GOARCH=amd64 - # CC=x86_64-w64-mingw32-clang - FLAGS="-lws2_32" - export CGO_LDFLAGS="${LIBGIT2_STATIC_PREFIX}/lib/libgit2.a -L${LIBGIT2_STATIC_PREFIX}/include ${FLAGS}" - build_libgit2_windows - ;; - windows/386*) - export GOOS=windows GOARCH=386 CC=i686-w64-mingw32-clang - FLAGS="-lws2_32" - export CGO_LDFLAGS="${LIBGIT2_STATIC_PREFIX}/lib/libgit2.a -L${LIBGIT2_STATIC_PREFIX}/include ${FLAGS}" - build_libgit2_windows - ;; - esac - - cmake --build . -- -j$(nproc 2>/dev/null || sysctl -n hw.ncpu) && cmake --build . --target install &>/dev/null - - popd -} - -build_gitql(){ - case "$TARGET_OS_ARCH" in - windows/amd64*) - ;& - windows/386*) - ;& - linux/amd64*) - go build -v -ldflags '-extldflags "-static"' . - ;; - darwin/amd64*) - # MacOS doesn't support fully static binaries, see - # https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag - # this is the best we could possibly do - ;& - "") - ;& - *) - go build -v . - ;; - esac -} - -main(){ - setup_vendor - build_libgit2 - build_gitql -} - -main "$@" \ No newline at end of file