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

Fix astyle Display Language Dependency & Makefile Colored Output #9441

Merged
merged 4 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ define cmake-build
+@(cd $(BUILD_DIR) && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS))
endef

COLOR_BLUE = \033[0;34m
COLOR_BLUE = \033[0;94m
NO_COLOR = \033[m

define colorecho
+@echo "${COLOR_BLUE}${1} ${NO_COLOR}"
+@echo -e '${COLOR_BLUE}${1} ${NO_COLOR}'
endef

# Get a list of all config targets cmake/configs/*.cmake
Expand Down Expand Up @@ -231,7 +231,7 @@ quick_check: check_posix_sitl_default check_px4fmu-v4pro_default tests check_for

check_%:
@echo
$(call colorecho,"Building" $(subst check_,,$@))
$(call colorecho,'Building' $(subst check_,,$@))
@$(MAKE) --no-print-directory $(subst check_,,$@)
@echo

Expand Down Expand Up @@ -269,12 +269,12 @@ px4_metadata: parameters_metadata airframe_metadata module_documentation
.PHONY: check_format format

check_format:
$(call colorecho,"Checking formatting with astyle")
$(call colorecho,'Checking formatting with astyle')
@$(SRC_DIR)/Tools/astyle/check_code_style_all.sh
@cd $(SRC_DIR) && git diff --check

format:
$(call colorecho,"Formatting with astyle")
$(call colorecho,'Formatting with astyle')
@$(SRC_DIR)/Tools/astyle/check_code_style_all.sh --fix

# Testing
Expand Down
4 changes: 2 additions & 2 deletions Tools/astyle/check_code_style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FILE=$1
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

if [ -f "$FILE" ]; then
${DIR}/fix_code_style.sh --dry-run $FILE | grep --quiet Formatted
if [[ $? -eq 0 ]]; then
CHECK_FAILED=$(${DIR}/fix_code_style.sh --dry-run --formatted $FILE)
if [[ $CHECK_FAILED ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

Can you check for an empty string like this: if [ -n "$CHECK_FAILED" ]; then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, I changed it.
For anyone else interested here's the explanation for the -n parameter in the man pages of test: https://linux.die.net/man/1/test

${DIR}/fix_code_style.sh --quiet < $FILE > $FILE.pretty

echo
Expand Down