From e65cb955677c842257a7a9413869611dd198f6f8 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 12 Jan 2017 18:03:11 +0300 Subject: [PATCH 1/4] Fix. Do not use redefine typedefs as forward declaration. --- .travis.yml | 11 ++++++++++- src/lceasy.h | 9 +++++++++ src/lcmulti.h | 12 ++++++++++++ src/lcutils.h | 12 ++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 197f214..d5cbc16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,14 +6,22 @@ matrix: include: - compiler: ": Lua51" env: LUA="lua 5.1" + os: osx + - compiler: ": Lua51" + env: LUA="lua 5.1" + os: linux - compiler: ": Lua52" env: LUA="lua 5.2" + os: linux - compiler: ": Lua53" env: LUA="lua 5.3" + os: linux - compiler: ": LuaJIT20" env: LUA="luajit 2.0" + os: linux - compiler: ": LuaJIT21" env: LUA="luajit 2.1" + os: linux cache: directories: @@ -26,10 +34,11 @@ branches: before_install: - export CC=gcc + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=$PATH:~/Library/Python/2.7/bin/; fi - pip install --user cpp-coveralls - pip install --user hererocks - hererocks here -r^ --$LUA - - export PATH=$PATH:$PWD/here/bin + - source here/bin/activate install: - luarocks make rockspecs/lua-curl-scm-0.rockspec CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage" diff --git a/src/lceasy.h b/src/lceasy.h index 96cdc1b..6f2a5e6 100644 --- a/src/lceasy.h +++ b/src/lceasy.h @@ -35,7 +35,12 @@ enum { #define LCURL_EASY_MAGIC 0xEA +#if LCURL_CC_SUPPORT_FORWARD_TYPEDEF typedef struct lcurl_multi_tag lcurl_multi_t; +#else +struct lcurl_multi_tag; +#define lcurl_multi_t struct lcurl_multi_tag +#endif typedef struct lcurl_easy_tag{ unsigned char magic; @@ -67,4 +72,8 @@ void lcurl_easy_initlib(lua_State *L, int nup); void lcurl__easy_assign_lua(lua_State *L, lcurl_easy_t *p, lua_State *value, int assign_multi); +#if !LCURL_CC_SUPPORT_FORWARD_TYPEDEF +#undef lcurl_multi_t +#endif + #endif diff --git a/src/lcmulti.h b/src/lcmulti.h index a49f832..2c1af0e 100644 --- a/src/lcmulti.h +++ b/src/lcmulti.h @@ -23,6 +23,14 @@ typedef struct lcurl_multi_tag{ lcurl_callback_t sc; }lcurl_multi_t; + +#if LCURL_CC_SUPPORT_FORWARD_TYPEDEF +typedef struct lcurl_multi_tag lcurl_multi_t; +#else +struct lcurl_easy_tag; +#define lcurl_easy_t struct lcurl_easy_tag +#endif + int lcurl_multi_create(lua_State *L, int error_mode); lcurl_multi_t *lcurl_getmulti_at(lua_State *L, int i); @@ -35,4 +43,8 @@ void lcurl__multi_assign_lua(lua_State *L, lcurl_multi_t *p, lua_State *value, i CURLMcode lcurl__multi_remove_handle(lua_State *L, lcurl_multi_t *p, lcurl_easy_t *e); +#if !LCURL_CC_SUPPORT_FORWARD_TYPEDEF +#undef lcurl_easy_t +#endif + #endif diff --git a/src/lcutils.h b/src/lcutils.h index 3bff3d4..2a061c9 100644 --- a/src/lcutils.h +++ b/src/lcutils.h @@ -13,6 +13,18 @@ #include "lcurl.h" +#ifdef _MSC_VER +# define LCURL_CC_SUPPORT_FORWARD_TYPEDEF 1 +#elif defined(__STDC_VERSION__) +# if __STDC_VERSION__ >= 201112 +# define LCURL_CC_SUPPORT_FORWARD_TYPEDEF 1 +# endif +#endif + +#ifndef LCURL_CC_SUPPORT_FORWARD_TYPEDEF +# define LCURL_CC_SUPPORT_FORWARD_TYPEDEF 0 +#endif + #define LCURL_MAKE_VERSION(MIN, MAJ, PAT) ((MIN<<16) + (MAJ<<8) + PAT) #define LCURL_CURL_VER_GE(MIN, MAJ, PAT) (LIBCURL_VERSION_NUM >= LCURL_MAKE_VERSION(MIN, MAJ, PAT)) From eff4ab6af955a73c0dacebab494c837dd78b7bc6 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 12 Jan 2017 18:08:24 +0300 Subject: [PATCH 2/4] Fix. Init hererocks on AppVeyor --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index bba29d7..bb77df0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,9 +35,9 @@ install: ) - if not exist c:\hererocks ( pip install hererocks && - hererocks c:\hererocks --%LUA% --target %HR_TARGET% -rlatest && - call c:\hererocks\bin\activate + hererocks c:\hererocks --%LUA% --target %HR_TARGET% -rlatest ) + - call c:\hererocks\bin\activate before_build: # external deps From 48d7993bba6ec0aac53dd8b27384b0fbe3281024 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 12 Jan 2017 20:13:44 +0300 Subject: [PATCH 3/4] Update Travis file. --- .travis.yml | 3 ++- src/lcutils.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d5cbc16..c0aaccb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ sudo: false matrix: include: - - compiler: ": Lua51" + - compiler: ": Lua51osx" env: LUA="lua 5.1" os: osx - compiler: ": Lua51" @@ -34,6 +34,7 @@ branches: before_install: - export CC=gcc + - gcc --version - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=$PATH:~/Library/Python/2.7/bin/; fi - pip install --user cpp-coveralls - pip install --user hererocks diff --git a/src/lcutils.h b/src/lcutils.h index 2a061c9..cb6417b 100644 --- a/src/lcutils.h +++ b/src/lcutils.h @@ -13,7 +13,7 @@ #include "lcurl.h" -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__cplusplus) # define LCURL_CC_SUPPORT_FORWARD_TYPEDEF 1 #elif defined(__STDC_VERSION__) # if __STDC_VERSION__ >= 201112 From 201623342f151c53ed1620a949a2aa6b4c146ce0 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 13 Jan 2017 10:21:34 +0300 Subject: [PATCH 4/4] Update Travis file --- .travis.yml | 18 ++++++++++++------ appveyor.yml | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index c0aaccb..098c160 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,14 @@ language: c sudo: false +env: + global: + - LCURL_CC_FLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" + - LCURL_LD_FLAGS="-shared --coverage" + matrix: include: - - compiler: ": Lua51osx" + - compiler: ": Lua51-osx" env: LUA="lua 5.1" os: osx - compiler: ": Lua51" @@ -36,19 +41,20 @@ before_install: - export CC=gcc - gcc --version - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=$PATH:~/Library/Python/2.7/bin/; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export LCURL_LD_FLAGS="-bundle -undefined dynamic_lookup -all_load --coverage"; fi - pip install --user cpp-coveralls - pip install --user hererocks - hererocks here -r^ --$LUA - source here/bin/activate install: - - luarocks make rockspecs/lua-curl-scm-0.rockspec CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage" + - luarocks make rockspecs/lua-curl-scm-0.rockspec CFLAGS="$LCURL_CC_FLAGS" LIBFLAG="$LCURL_LD_FLAGS" before_script: - - luarocks show luacov-coveralls || luarocks install luacov-coveralls - - luarocks show lunitx || luarocks install lunitx - - luarocks show luafilesystem || luarocks install luafilesystem - - luarocks show dkjson || luarocks install dkjson --deps-mode=none + - luarocks show luacov-coveralls > /dev/null 2>&1 || luarocks install luacov-coveralls + - luarocks show lunitx > /dev/null 2>&1 || luarocks install lunitx + - luarocks show luafilesystem > /dev/null 2>&1 || luarocks install luafilesystem + - luarocks show dkjson > /dev/null 2>&1 || luarocks install dkjson --deps-mode=none script: - cd test diff --git a/appveyor.yml b/appveyor.yml index bb77df0..a731df2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,6 +21,7 @@ platform: cache: - c:\hererocks -> appveyor.yml + - c:\external -> appveyor.yml install: - set PATH=C:\Python27\Scripts;%LR_EXTERNAL%;%PATH%