From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 205867030F; Thu, 25 Feb 2021 14:59:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 205867030F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1614254381; bh=5TKls4HAqwZbzK4exY60xqYLZulWTlOACG6j8IIQ0Aw=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=hAhalFH5AiKMQcyRgXIEuPH6Ck4IVPUDDrGmEWWtvPN8NAmZukfHIwfznY69FqOXt YswuQMdFc3fqGFIhXghlcNXxVnNN3dA+7oJoplZdGjLK+G1xq/MC4UABjJ9NiyuqsC IkxdiM/hHO+3N1lelyTwU23+ab8aqoxd+GRmZxnc= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 09B7D7030F for ; Thu, 25 Feb 2021 14:59:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 09B7D7030F Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lFFIx-0000oC-3e; Thu, 25 Feb 2021 14:59:39 +0300 To: Alexander Turenko References: <524c0ce8acc18111ab4c8b36e383ff192779c780.1613661908.git.alexander.turenko@tarantool.org> Message-ID: <47b923aa-6d73-451b-169f-ea0c0e48f628@tarantool.org> Date: Thu, 25 Feb 2021 14:59:38 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <524c0ce8acc18111ab4c8b36e383ff192779c780.1613661908.git.alexander.turenko@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD975C3EC174F56692254B0AABE1FB071B229FBFD4D57485274182A05F538085040DC941B3DFD78D3FA793F43E5E76CEDC8B3B3F63A0485C51A6C41121192B2EB76 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C8140302C704C25FEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C83F54BD885518138638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FCDF5726CFBCA3E2203ECE5B6151F92F91013F9F91E55D0108389733CBF5DBD5E913377AFFFEAFD269A417C69337E82CC2CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481F9449624AB7ADAF3735872C767BF85DA29E625A9149C048EE0A3850AC1BE2E735D028CC0B556B22BC4AD6D5ED66289B524E70A05D1297E1BB35872C767BF85DA227C277FBC8AE2E8B12B4E483DFBE153475ECD9A6C639B01B4E70A05D1297E1BBC6867C52282FAC85D9B7C4F32B44FF57285124B2A10EEC6C00306258E7E6ABB4E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A5B394622580E3408A1822CC56D17E5FD30A6A9DF785F5F362D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7557E988E9157162368E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3441661D6226BE8C31A20A8F4F5206E61CBB5F78FC37080C4EC7CD2BC646743B789675AE0D18CD961D1D7E09C32AA3244C0644632521C42A08719CF4AFE9852FA3A995755A1445935EFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojvz1c9SWJtj/7hUIr8VtCew== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638228507CF8A0FF1B5B553161F941AAFC473DD788429FD8613638ED9BB8B05EE7B3AFB559BB5D741EB96D19CD4E7312BAA970A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2] tools: fix luacheck invocation in different cases X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hello, thanks for the patch! LGTM and see my comment below On 18.02.2021 19:09, Alexander Turenko wrote: > Now `make luacheck` gracefully handles different cases: in-source and > out-of-source build (within the source tree or outside), current working > directory as a real path or with symlink components. > > As result of looking into those problems I filed the issue [1] against > luacheck. It seems, there are problems around absolute paths with > symlinks components. > > [1]: https://github.com/mpeterv/luacheck/issues/208 > --- > > no issue > Totktonada/fix-luacheck-invocation > https://github.com/tarantool/tarantool/tree/Totktonada/fix-luacheck-invocation > > Changes since v1: > > * Moved the logic to CMake, dropped the shell wrapper. > * Shrink comments. > * Handled the case, when a build directory is in the source directory, > and cmake is called not like `cmake ..`, but `cmake /path/to/source`, > where the path is not a real path. > > CMakeLists.txt | 28 ++++++++++++++++++++++++++-- > cmake/utils.cmake | 22 ++++++++++++++++++++++ > 2 files changed, 48 insertions(+), 2 deletions(-) > > diff --git a/CMakeLists.txt b/CMakeLists.txt > index 4fbd19558..97cfff7ae 100644 > --- a/CMakeLists.txt > +++ b/CMakeLists.txt > @@ -158,12 +158,36 @@ add_custom_target(ctags DEPENDS tags) > # > # Enable 'make luacheck' target. > # > - > +# The code looks tricky, because of luacheck side problems > +# (see [1]). > +# > +# The following circumstances may lead to missing of source files > +# or exclusions: > +# > +# * Calling `luacheck "${dir}/.luacheckrc" "${dir}"` from > +# outside of ${dir} or when ${dir} is not a real path. > +# * Using of a path with symlink components in --exclude-files. > +# > +# [1]: https://github.com/mpeterv/luacheck/issues/208 > +# > +set(EXCLUDE_FILES) > +get_filename_component(BINARY_REALPATH "${PROJECT_BINARY_DIR}" REALPATH) > +get_filename_component(SOURCE_REALPATH "${PROJECT_SOURCE_DIR}" REALPATH) > +file_is_in_directory(BINARY_DIR_INSIDE_SOURCE_DIR "${BINARY_REALPATH}" > + "${SOURCE_REALPATH}") > +if (BINARY_DIR_INSIDE_SOURCE_DIR) extra whitespace after "if" > + set(EXCLUDE_FILES --exclude-files "${BINARY_REALPATH}/**/*.lua") > +endif() > add_custom_target(luacheck) > add_custom_command(TARGET luacheck > - COMMAND ${LUACHECK} --codes --config "${PROJECT_SOURCE_DIR}/.luacheckrc" "${PROJECT_SOURCE_DIR}" > + COMMAND ${LUACHECK} --codes --config .luacheckrc . ${EXCLUDE_FILES} > + WORKING_DIRECTORY ${SOURCE_REALPATH} > COMMENT "Perform static analysis of Lua code" > ) > +unset(BINARY_REALPATH) > +unset(SOURCE_REALPATH) > +unset(BINARY_DIR_INSIDE_SOURCE_DIR) > +unset(EXCLUDE_FILES) > > if (WITH_JEPSEN) > ExternalProject_Add( > diff --git a/cmake/utils.cmake b/cmake/utils.cmake > index eaec821b3..e9b5fed5d 100644 > --- a/cmake/utils.cmake > +++ b/cmake/utils.cmake > @@ -86,3 +86,25 @@ function(bin_source varname srcfile dstfile) > > endfunction() > > +# > +# Whether a file is descendant to a directory. > +# > +# If the file is the directory itself, the answer is FALSE. > +# > +function(file_is_in_directory varname file dir) > + file(RELATIVE_PATH file_relative "${dir}" "${file}") > + if (file_relative STREQUAL "") > + # and is the same directory. > + set(${varname} FALSE PARENT_SCOPE) > + elseif (file_relative STREQUAL "..") > + # inside a (so it is a directory too), not > + # vice versa. > + set(${varname} FALSE PARENT_SCOPE) > + elseif (file_relative MATCHES "^\\.\\./") > + # somewhere outside of the . > + set(${varname} FALSE PARENT_SCOPE) > + else() > + # is descendant to . > + set(${varname} TRUE PARENT_SCOPE) > + endif() > +endfunction()