diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1b47dc9..aa3f85c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,22 +30,10 @@ jobs: libva-dev \ libvpx-dev \ libx264-dev - - name: go vet - run: go vet $(go list ./... | grep -v mmal) - - name: go build - run: go build $(go list ./... | grep -v mmal) - - name: go build without CGO - run: go build . pkg/... - env: - CGO_ENABLED: 0 - - name: go test - run: go test -v -race -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v mmal) - - uses: codecov/codecov-action@v1 + - name: Run Test Suite + run: make test + - uses: codecov/codecov-action@v1 if: matrix.go == '1.15' - - name: go test without CGO - run: go test . pkg/... -v - env: - CGO_ENABLED: 0 build-darwin: runs-on: macos-latest strategy: @@ -67,20 +55,8 @@ jobs: opus \ libvpx \ x264 - - name: go vet - run: go vet $(go list ./... | grep -v mmal) - - name: go build - run: go build $(go list ./... | grep -v mmal) - - name: go build without CGO - run: go build . pkg/... - env: - CGO_ENABLED: 0 - - name: go test - run: go test -v -race $(go list ./... | grep -v mmal) - - name: go test without CGO - run: go test . pkg/... -v - env: - CGO_ENABLED: 0 + - name: Run Test Suite + run: make test check-licenses: runs-on: ubuntu-latest name: Check Licenses diff --git a/.gitignore b/.gitignore index 802ed0b..e4588f2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ *.out scripts/cross +coverage.txt diff --git a/Makefile b/Makefile index b43c066..6131222 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,3 @@ -# When there's no argument provided to make, all codecs will be built to all -# supported platforms. Otherwise, it'll build only the provided target. -# -# Usage: -# make [--] -# -# Examples: -# * make: build all codecs for all supported platforms -# * make opus-darwin-x64: only build opus for darwin-x64 platform - docker_owner := lherman docker_prefix := cross toolchain_dockerfiles := dockerfiles @@ -27,14 +17,18 @@ supported_platforms := \ linux-x64 \ windows-x64 \ darwin-x64 +cmd_build := build +cmd_test := test +examples_dir := examples codec_dir := pkg/codec codec_list := $(shell ls $(codec_dir)/*/Makefile) codec_list := $(codec_list:$(codec_dir)/%/Makefile=%) -targets := $(foreach codec, $(codec_list), $(addprefix $(codec)-, $(supported_platforms))) +targets := $(foreach codec, $(codec_list), $(addprefix $(cmd_build)-$(codec)-, $(supported_platforms))) +pkgs_without_mmal := $(shell go list ./... | grep -v mmal) define BUILD_TEMPLATE ifneq (,$$(findstring $(2)-$(3),$$(supported_platforms))) -$(1)-$(2)-$(3): toolchain-$(2)-$(3) +$$(cmd_build)-$(1)-$(2)-$(3): toolchain-$(2)-$(3) $$(MAKE) --directory=$$(codec_dir)/$(1) \ MEDIADEVICES_TOOLCHAIN_BIN=$$(toolchain_path)/$(docker_prefix)-$(2)-$(3) \ MEDIADEVICES_TARGET_PLATFORM=$(2)-$(3) \ @@ -44,7 +38,18 @@ endif endef .PHONY: all -all: $(targets) +all: $(cmd_test) $(cmd_build) + +# Subcommand: +# make build[---] +# +# Description: +# Build codec dependencies to multiple platforms. +# +# Examples: +# * make build: build all codecs for all supported platforms +# * make build-opus-darwin-x64: only build opus for darwin-x64 platform +$(cmd_build): $(targets) toolchain-%: $(toolchain_dockerfiles) $(MAKE) --directory=$< "$*" \ @@ -59,3 +64,18 @@ $(foreach codec, $(codec_list), \ $(foreach os, $(os_list), \ $(foreach arch, $(arch_list), \ $(eval $(call BUILD_TEMPLATE,$(codec),$(os),$(arch)))))) + +# Subcommand: +# make test +# +# Description: +# Run a series of tests +$(cmd_test): + go vet $(pkgs_without_mmal) + go build $(pkgs_without_mmal) + # go build without CGO + CGO_ENABLED=0 go build . pkg/... + # go build with CGO + CGO_ENABLED=1 go build $(pkgs_without_mmal) + $(MAKE) --directory=$(examples_dir) + go test -v -race -coverprofile=coverage.txt -covermode=atomic $(pkgs_without_mmal) diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..efb8dbd --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,8 @@ +examples := $(shell find * -maxdepth 0 -type d) +examples := $(filter-out internal,$(examples)) + +.PHONY: all $(examples) +all: $(examples) + +$(examples): + cd $@ && go build