Skip to content

feat: add support for pkg-config #2555

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 2 commits into from
Feb 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -11,13 +11,6 @@ jobs:
SCCACHE_CACHE_SIZE: 1G
steps:
- checkout
# Populate GOCACHE.
- restore_cache:
name: Restoring GOCACHE
keys:
- flux-gocache-{{ .Branch }}-{{ .Revision }} # Matches when retrying a single run.
- flux-gocache-{{ .Branch }}- # Matches a new commit on an existing branch.
- flux-gocache- # Matches a new branch.
# Populate GOPATH/pkg.
- restore_cache:
name: Restoring GOPATH/pkg/mod
@@ -42,12 +35,6 @@ jobs:
name: Uploading coverage report
command: |
bash <(curl -s https://codecov.io/bash)
- save_cache:
name: Saving GOCACHE
key: flux-gocache-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/go-cache
when: always
- save_cache:
name: Saving GOPATH/pkg/mod
key: flux-gomod-{{checksum "go.sum"}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ target
.tern-project
.idea
/coverage.txt
/libflux/lib
/libflux/pkg
/libflux/site/node_modules
/libflux/.cache
96 changes: 19 additions & 77 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
# This Makefile encodes the "go generate" prerequisites ensuring that the proper tooling is installed and
# that the generate steps are executed when their prerequeisites files change.
#
# This Makefile follows a few conventions:
#
# * All cmds must be added to this top level Makefile.
# * All binaries are placed in ./bin, its recommended to add this directory to your PATH.
# * Each package that has a need to run go generate, must have its own Makefile for that purpose.
# * All recursive Makefiles must support the targets: generate and clean.
#

SHELL := /bin/bash

GO_TAGS=
GO_ARGS=-tags '$(GO_TAGS)'

# Test vars can be used by all recursive Makefiles
# This invokes a custom package config during Go builds, such that
# the Rust library libflux is built on the fly.
export PKG_CONFIG:=$(PWD)/pkg-config.sh

export GOOS=$(shell go env GOOS)
export GO_BUILD=env FLUX_PARSER_TYPE=rust GO111MODULE=on go build $(GO_ARGS)
export GO_TEST=env FLUX_PARSER_TYPE=rust GO111MODULE=on go test $(GO_ARGS)
export GO_BUILD=env GO111MODULE=on go build $(GO_ARGS)
export GO_TEST=env GO111MODULE=on go test $(GO_ARGS)
export GO_TEST_FLAGS=
# Do not add GO111MODULE=on to the call to go generate so it doesn't pollute the environment.
export GO_GENERATE=go generate $(GO_ARGS)
export GO_VET=env FLUX_PARSER_TYPE=rust GO111MODULE=on go vet $(GO_ARGS)
export GO_VET=env GO111MODULE=on go vet $(GO_ARGS)
export CARGO=cargo
export CARGO_ARGS=

@@ -40,10 +35,12 @@ GENERATED_TARGETS = \
stdlib/packages.go \
semantic/flatbuffers_gen.go \
semantic/internal/fbsemantic/semantic_generated.go \
$(LIBFLUX_GENERATED_TARGETS)

LIBFLUX_GENERATED_TARGETS = \
libflux/src/flux/ast/flatbuffers/ast_generated.rs \
libflux/src/flux/semantic/flatbuffers/semantic_generated.rs \
libflux/scanner.c \
libflux/go/libflux/flux.h
libflux/scanner.c

generate: $(GENERATED_TARGETS)

@@ -62,72 +59,18 @@ libflux/src/flux/semantic/flatbuffers/semantic_generated.rs: semantic/semantic.f
ast/asttest/cmpopts.go: ast/ast.go ast/asttest/gen.go $$(call go_deps,./internal/cmd/cmpgen)
$(GO_GENERATE) ./ast/asttest

stdlib/packages.go: libflux-go $(STDLIB_SOURCES)
stdlib/packages.go: $(STDLIB_SOURCES) $(LIBFLUX_GENERATED_TARGETS)
$(GO_GENERATE) ./stdlib

internal/scanner/unicode.rl: internal/scanner/unicode2ragel.rb
cd internal/scanner && ruby unicode2ragel.rb -e utf8 -o unicode.rl
internal/scanner/scanner.gen.go: internal/scanner/gen.go internal/scanner/scanner.rl internal/scanner/unicode.rl
$(GO_GENERATE) ./internal/scanner

libflux: libflux/target/debug/libflux.a libflux/target/debug/liblibstd.a

libflux-go: libflux libflux/go/libflux/flux.h

# Build the rust static library. Afterwards, fix the .d file that
# rust generates so it references the correct targets.
# The unix sed, which is on darwin machines, has a different
# command line interface than the gnu equivalent.
libflux/target/debug/libflux.a: libflux/scanner.c libflux/src/flux/ast/flatbuffers/ast_generated.rs libflux/src/flux/semantic/flatbuffers/semantic_generated.rs
cd libflux && $(CARGO) build -p flux $(CARGO_ARGS)

libflux/target/debug/liblibstd.a:
cd libflux && $(CARGO) build -p libstd $(CARGO_ARGS)

libflux/go/libflux/flux.h: libflux/include/influxdata/flux.h
$(GO_GENERATE) ./libflux/go/libflux

# The dependency file produced by Rust appears to be wrong and uses
# absolute paths while we use relative paths everywhere. So we need
# to do some post processing of the file to ensure that the
# dependencies we load are correct. But, we do not want to trigger
# a rust build just to load the dependencies since we may not need
# to build the static library to begin with.
# It is good enough for us to include this target so that the makefile
# doesn't error when the file doesn't exist. It does not actually
# have to create the file, just promise that the file will be created.
# If the .d file does not exist, then the .a file above also
# does not exist so the dependencies don't matter. If the .d file
# exists, this will never get called or, at a minimum, it won't modify
# the files at all. This allows the target below to depend on this
# file without the file necessarily existing and it will force
# post-processing of the file if the .d file is newer than our
# post-processed .deps file.
libflux/target/debug/libflux.d:

libflux/target/debug/libflux.deps: libflux/target/debug/libflux.d
@if [ -e "$<" ]; then \
sed -e "s@${CURDIR}/@@g" -e "s@debug/debug@debug@g" -e "s@\\.dylib@.a@g" -e "s@\\.so@.a@g" $< > $@; \
fi
# Conditionally include the libflux.deps file so if any of the
# source files are modified, they are considered when deciding
# whether to rebuild the library.
-include libflux/target/debug/libflux.deps

# Handle dependencies for liblibstd similar to how we handle them
# for libflux, above.
libflux/target/debug/liblibstd.d:

libflux/target/debug/liblibstd.deps: libflux/target/debug/liblibstd.d
@if [ -e "$<" ]; then \
sed -e "s@${CURDIR}/@@g" -e "s@debug/debug@debug@g" -e "s@\\.dylib@.a@g" -e "s@\\.so@.a@g" $< > $@; \
fi
# Conditionally include the liblibstd.deps file so if any of the
# source files are modified, they are considered when deciding
# whether to rebuild the library.
-include libflux/target/debug/liblibstd.deps

build: libflux
libflux: $(LIBFLUX_GENERATED_TARGETS)
cd libflux && $(CARGO) build $(CARGO_ARGS)

build:
$(GO_BUILD) ./...

clean:
@@ -159,16 +102,16 @@ staticcheck:

test: test-go test-rust

test-go: libflux
test-go:
$(GO_TEST) $(GO_TEST_FLAGS) ./...

test-rust:
cd libflux && $(CARGO) test $(CARGO_ARGS) && $(CARGO) clippy $(CARGO_ARGS) -- -Dclippy::all

test-race: libflux
test-race:
$(GO_TEST) -race -count=1 ./...

test-bench: libflux
test-bench:
$(GO_TEST) -run=NONE -bench=. -benchtime=1x ./...

vet: libflux
@@ -192,7 +135,6 @@ libflux-wasm:
build \
default \
libflux \
libflux-go \
libflux-wasm \
fmt \
checkfmt \
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,12 @@ The specification contains many examples to start learning Flux.

Flux is currently available in InfluxDB 1.7 and 2.0 or through the REPL that can be compiled from this repository.

To build flux, first install the `pkg-config` utility, and ensure the GNU `pkg-config` utility is also installed.

```
$ go get github.com/influxdata/pkg-config
```

To compile the REPL, use the following command:

```
10 changes: 3 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -17,9 +17,9 @@ require (
github.com/google/go-cmp v0.3.0
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e
github.com/influxdata/pkg-config v0.0.0-20200220204715-6668c8414ecc
github.com/influxdata/promql/v2 v2.12.0
github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9
github.com/kr/pretty v0.1.0 // indirect
github.com/lib/pq v1.0.0
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
@@ -29,22 +29,18 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.1
github.com/opentracing/opentracing-go v1.0.2
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
github.com/pkg/errors v0.8.1
github.com/pkg/errors v0.9.1
github.com/pkg/term v0.0.0-20180730021639-bffc007b7fd5 // indirect
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
github.com/prometheus/common v0.6.0
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
github.com/segmentio/kafka-go v0.1.0
github.com/sergi/go-diff v1.0.0 // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3
go.uber.org/atomic v1.3.2 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.9.1
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522
golang.org/x/net v0.0.0-20190620200207-3b0461eec859
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5
gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca
google.golang.org/api v0.7.0
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
)
Loading