Skip to content
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

Small cleanup in Makefile #4369

Merged
merged 1 commit into from
May 22, 2017
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
34 changes: 17 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

BUILD_DIR=build
COVERAGE_DIR=${BUILD_DIR}/coverage
COVERAGE_DIR=$(BUILD_DIR)/coverage
BEATS=packetbeat filebeat winlogbeat metricbeat heartbeat
PROJECTS=libbeat ${BEATS}
PROJECTS=libbeat $(BEATS)
PROJECTS_ENV=libbeat filebeat metricbeat
SNAPSHOT?=yes
PYTHON_ENV?=${BUILD_DIR}/python-env
PYTHON_ENV?=$(BUILD_DIR)/python-env
VIRTUALENV_PARAMS?=
FIND=find . -type f -not -path "*/vendor/*" -not -path "*/build/*" -not -path "*/.git/*"
GOLINT=golint
Expand Down Expand Up @@ -36,15 +36,15 @@ unit:

.PHONY: coverage-report
coverage-report:
mkdir -p ${COVERAGE_DIR}
mkdir -p $(COVERAGE_DIR)
# Writes atomic mode on top of file
echo 'mode: atomic' > ./${COVERAGE_DIR}/full.cov
echo 'mode: atomic' > ./$(COVERAGE_DIR)/full.cov
# Collects all coverage files and skips top line with mode
-tail -q -n +2 ./filebeat/${COVERAGE_DIR}/*.cov >> ./${COVERAGE_DIR}/full.cov
-tail -q -n +2 ./packetbeat/${COVERAGE_DIR}/*.cov >> ./${COVERAGE_DIR}/full.cov
-tail -q -n +2 ./winlogbeat/${COVERAGE_DIR}/*.cov >> ./${COVERAGE_DIR}/full.cov
-tail -q -n +2 ./libbeat/${COVERAGE_DIR}/*.cov >> ./${COVERAGE_DIR}/full.cov
go tool cover -html=./${COVERAGE_DIR}/full.cov -o ${COVERAGE_DIR}/full.html
-tail -q -n +2 ./filebeat/$(COVERAGE_DIR)/*.cov >> ./$(COVERAGE_DIR)/full.cov
-tail -q -n +2 ./packetbeat/$(COVERAGE_DIR)/*.cov >> ./$(COVERAGE_DIR)/full.cov
-tail -q -n +2 ./winlogbeat/$(COVERAGE_DIR)/*.cov >> ./$(COVERAGE_DIR)/full.cov
-tail -q -n +2 ./libbeat/$(COVERAGE_DIR)/*.cov >> ./$(COVERAGE_DIR)/full.cov
go tool cover -html=./$(COVERAGE_DIR)/full.cov -o $(COVERAGE_DIR)/full.html

.PHONY: update
update: notice
Expand All @@ -66,7 +66,7 @@ clean-vendor:
check: python-env
$(foreach var,$(PROJECTS),$(MAKE) -C $(var) check || exit 1;)
# Checks also python files which are not part of the beats
${FIND} -name *.py -exec autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false)
$(FIND) -name *.py -exec autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false)
# Validate that all updates were committed
$(MAKE) update
git diff | cat
Expand All @@ -83,7 +83,7 @@ misspell:
fmt: python-env
$(foreach var,$(PROJECTS),$(MAKE) -C $(var) fmt || exit 1;)
# Cleans also python files which are not part of the beats
. ${PYTHON_ENV}/bin/activate && find . -type f -name *.py -not -path "*/vendor/*" -not -path "*/build/*" -not -path "*/.git/*" -exec autopep8 --in-place --max-line-length 120 {} \;
. $(PYTHON_ENV)/bin/activate && find . -type f -name *.py -not -path "*/vendor/*" -not -path "*/build/*" -not -path "*/.git/*" -exec autopep8 --in-place --max-line-length 120 {} \;

.PHONY: lint
lint:
Expand All @@ -99,7 +99,7 @@ beats-dashboards:
# Builds the documents for each beat
.PHONY: docs
docs:
sh libbeat/scripts/build_docs.sh ${PROJECTS}
sh libbeat/scripts/build_docs.sh $(PROJECTS)

.PHONY: package
package: update beats-dashboards
Expand All @@ -108,15 +108,15 @@ package: update beats-dashboards
# build the dashboards package
echo "Start building the dashboards package"
mkdir -p build/upload/
BUILD_DIR=${shell pwd}/build SNAPSHOT=$(SNAPSHOT) $(MAKE) -C dev-tools/packer package-dashboards ${shell pwd}/build/upload/build_id.txt
BUILD_DIR=$(CURDIR)/build SNAPSHOT=$(SNAPSHOT) $(MAKE) -C dev-tools/packer package-dashboards $(CURDIR)/build/upload/build_id.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this has potential to break on any platforms? @andrewkroh thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that should be fine.

mv build/upload build/dashboards-upload

# Copy build files over to top build directory
mkdir -p build/upload/
$(foreach var,$(BEATS),cp -r $(var)/build/upload/ build/upload/$(var) || exit 1;)
cp -r build/dashboards-upload build/upload/dashboards
# Run tests on the generated packages.
go test ./dev-tools/package_test.go -files "${shell pwd}/build/upload/*/*"
go test ./dev-tools/package_test.go -files "$(CURDIR)/build/upload/*/*"

# Upload nightly builds to S3
.PHONY: upload-nightlies-s3
Expand All @@ -142,5 +142,5 @@ notice:
# Sets up the virtual python environment
.PHONY: python-env
python-env:
@test -d ${PYTHON_ENV} || virtualenv ${VIRTUALENV_PARAMS} ${PYTHON_ENV}
@. ${PYTHON_ENV}/bin/activate && pip install -q --upgrade pip autopep8
@test -d $(PYTHON_ENV) || virtualenv $(VIRTUALENV_PARAMS) $(PYTHON_ENV)
@. $(PYTHON_ENV)/bin/activate && pip install -q --upgrade pip autopep8