Meta: Move main to example target, better include compatibility
This commit is contained in:
+41
-37
@@ -11,6 +11,7 @@ endif()
|
||||
# Options
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||
option(BLAZE_BUILD_EXAMPLES "Build the Blaze example programs" ${BLAZE_STANDALONE})
|
||||
option(BLAZE_BUILD_TESTS "Build the Blaze test programs" ${BLAZE_STANDALONE})
|
||||
|
||||
# ------------------------------------------
|
||||
|
||||
@@ -55,18 +56,19 @@ endif()
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# ------------------------------------------
|
||||
# Library
|
||||
# Dependencies
|
||||
|
||||
add_subdirectory("vendor/ruc")
|
||||
|
||||
# ------------------------------------------
|
||||
# Application target
|
||||
# Library target
|
||||
|
||||
# Define source files
|
||||
file(GLOB_RECURSE PROJECT_SOURCES "src/*.cpp")
|
||||
file(GLOB_RECURSE LIBRARY_SOURCES "src/*.cpp")
|
||||
|
||||
add_executable(${PROJECT} ${PROJECT_SOURCES})
|
||||
target_include_directories(${PROJECT} PRIVATE "src")
|
||||
add_library(${PROJECT} ${LIBRARY_SOURCES})
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
"src")
|
||||
target_link_libraries(${PROJECT} readline ruc)
|
||||
|
||||
# ------------------------------------------
|
||||
@@ -78,53 +80,55 @@ add_custom_target(${PROJECT}-lisp
|
||||
add_dependencies(${PROJECT} ${PROJECT}-lisp)
|
||||
|
||||
# ------------------------------------------
|
||||
# Execute target
|
||||
# Example target
|
||||
|
||||
add_custom_target(run
|
||||
COMMAND ${PROJECT} -c
|
||||
DEPENDS ${PROJECT})
|
||||
if (BLAZE_BUILD_EXAMPLES)
|
||||
add_subdirectory("example")
|
||||
endif()
|
||||
|
||||
# ------------------------------------------
|
||||
# Test targets
|
||||
|
||||
function(make_test_target target_name step_name)
|
||||
if (BLAZE_BUILD_TESTS)
|
||||
function(make_test_target target_name step_name)
|
||||
add_custom_target(${target_name}
|
||||
COMMAND ../vendor/mal/runtest.py --deferrable --optional ../tests/${step_name}.mal -- ./${PROJECT})
|
||||
add_dependencies(${target_name} ${PROJECT})
|
||||
endfunction()
|
||||
endfunction()
|
||||
|
||||
make_test_target("test0" "step0_repl")
|
||||
make_test_target("test1" "step1_read_print")
|
||||
make_test_target("test2" "step2_eval")
|
||||
make_test_target("test3" "step3_env")
|
||||
make_test_target("test4" "step4_if_fn_do")
|
||||
make_test_target("test5" "step5_tco")
|
||||
make_test_target("test6" "step6_file")
|
||||
make_test_target("test7" "step7_quote")
|
||||
make_test_target("test8" "step8_macros")
|
||||
make_test_target("test9" "step9_try")
|
||||
make_test_target("testA" "stepA_mal")
|
||||
make_test_target("test0" "step0_repl")
|
||||
make_test_target("test1" "step1_read_print")
|
||||
make_test_target("test2" "step2_eval")
|
||||
make_test_target("test3" "step3_env")
|
||||
make_test_target("test4" "step4_if_fn_do")
|
||||
make_test_target("test5" "step5_tco")
|
||||
make_test_target("test6" "step6_file")
|
||||
make_test_target("test7" "step7_quote")
|
||||
make_test_target("test8" "step8_macros")
|
||||
make_test_target("test9" "step9_try")
|
||||
make_test_target("testA" "stepA_mal")
|
||||
|
||||
function(make_host_test_target target_name step_name)
|
||||
function(make_host_test_target target_name step_name)
|
||||
add_custom_target(${target_name}
|
||||
COMMAND ../vendor/mal/runtest.py --deferrable --optional ../tests/${step_name}.mal -- ./${PROJECT} ../mal/${step_name}.mal)
|
||||
add_dependencies(${target_name} ${PROJECT})
|
||||
endfunction()
|
||||
endfunction()
|
||||
|
||||
make_host_test_target("host_test0" "step0_repl")
|
||||
make_host_test_target("host_test1" "step1_read_print")
|
||||
make_host_test_target("host_test2" "step2_eval")
|
||||
make_host_test_target("host_test3" "step3_env")
|
||||
make_host_test_target("host_test4" "step4_if_fn_do")
|
||||
# make_host_test_target("host_test5" "step5_tco") # disabled
|
||||
make_host_test_target("host_test6" "step6_file")
|
||||
make_host_test_target("host_test7" "step7_quote")
|
||||
make_host_test_target("host_test8" "step8_macros")
|
||||
make_host_test_target("host_test9" "step9_try")
|
||||
make_host_test_target("host_testA" "stepA_mal")
|
||||
make_host_test_target("host_test0" "step0_repl")
|
||||
make_host_test_target("host_test1" "step1_read_print")
|
||||
make_host_test_target("host_test2" "step2_eval")
|
||||
make_host_test_target("host_test3" "step3_env")
|
||||
make_host_test_target("host_test4" "step4_if_fn_do")
|
||||
# make_host_test_target("host_test5" "step5_tco") # disabled
|
||||
make_host_test_target("host_test6" "step6_file")
|
||||
make_host_test_target("host_test7" "step7_quote")
|
||||
make_host_test_target("host_test8" "step8_macros")
|
||||
make_host_test_target("host_test9" "step9_try")
|
||||
make_host_test_target("host_testA" "stepA_mal")
|
||||
|
||||
add_custom_target(perf
|
||||
add_custom_target(perf
|
||||
COMMAND ./${PROJECT} ../tests/perf1.mal
|
||||
COMMAND ./${PROJECT} ../tests/perf2.mal
|
||||
COMMAND ./${PROJECT} ../tests/perf3.mal)
|
||||
add_dependencies(perf ${PROJECT})
|
||||
add_dependencies(perf ${PROJECT})
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# ------------------------------------------
|
||||
# User config between these lines
|
||||
|
||||
# Set project name
|
||||
set(EXAMPLE "repl")
|
||||
|
||||
# ------------------------------------------
|
||||
|
||||
project(${EXAMPLE} CXX)
|
||||
|
||||
# Define game source files
|
||||
file(GLOB_RECURSE EXAMPLE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
||||
|
||||
add_executable(${EXAMPLE} ${EXAMPLE_SOURCES})
|
||||
target_include_directories(${EXAMPLE} PRIVATE
|
||||
"src")
|
||||
target_link_libraries(${EXAMPLE} ${PROJECT})
|
||||
|
||||
# ------------------------------------------
|
||||
|
||||
# Add 'make run' target
|
||||
add_custom_target(run
|
||||
COMMAND ${EXAMPLE} -c
|
||||
DEPENDS ${PROJECT}
|
||||
WORKING_DIRECTORY "..")
|
||||
@@ -13,11 +13,11 @@
|
||||
#include "ruc/format/color.h"
|
||||
#include "ruc/format/print.h"
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/environment.h"
|
||||
#include "forward.h"
|
||||
#include "repl.h"
|
||||
#include "settings.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/environment.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/repl.h"
|
||||
#include "blaze/settings.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#include <utility> // std::move
|
||||
#include <vector>
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/environment.h"
|
||||
#include "error.h"
|
||||
#include "forward.h"
|
||||
#include "printer.h"
|
||||
#include "types.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/environment.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/printer.h"
|
||||
#include "blaze/types.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "ruc/format/formatter.h"
|
||||
|
||||
#include "forward.h"
|
||||
#include "blaze/forward.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
+5
-5
@@ -11,11 +11,11 @@
|
||||
#include "ruc/file.h"
|
||||
#include "ruc/format/format.h"
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/environment.h"
|
||||
#include "error.h"
|
||||
#include "forward.h"
|
||||
#include "repl.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/environment.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/repl.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "ast.h"
|
||||
#include "forward.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/forward.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
+4
-4
@@ -7,10 +7,10 @@
|
||||
#include <cstddef> // size_t
|
||||
#include <memory> // std:static_pointer_cast
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "forward.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
Vendored
+4
-4
@@ -7,10 +7,10 @@
|
||||
#include <cstddef> // size_t
|
||||
#include <memory> // std:static_pointer_cast
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "forward.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
+6
-6
@@ -8,12 +8,12 @@
|
||||
#include <cstddef> // size_t
|
||||
#include <memory> // std::static_pointer_cast
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/environment.h"
|
||||
#include "env/macro.h"
|
||||
#include "forward.h"
|
||||
#include "repl.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/environment.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/repl.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <functional> // std::function
|
||||
#include <memory> // std::static_pointer_cast
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <memory>
|
||||
#include <system_error> // std::errc
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
#include <iterator> // std::next
|
||||
#include <string>
|
||||
|
||||
#include "reader.h"
|
||||
#include "ruc/format/print.h"
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "printer.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/printer.h"
|
||||
#include "blaze/reader.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "error.h"
|
||||
#include "forward.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
#include <algorithm> // std::copy
|
||||
#include <memory> // std::static_pointer_cast
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/environment.h"
|
||||
#include "env/macro.h"
|
||||
#include "forward.h"
|
||||
#include "repl.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/environment.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/repl.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <cstdint> // int64_t
|
||||
#include <memory> // std::static_pointer_cast
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include <chrono> // std::chrono::sytem_clock
|
||||
#include <cstdint> // int64_t
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "error.h"
|
||||
#include "forward.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
#include "ruc/file.h"
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/macro.h"
|
||||
#include "repl.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/macro.h"
|
||||
#include "blaze/repl.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
+3
-1
@@ -4,9 +4,11 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "env/environment.h"
|
||||
#include "blaze/env/environment.h"
|
||||
|
||||
#define ADD_FUNCTION(name, signature, documentation, lambda) \
|
||||
Environment::registerFunction( \
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
#include "ruc/singleton.h"
|
||||
|
||||
#include "forward.h"
|
||||
#include "lexer.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/lexer.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -16,16 +16,16 @@
|
||||
#include "ruc/format/format.h"
|
||||
#include "ruc/format/print.h"
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/environment.h"
|
||||
#include "error.h"
|
||||
#include "eval.h"
|
||||
#include "forward.h"
|
||||
#include "macro.h"
|
||||
#include "printer.h"
|
||||
#include "settings.h"
|
||||
#include "types.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/environment.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/eval.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/macro.h"
|
||||
#include "blaze/printer.h"
|
||||
#include "blaze/settings.h"
|
||||
#include "blaze/types.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#include <span> // std::span
|
||||
#include <string>
|
||||
|
||||
#include "ast.h"
|
||||
#include "env/environment.h"
|
||||
#include "error.h"
|
||||
#include "eval.h"
|
||||
#include "forward.h"
|
||||
#include "types.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/env/environment.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/eval.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/types.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "forward.h" // EnvironmentPtr
|
||||
#include "blaze/forward.h" // EnvironmentPtr
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "ruc/format/print.h"
|
||||
#include "ruc/genericlexer.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "lexer.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/lexer.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "eval.h"
|
||||
#pragma once
|
||||
|
||||
#include "blaze/eval.h"
|
||||
|
||||
#define CONCAT(a, b) CONCAT_IMPL(a, b)
|
||||
#define CONCAT_IMPL(a, b) a##b
|
||||
@@ -11,13 +11,13 @@
|
||||
#include "ruc/format/color.h"
|
||||
#include "ruc/format/format.h"
|
||||
|
||||
#include "ast.h"
|
||||
#include "error.h"
|
||||
#include "lexer.h"
|
||||
#include "printer.h"
|
||||
#include "settings.h"
|
||||
#include "types.h"
|
||||
#include "util.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/lexer.h"
|
||||
#include "blaze/printer.h"
|
||||
#include "blaze/settings.h"
|
||||
#include "blaze/types.h"
|
||||
#include "blaze/util.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ast.h"
|
||||
#include <string>
|
||||
|
||||
#include "blaze/ast.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
// Serializer -> return to string
|
||||
@@ -12,14 +12,14 @@
|
||||
#include <system_error> // std::errc
|
||||
#include <utility> // std::move
|
||||
|
||||
#include "error.h"
|
||||
#include "ruc/format/color.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "ast.h"
|
||||
#include "reader.h"
|
||||
#include "settings.h"
|
||||
#include "types.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/reader.h"
|
||||
#include "blaze/settings.h"
|
||||
#include "blaze/types.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <memory> // std::shared_ptr
|
||||
#include <vector>
|
||||
|
||||
#include "ast.h"
|
||||
#include "lexer.h"
|
||||
#include "blaze/ast.h"
|
||||
#include "blaze/lexer.h"
|
||||
|
||||
#define INDENTATION_WIDTH 2
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "ruc/format/color.h"
|
||||
#include "ruc/format/print.h"
|
||||
|
||||
#include "readline.h"
|
||||
#include "blaze/readline.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
|
||||
#include "ruc/format/print.h"
|
||||
|
||||
#include "env/environment.h"
|
||||
#include "error.h"
|
||||
#include "eval.h"
|
||||
#include "forward.h"
|
||||
#include "lexer.h"
|
||||
#include "printer.h"
|
||||
#include "reader.h"
|
||||
#include "readline.h"
|
||||
#include "repl.h"
|
||||
#include "settings.h"
|
||||
#include "blaze/env/environment.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/eval.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/lexer.h"
|
||||
#include "blaze/printer.h"
|
||||
#include "blaze/reader.h"
|
||||
#include "blaze/readline.h"
|
||||
#include "blaze/repl.h"
|
||||
#include "blaze/settings.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "forward.h"
|
||||
#include "readline.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/readline.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "env/environment.h"
|
||||
#include "forward.h"
|
||||
#include "settings.h"
|
||||
#include "types.h"
|
||||
#include "blaze/env/environment.h"
|
||||
#include "blaze/forward.h"
|
||||
#include "blaze/settings.h"
|
||||
#include "blaze/types.h"
|
||||
|
||||
namespace blaze {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "error.h"
|
||||
#include "types.h"
|
||||
#include "blaze/error.h"
|
||||
#include "blaze/types.h"
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user