Merge pull request #1879 from aquesnel/check_formatting
Add checking the code formatting with astyle during CI builds (#1879)
This commit is contained in:
commit
ce10d3a1a8
29
.github/workflows/build.yml
vendored
29
.github/workflows/build.yml
vendored
@ -146,3 +146,32 @@ jobs:
|
|||||||
- run: ./bootstrap
|
- run: ./bootstrap
|
||||||
- run: scripts/install_cppcheck.sh $CPPCHECK_REPO $CPPCHECK_VER
|
- run: scripts/install_cppcheck.sh $CPPCHECK_REPO $CPPCHECK_VER
|
||||||
- run: scripts/run_cppcheck.sh -v $CPPCHECK_VER
|
- run: scripts/run_cppcheck.sh -v $CPPCHECK_VER
|
||||||
|
|
||||||
|
code_formatting_check:
|
||||||
|
name: code formatting check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
CC: gcc
|
||||||
|
# This is required to use a version of astyle other than that
|
||||||
|
# supplied with the operating system
|
||||||
|
ASTYLE_VER: 3.1
|
||||||
|
ASTYLE_REPO: https://svn.code.sf.net/p/astyle/code/tags
|
||||||
|
steps:
|
||||||
|
# This is currently the only way to get a version into
|
||||||
|
# the cache tag name - see https://github.com/actions/cache/issues/543
|
||||||
|
- run: |
|
||||||
|
echo "OS_VERSION=`lsb_release -sr`" >> $GITHUB_ENV
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Cache astyle
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-astyle
|
||||||
|
with:
|
||||||
|
path: ~/astyle.local
|
||||||
|
key: ${{ runner.os }}-${{ env.OS_VERSION }}-build-${{ env.cache-name }}-${{ env.ASTYLE_VER }}
|
||||||
|
- run: sudo scripts/install_astyle_dependencies_with_apt.sh
|
||||||
|
- run: scripts/install_astyle.sh $ASTYLE_REPO $ASTYLE_VER
|
||||||
|
- name: Format code with astyle
|
||||||
|
run: scripts/run_astyle.sh
|
||||||
|
- name: Check code formatting
|
||||||
|
run: git diff --exit-code
|
||||||
|
@ -45,6 +45,14 @@
|
|||||||
# For each directory in the command line, process all subdirectories recursively.
|
# For each directory in the command line, process all subdirectories recursively.
|
||||||
--recursive
|
--recursive
|
||||||
|
|
||||||
|
# Exclude git submodule directories and generated files.
|
||||||
|
--exclude=libpainter
|
||||||
|
--exclude=librfxcodec
|
||||||
|
--exclude=xrdp_configure_options.h
|
||||||
|
|
||||||
|
# ignore errors from generated files that do not exist
|
||||||
|
--ignore-exclude-errors
|
||||||
|
|
||||||
# Preserve the original file's date and time modified.
|
# Preserve the original file's date and time modified.
|
||||||
--preserve-date
|
--preserve-date
|
||||||
|
|
||||||
@ -53,4 +61,3 @@
|
|||||||
--formatted
|
--formatted
|
||||||
|
|
||||||
--lineend=linux
|
--lineend=linux
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
* xfree86(base)->evdev keycode mapping
|
* xfree86(base)->evdev keycode mapping
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int xfree86_to_evdev[137-8+1] = {
|
int xfree86_to_evdev[137 - 8 + 1] =
|
||||||
|
{
|
||||||
/* MDSW */ 203,
|
/* MDSW */ 203,
|
||||||
/* ESC */ 9,
|
/* ESC */ 9,
|
||||||
/* AE01 */ 10,
|
/* AE01 */ 10,
|
||||||
|
@ -52,7 +52,8 @@ int main(int argc, char **argv)
|
|||||||
char text[256];
|
char text[256];
|
||||||
char *displayname = NULL;
|
char *displayname = NULL;
|
||||||
char *outfname;
|
char *outfname;
|
||||||
const char *sections[8] = {
|
const char *sections[8] =
|
||||||
|
{
|
||||||
"noshift", "shift", "altgr", "shiftaltgr",
|
"noshift", "shift", "altgr", "shiftaltgr",
|
||||||
"capslock", "capslockaltgr", "shiftcapslock", "shiftcapslockaltgr"
|
"capslock", "capslockaltgr", "shiftcapslock", "shiftcapslockaltgr"
|
||||||
};
|
};
|
||||||
@ -139,9 +140,13 @@ int main(int argc, char **argv)
|
|||||||
for (i = 8; i < 137; i++) /* Keycodes */
|
for (i = 8; i < 137; i++) /* Keycodes */
|
||||||
{
|
{
|
||||||
if (is_evdev)
|
if (is_evdev)
|
||||||
|
{
|
||||||
e.keycode = xfree86_to_evdev[i - 8];
|
e.keycode = xfree86_to_evdev[i - 8];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
e.keycode = i;
|
e.keycode = i;
|
||||||
|
}
|
||||||
nbytes = XLookupString(&e, text, 255, &ks, NULL);
|
nbytes = XLookupString(&e, text, 255, &ks, NULL);
|
||||||
text[nbytes] = 0;
|
text[nbytes] = 0;
|
||||||
char_count = mbstowcs(wtext, text, 255);
|
char_count = mbstowcs(wtext, text, 255);
|
||||||
|
108
scripts/install_astyle.sh
Executable file
108
scripts/install_astyle.sh
Executable file
@ -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
|
6
scripts/install_astyle_dependencies_with_apt.sh
Executable file
6
scripts/install_astyle_dependencies_with_apt.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eufx
|
||||||
|
|
||||||
|
PACKAGES="subversion cmake"
|
||||||
|
|
||||||
|
apt-get -yq --no-install-suggests --no-install-recommends install $PACKAGES
|
74
scripts/run_astyle.sh
Executable file
74
scripts/run_astyle.sh
Executable file
@ -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
|
||||||
|
}
|
@ -77,13 +77,15 @@
|
|||||||
#define SESMAN_CFG_SESS_POLICY_UBDI_S "UBDI"
|
#define SESMAN_CFG_SESS_POLICY_UBDI_S "UBDI"
|
||||||
#define SESMAN_CFG_SESS_POLICY_UBDC_S "UBDC"
|
#define SESMAN_CFG_SESS_POLICY_UBDC_S "UBDC"
|
||||||
|
|
||||||
enum SESMAN_CFG_SESS_POLICY_BITS {
|
enum SESMAN_CFG_SESS_POLICY_BITS
|
||||||
|
{
|
||||||
SESMAN_CFG_SESS_POLICY_D = 0x01,
|
SESMAN_CFG_SESS_POLICY_D = 0x01,
|
||||||
SESMAN_CFG_SESS_POLICY_I = 0x02,
|
SESMAN_CFG_SESS_POLICY_I = 0x02,
|
||||||
SESMAN_CFG_SESS_POLICY_C = 0x04
|
SESMAN_CFG_SESS_POLICY_C = 0x04
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SESMAN_CFG_SESS_POLICY {
|
enum SESMAN_CFG_SESS_POLICY
|
||||||
|
{
|
||||||
SESMAN_CFG_SESS_POLICY_DFLT = 0,
|
SESMAN_CFG_SESS_POLICY_DFLT = 0,
|
||||||
SESMAN_CFG_SESS_POLICY_UBD = SESMAN_CFG_SESS_POLICY_D,
|
SESMAN_CFG_SESS_POLICY_UBD = SESMAN_CFG_SESS_POLICY_D,
|
||||||
SESMAN_CFG_SESS_POLICY_UBI = SESMAN_CFG_SESS_POLICY_I,
|
SESMAN_CFG_SESS_POLICY_UBI = SESMAN_CFG_SESS_POLICY_I,
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class DlgAbout;
|
class DlgAbout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1134,7 +1134,8 @@ dynamic_monitor_data(intptr_t id, int chan_id, char *data, int bytes)
|
|||||||
xrdp_bitmap_invalidate(wm->screen, 0);
|
xrdp_bitmap_invalidate(wm->screen, 0);
|
||||||
|
|
||||||
struct xrdp_mod *v = wm->mm->mod;
|
struct xrdp_mod *v = wm->mm->mod;
|
||||||
if (v != 0) {
|
if (v != 0)
|
||||||
|
{
|
||||||
v->mod_server_version_message(v);
|
v->mod_server_version_message(v);
|
||||||
v->mod_server_monitor_resize(v, session_width, session_height);
|
v->mod_server_monitor_resize(v, session_width, session_height);
|
||||||
v->mod_server_monitor_full_invalidate(v, session_width, session_height);
|
v->mod_server_monitor_full_invalidate(v, session_width, session_height);
|
||||||
|
@ -337,7 +337,9 @@ xrdpvr_get_frame(void **av_pkt_ret, int *is_video_frame, int *delay_in_us)
|
|||||||
//printf("xrdpvr_get_frame:\n");
|
//printf("xrdpvr_get_frame:\n");
|
||||||
/* alloc an AVPacket */
|
/* alloc an AVPacket */
|
||||||
if ((av_pkt = (AVPacket *) malloc(sizeof(AVPacket))) == NULL)
|
if ((av_pkt = (AVPacket *) malloc(sizeof(AVPacket))) == NULL)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* read one frame into AVPacket */
|
/* read one frame into AVPacket */
|
||||||
if (av_read_frame(g_psi.p_format_ctx, av_pkt) < 0)
|
if (av_read_frame(g_psi.p_format_ctx, av_pkt) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user