Skip to content

Commit

Permalink
Change layout
Browse files Browse the repository at this point in the history
  • Loading branch information
fat-fellow committed Aug 1, 2024
1 parent 877018f commit 55ca2a6
Show file tree
Hide file tree
Showing 40 changed files with 264 additions and 258 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ jobs:
fetch-depth: 0
- name: build rust
run: |
cd rust
cargo test
make install-all
- name: build go
run: |
echo GOPATH=$(go env GOPATH) >> $GITHUB_ENV
echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_ENV
echo $(go env GOPATH)/bin >> $GITHUB_PATH
cd go
make build-verify
make test
- name: Create archives
run: |
mkdir -p .release
for dir in go/libs/*/ ; do
for dir in libs/*/ ; do
dir_name=$(basename "$dir")
tar -czf ".release/${dir_name}.tar.gz" -C "$dir" .
done
Expand Down
13 changes: 1 addition & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
.idea/*
linux-compiler-musl-x86/*
!.idea/codeStyles/
*.iml
debug/
target/

Cargo.lock

**/*.rs.bk

*.pdb
libs/*
213 changes: 9 additions & 204 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,207 +1,12 @@
all:
@set -e;

setup:
@rustup target add x86_64-unknown-linux-musl
@rustup target add armv7-linux-androideabi
@rustup target add i686-linux-android
@rustup target add aarch64-linux-android
@rustup target add x86_64-linux-android
@rustup target add aarch64-apple-ios
@rustup target add x86_64-apple-ios
@rustup target add x86_64-apple-darwin
@rustup target add x86_64-apple-darwin
@rustup target add x86_64-pc-windows-gnu

build-linux-amd64-musl:
env TARGET_CC=x86_64-linux-musl-gcc cargo build --release --target x86_64-unknown-linux-musl

install-linux-amd64-musl: build-linux-amd64-musl
@mkdir -p go/libs/linux-amd64-musl
@cp target/x86_64-unknown-linux-musl/release/libtantivy_go.a go/libs/linux-amd64-musl

build-debug-linux-amd64-musl:
env TARGET_CC=x86_64-linux-musl-gcc cargo build --target x86_64-unknown-linux-musl

install-debug-linux-amd64-musl: build-debug-linux-amd64-musl
@mkdir -p go/libs/linux-amd64-musl
@cp target/x86_64-unknown-linux-musl/debug/libtantivy_go.a go/libs/linux-amd64-musl

build-android-arm:
env TARGET_CC=armv7a-linux-androideabi26-clang cargo build --release --target armv7-linux-androideabi

install-android-arm: build-android-arm
@mkdir -p go/libs/android-arm
@cp target/armv7-linux-androideabi/release/libtantivy_go.a go/libs/android-arm

build-debug-android-arm:
env TARGET_CC=armv7a-linux-androideabi26-clang cargo build --target armv7-linux-androideabi

install-debug-android-arm: build-debug-android-arm
@mkdir -p go/libs/android-arm
@cp target/armv7-linux-androideabi/debug/libtantivy_go.a go/libs/android-arm

build-android-386:
env TARGET_CC=i686-linux-android26-clang cargo build --release --target i686-linux-android

install-android-386: build-android-386
@mkdir -p go/libs/android-386
@cp target/i686-linux-android/release/libtantivy_go.a go/libs/android-386

build-debug-android-386:
env TARGET_CC=i686-linux-android26-clang cargo build --target i686-linux-android

install-debug-android-386: build-debug-android-386
@mkdir -p go/libs/android-386
@cp target/i686-linux-android/debug/libtantivy_go.a go/libs/android-386

build-android-arm64:
cargo build --release --target aarch64-linux-android

install-android-arm64: build-android-arm64
@mkdir -p go/libs/android-arm64
@cp target/aarch64-linux-android/release/libtantivy_go.a go/libs/android-arm64

build-debug-android-arm64:
cargo build --target aarch64-linux-android

install-debug-android-arm64: build-debug-android-arm64
@mkdir -p go/libs/android-arm64
@cp target/aarch64-linux-android/debug/libtantivy_go.a go/libs/android-arm64

build-android-amd64:
cargo build --release --target x86_64-linux-android

install-android-amd64: build-android-amd64
@mkdir -p go/libs/android-amd64
@cp target/x86_64-linux-android/release/libtantivy_go.a go/libs/android-amd64

build-debug-android-amd64:
cargo build --target x86_64-linux-android

install-debug-android-amd64: build-debug-android-amd64
@mkdir -p go/libs/android-amd64
@cp target/x86_64-linux-android/debug/libtantivy_go.a go/libs/android-amd64

build-ios-arm64:
cargo build --release --target aarch64-apple-ios

install-ios-arm64: build-ios-arm64
@mkdir -p go/libs/ios-arm64
@cp target/aarch64-apple-ios/release/libtantivy_go.a go/libs/ios-arm64

build-debug-ios-arm64:
cargo build --target aarch64-apple-ios

install-debug-ios-arm64: build-debug-ios-arm64
@mkdir -p go/libs/ios-arm64
@cp target/aarch64-apple-ios/debug/libtantivy_go.a go/libs/ios-arm64

build-ios-amd64:
cargo build --release --target x86_64-apple-ios

install-ios-amd64: build-ios-amd64
@mkdir -p go/libs/ios-amd64
@cp target/x86_64-apple-ios/release/libtantivy_go.a go/libs/ios-amd64

build-debug-ios-amd64:
cargo build --target x86_64-apple-ios

install-debug-ios-amd64: build-debug-ios-amd64
@mkdir -p go/libs/ios-amd64
@cp target/x86_64-apple-ios/debug/libtantivy_go.a go/libs/ios-amd64

build-darwin-amd64:
ENV MACOSX_DEPLOYMENT_TARGET=10.15 cargo build --release --target x86_64-apple-darwin

install-darwin-amd64: build-darwin-amd64
@mkdir -p go/libs/darwin-amd64
@cp target/x86_64-apple-darwin/release/libtantivy_go.a go/libs/darwin-amd64

build-debug-darwin-amd64:
ENV MACOSX_DEPLOYMENT_TARGET=10.15 cargo build --target x86_64-apple-darwin

install-debug-darwin-amd64: build-debug-darwin-amd64
@mkdir -p go/libs/darwin-amd64
@cp target/x86_64-apple-darwin/debug/libtantivy_go.a go/libs/darwin-amd64

build-darwin-arm64:
ENV MACOSX_DEPLOYMENT_TARGET=10.15 cargo build --release --target aarch64-apple-darwin

install-darwin-arm64: build-darwin-arm64
@mkdir -p go/libs/darwin-arm64
@cp target/aarch64-apple-darwin/release/libtantivy_go.a go/libs/darwin-arm64

build-debug-darwin-arm64:
ENV MACOSX_DEPLOYMENT_TARGET=10.15 cargo build --target aarch64-apple-darwin

install-debug-darwin-arm64: build-debug-darwin-arm64
@mkdir -p go/libs/darwin-arm64
@cp target/aarch64-apple-darwin/debug/libtantivy_go.a go/libs/darwin-arm64

build-windows-amd64:
cargo build --release --target x86_64-pc-windows-gnu

install-windows-amd64: build-windows-amd64
@mkdir -p go/libs/windows-amd64
@cp target/x86_64-pc-windows-gnu/release/libtantivy_go.a go/libs/windows-amd64

build-debug-windows-amd64:
cargo build --target x86_64-pc-windows-gnu

install-debug-windows-amd64: build-debug-windows-amd64
@mkdir -p go/libs/windows-amd64
@cp target/x86_64-pc-windows-gnu/debug/libtantivy_go.a go/libs/windows-amd64

install-all: \
install-linux-amd64-musl \
install-android-arm \
install-android-386 \
install-android-arm64 \
install-android-amd64 \
install-ios-arm64 \
install-ios-amd64 \
install-darwin-amd64 \
install-darwin-arm64 \
install-windows-amd64

install-debug-all: \
install-debug-linux-amd64-musl \
install-debug-android-arm \
install-debug-android-386 \
install-debug-android-arm64 \
install-debug-android-amd64 \
install-debug-ios-arm64 \
install-debug-ios-amd64 \
install-debug-darwin-amd64 \
install-debug-darwin-arm64 \
install-debug-windows-amd64

### Download release
REPO := anyproto/tantivy-go
VERSION := go/v0.0.3
OUTPUT_DIR := go/libs

TANTIVY_LIBS := android-386.tar.gz \
android-amd64.tar.gz \
android-arm.tar.gz \
android-arm64.tar.gz \
darwin-amd64.tar.gz \
darwin-arm64.tar.gz \
ios-amd64.tar.gz \
ios-arm64.tar.gz \
linux-amd64-musl.tar.gz \
windows-amd64.tar.gz

define download_tantivy_lib
curl -L -o $(OUTPUT_DIR)/$(1) https://github.com/$(REPO)/releases/download/$(VERSION)/$(1)
endef

download-tantivy-all: $(TANTIVY_LIBS)

$(TANTIVY_LIBS):
@mkdir -p $(OUTPUT_DIR)/$(shell echo $@ | cut -d'.' -f1)
$(call download_tantivy_lib,$@)
@tar -C $(OUTPUT_DIR)/$(shell echo $@ | cut -d'.' -f1) -xvzf $(OUTPUT_DIR)/$@
@rm -f $(OUTPUT_DIR)/$@
@echo "Extracted $@"
build-verify:
CGO_LDFLAGS='-static' GOOS="windows" GOARCH="amd64" CGO_ENABLED="1" CC="x86_64-w64-mingw32-gcc" go build -v main.go
CGO_LDFLAGS='-static' GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" CC="x86_64-linux-musl-gcc" go build -v main.go
CGO_ENABLED="1" gomobile bind -v -target=android -androidapi 26 -o lib.aar github.com/anyproto/tantivy-go/tantivy/gomobile
CGO_ENABLED="1" gomobile bind -v -target=ios -o Lib.xcframework github.com/anyproto/tantivy-go/tantivy/gomobile

test:
@echo 'Running tests...'
go test ./...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Do not use in production.
## Installation

```bash
go get github.com/anyproto/tantivy-go/go
go get github.com/anyproto/tantivy-go
```

Ensure your libraries are in your `ld` path.
Expand Down
19 changes: 1 addition & 18 deletions go/main.go → example.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/anyproto/tantivy-go/go/tantivy"
"github.com/anyproto/tantivy-go/tantivy"
)

const NameBody = "body"
Expand Down Expand Up @@ -173,20 +173,3 @@ func main() {
docs, err = index.NumDocs()
fmt.Println("Number of documents after:", docs)
}

type DocSample struct {
Title string
Id string
Body string
Highlights []Highlight
}

type Fragment struct {
R [][2]int `json:"r"`
T string `json:"t"`
}

type Highlight struct {
FieldName string `json:"field_name"`
Fragment Fragment `json:"fragment"`
}
2 changes: 1 addition & 1 deletion go/go.mod → go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/anyproto/tantivy-go/go
module github.com/anyproto/tantivy-go

go 1.22

Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion go/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions go/Makefile

This file was deleted.

12 changes: 12 additions & 0 deletions rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.idea/*
linux-compiler-musl-x86/*
!.idea/codeStyles/
*.iml
debug/
target/

Cargo.lock

**/*.rs.bk

*.pdb
File renamed without changes.
Loading

0 comments on commit 55ca2a6

Please sign in to comment.