-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e44660
commit 8661625
Showing
54 changed files
with
4,713 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. | ||
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Debug | ||
|
||
jobs: | ||
build: | ||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. | ||
# You can convert this to a matrix build if you need cross-platform coverage. | ||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Init Submodules | ||
run: git submodule update --init --recursive | ||
|
||
- name: Configure CMake | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | ||
|
||
- name: Build | ||
# Build your program with the given configuration | ||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} | ||
|
||
- name: Test | ||
working-directory: ${{github.workspace}}/build | ||
run: ctest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
checkpatch | ||
cmake-build-debug | ||
debug-build | ||
.idea | ||
|
||
# Prerequisites | ||
*.d | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "src/lib/small"] | ||
path = src/lib/small | ||
url = https://github.com/tarantool/small | ||
ignore = dirty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
cmake_minimum_required(VERSION 3.26) | ||
project(routes C) | ||
|
||
set(CMAKE_C_STANDARD 11) | ||
|
||
include(cmake/utils.cmake) | ||
|
||
# | ||
# Specify where to look for include files. | ||
# | ||
include_directories(${PROJECT_SOURCE_DIR}/src) | ||
include_directories(${PROJECT_BINARY_DIR}/src) | ||
include_directories(${PROJECT_SOURCE_DIR}/src/lib) | ||
include_directories(${PROJECT_SOURCE_DIR}/src/lib/small/include) | ||
include_directories(${PROJECT_BINARY_DIR}/src/lib/small/small/include) | ||
include_directories(${PROJECT_SOURCE_DIR}/src/lib/small/third_party) | ||
|
||
enable_testing() | ||
|
||
add_subdirectory(src) | ||
|
||
set (sources | ||
src/c_penalty.c | ||
src/customer.c | ||
src/distance.c | ||
src/modification.c | ||
src/problem.c | ||
src/route.c | ||
src/solution.c | ||
src/tw_penalty.c | ||
src/main.c | ||
) | ||
|
||
add_executable(routes ${sources}) | ||
target_link_libraries(routes small) | ||
|
||
add_subdirectory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
macro(add_compile_flags langs) | ||
foreach(_lang ${langs}) | ||
string (REPLACE ";" " " _flags "${ARGN}") | ||
set ("CMAKE_${_lang}_FLAGS" "${CMAKE_${_lang}_FLAGS} ${_flags}") | ||
unset (_lang) | ||
unset (_flags) | ||
endforeach() | ||
endmacro(add_compile_flags) | ||
|
||
macro(set_source_files_compile_flags) | ||
foreach(file ${ARGN}) | ||
get_filename_component(_file_ext ${file} EXT) | ||
set(_lang "") | ||
if ("${_file_ext}" STREQUAL ".m") | ||
set(_lang OBJC) | ||
# CMake believes that Objective C is a flavor of C++, not C, | ||
# and uses g++ compiler for .m files. | ||
# LANGUAGE property forces CMake to use CC for ${file} | ||
set_source_files_properties(${file} PROPERTIES LANGUAGE C) | ||
elseif("${_file_ext}" STREQUAL ".mm") | ||
set(_lang OBJCXX) | ||
endif() | ||
|
||
if (_lang) | ||
get_source_file_property(_flags ${file} COMPILE_FLAGS) | ||
if ("${_flags}" STREQUAL "NOTFOUND") | ||
set(_flags "${CMAKE_${_lang}_FLAGS}") | ||
else() | ||
set(_flags "${_flags} ${CMAKE_${_lang}_FLAGS}") | ||
endif() | ||
# message(STATUS "Set (${file} ${_flags}") | ||
set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS | ||
"${_flags}") | ||
endif() | ||
endforeach() | ||
unset(_file_ext) | ||
unset(_lang) | ||
endmacro(set_source_files_compile_flags) | ||
|
||
# A helper function to compile *.lua source into *.lua.c sources | ||
function(lua_source varname filename symbolname) | ||
if (IS_ABSOLUTE "${filename}") | ||
string (REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" | ||
genname "${filename}") | ||
set (srcfile "${filename}") | ||
set (tmpfile "${genname}.new.c") | ||
set (dstfile "${genname}.c") | ||
else(IS_ABSOLUTE "${filename}") | ||
set (srcfile "${CMAKE_CURRENT_SOURCE_DIR}/${filename}") | ||
set (tmpfile "${CMAKE_CURRENT_BINARY_DIR}/${filename}.new.c") | ||
set (dstfile "${CMAKE_CURRENT_BINARY_DIR}/${filename}.c") | ||
endif(IS_ABSOLUTE "${filename}") | ||
get_filename_component(_name ${dstfile} NAME) | ||
string(REGEX REPLACE "${_name}$" "" dstdir ${dstfile}) | ||
if (IS_DIRECTORY ${dstdir}) | ||
else() | ||
file(MAKE_DIRECTORY ${dstdir}) | ||
endif() | ||
|
||
ADD_CUSTOM_COMMAND(OUTPUT ${dstfile} | ||
COMMAND ${ECHO} 'const char ${symbolname}[] =' > ${tmpfile} | ||
COMMAND ${PROJECT_BINARY_DIR}/extra/txt2c ${srcfile} >> ${tmpfile} | ||
COMMAND ${ECHO} '\;' >> ${tmpfile} | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmpfile} ${dstfile} | ||
COMMAND ${CMAKE_COMMAND} -E remove ${tmpfile} | ||
DEPENDS ${srcfile} txt2c libluajit) | ||
|
||
set(var ${${varname}}) | ||
set(${varname} ${var} ${dstfile} PARENT_SCOPE) | ||
endfunction() | ||
|
||
# A helper function to unpack list with filenames and variable names | ||
# and compile *.lua source into *.lua.c sources using lua_source() function. | ||
# Function expects a list 'source_list' with pairs of paths to a Lua source file | ||
# and a symbol names that should be used in C source code for that file. | ||
function(lua_multi_source var_name source_list) | ||
set(source_list ${source_list} ${ARGN}) | ||
list(LENGTH source_list len) | ||
math(EXPR len "${len} - 1") | ||
set(_sources) | ||
foreach(filename_idx RANGE 0 ${len} 2) | ||
list(GET source_list ${filename_idx} filename) | ||
math(EXPR symbolname_idx "${filename_idx} + 1") | ||
list(GET source_list ${symbolname_idx} symbolname) | ||
lua_source(_sources ${filename} ${symbolname}) | ||
endforeach() | ||
set(${var_name} ${${var_name}};${_sources} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(bin_source varname srcfile dstfile symbolname) | ||
set(var ${${varname}}) | ||
set (srcfile "${CMAKE_CURRENT_SOURCE_DIR}/${srcfile}") | ||
set (dstfile "${CMAKE_CURRENT_BINARY_DIR}/${dstfile}") | ||
set(${varname} ${var} "${dstfile}" PARENT_SCOPE) | ||
set (tmpfile "${dstfile}.tmp") | ||
|
||
ADD_CUSTOM_COMMAND(OUTPUT ${dstfile} | ||
COMMAND ${ECHO} 'const unsigned char ${symbolname}[] = {' > ${tmpfile} | ||
COMMAND ${PROJECT_BINARY_DIR}/extra/bin2c "${srcfile}" >> ${tmpfile} | ||
COMMAND ${ECHO} '}\;' >> ${tmpfile} | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmpfile} ${dstfile} | ||
COMMAND ${CMAKE_COMMAND} -E remove ${tmpfile} | ||
DEPENDS ${srcfile} bin2c) | ||
|
||
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}") | ||
|
||
# Tricky point: one may find <STREQUAL ".."> and | ||
# <MATCHES "^\\.\\./"> if-branches quite similar and coalesce | ||
# them as <MATCHES "^\\.\\.">. However it'll match paths like | ||
# "..." or "..foo/bar", whose are definitely descendant to | ||
# the directory. | ||
if (file_relative STREQUAL "") | ||
# <file> and <dir> is the same directory. | ||
set(${varname} FALSE PARENT_SCOPE) | ||
elseif (file_relative STREQUAL "..") | ||
# <dir> inside a <file> (so it is a directory too), not | ||
# vice versa. | ||
set(${varname} FALSE PARENT_SCOPE) | ||
elseif (file_relative MATCHES "^\\.\\./") | ||
# <file> somewhere outside of the <dir>. | ||
set(${varname} FALSE PARENT_SCOPE) | ||
else() | ||
# <file> is descendant to <dir>. | ||
set(${varname} TRUE PARENT_SCOPE) | ||
endif() | ||
endfunction() | ||
|
||
# list() has TRANSFORM option but only since 3.12. | ||
function(list_add_prefix | ||
list_in | ||
prefix | ||
list_out | ||
) | ||
set(result "") | ||
foreach(i ${${list_in}}) | ||
list(APPEND result "${prefix}${i}") | ||
endforeach() | ||
set(${list_out} ${result} PARENT_SCOPE) | ||
endfunction() | ||
|
||
# string() has JOIN option but only since 3.12. | ||
function(string_join | ||
glue | ||
string_out | ||
) | ||
set(result "") | ||
set(is_first_item TRUE) | ||
foreach(item IN LISTS ARGN) | ||
if(is_first_item) | ||
set(result "${item}") | ||
set(is_first_item FALSE) | ||
else() | ||
set(result "${result}${glue}${item}") | ||
endif() | ||
endforeach() | ||
set(${string_out} ${result} PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(lib) |
Oops, something went wrong.