diff --git a/CMakeLists.txt b/CMakeLists.txt index 3aaac74e5..c340ec2c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,7 @@ project(meevax DESCRIPTION "A programmable programming language" LANGUAGES CXX VERSION ${CURRENT_VERSION}) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) -set(CMAKE_VERBOSE_MAKEFILE OFF) +include(GNUInstallDirs) string(JOIN " " AGGRESSIVE_OPTIMIZATION_OPTIONS # "-flto" # This optimization causes a SEGV when compiling with Clang 10. @@ -23,17 +19,18 @@ string(JOIN " " AGGRESSIVE_OPTIMIZATION_OPTIONS # "-mtune=native" ) -# NOTE: The `-gdwarf-4` option is set due to the following issues with Clang 14 and Valgrind versions below 3.20: https://bugzilla.mozilla.org/show_bug.cgi?id=1758782 -set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe") -set(CMAKE_CXX_FLAGS_DEBUG "-Og -gdwarf-4") +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_FLAGS_DEBUG "-Og -gdwarf-4") # NOTE: The `-gdwarf-4` option is set due to the following issues with Clang 14 and Valgrind versions below 3.20: https://bugzilla.mozilla.org/show_bug.cgi?id=1758782 set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gdwarf-4 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${AGGRESSIVE_OPTIMIZATION_OPTIONS}") - -include(GNUInstallDirs) - +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gdwarf-4 -DNDEBUG") +set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe") +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) +set(CMAKE_VERBOSE_MAKEFILE OFF) # ---- Configure --------------------------------------------------------------- @@ -63,12 +60,6 @@ file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/unicode/upcase.hp string(TOLOWER ${CMAKE_SYSTEM_NAME} ${PROJECT_NAME}_SYSTEM_NAME) -file(GLOB ${PROJECT_NAME}_BASIS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/basis/*.ss) -foreach(EACH IN LISTS ${PROJECT_NAME}_BASIS_SOURCES) - get_filename_component(FILENAME ${EACH} NAME) - file(READ ${EACH} ${PROJECT_NAME}_BASIS_${FILENAME}) -endforeach() - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/README.md ${CMAKE_CURRENT_SOURCE_DIR}/README.md) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/version.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/version.cpp) @@ -94,24 +85,30 @@ set_target_properties(kernel PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename lib SOVERSION ${PROJECT_VERSION_MAJOR} LINK_FLAGS_RELEASE -s) -# ---- Target basis ------------------------------------------------------------ +# ---- Target format ----------------------------------------------------------- + +add_executable(format) -add_library(basis INTERFACE) +target_sources(format PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/format.cpp) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/configure/basis.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/include/meevax/basis/scheme.hpp) +target_link_libraries(format PRIVATE kernel) -target_include_directories(basis INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) +# ---- Target basis ------------------------------------------------------------ + +add_custom_target(basis + DEPENDS format + COMMAND ${CMAKE_COMMAND} -DREPOSITORY_ROOT=${CMAKE_CURRENT_SOURCE_DIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/basis/configure.cmake) # ---- Target shell ------------------------------------------------------------ add_executable(shell) +add_dependencies(shell basis) + target_sources(shell PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp) -target_link_libraries(shell PRIVATE kernel - PRIVATE basis) +target_link_libraries(shell PRIVATE kernel) set_target_properties(shell PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename shell => meevax LINK_FLAGS_RELEASE -s) @@ -189,8 +186,7 @@ file(GLOB ${PROJECT_NAME}_TEST_CPP ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp) foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_CPP) get_filename_component(FILENAME ${EACH} NAME_WE) add_executable(assert-${FILENAME} ${EACH}) - target_link_libraries(assert-${FILENAME} PRIVATE kernel - PRIVATE basis) + target_link_libraries(assert-${FILENAME} PRIVATE kernel) add_test(NAME assert-${FILENAME} COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND} ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND_OPTIONS} diff --git a/README.md b/README.md index 1cb0b873c..64c4b960a 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Subset of R7RS-small. cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.4.815_amd64.deb +sudo apt install build/meevax_0.4.816_amd64.deb ``` or @@ -106,9 +106,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.4.815.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.4.816.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.4.815_amd64.deb` +| `package` | Generate debian package `meevax_0.4.816_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index a344e6c88..009b7f9f0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.815 +0.4.816 diff --git a/basis/configure.cmake b/basis/configure.cmake new file mode 100644 index 000000000..379723940 --- /dev/null +++ b/basis/configure.cmake @@ -0,0 +1,12 @@ +file(GLOB ${PROJECT_NAME}_BASIS_SOURCES ${REPOSITORY_ROOT}/basis/*.ss) + +foreach(EACH IN LISTS ${PROJECT_NAME}_BASIS_SOURCES) + get_filename_component(FILENAME ${EACH} NAME) + execute_process( + COMMAND ${REPOSITORY_ROOT}/build/bin/format ${EACH} + OUTPUT_VARIABLE CONFIGURED_${FILENAME}) +endforeach() + +configure_file( + ${REPOSITORY_ROOT}/configure/basis.hpp + ${REPOSITORY_ROOT}/include/meevax/basis/scheme.hpp) diff --git a/configure/basis.hpp b/configure/basis.hpp index 044a00097..45f978ffe 100644 --- a/configure/basis.hpp +++ b/configure/basis.hpp @@ -32,29 +32,29 @@ inline namespace kernel constexpr auto basis() { return make_array( - R"##(${${PROJECT_NAME}_BASIS_meevax.ss})##", - R"##(${${PROJECT_NAME}_BASIS_r4rs-essential.ss})##", - R"##(${${PROJECT_NAME}_BASIS_r4rs.ss})##", - R"##(${${PROJECT_NAME}_BASIS_r5rs.ss})##", - R"##(${${PROJECT_NAME}_BASIS_r7rs.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-0.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-1.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-4.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-6.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-8.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-9.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-11.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-16.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-23.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-31.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-34.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-38.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-39.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-45.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-78.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-98.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-111.ss})##", - R"##(${${PROJECT_NAME}_BASIS_srfi-149.ss})##"); + R"##(${CONFIGURED_meevax.ss})##", + R"##(${CONFIGURED_r4rs-essential.ss})##", + R"##(${CONFIGURED_r4rs.ss})##", + R"##(${CONFIGURED_r5rs.ss})##", + R"##(${CONFIGURED_r7rs.ss})##", + R"##(${CONFIGURED_srfi-0.ss})##", + R"##(${CONFIGURED_srfi-1.ss})##", + R"##(${CONFIGURED_srfi-4.ss})##", + R"##(${CONFIGURED_srfi-6.ss})##", + R"##(${CONFIGURED_srfi-8.ss})##", + R"##(${CONFIGURED_srfi-9.ss})##", + R"##(${CONFIGURED_srfi-11.ss})##", + R"##(${CONFIGURED_srfi-16.ss})##", + R"##(${CONFIGURED_srfi-23.ss})##", + R"##(${CONFIGURED_srfi-31.ss})##", + R"##(${CONFIGURED_srfi-34.ss})##", + R"##(${CONFIGURED_srfi-38.ss})##", + R"##(${CONFIGURED_srfi-39.ss})##", + R"##(${CONFIGURED_srfi-45.ss})##", + R"##(${CONFIGURED_srfi-78.ss})##", + R"##(${CONFIGURED_srfi-98.ss})##", + R"##(${CONFIGURED_srfi-111.ss})##", + R"##(${CONFIGURED_srfi-149.ss})##"); } } // namespace kernel } // namespace meevax diff --git a/src/format.cpp b/src/format.cpp new file mode 100644 index 000000000..583dcf8f6 --- /dev/null +++ b/src/format.cpp @@ -0,0 +1,29 @@ +/* + Copyright 2018-2023 Tatsuya Yamasaki. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +auto main(int const, char const* const* const argv) -> int +{ + using namespace meevax; + + for (let const& x : input_file_port(argv[1])) + { + std::cout << x << std::flush; + } + + return EXIT_SUCCESS; +}