Skip to content

Commit 161004a

Browse files
committed
Use cmake build instead make
1 parent 17b642d commit 161004a

File tree

10 files changed

+156
-50
lines changed

10 files changed

+156
-50
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
tarantool-version: '2.8'
1717

1818
- run: echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
19-
- run: echo "return { VERSION = '"$TAG"-1' }" > graphql/init.lua
2019
- run: tarantoolctl rocks new_version --tag $TAG
21-
- run: tarantoolctl rocks pack graphql-$TAG-1.rockspec
20+
- run: tarantoolctl rocks make graphql-${{ env.TAG }}-1.rockspec
21+
- run: tarantoolctl rocks pack graphql ${{ env.TAG }}
2222

2323
- uses: tarantool/rocks.tarantool.org/github-action@master
2424
with:
2525
auth: ${{ secrets.ROCKS_AUTH }}
2626
files: |
2727
graphql-${{ env.TAG }}-1.rockspec
28-
graphql-${{ env.TAG }}-1.src.rock
28+
graphql-${{ env.TAG }}-1.all.rock

.github/workflows/test_on_push.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@ jobs:
2121
tarantool-version: ${{ matrix.tarantool-version }}
2222

2323
- name: Install dependencies
24-
run: make .rocks
24+
shell: bash
25+
run: ./deps.sh
26+
27+
- name: Build
28+
run: tarantoolctl rocks make
2529

2630
- name: Run linter
27-
run: make lint
31+
run: .rocks/bin/luacheck .
2832

2933
- name: Run tests
30-
run: make test
34+
run: |
35+
rm -f tmp/luacov*
36+
.rocks/bin/luatest --verbose --coverage --shuffle group
37+
.rocks/bin/luacov . && grep -A999 '^Summary' tmp/luacov.report.out

CMakeLists.txt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
2+
3+
project(graphql C)
4+
5+
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
6+
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
7+
8+
# Find Tarantool and Lua dependencies
9+
set(TARANTOOL_FIND_REQUIRED ON)
10+
find_package(Tarantool)
11+
include_directories(${TARANTOOL_INCLUDE_DIRS})
12+
13+
file(GLOB_RECURSE LUA_FILES
14+
"${CMAKE_CURRENT_SOURCE_DIR}/graphql/*.lua"
15+
)
16+
17+
18+
## VERSION ####################################################################
19+
###############################################################################
20+
21+
execute_process(
22+
COMMAND git describe --tags --always
23+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
24+
OUTPUT_STRIP_TRAILING_WHITESPACE
25+
OUTPUT_VARIABLE GIT_DESCRIBE
26+
ERROR_QUIET
27+
)
28+
29+
if (NOT GIT_DESCRIBE)
30+
set(GIT_DESCRIBE "unknown")
31+
endif()
32+
33+
configure_file (
34+
"${PROJECT_SOURCE_DIR}/graphql/VERSION.lua.in"
35+
"${CMAKE_CURRENT_BINARY_DIR}/graphql/VERSION.lua"
36+
)
37+
38+
39+
## Testing ####################################################################
40+
###############################################################################
41+
42+
enable_testing()
43+
44+
add_test(
45+
NAME lint
46+
COMMAND luacheck .
47+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
48+
)
49+
50+
## Install ####################################################################
51+
###############################################################################
52+
53+
install(
54+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}
55+
DESTINATION ${TARANTOOL_INSTALL_LUADIR}
56+
PATTERN "*.in" EXCLUDE
57+
)
58+
59+
install(
60+
FILES
61+
${CMAKE_CURRENT_BINARY_DIR}/graphql/VERSION.lua
62+
DESTINATION ${TARANTOOL_INSTALL_LUADIR}/${PROJECT_NAME}/
63+
)

Makefile

Lines changed: 0 additions & 29 deletions
This file was deleted.

cmake/FindTarantool.cmake

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Define GNU standard installation directories
2+
include(GNUInstallDirs)
3+
4+
macro(extract_definition name output input)
5+
string(REGEX MATCH "#define[\t ]+${name}[\t ]+\"([^\"]*)\""
6+
_t "${input}")
7+
string(REGEX REPLACE "#define[\t ]+${name}[\t ]+\"(.*)\"" "\\1"
8+
${output} "${_t}")
9+
endmacro()
10+
11+
find_path(TARANTOOL_INCLUDE_DIR tarantool/module.h
12+
HINTS ${TARANTOOL_DIR} ENV TARANTOOL_DIR
13+
PATH_SUFFIXES include
14+
)
15+
16+
if(TARANTOOL_INCLUDE_DIR)
17+
set(_config "-")
18+
file(READ "${TARANTOOL_INCLUDE_DIR}/tarantool/module.h" _config0)
19+
string(REPLACE "\\" "\\\\" _config ${_config0})
20+
unset(_config0)
21+
extract_definition(PACKAGE_VERSION TARANTOOL_VERSION ${_config})
22+
extract_definition(INSTALL_PREFIX _install_prefix ${_config})
23+
unset(_config)
24+
endif()
25+
26+
include(FindPackageHandleStandardArgs)
27+
find_package_handle_standard_args(TARANTOOL
28+
REQUIRED_VARS TARANTOOL_INCLUDE_DIR VERSION_VAR TARANTOOL_VERSION)
29+
if(TARANTOOL_FOUND)
30+
set(TARANTOOL_INCLUDE_DIRS "${TARANTOOL_INCLUDE_DIR}"
31+
"${TARANTOOL_INCLUDE_DIR}/tarantool/"
32+
CACHE PATH "Include directories for Tarantool")
33+
set(TARANTOOL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/tarantool"
34+
CACHE PATH "Directory for storing Lua modules written in Lua")
35+
set(TARANTOOL_INSTALL_LUADIR "${CMAKE_INSTALL_DATADIR}/tarantool"
36+
CACHE PATH "Directory for storing Lua modules written in C")
37+
set(TARANTOOL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}"
38+
CACHE PATH "Directory for storing Lua scripts")
39+
40+
if (NOT TARANTOOL_FIND_QUIETLY AND NOT FIND_TARANTOOL_DETAILS)
41+
set(FIND_TARANTOOL_DETAILS ON CACHE INTERNAL "Details about TARANTOOL")
42+
message(STATUS "Tarantool LUADIR is ${TARANTOOL_INSTALL_LUADIR}")
43+
message(STATUS "Tarantool LIBDIR is ${TARANTOOL_INSTALL_LIBDIR}")
44+
message(STATUS "Tarantool BINDIR is ${TARANTOOL_INSTALL_BINDIR}")
45+
endif ()
46+
endif()
47+
mark_as_advanced(
48+
TARANTOOL_INCLUDE_DIRS
49+
TARANTOOL_INSTALL_LIBDIR
50+
TARANTOOL_INSTALL_LUADIR
51+
TARANTOOL_INSTALL_BINDIR
52+
)

deps.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
# Call this script to install dependencies
3+
4+
set -e
5+
6+
tarantoolctl rocks install luatest 0.5.7
7+
tarantoolctl rocks install luacov 0.13.0
8+
tarantoolctl rocks install luacheck 0.26.0

graphql-scm-1.rockspec

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,11 @@ dependencies = {
1818
}
1919

2020
build = {
21-
type = 'builtin',
22-
modules = {
23-
['graphql.execute'] = 'graphql/execute.lua',
24-
['graphql.introspection'] = 'graphql/introspection.lua',
25-
['graphql.parse'] = 'graphql/parse.lua',
26-
['graphql.query_util'] = 'graphql/query_util.lua',
27-
['graphql.rules'] = 'graphql/rules.lua',
28-
['graphql.schema'] = 'graphql/schema.lua',
29-
['graphql.types'] = 'graphql/types.lua',
30-
['graphql.util'] = 'graphql/util.lua',
31-
['graphql.validate'] = 'graphql/validate.lua',
32-
['graphql.validate_variables'] = 'graphql/validate_variables.lua',
33-
}
21+
type = 'cmake',
22+
variables = {
23+
TARANTOOL_DIR = '$(TARANTOOL_DIR)',
24+
TARANTOOL_INSTALL_LIBDIR = '$(LIBDIR)',
25+
TARANTOOL_INSTALL_LUADIR = '$(LUADIR)',
26+
TARANTOOL_INSTALL_BINDIR = '$(BINDIR)',
27+
}
3428
}

graphql/VERSION.lua.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env tarantool
2+
3+
return "@GIT_DESCRIBE@"

graphql/init.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
return { VERSION = 'scm-1' }
1+
local ok, VERSION = pcall(require, 'graphql.VERSION')
2+
if not ok then
3+
VERSION = 'unknown'
4+
end
5+
6+
return { VERSION = VERSION }

test/unit/graphql_test.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,5 +1090,8 @@ function g.test_util_find_by_name()
10901090
end
10911091

10921092
g.test_version = function()
1093-
t.assert_equals(require('graphql').VERSION, 'scm-1')
1093+
local handle = io.popen('git describe --tags --always')
1094+
local version = handle:read("*a"):gsub('\n*', '')
1095+
handle:close()
1096+
t.assert_equals(require('graphql').VERSION, version)
10941097
end

0 commit comments

Comments
 (0)