Skip to content

Commit

Permalink
Initial project skeleton. (#2)
Browse files Browse the repository at this point in the history
* Initial project skeleton.

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>

* Adds new lines at the end of the files.

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
  • Loading branch information
agalbachicar committed Aug 8, 2022
1 parent d3866a1 commit f8ce525
Show file tree
Hide file tree
Showing 22 changed files with 757 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .clang-format
@@ -0,0 +1,36 @@
# This file determines clang-format's style settings; for details, refer to
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html

BasedOnStyle: Google
ColumnLimit: 120

DerivePointerAlignment: false
PointerAlignment: Left

# Specify the #include statement order. This implements the order mandated by
# the Google C++ Style Guide: related header, C headers, C++ headers, library
# headers, and finally the project headers.
#
# To obtain updated lists of system headers used in the below expressions, see:
# http://stackoverflow.com/questions/2027991/list-of-standard-header-files-in-c-and-c/2029106#2029106.
IncludeCategories:
- Regex: '^<clang-format-priority-15>$'
Priority: 15
- Regex: '^<clang-format-priority-25>$'
Priority: 25
- Regex: '^<clang-format-priority-35>$'
Priority: 35
- Regex: '^<clang-format-priority-45>$'
Priority: 45
# C system headers.
- Regex: '^[<"](aio|arpa/inet|assert|complex|cpio|ctype|curses|dirent|dlfcn|errno|fcntl|fenv|float|fmtmsg|fnmatch|ftw|glob|grp|iconv|inttypes|iso646|langinfo|libgen|limits|locale|math|monetary|mqueue|ndbm|netdb|net/if|netinet/in|netinet/tcp|nl_types|poll|pthread|pwd|regex|sched|search|semaphore|setjmp|signal|spawn|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|strings|stropts|sys/ipc|syslog|sys/mman|sys/msg|sys/resource|sys/select|sys/sem|sys/shm|sys/socket|sys/stat|sys/statvfs|sys/time|sys/times|sys/types|sys/uio|sys/un|sys/utsname|sys/wait|tar|term|termios|tgmath|threads|time|trace|uchar|ulimit|uncntrl|unistd|utime|utmpx|wchar|wctype|wordexp)\.h[">]$'
Priority: 20
# C++ system headers (as of C++17).
- Regex: '^[<"](algorithm|array|atomic|bitset|cassert|ccomplex|cctype|cerrno|cfenv|cfloat|chrono|cinttypes|ciso646|climits|clocale|cmath|codecvt|complex|condition_variable|csetjmp|csignal|cstdalign|cstdarg|cstdbool|cstddef|cstdint|cstdio|cstdlib|cstring|ctgmath|ctime|cuchar|cwchar|cwctype|deque|exception|forward_list|fstream|functional|future|initializer_list|iomanip|ios|iosfwd|iostream|istream|iterator|limits|list|locale|map|memory|mutex|new|numeric|optional|ostream|queue|random|ratio|regex|scoped_allocator|set|shared_mutex|sstream|stack|stdexcept|streambuf|string|strstream|system_error|thread|tuple|type_traits|typeindex|typeinfo|unordered_map|unordered_set|utility|valarray|variant|vector)[">]$'
Priority: 30
# Other libraries' h files (with angles).
- Regex: '^<'
Priority: 40
# Other libraries' h files (with quotes).
- Regex: '^"'
Priority: 41
89 changes: 89 additions & 0 deletions .clang-tidy
@@ -0,0 +1,89 @@
# Copyright 2022 Toyota Research Institute. All rights reserved.
#
# clang-tidy lists all rules in a single YAML string, which makes it
# hard to have inline comments. Thus we'll add comments out-of-line
# up here.
#
# Disabled checks have rationale documented here.

# * cert-err58-cpp - This verifies that exceptions are not thrown
# during static initialization or destruction. However, boost::test
# violates this, so we leave it off for now.

# * cert-err60-cpp - This requires that exception types have noexcept
# copy constructors. SystemError could do so, except that it
# contains a std::string, which can throw std::bad_alloc. Hopefully
# soon C++ will delete std::bad_alloc entirely, but in the meantime,
# we disable this check.

# * cppcoreguidelines-pro-type-vararg,hicpp-vararg - boost::test uses
# varargs, so for now we leave this disabled globally

# * cppcoreguidelines-pro-bounds-array-to-pointer-decay,
# hicpp-no-array-decay - every call to BOOST_ASSERT_MSG triggers
# this along with things like using std::cout

# * cppcoreguidelines-pro-type-reinterpret-cast - we currently have a
# lot of reinterpret_casts that are required in order to perform low
# level bit manipulation. It probably isn't worth annotating all of
# them yet.

# * cppcoreguidelines-pro-bounds-pointer-arithmetic - until we get
# C++20's span or some similar construct, this will be difficult to
# satisfy.

# * fuchsia-default-arguments - we currently permit C++ default
# arguments

# * fuchsia-multiple-inheritance - we currently permit inheriting
# implementation and multiple inheritance

# * fuchsia-overloaded-operator - we (and GSG) consider operator
# overloading fine

# * fuchsia-statically-constructed-objects - boost::test uses
# statically constructed objects, so we leave this around.

# * google-runtime-references - boost::asio widely uses the convention
# of passing io_service by mutable reference, as does the C++
# iostreams library

# * hicpp-exception-baseclass - either boost::system::system_error
# doesn't inherit from std::exception or clang can't discover that
# it does. In either case, this isn't important enough to figure
# out.

# * readability-named-parameter - This requires that all parameters be
# named. This rule seems to be of dubious value, since often the
# type alone of an argument is sufficient documentation.

# * readability-redundant-declaration - C++14 requires static
# constexpr class members to have a separate definition. Until we
# drop C++14 support, it is easiest to just ignore this warning.

# * performance-unnecessary-copy-initialization,
# performance-unnecessary-value-param - These checks seem to be of
# dubious value, as the conditions they warn about would all likely
# be optimized away by a sane compiler and they require moderate
# contortions to satisfy.

Checks: >
*,
-cert-err58-cpp,
-cert-err60-cpp,
-cppcoreguidelines-pro-type-vararg,
-hicpp-vararg,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-hicpp-no-array-decay,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-fuchsia-default-arguments,
-fuchsia-multiple-inheritance,
-fuchsia-overloaded-operator,
-fuchsia-statically-constructed-objects,
-google-runtime-references,
-hicpp-exception-baseclass,
-readability-named-parameter,
-readability-redundant-declaration,
-performance-unnecessary-copy-initialization,
-performance-unnecessary-value-param,
28 changes: 28 additions & 0 deletions .github/clang_suite_installation.sh
@@ -0,0 +1,28 @@
#! /bin/bash

#######################################
# Installs clang suite packages.
# Arguments:
# Version of the clang suite package.
# Returns:
# 0 if no error was detected, non-zero otherwise.
#######################################
function install_clang_suite() {
local version=$1

apt install -y \
clang-${version} \
lldb-${version} \
lld-${version} \
clang-format-${version} \
clang-tidy-${version} \
libc++-${version}-dev \
libc++abi-${version}-dev
}

#######################################
# Modify clang suite version as required.
#######################################
CLANG_SUITE_VERSION=8

install_clang_suite ${CLANG_SUITE_VERSION}
9 changes: 9 additions & 0 deletions .github/dependencies.repos
@@ -0,0 +1,9 @@
repositories:
ament_cmake_doxygen:
type: git
url: https://github.com/ToyotaResearchInstitute/ament_cmake_doxygen
version: main
maliput:
type: git
url: https://github.com/maliput/maliput
version: main
144 changes: 144 additions & 0 deletions .github/run_scan_build
@@ -0,0 +1,144 @@
#!/usr/bin/python3

# BSD 3-Clause License
#
# Copyright (c) 2022, Woven Planet. All rights reserved.
# Copyright (c) 2020-2022, Toyota Research Institute. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os
import sys

EXTRA_EXCLUDE_ARGS = " --exclude src/pybind11 --exclude /usr/include/eigen3 "

def get_package_dependencies_names(packages_up_to = None):
'''
Returns a set of dependencies by name of all the `packages-up-to` argument.
When None is provided, all the packages are returned.
'''
stream = os.popen('colcon graph') if not packages_up_to else os.popen('colcon graph --packages-up-to ' + packages_up_to)

colcon_graph = stream.read().splitlines()
result = set()
for line in colcon_graph:
result.add(line[:line.find(' ')])
return result

def get_exclusion_paths_from_file(filepath, store):
'''
Get the paths located in the `filepath` and save them in the `store` set.
'''
if(os.path.exists(filepath)):
with open(filepath) as fp:
for line in fp.readlines():
store.add(line.replace('\n', ' '))

def convert_in_exclude_argument(paths):
'''
Convert a set of paths in a `--exclude`s arguments of scan-build command.
'''
final_string = ''
for path in paths:
final_string = final_string + " --exclude " + str(path)
return final_string

def get_effective_key(args):
class Key:
def __init__(self, name):
self.name = name
self.counter = 0
self.index = 0

keys = [Key("--packages-select"), Key("--packages-up-to")]
for i, potential_key in enumerate(keys):
keys[i].counter = args.count(potential_key.name)
if (keys[i].counter > 0):
keys[i].index = args.index(potential_key.name)

if (keys[0].counter == 0 and keys[1].counter == 0):
return ''
elif (keys[0].counter == keys[1].counter):
# When there are two keys present, it just cares about the first one as colcon does.
return keys[0].name if keys[0].index < keys[1].index else keys[1].name
else:
return keys[0].name if keys[0].counter else keys[1].name

def is_colcon_option(arg):
return True if (arg[0:2] == '--') else False

def get_packages_from_args(args):
key = get_effective_key(args)
if not key:
return set()
index_of_key = args.index(key)

packages = set()
indexer = 1
while (len(args) > (index_of_key + indexer)) and (not is_colcon_option(args[index_of_key + indexer])):
packages.add(args[index_of_key + indexer])
indexer += 1
return packages

def get_packages_to_get_excludes_file_of(packages):
packages_to_get_exclude_file_of = set()
if not packages:
packages_to_get_exclude_file_of = packages_to_get_exclude_file_of.union(get_package_dependencies_names())
else:
for package_from_arg in packages:
packages_to_get_exclude_file_of = packages_to_get_exclude_file_of.union(get_package_dependencies_names(package_from_arg))
return packages_to_get_exclude_file_of


def generate_exclude_args(argv):
packages_from_arg = get_packages_from_args(argv)
packages_to_get_exclude_file_of = get_packages_to_get_excludes_file_of(packages_from_arg)

exclusion_paths = set()
for package in packages_to_get_exclude_file_of:
package_path = os.popen('colcon list --packages-select ' + package + ' --paths-only')
command = 'find ' + package_path.read().splitlines()[0] + ' -name scan_build.supp'
find = os.popen(command)
supp_filepaths = find.read().splitlines()
for filepath in supp_filepaths:
get_exclusion_paths_from_file(filepath, exclusion_paths)
return convert_in_exclude_argument(exclusion_paths)

def main(argv):
excludes_args = generate_exclude_args(argv)
excludes_args += EXTRA_EXCLUDE_ARGS

colcon_extra_build_args = " ".join(argv[1:]) if(len(argv) > 1) else ""
cmd = "scan-build-8 --status-bugs --use-cc=clang-8 --use-c++=clang++-8 {} colcon build {} ".format(excludes_args, colcon_extra_build_args)
print("scan-build command...\n--> " + cmd)
return_code = os.system(cmd)
if return_code > 255 :
sys.exit(1)
else:
sys.exit(0)

if __name__ == "__main__":
main(sys.argv)
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,28 @@
name: gcc

on:
push:
pull_request:
branches:
- main
workflow_dispatch:

env:
PACKAGE_NAME: maliput_sparse
ROS_DISTRO: foxy

jobs:
compile_and_test:
name: Compile and test
runs-on: ubuntu-latest
container:
image: ubuntu:20.04
steps:
- uses: actions/checkout@v3
- uses: ros-tooling/setup-ros@v0.3
- uses: ros-tooling/action-ros-ci@v0.2
id: action_ros_ci_step
with:
package-name: ${{ env.PACKAGE_NAME }}
target-ros2-distro: ${{ env.ROS_DISTRO }}
vcs-repo-file-url: ${GITHUB_WORKSPACE}/.github/dependencies.repos

0 comments on commit f8ce525

Please sign in to comment.