2018-05-18 03:41:20 +00:00
|
|
|
# Copyright (c) 2018 Calvin Rose
|
2018-01-19 21:43:19 +00:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to
|
|
|
|
# deal in the Software without restriction, including without limitation the
|
|
|
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
# sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
# IN THE SOFTWARE.
|
|
|
|
|
2018-01-29 20:46:26 +00:00
|
|
|
cmake_minimum_required(VERSION 3.7)
|
2018-01-19 21:43:19 +00:00
|
|
|
project(dst)
|
|
|
|
|
|
|
|
# Set Some Variables
|
|
|
|
set(TARGET_NAME ${PROJECT_NAME})
|
2018-07-17 02:55:45 +00:00
|
|
|
set(CMAKE_C_STANDARD 99)
|
2018-02-02 01:09:22 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
2018-01-19 21:43:19 +00:00
|
|
|
|
2018-06-08 20:54:08 +00:00
|
|
|
# Set configurations
|
|
|
|
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
|
|
|
|
SET(CMAKE_C_FLAGS_RELEASE "-O2")
|
|
|
|
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
|
|
|
|
|
2018-01-19 21:43:19 +00:00
|
|
|
include_directories(src/include)
|
2018-01-31 22:39:18 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
2018-01-19 21:43:19 +00:00
|
|
|
set(CORE_SOURCES
|
|
|
|
src/core/abstract.c
|
|
|
|
src/core/array.c
|
2018-06-30 02:52:55 +00:00
|
|
|
src/core/asm.c
|
2018-01-19 21:43:19 +00:00
|
|
|
src/core/buffer.c
|
2018-01-20 22:19:47 +00:00
|
|
|
src/core/bytecode.c
|
2018-07-04 03:19:16 +00:00
|
|
|
src/core/cfuns.c
|
|
|
|
src/core/compile.c
|
2018-01-30 04:38:49 +00:00
|
|
|
src/core/corelib.c
|
2018-07-04 03:19:16 +00:00
|
|
|
src/core/emit.c
|
2018-01-19 21:43:19 +00:00
|
|
|
src/core/fiber.c
|
|
|
|
src/core/gc.c
|
|
|
|
src/core/io.c
|
2018-06-12 18:24:45 +00:00
|
|
|
src/core/marsh.c
|
2018-01-19 21:43:19 +00:00
|
|
|
src/core/math.c
|
2018-03-29 00:50:20 +00:00
|
|
|
src/core/os.c
|
2018-06-29 03:36:31 +00:00
|
|
|
src/core/parse.c
|
2018-07-04 03:19:16 +00:00
|
|
|
src/core/regalloc.c
|
|
|
|
src/core/run.c
|
|
|
|
src/core/specials.c
|
2018-01-19 21:43:19 +00:00
|
|
|
src/core/string.c
|
2018-05-01 15:06:31 +00:00
|
|
|
src/core/strtod.c
|
2018-01-19 21:43:19 +00:00
|
|
|
src/core/struct.c
|
|
|
|
src/core/symcache.c
|
|
|
|
src/core/table.c
|
|
|
|
src/core/tuple.c
|
|
|
|
src/core/util.c
|
|
|
|
src/core/value.c
|
2018-07-04 03:19:16 +00:00
|
|
|
src/core/vector.c
|
2018-01-19 21:43:19 +00:00
|
|
|
src/core/vm.c
|
|
|
|
src/core/wrap.c
|
|
|
|
|
2018-07-04 03:19:16 +00:00
|
|
|
src/core/compile.h
|
|
|
|
src/core/emit.h
|
2018-03-11 19:35:23 +00:00
|
|
|
src/core/fiber.h
|
2018-05-18 03:41:20 +00:00
|
|
|
src/core/gc.h
|
2018-07-04 03:19:16 +00:00
|
|
|
src/core/regalloc.h
|
2018-03-31 20:40:36 +00:00
|
|
|
src/core/state.h
|
2018-05-18 03:41:20 +00:00
|
|
|
src/core/symcache.h
|
2018-01-19 21:43:19 +00:00
|
|
|
src/core/util.h
|
2018-07-04 03:19:16 +00:00
|
|
|
|
2018-07-04 15:02:03 +00:00
|
|
|
generated/core.h
|
2018-01-19 21:43:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
set(MAINCLIENT_SOURCES
|
|
|
|
src/mainclient/main.c
|
2018-03-14 03:39:49 +00:00
|
|
|
src/mainclient/line.c
|
|
|
|
src/mainclient/line.h
|
2018-07-04 03:19:16 +00:00
|
|
|
|
2018-07-04 15:02:03 +00:00
|
|
|
generated/init.h
|
2018-01-19 21:43:19 +00:00
|
|
|
)
|
|
|
|
|
2018-01-29 20:46:26 +00:00
|
|
|
set(REPL_SOURCES
|
2018-01-19 21:43:19 +00:00
|
|
|
${CORE_SOURCES}
|
|
|
|
${MAINCLIENT_SOURCES}
|
|
|
|
)
|
|
|
|
|
2018-01-29 20:46:26 +00:00
|
|
|
# Set Public headers
|
|
|
|
set(DST_PUBLIC_HEADERS
|
|
|
|
src/include/dst/dst.h
|
|
|
|
)
|
|
|
|
|
2018-01-19 21:43:19 +00:00
|
|
|
# Build the executable
|
2018-01-29 20:46:26 +00:00
|
|
|
add_executable(${TARGET_NAME} ${REPL_SOURCES})
|
2018-06-08 20:54:08 +00:00
|
|
|
if (APPLE)
|
|
|
|
# macOS flags here
|
2018-06-29 05:18:20 +00:00
|
|
|
elseif (UNIX)
|
2018-04-26 17:13:31 +00:00
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic")
|
2018-02-02 01:09:22 +00:00
|
|
|
target_link_libraries(${TARGET_NAME} m dl)
|
2018-06-08 20:54:08 +00:00
|
|
|
endif (APPLE)
|
2018-01-29 20:46:26 +00:00
|
|
|
set_target_properties(${TARGET_NAME} PROPERTIES PUBLIC_HEADER "${DST_PUBLIC_HEADERS}")
|
|
|
|
|
2018-03-13 17:31:25 +00:00
|
|
|
# Generate header containing standard library
|
|
|
|
add_custom_command(
|
2018-07-04 15:02:03 +00:00
|
|
|
OUTPUT generated/core.h
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gencore.cmake
|
|
|
|
DEPENDS src/core/core.dst
|
2018-03-13 17:31:25 +00:00
|
|
|
COMMENT "Generating stl bootstrap C header for embedding"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Generate header containing main client script
|
|
|
|
add_custom_command(
|
2018-07-04 03:19:16 +00:00
|
|
|
OUTPUT generated/init.h
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/geninit.cmake
|
2018-03-13 17:31:25 +00:00
|
|
|
DEPENDS src/mainclient/init.dst
|
|
|
|
COMMENT "Generating mainclient init C header for embedding"
|
|
|
|
)
|
|
|
|
|
2018-01-29 20:46:26 +00:00
|
|
|
# Install
|
|
|
|
install(TARGETS ${TARGET_NAME}
|
|
|
|
LIBRARY DESTINATION "lib"
|
|
|
|
RUNTIME DESTINATION "bin"
|
|
|
|
PUBLIC_HEADER DESTINATION "include/dst"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Add some test scripts
|
|
|
|
enable_testing()
|
2018-06-08 20:54:08 +00:00
|
|
|
add_test(NAME suite0 COMMAND ${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/test/suite0.dst
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
add_test(NAME suite1 COMMAND ${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/test/suite1.dst
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
2018-01-29 20:46:26 +00:00
|
|
|
|
|
|
|
# Add convenience script to run repl
|
|
|
|
add_custom_target(run
|
|
|
|
COMMAND ${TARGET_NAME}
|
|
|
|
DEPENDS ${TARGET_NAME}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
|
|
|
)
|