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 6A5876F153; Wed, 31 Aug 2022 18:29:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6A5876F153 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1661959794; bh=e6NcT4aLFpPcuH0eDNrXvTM6efIVSFB5L+66SH1f/pY=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=itN1KMxb6PfOlL0WhxYNcBjsXSutoVHI4So0fXVA3vvPINTe1KDM9lqk0wGGoX9zA vNOgMEw8uMlEk4XIEZz42mrGS5S2GfoJ16ec+7g+/MNEbArBdyWtSCOd2WxkBXnd0D baK7bUMayPxIkLZ4BJd+wLo0q73YdfXovBjIS8ws= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [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 CA67B6F153 for ; Wed, 31 Aug 2022 18:29:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CA67B6F153 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1oTPf6-0004dS-Ml; Wed, 31 Aug 2022 18:29:53 +0300 Date: Wed, 31 Aug 2022 18:19:35 +0300 To: Sergey Kaplun Message-ID: References: <1d05bbecc9c9ae57250ec563e202a8e103f86fa4.1660216002.git.imun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9BF9AC82A1D2D72373D7B6BD1783EF43F26EE5E824BBE481C182A05F5380850400091D4E9C45AA1BAE873607EF6F2075897DA017013A06CF72D50E461E822F6F4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE731D82F3F177D3BCDEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637844B7CE711CAEAD08638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8B97DD39DC28B7BBFF99DC41B7288A8B8117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BECADA55FE5B58BB7A471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C747589E6AAA3516243847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 9604B64F49C60606AD91A466A1DEF99B296C473AB1E142185AC9E3593CE4B31AB1881A6453793CE9274300E5CE05BD4401A9E91200F654B0F56C66D0505D9834523897933F9F83879D9084968D120CFDBCFD0D8713511A549C2B6934AE262D3EE7EAB7254005DCED8DA55E71E02F9FC08E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A783A638E01A3CDE8E2F6506A7B43D99AE5428A80F264A02663BF4E54F37AA8924183FE0CEF68BE71D7E09C32AA3244CF5C987AD533CF5BBB73462CE57151A8B250262A5EE9971B0927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojxzT94hBWypo2aZdppkdc4w== X-DA7885C5: E784787402CA307491CC44C3090FA7571F70397981B1C245837B97DD4155A33C262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F7393CC2E0F076E87284EE74F1DC4708DB9366BB19B2DBD988AF7A7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E3365FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/8] test: introduce MakeLuaPath.cmake helper 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, Thanks for your review! On 18.08.22, Sergey Kaplun wrote: > Hi, Igor! > > Thanks for the patch! > > Please consider my comments below. > > On 11.08.22, Igor Munkin wrote: > > While extending test suites it is often required to append additional > > path where Lua or Lua-C auxiliary modules are located to LUA_PATH or > > LUA_CPATH environment variables. Due to insane semicolon interpolation > > in CMake strings (that converts such string to a list as a result), we > > need to escape semicolon in LUA_PATH/LUA_CPATH strings while building > > the resulting value. > > > > After the years of struggling MakeLuaPath.cmake module is introduced to > > Minor: s/After/Over/ No it's not. I mean that as a result of the years of struggling the module is introduced. It was not being introduced over the years of struggling. > > > make LUA_PATH and LUA_CPATH definition convenient with > > helper. This function takes all paths given as a variable list argument, > > joins them in a reverse order by a semicolon and yields the resulting > > string to a specified CMake variable. > > > > Signed-off-by: Igor Munkin > > --- > > cmake/MakeLuaPath.cmake | 46 +++++++++++++++++++++++ > > test/CMakeLists.txt | 2 + > > test/PUC-Rio-Lua-5.1-tests/CMakeLists.txt | 8 +++- > > test/lua-Harness-tests/CMakeLists.txt | 16 +++++--- > > test/tarantool-tests/CMakeLists.txt | 28 ++++++++------ > > 5 files changed, 81 insertions(+), 19 deletions(-) > > create mode 100644 cmake/MakeLuaPath.cmake > > > > diff --git a/cmake/MakeLuaPath.cmake b/cmake/MakeLuaPath.cmake > > new file mode 100644 > > index 00000000..9a5a3bb8 > > --- /dev/null > > +++ b/cmake/MakeLuaPath.cmake > > @@ -0,0 +1,46 @@ > > +# make_lua_path provides a convenient way to define LUA_PATH and > > +# LUA_CPATH variables. > > +# > > +# Example usage: > > +# > > +# make_lua_path(LUA_PATH > > +# PATH > > +# ${CMAKE_CURRENT_SOURCE_DIR}/?.lua > > +# ${CMAKE_BINARY_DIR}/?.lua > > +# ./?.lua > > +# ) > > +# > > +# This will give you the string: > > +# "./?.lua;${CMAKE_BINARY_DIR}/?.lua;${CMAKE_CURRENT_SOURCE_DIR}/?.lua;;" > > +# XXX: Mind the reverse order of the entries in the result string. > > Why do we need this behaviour? May be it is better to save strict order > of entries? The code will become more complex as a result and in the 99.999% of the cases the order of LUA_PATH entries doesn't bother you. So I don't see we should make the code more complex to save the order of the entries. > > > + > > +function(make_lua_path path) > > + set(prefix ARG) > > + set(noValues) > > + set(singleValues) > > + set(multiValues PATHS) > > + > > + # FIXME: if we update to CMake >= 3.5, can remove this line. > > So, we can just check CMake version as Sergey suggested. No, we can't (see the comment in the Sergey's thread). > > > + include(CMakeParseArguments) > > + cmake_parse_arguments(${prefix} > > + "${noValues}" > > + "${singleValues}" > > + "${multiValues}" > > + ${ARGN}) > > + > > + # XXX: This is the sentinel semicolon having special meaning > > Nit: It's not single semicolon, but two of them. This ";;" special value > is created during concatenation at the next lines. Yes, it is. But strictly saying only the second semicolon has a special meaning, the first one is a separator; otherwise it should be three of them :) > > > + # for LUA_PATH and LUA_CPATH variables. For more info, see the > > + # link below: > > + # https://www.lua.org/manual/5.1/manual.html#pdf-LUA_PATH > > + set(result "\;") > > + > > + foreach(inc ${ARG_PATHS}) > > + # XXX: If one joins two strings with semicolon, the value > > Typo: s/semicolon/the semicolon/ Fixed. > > > + # automatically becomes a list. I found a single working > > + # solution to make result variable be a string via "escaping" > > Minor: s/be/stay/ or just s/be// > Feel free to ignore. I don't get why. Ignoring. > > > + # the semicolon right in string interpolation. > > + set(result "${inc}\;${result}") > > + endforeach() > > + > > + set(${path} "${result}" PARENT_SCOPE) > > +endfunction() > > diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt > > index ba25af54..a8262b12 100644 > > --- a/test/CMakeLists.txt > > +++ b/test/CMakeLists.txt > > @@ -3,6 +3,8 @@ > > # See the rationale in the root CMakeLists.txt. > > cmake_minimum_required(VERSION 3.1 FATAL_ERROR) > > > > +include(MakeLuaPath) > > + > > Minor: It would be nice to drop the comment that this will be used in > all test suites by transitivity. > Feel free to ignore. There are some includes made in the root CMakeLists.txt that are used project-wide. There are no comments nearby. Ignoring for this case too. > > > find_program(LUACHECK luacheck) > > if(LUACHECK) > > # XXX: The tweak below relates to luacheck problem with paths. > > diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt > > index ecda2e63..27866869 100644 > > --- a/test/tarantool-tests/CMakeLists.txt > > +++ b/test/tarantool-tests/CMakeLists.txt > > @@ -43,14 +43,11 @@ macro(BuildTestCLib lib sources) > > # semicolon. If one finds the normal way to make it work, feel > > # free to reach me. > > set(TESTLIBS "${lib};${TESTLIBS}" PARENT_SCOPE) > > - # Add the directory where the lib is built to the LUA_CPATH > > - # environment variable, so LuaJIT can find and load it. > > - # XXX: Here we see the other side of the coin. If one joins two > > - # strings with semicolon, the value automatically becomes a > > - # list. I found a single working solution to make LUA_CPATH be > > - # a string via "escaping" the semicolon right in string > > - # interpolation. > > - set(LUA_CPATH "${CMAKE_CURRENT_BINARY_DIR}/?${CMAKE_SHARED_LIBRARY_SUFFIX}\;${LUA_CPATH}" PARENT_SCOPE) > > + # Add the directory where the lib is built to the list with > > + # entries for LUA_CPATH environment variable, so LuaJIT can find > > + # and load it. See the comment about extending the list in the > > + # parent scope few lines above. > > + set(LUA_CPATHS "${CMAKE_CURRENT_BINARY_DIR}/?${CMAKE_SHARED_LIBRARY_SUFFIX};${LUA_CPATHS}" PARENT_SCOPE) > > # Also add this directory to LD_LIBRARY_PATH environment > > # variable, so FFI machinery can find and load it. > > set(LD_LIBRARY_PATH "${CMAKE_CURRENT_BINARY_DIR}:${LD_LIBRARY_PATH}" PARENT_SCOPE) > > @@ -76,14 +73,21 @@ add_subdirectory(misclib-sysprof-capi) > > # in src/ directory and auxiliary tests-related modules are > > # located in the current directory (but tests are run in the > > # binary directory), so LUA_PATH need to be updated. > > -set(LUA_PATH > > - "${CMAKE_CURRENT_SOURCE_DIR}/?.lua\;${PROJECT_SOURCE_DIR}/tools/?.lua\;${PROJECT_SOURCE_DIR}/src/?.lua" > > +make_lua_path(LUA_PATH > > + PATHS > > + ${CMAKE_CURRENT_SOURCE_DIR}/?.lua > > + ${PROJECT_SOURCE_DIR}/tools/?.lua > > + ${PROJECT_SOURCE_DIR}/src/?.lua > > ) > > +# Update LUA_CPATH with the library paths collected within > > +# macro. > > +make_lua_path(LUA_CPATH PATHS ${LUA_CPATHS}) > > Side note: Looks like this part of patching is unnecessary -- we can > just leave it as is (isntead manipulation with ; later in > `make_lua_path()`). But it is good for consistency of working with env > variables, so feel free to ignore. Yes, I did it for consistency of working with env variables (otherwise there would be a mess with semicolons everywhere). Ignoring. > > > + > > set(LUA_TEST_SUFFIX .test.lua) > > set(LUA_TEST_FLAGS --failures --shuffle) > > set(LUA_TEST_ENV > > - "LUA_PATH=\"${LUA_PATH}\;\;\"" > > - "LUA_CPATH=\"${LUA_CPATH}\;\;\"" > > + "LUA_PATH=\"${LUA_PATH}\"" > > + "LUA_CPATH=\"${LUA_CPATH}\"" > > ) > > > > if(CMAKE_VERBOSE_MAKEFILE) > > -- > > 2.34.0 > > > > -- > Best regards, > Sergey Kaplun -- Best regards, IM