-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add checking the code formatting with astyle during CI builds #1879
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| #!/bin/sh | ||
|
|
||
| # Script to install a version of astyle in ~/astyle.local/ | ||
| # | ||
| # Used by CI builds | ||
| # | ||
| # Currently only supports git repos as sources | ||
| # | ||
| # Usage: /path/to/install_astyle.sh <astyle-git-repo> <version-tag> | ||
|
|
||
| INSTALL_ROOT=~/astyle.local | ||
|
|
||
| # ---------------------------------------------------------------------------- | ||
| # U S A G E | ||
| # ---------------------------------------------------------------------------- | ||
| usage() | ||
| { | ||
| echo "** Usage: $0 <svn-tags-url> <tag-name>" | ||
| echo " e.g. $0 https://svn.code.sf.net/p/astyle/code/tags 3.1" | ||
| } >&2 | ||
|
|
||
| # ---------------------------------------------------------------------------- | ||
| # C A L L _ M A K E | ||
| # | ||
| # Calls make with the specified parameters, but only displays the error | ||
| # log if it fails | ||
| # ---------------------------------------------------------------------------- | ||
| call_make() | ||
| { | ||
| # Disable set -e, if active | ||
| set_entry_opts=`set +o` | ||
| set +e | ||
|
|
||
| status=1 | ||
| log=`mktemp /tmp/astyle-log.XXXXXXXXXX` | ||
| if [ -n "$log" ]; then | ||
| make "$@" >$log 2>&1 | ||
| status=$? | ||
| if [ $status -ne 0 ]; then | ||
| cat $log >&2 | ||
| fi | ||
| rm $log | ||
| fi | ||
|
|
||
| # Re-enable `set -e` if active before | ||
| $set_entry_opts | ||
|
|
||
| return $status | ||
| } | ||
|
|
||
|
|
||
| # ---------------------------------------------------------------------------- | ||
| # M A I N | ||
| # ---------------------------------------------------------------------------- | ||
| if [ $# -ne 2 ]; then | ||
| usage | ||
| exit 1 | ||
| fi | ||
|
|
||
| REPO_URL="$1" | ||
| ASTYLE_VER="$2" | ||
|
|
||
| # Already installed? | ||
| exe=$INSTALL_ROOT/$ASTYLE_VER/usr/bin/astyle | ||
| if [ -x "$exe" ]; then | ||
| echo "astyle version $ASTYLE_VER is already installed at $exe" >&2 | ||
| exit 0 | ||
| fi | ||
|
|
||
| workdir=`mktemp -d /tmp/astyle.XXXXXXXXXX` | ||
| if [ -z "$workdir" ]; then | ||
| echo "** Unable to create temporary working directory" 2>&1 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Use a sub-process for the next bit to restrict the scope of 'set -e' | ||
| ( | ||
| set -e ; # Exit sub-process on first error | ||
|
|
||
| # Put everything in this directory | ||
| FILESDIR=$INSTALL_ROOT/$ASTYLE_VER | ||
|
|
||
| svn checkout ${REPO_URL}/${ASTYLE_VER}/AStyle $workdir | ||
|
|
||
| cd $workdir | ||
|
|
||
| make_args="DESTDIR=$FILESDIR" | ||
|
|
||
| echo "Creating Makefiles..." | ||
| cmake . | ||
|
|
||
| echo "Making astyle..." | ||
| call_make $make_args | ||
|
|
||
| echo "Installing astyle..." | ||
| mkdir -p $FILESDIR | ||
| call_make install $make_args | ||
| # make install DESTDIR=~/astyle.local/3.1 | ||
| ) | ||
| status=$? | ||
|
|
||
| if [ $status -eq 0 ]; then | ||
| rm -rf $workdir | ||
| else | ||
| "** Script failed. Work dir is $workdir" >&2 | ||
| fi | ||
|
|
||
| exit $status |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/sh | ||
| set -eufx | ||
|
|
||
| PACKAGES="subversion cmake" | ||
|
|
||
| apt-get -yq --no-install-suggests --no-install-recommends install $PACKAGES |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #!/bin/sh | ||
|
|
||
| # Script to run astyle on the code | ||
| # | ||
| # Usage: /path/to/run_astyle.sh | ||
| # | ||
| # Note: the script must be run from the root directory of the xrdp repository | ||
|
|
||
| INSTALL_ROOT=~/astyle.local | ||
| ASTYLE_FROM_XRDP=$INSTALL_ROOT/3.1/usr/bin/astyle | ||
| MIN_ASTYLE_VER="3.1" | ||
|
|
||
| # ---------------------------------------------------------------------------- | ||
| # U S A G E | ||
| # ---------------------------------------------------------------------------- | ||
| usage() | ||
| { | ||
| echo "** Usage: $0" | ||
| echo " e.g. $0" | ||
| } >&2 | ||
|
|
||
| # ---------------------------------------------------------------------------- | ||
| # M A I N | ||
| # ---------------------------------------------------------------------------- | ||
| if [ $# -ne 0 ]; then | ||
| usage | ||
| exit 1 | ||
| fi | ||
|
|
||
| # check if the built-in astyle meets the minimum requrements | ||
| ASTYLE_FROM_OS_VER_OUTPUT=`astyle --version | grep "Artistic Style Version" | cut -d' ' -f4` | ||
|
|
||
| ASTYLE="" | ||
| ERROR_MESSAGE="" | ||
| if [ ! -z "$ASTYLE_FROM_OS_VER_OUTPUT" ]; then | ||
| # astyle is installed, so check if it's version meets the minimum requirements | ||
| LOWEST_VERSION=`echo -e "$MIN_ASTYLE_VER\n$ASTYLE_FROM_OS_VER_OUTPUT" | sort -V | head -n1` | ||
| if [ "$MIN_ASTYLE_VER" = "$LOWEST_VERSION" ]; then | ||
| ASTYLE=astyle | ||
| else | ||
| ERROR_MESSAGE="The version of astyle installed does not meet the minimum version requirement: >= $MIN_ASTYLE_VER " | ||
| fi | ||
| else | ||
| ERROR_MESSAGE="astyle is not installed on the system path" | ||
| fi | ||
|
|
||
| if [ -z "$ASTYLE" ]; then | ||
| # astyle from the os is invlid, fallback to the xrdp version if it is installed | ||
| if [ -x "$ASTYLE_FROM_XRDP" ]; then | ||
| ASTYLE="$ASTYLE_FROM_XRDP" | ||
| ERROR_MESSAGE="" | ||
| else | ||
| ERROR_MESSAGE="${ERROR_MESSAGE}\nastyle $MIN_ASTYLE_VER is not installed at the expected path: $ASTYLE_FROM_XRDP" | ||
| fi | ||
| fi | ||
|
|
||
| if [ ! -z "$ERROR_MESSAGE" ]; then | ||
| echo "$ERROR_MESSAGE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -f "astyle_config.as" ]; then | ||
| echo "$0 must be run from the root xrdp repository directory which " | ||
| echo "contains the 'astyle_config.as' file." | ||
| exit 2 | ||
| fi | ||
|
|
||
| ASTYLE_FLAGS="--options=astyle_config.as ./\*.c ./\*.h" | ||
|
|
||
| # Display the astyle version and command for debugging | ||
| "$ASTYLE" --version && { | ||
| echo Command: $ASTYLE $ASTYLE_FLAGS | ||
| "$ASTYLE" $ASTYLE_FLAGS | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be unstable because the "latest" version will change as time flows but not a big problem.