#!/bin/bash # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. global SRCDIR := '/tmp/SRC' # Prepare sources git clone --depth 1 file:///SRC $(SRCDIR) || exit 1 shell {cd $(SRCDIR) && ./bootstrap} || exit 1 # Configure sources $(SRCDIR)/configure $(CONFIGURE_FLAGS) || exit 1 # Build sources bear make -j $[nproc] tests || exit 1 # TODO(bbannier): Use a less restrictive `grep` pattern and `header-filter` # once MESOS-6115 is fixed. cat compile_commands.json \ | jq '.[].file' \ | sed 's/"//g' \ | sed 's/^\ //g' \ | grep "^$(SRCDIR)/.*\.cpp$" \ | parallel -j $[nproc] clang-tidy -p $(PWD) \ -extra-arg=-Wno-unknown-warning-option \ -extra-arg=-Wno-unused-command-line-argument \ -header-filter="^$(SRCDIR)/.*\.hpp$" -checks="$(CHECKS)" \ !1 > clang-tidy.log !2 > /dev/null # Propagate any errors. if test -s clang-tidy.log { cat clang-tidy.log exit 1 } else { echo "No mesos-tidy violations found." } (CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:SRCDIR) op:Equal rhs:{(/tmp/SRC)} spids:[46])] spids: [46] ) (AndOr children: [ (C {(git)} {(clone)} {(--depth)} {(1)} {(file) (Lit_Other ":") (///SRC)} {(DQ (${ VSub_Name SRCDIR))} ) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) (AndOr children: [ (Subshell child: (AndOr children: [(C {(cd)} {(${ VSub_Name SRCDIR)}) (C {(./bootstrap)})] op_id: Op_DAmp ) spids: [77 87] ) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) (AndOr children: [ (C {(${ VSub_Name SRCDIR) (/configure)} {(${ VSub_Name CONFIGURE_FLAGS)}) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) (AndOr children: [ (C {(bear)} {(make)} {(-j)} { (CommandSubPart command_list: (CommandList children:[(C {(nproc)})]) left_token: spids: [124 126] ) } {(tests)} ) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) (Pipeline children: [ (C {(cat)} {(compile_commands.json)}) (C {(jq)} {(SQ <".[].file">)}) (C {(sed)} {(SQ <"s/\"//g">)}) (C {(sed)} {(SQ <"s/^\\ //g">)}) (C {(grep)} { (DQ ("^") (${ VSub_Name SRCDIR) ("/.*") (EscapedLiteralPart token:) (cpp) (Lit_Other "$") ) } ) (SimpleCommand words: [ {(parallel)} {(-j)} { (CommandSubPart command_list: (CommandList children:[(C {(nproc)})]) left_token: spids: [202 204] ) } {(clang-tidy)} {(-p)} {(DQ (${ VSub_Name PWD))} {(-extra-arg) (Lit_Other "=") (-Wno-unknown-warning-option)} {(-extra-arg) (Lit_Other "=") (-Wno-unused-command-line-argument)} {(-header-filter) (Lit_Other "=") (DQ ("^") (${ VSub_Name SRCDIR) ("/.*") (EscapedLiteralPart token:) (hpp) (Lit_Other "$") ) } {(-checks) (Lit_Other "=") (DQ (${ VSub_Name CHECKS))} ] redirects: [ (Redir op_id:Redir_Great fd:1 arg_word:{(clang-tidy.log)} spids:[253]) (Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[257]) ] ) ] negated: False ) (If arms: [ (if_arm cond: [(Sentence child:(C {(test)} {(-s)} {(clang-tidy.log)}) terminator:)] action: [(C {(cat)} {(clang-tidy.log)}) (C {(exit)} {(1)})] spids: [-1 274] ) ] else_action: [(C {(echo)} {(DQ ("No mesos-tidy violations found."))})] spids: [286 295] ) ] )