From 6fa8038a89f6cc3de31a457e419788ad849a0819 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 1 Sep 2024 02:03:52 +0900 Subject: [PATCH 01/19] Update `execute_process` to avoid non-portable command usage --- CMakeLists.txt | 8 ++++++-- README.md | 6 +++--- VERSION | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e92ccc68..c46ed21c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.16.3) # Ubuntu 20.04 LTS default execute_process( - COMMAND head -c -1 ${CMAKE_CURRENT_SOURCE_DIR}/VERSION + COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/VERSION + COMMAND tr -d \n OUTPUT_VARIABLE CURRENT_VERSION) project(meevax @@ -49,7 +50,10 @@ execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/script/unicode.sh --property execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/script/unicode.sh --upcase OUTPUT_VARIABLE ${PROJECT_NAME}_UNICODE_UPCASE) execute_process( - COMMAND head -c -1 ${CMAKE_CURRENT_SOURCE_DIR}/configure/help.txt + COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/configure/help.txt + COMMAND tr \n \r + COMMAND sed s/\r$// + COMMAND tr \r \n OUTPUT_VARIABLE ${PROJECT_NAME}_HELP) file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/unicode/digit_value.hpp "${${PROJECT_NAME}_UNICODE_DIGIT_VALUE}") diff --git a/README.md b/README.md index f8511be79..d82a05521 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.225_amd64.deb +sudo apt install build/meevax_0.5.226_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.225.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.226.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.225_amd64.deb` +| `package` | Generate debian package `meevax_0.5.226_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 0f788f401..d83bd7a3c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.225 +0.5.226 From 8cbfba655d3e6399d245c63e598492aa53989f56 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 1 Sep 2024 02:20:56 +0900 Subject: [PATCH 02/19] Delete branch using predefined macro `__unix__` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/memory/collector.hpp | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d82a05521..56d7c4227 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.226_amd64.deb +sudo apt install build/meevax_0.5.227_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.226.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.227.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.226_amd64.deb` +| `package` | Generate debian package `meevax_0.5.227_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index d83bd7a3c..8098e54cc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.226 +0.5.227 diff --git a/include/meevax/memory/collector.hpp b/include/meevax/memory/collector.hpp index 370bf8448..68db795c9 100644 --- a/include/meevax/memory/collector.hpp +++ b/include/meevax/memory/collector.hpp @@ -17,11 +17,7 @@ #ifndef INCLUDED_MEEVAX_MEMORY_COLLECTOR_HPP #define INCLUDED_MEEVAX_MEMORY_COLLECTOR_HPP -#if __unix__ #include // dlopen, dlclose, dlerror -#else -#error -#endif #include // std::allocator #include From 0065de041a944cb8db84977d48f40084e934d8fb Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 1 Sep 2024 02:35:38 +0900 Subject: [PATCH 03/19] Update to not use unsigned long to obtain 64-bit integer Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/memory/integer_set.hpp | 27 ++++++++++++++++----------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 56d7c4227..670026675 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.227_amd64.deb +sudo apt install build/meevax_0.5.228_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.227.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.228.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.227_amd64.deb` +| `package` | Generate debian package `meevax_0.5.228_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 8098e54cc..6e3ecf4f9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.227 +0.5.228 diff --git a/include/meevax/memory/integer_set.hpp b/include/meevax/memory/integer_set.hpp index a9f2a2e56..9e440faa4 100644 --- a/include/meevax/memory/integer_set.hpp +++ b/include/meevax/memory/integer_set.hpp @@ -33,6 +33,11 @@ inline namespace memory template constexpr auto compressible_bitwidth_of = std::is_pointer_v ? log2(alignof(std::remove_pointer_t)) - 1 : 0; + constexpr auto operator ""_u64(unsigned long long int value) + { + return static_cast(value); + } + template struct integer_set { @@ -277,9 +282,9 @@ inline namespace memory template struct integer_set { - static_assert(std::is_same_v); + static_assert(std::is_same_v); - static constexpr auto N = 1ul << E; + static constexpr auto N = 1_u64 << E; std::uint64_t data[N / 64] {}; @@ -303,10 +308,10 @@ inline namespace memory { if (auto i = index / 64; i < N/64) { - if (auto datum = data[i] & (~0ul << index % 64); datum) + if (auto datum = data[i] & (~0_u64 << index % 64); datum) { index = i * 64 + __builtin_ctzl(datum); - assert(data[index / 64] & (1ul << index % 64)); + assert(data[index / 64] & (1_u64 << index % 64)); return; } else while (++i < N/64) @@ -314,7 +319,7 @@ inline namespace memory if (auto datum = data[i]; datum) { index = i * 64 + __builtin_ctzl(datum); - assert(data[index / 64] & (1ul << index % 64)); + assert(data[index / 64] & (1_u64 << index % 64)); return; } } @@ -329,10 +334,10 @@ inline namespace memory { if (auto i = index / 64; i < N/64) { - if (auto datum = data[i] & (~0ul >> (63 - index % 64)); datum) + if (auto datum = data[i] & (~0_u64 >> (63 - index % 64)); datum) { index = i * 64 + (63 - __builtin_clzl(datum)); - assert(data[index / 64] & (1ul << index % 64)); + assert(data[index / 64] & (1_u64 << index % 64)); return; } else while (--i < N/64) @@ -340,7 +345,7 @@ inline namespace memory if (auto datum = data[i]; datum) { index = i * 64 + (63 - __builtin_clzl(datum)); - assert(data[index / 64] & (1ul << index % 64)); + assert(data[index / 64] & (1_u64 << index % 64)); return; } } @@ -418,21 +423,21 @@ inline namespace memory { auto i = reinterpret_cast(value) / 64; auto j = reinterpret_cast(value) % 64; - data[i] |= (1ul << j); + data[i] |= (1_u64 << j); } auto erase(T value) noexcept { auto i = reinterpret_cast(value) / 64; auto j = reinterpret_cast(value) % 64; - data[i] &= ~(1ul << j); + data[i] &= ~(1_u64 << j); } auto contains(T value) noexcept -> bool { auto i = reinterpret_cast(value) / 64; auto j = reinterpret_cast(value) % 64; - return data[i] & (1ul << j); + return data[i] & (1_u64 << j); } auto lower_bound(T value) const noexcept From 6179fbb8d7f42370bdd25c8a2750acee6041c68b Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 2 Sep 2024 01:47:04 +0900 Subject: [PATCH 04/19] Simplify struct `exact_integer` definition Signed-off-by: yamacir-kit --- CMakeLists.txt | 2 +- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/exact_integer.hpp | 112 +++++++++++------------ src/kernel/exact_integer.cpp | 116 ------------------------ 5 files changed, 61 insertions(+), 177 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c46ed21c9..8e1e02045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,7 +182,7 @@ enable_testing() find_program(${PROJECT_NAME}_MEMORY_CHECK_COMMAND valgrind) set(${PROJECT_NAME}_MEMORY_CHECK_OPTIONS - --error-exitcode=1 # = EXIT_FAILURE) + --error-exitcode=1 # = EXIT_FAILURE --leak-check=full --quiet --show-leak-kinds=all) diff --git a/README.md b/README.md index 670026675..dc89c7f1c 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.228_amd64.deb +sudo apt install build/meevax_0.5.229_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.228.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.229.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.228_amd64.deb` +| `package` | Generate debian package `meevax_0.5.229_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 6e3ecf4f9..06fbeca31 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.228 +0.5.229 diff --git a/include/meevax/kernel/exact_integer.hpp b/include/meevax/kernel/exact_integer.hpp index 3d2dff835..d56431ffa 100644 --- a/include/meevax/kernel/exact_integer.hpp +++ b/include/meevax/kernel/exact_integer.hpp @@ -39,23 +39,22 @@ inline namespace kernel explicit exact_integer(mpz_t const) noexcept; - explicit exact_integer(std::int8_t); - - explicit exact_integer(std::int16_t); - - explicit exact_integer(std::int32_t); - - explicit exact_integer(std::int64_t); - - explicit exact_integer(std::uint8_t); - - explicit exact_integer(std::uint16_t); - - explicit exact_integer(std::uint32_t); - - explicit exact_integer(std::uint64_t); - - explicit exact_integer(double); + template >> + explicit exact_integer(T x) + { + if constexpr (std::is_floating_point_v) + { + mpz_init_set_d(value, x); + } + else if constexpr (std::is_signed_v) + { + mpz_init_set_si(value, x); + } + else + { + mpz_init_set_ui(value, x); + } + } explicit exact_integer(std::string const&, int = 0); @@ -67,49 +66,50 @@ inline namespace kernel explicit operator bool() const; - operator std::int8_t() const; - - operator std::int16_t() const; - - operator std::int32_t() const; - - operator std::int64_t() const; - - operator std::uint8_t() const; - - operator std::uint16_t() const; - - operator std::uint32_t() const; - - operator std::uint64_t() const; - - explicit operator float() const; - - explicit operator double() const; + template >> + operator T() const + { + if constexpr (std::is_floating_point_v) + { + return mpz_get_d(value); + } + else if constexpr (std::is_signed_v) + { + return mpz_get_si(value); + } + else + { + return mpz_get_ui(value); + } + } auto square_root() const -> std::tuple; }; - auto operator ==(exact_integer const&, int const) -> bool; - auto operator !=(exact_integer const&, int const) -> bool; - auto operator < (exact_integer const&, int const) -> bool; - auto operator <=(exact_integer const&, int const) -> bool; - auto operator > (exact_integer const&, int const) -> bool; - auto operator >=(exact_integer const&, int const) -> bool; - - auto operator ==(exact_integer const&, signed long const) -> bool; - auto operator !=(exact_integer const&, signed long const) -> bool; - auto operator < (exact_integer const&, signed long const) -> bool; - auto operator <=(exact_integer const&, signed long const) -> bool; - auto operator > (exact_integer const&, signed long const) -> bool; - auto operator >=(exact_integer const&, signed long const) -> bool; - - auto operator ==(exact_integer const&, unsigned long const) -> bool; - auto operator !=(exact_integer const&, unsigned long const) -> bool; - auto operator < (exact_integer const&, unsigned long const) -> bool; - auto operator <=(exact_integer const&, unsigned long const) -> bool; - auto operator > (exact_integer const&, unsigned long const) -> bool; - auto operator >=(exact_integer const&, unsigned long const) -> bool; + #define DEFINE_COMPARISON_OPERATOR(SYMBOL) \ + template >> \ + auto operator SYMBOL(exact_integer const& a, T b) \ + { \ + if constexpr (std::is_floating_point_v) \ + { \ + return mpz_cmp_d(a.value, b) SYMBOL 0; \ + } \ + else if constexpr (std::is_signed_v) \ + { \ + return mpz_cmp_si(a.value, b) SYMBOL 0; \ + } \ + else \ + { \ + return mpz_cmp_ui(a.value, b) SYMBOL 0; \ + } \ + } static_assert(true) + + DEFINE_COMPARISON_OPERATOR(==); + DEFINE_COMPARISON_OPERATOR(!=); + DEFINE_COMPARISON_OPERATOR(< ); + DEFINE_COMPARISON_OPERATOR(<=); + DEFINE_COMPARISON_OPERATOR(> ); + DEFINE_COMPARISON_OPERATOR(>=); auto operator <<(std::ostream &, exact_integer const&) -> std::ostream &; diff --git a/src/kernel/exact_integer.cpp b/src/kernel/exact_integer.cpp index 3c498d050..527f8084e 100644 --- a/src/kernel/exact_integer.cpp +++ b/src/kernel/exact_integer.cpp @@ -53,51 +53,6 @@ inline namespace kernel mpz_init_set(value, z); } - exact_integer::exact_integer(std::int8_t si) - { - mpz_init_set_si(value, si); - } - - exact_integer::exact_integer(std::int16_t si) - { - mpz_init_set_si(value, si); - } - - exact_integer::exact_integer(std::int32_t si) - { - mpz_init_set_si(value, si); - } - - exact_integer::exact_integer(std::int64_t si) - { - mpz_init_set_si(value, si); - } - - exact_integer::exact_integer(std::uint8_t ui) - { - mpz_init_set_ui(value, ui); - } - - exact_integer::exact_integer(std::uint16_t ui) - { - mpz_init_set_ui(value, ui); - } - - exact_integer::exact_integer(std::uint32_t ui) - { - mpz_init_set_ui(value, ui); - } - - exact_integer::exact_integer(std::uint64_t ui) - { - mpz_init_set_ui(value, ui); - } - - exact_integer::exact_integer(double d) - { - mpz_init_set_d(value, d); - } - exact_integer::exact_integer(std::string const& s, int radix) { if (mpz_init_set_str(value, (s.at(0) == '+' ? s.substr(1) : s).c_str(), radix)) @@ -136,56 +91,6 @@ inline namespace kernel return (*value)._mp_size; } - exact_integer::operator std::int8_t() const - { - return mpz_get_si(value); - } - - exact_integer::operator std::int16_t() const - { - return mpz_get_si(value); - } - - exact_integer::operator std::int32_t() const - { - return mpz_get_si(value); - } - - exact_integer::operator std::int64_t() const - { - return mpz_get_si(value); - } - - exact_integer::operator std::uint8_t() const - { - return mpz_get_ui(value); - } - - exact_integer::operator std::uint16_t() const - { - return mpz_get_ui(value); - } - - exact_integer::operator std::uint32_t() const - { - return mpz_get_ui(value); - } - - exact_integer::operator std::uint64_t() const - { - return mpz_get_ui(value); - } - - exact_integer::operator float() const - { - return mpz_get_d(value); - } - - exact_integer::operator double() const - { - return mpz_get_d(value); - } - auto exact_integer::square_root() const -> std::tuple { exact_integer s, r; @@ -193,27 +98,6 @@ inline namespace kernel return std::make_tuple(s, r); } - auto operator ==(exact_integer const& a, int const b) -> bool { return a == static_cast(b); } - auto operator !=(exact_integer const& a, int const b) -> bool { return a != static_cast(b); } - auto operator < (exact_integer const& a, int const b) -> bool { return a < static_cast(b); } - auto operator <=(exact_integer const& a, int const b) -> bool { return a <= static_cast(b); } - auto operator > (exact_integer const& a, int const b) -> bool { return a > static_cast(b); } - auto operator >=(exact_integer const& a, int const b) -> bool { return a >= static_cast(b); } - - auto operator ==(exact_integer const& a, signed long const b) -> bool { return mpz_cmp_si(a.value, b) == 0; } - auto operator !=(exact_integer const& a, signed long const b) -> bool { return mpz_cmp_si(a.value, b) != 0; } - auto operator < (exact_integer const& a, signed long const b) -> bool { return mpz_cmp_si(a.value, b) < 0; } - auto operator <=(exact_integer const& a, signed long const b) -> bool { return mpz_cmp_si(a.value, b) <= 0; } - auto operator > (exact_integer const& a, signed long const b) -> bool { return mpz_cmp_si(a.value, b) > 0; } - auto operator >=(exact_integer const& a, signed long const b) -> bool { return mpz_cmp_si(a.value, b) >= 0; } - - auto operator ==(exact_integer const& a, unsigned long const b) -> bool { return mpz_cmp_ui(a.value, b) == 0; } - auto operator !=(exact_integer const& a, unsigned long const b) -> bool { return mpz_cmp_ui(a.value, b) != 0; } - auto operator < (exact_integer const& a, unsigned long const b) -> bool { return mpz_cmp_ui(a.value, b) < 0; } - auto operator <=(exact_integer const& a, unsigned long const b) -> bool { return mpz_cmp_ui(a.value, b) <= 0; } - auto operator > (exact_integer const& a, unsigned long const b) -> bool { return mpz_cmp_ui(a.value, b) > 0; } - auto operator >=(exact_integer const& a, unsigned long const b) -> bool { return mpz_cmp_ui(a.value, b) >= 0; } - auto operator <<(std::ostream & os, exact_integer const& datum) -> std::ostream & { return os << cyan(std::unique_ptr(mpz_get_str(nullptr, 10, datum.value)).get()); From 0264b68a0990f3a2d5a7d1b9036fdf233f7dee3e Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 2 Sep 2024 02:12:59 +0900 Subject: [PATCH 05/19] Fix some Linux-dependent code Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/library.hpp | 6 ++---- include/meevax/memory/allocator.hpp | 2 +- src/kernel/boot.cpp | 2 ++ 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index dc89c7f1c..58f19493e 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.229_amd64.deb +sudo apt install build/meevax_0.5.230_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.229.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.230.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.229_amd64.deb` +| `package` | Generate debian package `meevax_0.5.230_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 06fbeca31..dcdaa52a4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.229 +0.5.230 diff --git a/include/meevax/kernel/library.hpp b/include/meevax/kernel/library.hpp index 3721f4fb2..661e1285c 100644 --- a/include/meevax/kernel/library.hpp +++ b/include/meevax/kernel/library.hpp @@ -17,6 +17,8 @@ #ifndef INCLUDED_MEEVAX_KERNEL_LIBRARY_HPP #define INCLUDED_MEEVAX_KERNEL_LIBRARY_HPP +#include + #include #include @@ -60,10 +62,6 @@ inline namespace kernel auto operator <<(std::ostream &, library const&) -> std::ostream &; - /* - In order to improve the usability of the help procedure, it is desirable - to sort by library name in lexicographical order. - */ auto libraries() -> std::map &; template diff --git a/include/meevax/memory/allocator.hpp b/include/meevax/memory/allocator.hpp index cee480b6b..c69511e69 100644 --- a/include/meevax/memory/allocator.hpp +++ b/include/meevax/memory/allocator.hpp @@ -32,7 +32,7 @@ inline namespace memory template > class allocator { - struct alignas(T) chunk + struct chunk { chunk * tail; }; diff --git a/src/kernel/boot.cpp b/src/kernel/boot.cpp index 8f8ba9004..c0ecfcfaf 100644 --- a/src/kernel/boot.cpp +++ b/src/kernel/boot.cpp @@ -35,6 +35,8 @@ #include #include +extern char ** environ; // for procedure get-environment-variables + namespace meevax { inline namespace kernel From 7986c52153c10a0c3add2819f09d6a9d545a0dfa Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 5 Sep 2024 00:28:17 +0900 Subject: [PATCH 06/19] Update library serach path to include `/opt/homebrew` if on MacOS Signed-off-by: yamacir-kit --- CMakeLists.txt | 6 +++++- README.md | 6 +++--- VERSION | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e1e02045..676ed9711 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,11 @@ target_sources(kernel PRIVATE ${${PROJECT_NAME}_KERNEL_SOURCES}) target_include_directories(kernel PUBLIC $ - PUBLIC $) + PUBLIC $ + PUBLIC $<$:/opt/homebrew/include>) + +target_link_directories(kernel + PUBLIC $<$:/opt/homebrew/lib>) target_link_libraries(kernel PRIVATE ${CMAKE_DL_LIBS} diff --git a/README.md b/README.md index 58f19493e..26f1dd7ab 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.230_amd64.deb +sudo apt install build/meevax_0.5.231_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.230.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.231.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.230_amd64.deb` +| `package` | Generate debian package `meevax_0.5.231_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index dcdaa52a4..f7f7045dd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.230 +0.5.231 From 5b976773ad64fac09e15e11d40b2f20643be4667 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 5 Sep 2024 00:50:50 +0900 Subject: [PATCH 07/19] Update the test definition not to use Valgrind if on MacOS Signed-off-by: yamacir-kit --- CMakeLists.txt | 14 +++++++------- README.md | 6 +++--- VERSION | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 676ed9711..3c38085a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,13 +183,13 @@ include(CPack) enable_testing() -find_program(${PROJECT_NAME}_MEMORY_CHECK_COMMAND valgrind) - -set(${PROJECT_NAME}_MEMORY_CHECK_OPTIONS - --error-exitcode=1 # = EXIT_FAILURE - --leak-check=full - --quiet - --show-leak-kinds=all) +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + find_program(${PROJECT_NAME}_MEMORY_CHECK_COMMAND valgrind) + set(${PROJECT_NAME}_MEMORY_CHECK_OPTIONS --error-exitcode=1 --leak-check=full --quiet --show-leak-kinds=all) +else() + set(${PROJECT_NAME}_MEMORY_CHECK_COMMAND "") + set(${PROJECT_NAME}_MEMORY_CHECK_OPTIONS "") +endif() file(GLOB ${PROJECT_NAME}_TEST_SS ${CMAKE_CURRENT_SOURCE_DIR}/test/*.ss) diff --git a/README.md b/README.md index 26f1dd7ab..80ca21eb4 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.231_amd64.deb +sudo apt install build/meevax_0.5.232_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.231.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.232.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.231_amd64.deb` +| `package` | Generate debian package `meevax_0.5.232_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index f7f7045dd..20ea74ab7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.231 +0.5.232 From a43d713c1b277891ac38dc31a0413e63e5133f44 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 7 Sep 2024 23:36:50 +0900 Subject: [PATCH 08/19] Rename `setup.sh` to `setup-ubuntu.sh` Signed-off-by: yamacir-kit --- .github/workflows/build.yaml | 2 +- README.md | 6 +++--- VERSION | 2 +- script/setup-ubuntu-20.04.sh | 1 + script/setup-ubuntu-22.04.sh | 1 + script/{setup.sh => setup-ubuntu.sh} | 12 ++++++------ 6 files changed, 13 insertions(+), 11 deletions(-) create mode 120000 script/setup-ubuntu-20.04.sh create mode 120000 script/setup-ubuntu-22.04.sh rename script/{setup.sh => setup-ubuntu.sh} (81%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a871a603b..b92bc78ee 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,7 +17,7 @@ jobs: system: [ ubuntu-20.04, ubuntu-22.04 ] steps: - uses: actions/checkout@v3 - - run: ./script/setup.sh --all + - run: ./script/setup-${{ matrix.system }}.sh --all - run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} - run: cmake --build build --target develop - run: cmake -B example/build -S example -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} diff --git a/README.md b/README.md index 80ca21eb4..6f9bf08a1 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.232_amd64.deb +sudo apt install build/meevax_0.5.233_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.232.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.233.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.232_amd64.deb` +| `package` | Generate debian package `meevax_0.5.233_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 20ea74ab7..2c3ffcedb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.232 +0.5.233 diff --git a/script/setup-ubuntu-20.04.sh b/script/setup-ubuntu-20.04.sh new file mode 120000 index 000000000..3a2605f79 --- /dev/null +++ b/script/setup-ubuntu-20.04.sh @@ -0,0 +1 @@ +setup-ubuntu.sh \ No newline at end of file diff --git a/script/setup-ubuntu-22.04.sh b/script/setup-ubuntu-22.04.sh new file mode 120000 index 000000000..3a2605f79 --- /dev/null +++ b/script/setup-ubuntu-22.04.sh @@ -0,0 +1 @@ +setup-ubuntu.sh \ No newline at end of file diff --git a/script/setup.sh b/script/setup-ubuntu.sh similarity index 81% rename from script/setup.sh rename to script/setup-ubuntu.sh index ab0455a22..98a769696 100755 --- a/script/setup.sh +++ b/script/setup-ubuntu.sh @@ -8,18 +8,18 @@ required() optional() { - echo kcachegrind - echo massif-visualizer + echo kcachegrind # script/callgrind.sh + echo massif-visualizer # script/massif.sh echo valgrind } documentation() { - echo bibtex2html - echo doxygen - wget -q https://github.com/jgm/pandoc/releases/download/3.3/pandoc-3.3-1-amd64.deb -P /tmp - echo /tmp/pandoc-3.3-1-amd64.deb + + echo bibtex2html # script/references.sh + echo doxygen + echo /tmp/pandoc-3.3-1-amd64.deb # script/references.sh } sudo apt update From 7530c818578bbf31833406f8144be316d7b27171 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 8 Sep 2024 00:07:24 +0900 Subject: [PATCH 09/19] Add new script `setup-macos.sh` Signed-off-by: yamacir-kit --- .github/workflows/release.yaml | 2 +- README.md | 6 +++--- VERSION | 2 +- script/setup-macos-14.sh | 1 + script/setup-macos.sh | 35 ++++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) create mode 120000 script/setup-macos-14.sh create mode 100755 script/setup-macos.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 34a013e6a..b5f75c368 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v3 - run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV - - run: ./script/setup.sh + - run: ./script/setup-ubuntu.sh - run: cmake -B build -DCMAKE_BUILD_TYPE=Release - run: cmake --build build --target package - run: gh release create v${{ env.VERSION }} build/meevax_${{ env.VERSION }}_amd64.deb --title "Version ${{ env.VERSION }}" diff --git a/README.md b/README.md index 6f9bf08a1..dd6f554b2 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.233_amd64.deb +sudo apt install build/meevax_0.5.234_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.233.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.234.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.233_amd64.deb` +| `package` | Generate debian package `meevax_0.5.234_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 2c3ffcedb..0445208a8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.233 +0.5.234 diff --git a/script/setup-macos-14.sh b/script/setup-macos-14.sh new file mode 120000 index 000000000..93f928f11 --- /dev/null +++ b/script/setup-macos-14.sh @@ -0,0 +1 @@ +setup-macos.sh \ No newline at end of file diff --git a/script/setup-macos.sh b/script/setup-macos.sh new file mode 100755 index 000000000..f9a325a75 --- /dev/null +++ b/script/setup-macos.sh @@ -0,0 +1,35 @@ +#!/bin/sh -e + +required() +{ + echo gmp +} + +optional() +{ + echo gcc +} + +documentation() +{ + echo bibtex2html # script/references.sh + echo doxygen + echo pandoc # script/references.sh +} + +brew update + +if test "$#" -eq 0 +then + required | xargs brew install +else + for each in "$@" + do + case "$each" in + -a | --all ) ( required && optional && documentation ) | xargs brew install ;; + -d | --documentation ) ( documentation ) | xargs brew install ;; + -o | --optional ) ( optional ) | xargs brew install ;; + -r | --required ) ( required ) | xargs brew install ;; + esac + done +fi From d03e4873ea95722bd25698d190d1cb3319e676e4 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 8 Sep 2024 02:14:35 +0900 Subject: [PATCH 10/19] Add new OS `macos-14` to matrix `system` of workflow `build.yaml` Signed-off-by: yamacir-kit --- .github/workflows/build.yaml | 2 +- CMakeLists.txt | 41 +++++++++++++++++++++++------------- README.md | 6 +++--- VERSION | 2 +- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b92bc78ee..6eaa6182e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,7 +14,7 @@ jobs: matrix: compiler: [ g++, clang++ ] configuration: [ Debug, Release ] - system: [ ubuntu-20.04, ubuntu-22.04 ] + system: [ ubuntu-20.04, ubuntu-22.04, macos-14 ] steps: - uses: actions/checkout@v3 - run: ./script/setup-${{ matrix.system }}.sh --all diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c38085a3..2eb1dfa3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,13 +169,16 @@ install( # /usr/share/meevax/meevax-config-version.cmake # ---- Target package ---------------------------------------------------------- -set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Tatsuya Yamasaki") -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) -set(CPACK_GENERATOR DEB) -set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) -set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) -set(CPACK_THREADS 0) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Tatsuya Yamasaki") + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + set(CPACK_GENERATOR DEB) + set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) + set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) +else() + set(CPACK_GENERATOR productbuild) +endif() include(CPack) @@ -183,7 +186,7 @@ include(CPack) enable_testing() -if (CMAKE_SYSTEM_NAME STREQUAL "Linux") +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") find_program(${PROJECT_NAME}_MEMORY_CHECK_COMMAND valgrind) set(${PROJECT_NAME}_MEMORY_CHECK_OPTIONS --error-exitcode=1 --leak-check=full --quiet --show-leak-kinds=all) else() @@ -231,10 +234,18 @@ endforeach() # ---- Additional Targets ------------------------------------------------------ -execute_process(COMMAND nproc OUTPUT_VARIABLE ${PROJECT_NAME}_NPROC) - -add_custom_target(develop - COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NPROC} - COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NPROC} - COMMAND ${CMAKE_MAKE_PROGRAM} package - COMMAND sudo dpkg -i ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION}_amd64.deb) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + execute_process(COMMAND nproc OUTPUT_VARIABLE ${PROJECT_NAME}_NPROC) + add_custom_target(develop + COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NPROC} + COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NPROC} + COMMAND ${CMAKE_MAKE_PROGRAM} package + COMMAND sudo dpkg -i ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION}_amd64.deb) +else() + execute_process(COMMAND sysctl -n hw.ncpu OUTPUT_VARIABLE ${PROJECT_NAME}_NCPU) + add_custom_target(develop + COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NCPU} + COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NCPU} + COMMAND ${CMAKE_MAKE_PROGRAM} package + COMMAND sudo installer -pkg ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}-Darwin.pkg -target $ENV{HOME}) +endif() diff --git a/README.md b/README.md index dd6f554b2..d5e4fecf7 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.234_amd64.deb +sudo apt install build/meevax_0.5.235_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.234.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.235.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.234_amd64.deb` +| `package` | Generate debian package `meevax_0.5.235_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 0445208a8..4c3b86c1f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.234 +0.5.235 From c7cfed0f2604e0036d34c5b754bc07677652ab47 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 10 Sep 2024 00:24:12 +0900 Subject: [PATCH 11/19] Add `.DS_Store` to `.gitignore` Signed-off-by: yamacir-kit --- .gitignore | 1 + CMakeLists.txt | 3 ++- README.md | 6 +++--- VERSION | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index ce0ee6f47..41995e26c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store basis/src build document diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eb1dfa3e..33731bd99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) else() set(CPACK_GENERATOR productbuild) + set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION}) endif() include(CPack) @@ -247,5 +248,5 @@ else() COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NCPU} COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NCPU} COMMAND ${CMAKE_MAKE_PROGRAM} package - COMMAND sudo installer -pkg ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}-Darwin.pkg -target $ENV{HOME}) + COMMAND sudo installer -pkg ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.pkg -target $ENV{HOME}) endif() diff --git a/README.md b/README.md index d5e4fecf7..e8210a898 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.235_amd64.deb +sudo apt install build/meevax_0.5.236_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.235.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.236.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.235_amd64.deb` +| `package` | Generate debian package `meevax_0.5.236_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 4c3b86c1f..7bc1e009c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.235 +0.5.236 From 9b66afe3d73ff1568073ff9ac43f79b7107bf91a Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Fri, 13 Sep 2024 00:57:43 +0900 Subject: [PATCH 12/19] Remove the code that directly uses `dpkg` from `update.sh` Signed-off-by: yamacir-kit --- CMakeLists.txt | 3 ++- README.md | 6 +++--- VERSION | 2 +- script/update.sh | 5 ----- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33731bd99..cc3ed5b19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,5 +248,6 @@ else() COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NCPU} COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NCPU} COMMAND ${CMAKE_MAKE_PROGRAM} package - COMMAND sudo installer -pkg ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.pkg -target $ENV{HOME}) + # COMMAND sudo installer -pkg ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.pkg -target $ENV{HOME} + ) endif() diff --git a/README.md b/README.md index e8210a898..3a457d4c2 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.236_amd64.deb +sudo apt install build/meevax_0.5.237_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.236.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.237.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.236_amd64.deb` +| `package` | Generate debian package `meevax_0.5.237_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 7bc1e009c..3eaf9672b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.236 +0.5.237 diff --git a/script/update.sh b/script/update.sh index a1d92b6f3..680d487c5 100755 --- a/script/update.sh +++ b/script/update.sh @@ -13,11 +13,6 @@ build() echo "0.5.$(($(git rev-list --no-merges --count HEAD) - 3681))" > "$root/VERSION" -if dpkg --status meevax -then - sudo dpkg --purge meevax -fi - build "$root" "$@" build "$root/example" "$@" From bc719e758696b2ab9539f710c87246f4565d8f40 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 17 Sep 2024 21:50:46 +0900 Subject: [PATCH 13/19] Add support for numerical constants with exponent marker `f` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- src/kernel/boot.cpp | 10 +++ src/kernel/number.cpp | 40 +++++++++++- test/number.ss | 103 +++++++++++++++++++++++++++++++ test/numerical-operations.ss | 114 ----------------------------------- test/r7rs.ss | 2 +- 7 files changed, 155 insertions(+), 122 deletions(-) create mode 100644 test/number.ss delete mode 100644 test/numerical-operations.ss diff --git a/README.md b/README.md index 3a457d4c2..37f3593d1 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.237_amd64.deb +sudo apt install build/meevax_0.5.238_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.237.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.238.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.237_amd64.deb` +| `package` | Generate debian package `meevax_0.5.238_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 3eaf9672b..119d20e7e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.237 +0.5.238 diff --git a/src/kernel/boot.cpp b/src/kernel/boot.cpp index c0ecfcfaf..f75d4d572 100644 --- a/src/kernel/boot.cpp +++ b/src/kernel/boot.cpp @@ -431,6 +431,16 @@ inline namespace kernel define("(meevax inexact)", [](library & library) { + library.define("binary32?", [](let const& xs) + { + return std::numeric_limits::is_iec559 and car(xs).is(); + }); + + library.define("binary64?", [](let const& xs) + { + return std::numeric_limits::is_iec559 and car(xs).is(); + }); + library.define("finite?", [](let const& xs) { return is_finite(car(xs)); diff --git a/src/kernel/number.cpp b/src/kernel/number.cpp index ffd3f37f2..ee2474e60 100644 --- a/src/kernel/number.cpp +++ b/src/kernel/number.cpp @@ -464,15 +464,49 @@ inline namespace kernel { "fl-1/sqrt-2", M_SQRT1_2 }, }; - auto static const pattern = std::regex(R"(([+-]?(?:\d+\.?|\d*\.\d+))([DEFLSdefls][+-]?\d+)?)"); + auto static const pattern = std::regex(R"([+-]?(?:\d+\.?|\d*\.\d+)(?:([DEFdef])[+-]?\d+)?)"); if (auto iter = constants.find(literal); iter != constants.end()) { return make(iter->second); } - else if (std::regex_match(literal, pattern)) + else if (auto result = std::smatch(); std::regex_match(literal, result, pattern)) { - return make(lexical_cast(literal)); + /* + R7RS 6.2.5. Syntax of numerical constants + + In systems with inexact numbers of varying precisions it can be + useful to specify the precision of a constant. For this purpose, + implementations may accept numerical constants written with an + exponent marker that indicates the desired precision of the inexact + representation. If so, the letter s, f, d, or l, meaning short, + single, double, or long precision, respectively, can be used in + place of e. The default precision has at least as much precision as + double, but implementations may allow this default to be set by the + user. + */ + assert(result.ready()); + assert(result.size() == 2); + + if (result[1].matched) + { + assert(result[1].length() == 1); + + switch (*result[1].first) + { + case 'D': case 'd': + case 'E': case 'e': + default: + return make(std::stod(literal)); + + case 'F': case 'f': + return make(std::stof(literal.substr().replace(result.position(1), 1, "e"))); + } + } + else + { + return make(lexical_cast(literal)); + } } else { diff --git a/test/number.ss b/test/number.ss new file mode 100644 index 000000000..347ed06a3 --- /dev/null +++ b/test/number.ss @@ -0,0 +1,103 @@ +(import (scheme base) + (scheme inexact) + (scheme process-context) + (only (meevax inexact) binary32? binary64?) + (srfi 78)) + +(check (real? 1.0e0) => #t) +(check (binary32? 1.0e0) => #f) +(check (binary64? 1.0e0) => #t) + +(check (real? 1.0f0) => #t) +(check (binary32? 1.0f0) => #t) +(check (binary64? 1.0f0) => #f) + +(check (real? 1.0d0) => #t) +(check (binary32? 1.0d0) => #f) +(check (binary64? 1.0d0) => #t) + +(check (rational? 1/3) => #t) +(check (rational? 0.5) => #t) + +(check (+ 1 2 3) (=> =) 6) +(check (number? (+ 1 2 3)) => #t) +(check (complex? (+ 1 2 3)) => #t) +(check (real? (+ 1 2 3)) => #t) +(check (rational? (+ 1 2 3)) => #t) +(check (integer? (+ 1 2 3)) => #t) +(check (exact? (+ 1 2 3)) => #t) +(check (inexact? (+ 1 2 3)) => #f) + +(check (+ 1 1/2) (=> =) 3/2) +(check (number? (+ 1 1/2)) => #t) +(check (complex? (+ 1 1/2)) => #t) +(check (real? (+ 1 1/2)) => #t) +(check (rational? (+ 1 1/2)) => #t) +(check (integer? (+ 1 1/2)) => #f) +(check (exact? (+ 1 1/2)) => #t) +(check (inexact? (+ 1 1/2)) => #f) + +(check (* 2 1/2) (=> =) 1) +(check (number? (* 2 1/2)) => #t) +(check (complex? (* 2 1/2)) => #t) +(check (real? (* 2 1/2)) => #t) +(check (rational? (* 2 1/2)) => #t) +(check (integer? (* 2 1/2)) => #t) +(check (exact? (* 2 1/2)) => #t) +(check (inexact? (* 2 1/2)) => #f) + +(check (+ 1/3 1/3 1/3) (=> =) 1) +(check (number? (+ 1/3 1/3 1/3)) => #t) +(check (complex? (+ 1/3 1/3 1/3)) => #t) +(check (real? (+ 1/3 1/3 1/3)) => #t) +(check (rational? (+ 1/3 1/3 1/3)) => #t) +(check (integer? (+ 1/3 1/3 1/3)) => #t) +(check (exact? (+ 1/3 1/3 1/3)) => #t) +(check (inexact? (+ 1/3 1/3 1/3)) => #f) + +(check (+ 1 1.0) (=> =) 2.0) +(check (+ 1.0 1 ) (=> =) 2.0) + +(check (+ 1 1/2) (=> =) 3/2) +(check (+ 1.0 1/2) (=> =) 1.5) + +(check (+ 1/2 1 ) (=> =) 3/2) +(check (+ 1/2 1.0) (=> =) 1.5) + +(check (* 2 1/2) (=> =) 1 ) +(check (* 2.0 1/2) (=> =) 1.0) + +(check (modulo 13 4) => 1) +(check (modulo -13 4) => 3) +(check (modulo 13 -4) => -3) +(check (modulo -13 -4) => -1) + +(check (remainder 13 4) => 1) +(check (remainder -13 4) => -1) +(check (remainder 13 -4) => 1) +(check (remainder -13 -4) => -1) +(check (remainder -13 -4.0) => -1.0) ; inexact + +(check (log 0.0) => -inf.0) + +(check (sin 0) (=> =) 0) +(check (sin (/ fl-pi 6)) (=> =) 0.5) +; (check (sin (/ fl-pi 4)) (=> =) 0.707107) +; (check (sin (/ fl-pi 3)) (=> =) 0.866025) +(check (sin (/ fl-pi 2)) (=> =) 1) +; (check (sin fl-pi) (=> =) 0) + +(check (atan 0.0 1.0) => 0.000000) +; (check (atan 1.0 1.0) => 0.785398) +; (check (atan 1.0 0.0) => 1.570796) +; (check (atan 1.0 -1.0) => 2.356194) +; (check (atan 0.0 -1.0) => 3.141593) +; (check (atan -1.0 -1.0) => -2.356194) +; (check (atan -1.0 0.0) => -1.570796) +; (check (atan -1.0 1.0) => -0.785398) + +(check (exact 0.333333) => 3002396749180579/9007199254740992) + +(check-report) + +(exit (check-passed? 66)) diff --git a/test/numerical-operations.ss b/test/numerical-operations.ss deleted file mode 100644 index 4e5ae4dd9..000000000 --- a/test/numerical-operations.ss +++ /dev/null @@ -1,114 +0,0 @@ -(import (scheme base) - (scheme inexact) - (scheme process-context) - (srfi 78)) - -; ---- 6.2.6. Numerical operations --------------------------------------------- - -(check (rational? 1/3) => #t) -(check (rational? 0.5) => #t) - -(let ((x (+ 1 2 3))) - - (check x => 6) - - (check (number? x) => #t) - (check (complex? x) => #t) - (check (real? x) => #t) - (check (rational? x) => #t) - (check (integer? x) => #t) - - (check (exact? x) => #t) - (check (inexact? x) => #f) - ) - -(let ((x (+ 1 1/2))) - - (check x (=> =) 3/2) - - (check (number? x) => #t) - (check (complex? x) => #t) - (check (real? x) => #t) - (check (rational? x) => #t) - (check (integer? x) => #f) - - (check (exact? x) => #t) - (check (inexact? x) => #f) - ) - -(let ((x (* 2 1/2))) - - (check x (=> =) 1) - - (check (number? x) => #t) - (check (complex? x) => #t) - (check (real? x) => #t) - (check (rational? x) => #t) - (check (integer? x) => #t) - - (check (exact? x) => #t) - (check (inexact? x) => #f) - ) - -(let ((x (+ 1/3 1/3 1/3))) - - (check x (=> =) 1) - - (check (number? x) => #t) - (check (complex? x) => #t) - (check (real? x) => #t) - (check (rational? x) => #t) - (check (integer? x) => #t) - - (check (exact? x) => #t) - (check (inexact? x) => #f) - ) - -(check (+ 1 1.0) (=> =) 2.0) -(check (+ 1.0 1 ) (=> =) 2.0) - -(check (+ 1 1/2) (=> =) 3/2) -(check (+ 1.0 1/2) (=> =) 1.5) - -(check (+ 1/2 1 ) (=> =) 3/2) -(check (+ 1/2 1.0) (=> =) 1.5) - -(check (* 2 1/2) (=> =) 1 ) -(check (* 2.0 1/2) (=> =) 1.0) - -(check (modulo 13 4) => 1) -(check (modulo -13 4) => 3) -(check (modulo 13 -4) => -3) -(check (modulo -13 -4) => -1) - -(check (remainder 13 4) => 1) -(check (remainder -13 4) => -1) -(check (remainder 13 -4) => 1) -(check (remainder -13 -4) => -1) -(check (remainder -13 -4.0) => -1.0) ; inexact - -(check (log 0.0) => -inf.0) - -(check (sin 0) (=> =) 0) -(check (sin (/ fl-pi 6)) (=> =) 0.5) -; (check (sin (/ fl-pi 4)) (=> =) 0.707107) -; (check (sin (/ fl-pi 3)) (=> =) 0.866025) -(check (sin (/ fl-pi 2)) (=> =) 1) -; (check (sin fl-pi) (=> =) 0) - -(check (atan 0.0 1.0) => 0.000000) -; (check (atan 1.0 1.0) => 0.785398) -; (check (atan 1.0 0.0) => 1.570796) -; (check (atan 1.0 -1.0) => 2.356194) -; (check (atan 0.0 -1.0) => 3.141593) -; (check (atan -1.0 -1.0) => -2.356194) -; (check (atan -1.0 0.0) => -1.570796) -; (check (atan -1.0 1.0) => -0.785398) - -(check (exact 0.333333) => 3002396749180579/9007199254740992) - -; ---- SRFI-78 ----------------------------------------------------------------- - -(check-report) - -(exit (check-passed? 57)) diff --git a/test/r7rs.ss b/test/r7rs.ss index c8f4d1cef..73511944c 100644 --- a/test/r7rs.ss +++ b/test/r7rs.ss @@ -749,7 +749,7 @@ (check (eqv? (lambda (x) x) (lambda (y) y)) => #f) ; unspecified -(check (eqv? 1.0e0 1.0f0) => #t) ; unspecified +(check (eqv? 1.0e0 1.0f0) => #f) ; unspecified (check (eqv? +nan.0 +nan.0) => #t) ; unspecified From 999e288dec5fd283ccb5fa61c2df2b33b6ccbdda Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Fri, 20 Sep 2024 02:23:27 +0900 Subject: [PATCH 14/19] Fix `@vector-copy!` to not cause undefined behavior for `slice_array` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- src/kernel/boot.cpp | 28 +++++++++++++++++++++------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 37f3593d1..ce5267e72 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.238_amd64.deb +sudo apt install build/meevax_0.5.239_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.238.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.239.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.238_amd64.deb` +| `package` | Generate debian package `meevax_0.5.239_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 119d20e7e..0f3ab1199 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.238 +0.5.239 diff --git a/src/kernel/boot.cpp b/src/kernel/boot.cpp index f75d4d572..b9c9147a1 100644 --- a/src/kernel/boot.cpp +++ b/src/kernel/boot.cpp @@ -2109,19 +2109,33 @@ inline namespace kernel switch (length(xs)) \ { \ case 3: \ - car(xs).as().slice(cadr(xs).as()) = \ - caddr(xs).as().slice(); \ + { \ + std::size_t at = cadr(xs).as(); \ + std::size_t begin = 0; \ + std::size_t end = caddr(xs).as().valarray.size(); \ + assert(begin <= end); \ + car(xs).as().valarray[std::slice(at, end - begin, 1)] = caddr(xs).as().valarray[std::slice(begin, end - begin, 1)]; \ + } \ break; \ \ case 4: \ - car(xs).as().slice(cadr(xs).as()) = \ - caddr(xs).as().slice(cadddr(xs).as()); \ + { \ + std::size_t at = cadr(xs).as(); \ + std::size_t begin = cadddr(xs).as(); \ + std::size_t end = caddr(xs).as().valarray.size(); \ + assert(begin <= end); \ + car(xs).as().valarray[std::slice(at, end - begin, 1)] = caddr(xs).as().valarray[std::slice(begin, end - begin, 1)]; \ + } \ break; \ \ case 5: \ - car(xs).as().slice(cadr(xs).as()) = \ - caddr(xs).as().slice(cadddr(xs).as(), \ - caddddr(xs).as()); \ + { \ + std::size_t at = cadr(xs).as(); \ + std::size_t begin = cadddr(xs).as(); \ + std::size_t end = caddddr(xs).as(); \ + assert(begin <= end); \ + car(xs).as().valarray[std::slice(at, end - begin, 1)] = caddr(xs).as().valarray[std::slice(begin, end - begin, 1)]; \ + } \ break; \ \ default: \ From 0ba0da9342f6867d81fb5771047eb5d2e53db4eb Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 22 Sep 2024 02:44:03 +0900 Subject: [PATCH 15/19] Update `default_collector` to be declared as an extern template Signed-off-by: yamacir-kit --- CMakeLists.txt | 2 +- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/pair.hpp | 14 +++++++++++--- src/kernel/pair.cpp | 5 +++++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc3ed5b19..f1db6974f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,6 +248,6 @@ else() COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NCPU} COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NCPU} COMMAND ${CMAKE_MAKE_PROGRAM} package - # COMMAND sudo installer -pkg ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.pkg -target $ENV{HOME} + COMMAND sudo installer -pkg ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.pkg -target $ENV{HOME} ) endif() diff --git a/README.md b/README.md index ce5267e72..9beb710ba 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.239_amd64.deb +sudo apt install build/meevax_0.5.240_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.239.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.240.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.239_amd64.deb` +| `package` | Generate debian package `meevax_0.5.240_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 0f3ab1199..af4882b3a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.239 +0.5.240 diff --git a/include/meevax/kernel/pair.hpp b/include/meevax/kernel/pair.hpp index ebe317594..93dd859cb 100644 --- a/include/meevax/kernel/pair.hpp +++ b/include/meevax/kernel/pair.hpp @@ -27,11 +27,19 @@ namespace meevax { inline namespace kernel { - using null = std::nullptr_t; - struct pair; +} + +inline namespace memory +{ + extern template class collector; +} + +inline namespace kernel +{ + using null = std::nullptr_t; - using default_collector = collector; + using default_collector = collector; using object = default_collector::mutator; diff --git a/src/kernel/pair.cpp b/src/kernel/pair.cpp index 8e0e83dfa..fd398ede6 100644 --- a/src/kernel/pair.cpp +++ b/src/kernel/pair.cpp @@ -18,6 +18,11 @@ namespace meevax { +inline namespace memory +{ + template class collector; +} + inline namespace kernel { let unit = nullptr; From 382d1e6318343e5ac3cdfafc9be2a703f8405928 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 10 Oct 2024 03:34:44 +0900 Subject: [PATCH 16/19] Update to not define make target `package` for MacOS Signed-off-by: yamacir-kit --- CMakeLists.txt | 34 +++++++--------------------------- README.md | 6 +++--- VERSION | 2 +- 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1db6974f..0ac4893ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,35 +176,25 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(CPACK_GENERATOR DEB) set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) -else() - set(CPACK_GENERATOR productbuild) - set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION}) + include(CPack) endif() -include(CPack) - # ---- Target test ------------------------------------------------------------- enable_testing() if(CMAKE_SYSTEM_NAME STREQUAL "Linux") find_program(${PROJECT_NAME}_MEMORY_CHECK_COMMAND valgrind) - set(${PROJECT_NAME}_MEMORY_CHECK_OPTIONS --error-exitcode=1 --leak-check=full --quiet --show-leak-kinds=all) + set(${PROJECT_NAME}_MEMORY_CHECK ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND} --error-exitcode=1 --leak-check=full --quiet --show-leak-kinds=all) else() - set(${PROJECT_NAME}_MEMORY_CHECK_COMMAND "") - set(${PROJECT_NAME}_MEMORY_CHECK_OPTIONS "") + set(${PROJECT_NAME}_MEMORY_CHECK "") endif() file(GLOB ${PROJECT_NAME}_TEST_SS ${CMAKE_CURRENT_SOURCE_DIR}/test/*.ss) foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_SS) get_filename_component(FILENAME ${EACH} NAME_WE) - add_test( - NAME ${FILENAME} - COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND} - ${${PROJECT_NAME}_MEMORY_CHECK_OPTIONS} - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meevax - ${EACH}) + add_test(NAME ${FILENAME} COMMAND ${${PROJECT_NAME}_MEMORY_CHECK} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meevax ${EACH}) endforeach() file(GLOB ${PROJECT_NAME}_TEST_CPP ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp) @@ -214,23 +204,14 @@ foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_CPP) add_executable(test_${FILENAME} ${EACH}) target_link_libraries(test_${FILENAME} PRIVATE basis kernel) target_compile_options(test_${FILENAME} PUBLIC -Wno-deprecated-declarations) - add_test( - NAME test/${FILENAME} - COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND} - ${${PROJECT_NAME}_MEMORY_CHECK_OPTIONS} - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_${FILENAME}) + add_test(NAME test/${FILENAME} COMMAND ${${PROJECT_NAME}_MEMORY_CHECK} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_${FILENAME}) endforeach() file(GLOB ${PROJECT_NAME}_TEST_SH ${CMAKE_CURRENT_SOURCE_DIR}/test/*.sh) foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_SH) get_filename_component(FILENAME ${EACH} NAME_WE) - add_test( - NAME ${FILENAME} - COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND} - ${${PROJECT_NAME}_MEMORY_CHECK_OPTIONS} - ${EACH} - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meevax) + add_test(NAME ${FILENAME} COMMAND ${${PROJECT_NAME}_MEMORY_CHECK} ${EACH} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meevax) endforeach() # ---- Additional Targets ------------------------------------------------------ @@ -248,6 +229,5 @@ else() COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NCPU} COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NCPU} COMMAND ${CMAKE_MAKE_PROGRAM} package - COMMAND sudo installer -pkg ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.pkg -target $ENV{HOME} - ) + COMMAND sudo ${CMAKE_MAKE_PROGRAM} install) endif() diff --git a/README.md b/README.md index 9beb710ba..cfb7b290b 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.240_amd64.deb +sudo apt install build/meevax_0.5.241_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.240.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.241.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.240_amd64.deb` +| `package` | Generate debian package `meevax_0.5.241_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index af4882b3a..53f6cc480 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.240 +0.5.241 From 72c2106abcdf9a63de1de51177fa3c7fa66ff123 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Oct 2024 00:05:20 +0900 Subject: [PATCH 17/19] Add the definition of `CMAKE_INSTALL_NAME_DIR` to `CMakeLists.txt` Signed-off-by: yamacir-kit --- CMakeLists.txt | 4 ++-- README.md | 6 +++--- VERSION | 2 +- example/example.ss | 18 ++++++++---------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ac4893ce..d367b5093 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,13 +20,14 @@ string(JOIN " " ${PROJECT_NAME}_RELEASE_PLUS ) set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe") 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_RELEASE "-O3 -flto -DNDEBUG ${${PROJECT_NAME}_RELEASE_PLUS}") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-4") -set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) 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}) @@ -228,6 +229,5 @@ else() add_custom_target(develop COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NCPU} COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NCPU} - COMMAND ${CMAKE_MAKE_PROGRAM} package COMMAND sudo ${CMAKE_MAKE_PROGRAM} install) endif() diff --git a/README.md b/README.md index cfb7b290b..33f988b70 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.241_amd64.deb +sudo apt install build/meevax_0.5.242_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.241.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.242.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.241_amd64.deb` +| `package` | Generate debian package `meevax_0.5.242_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 53f6cc480..cd8d60286 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.241 +0.5.242 diff --git a/example/example.ss b/example/example.ss index 334502007..9cde255fb 100644 --- a/example/example.ss +++ b/example/example.ss @@ -7,34 +7,32 @@ (display (get-environment-variable "LD_LIBRARY_PATH")) (newline) -; ------------------------------------------------------------------------------ +(define libexample + (cond-expand (darwin "libexample.dylib") + (linux "libexample.so"))) (define dummy-procedure - (procedure "libexample.so" 'dummy_procedure)) + (procedure libexample 'dummy_procedure)) (check (procedure? dummy-procedure) => #t) (check (dummy-procedure 'hoge 42 #(1 2 3) 3.14) => 43) -; ------------------------------------------------------------------------------ - (define argument-length - (procedure "libexample.so" 'argument_length)) + (procedure libexample 'argument_length)) (check (procedure? argument-length) => #t) (check (argument-length 'hoge 42 #(1 2 3) 3.14) => 4) -; ------------------------------------------------------------------------------ - (define make-hoge - (procedure "libexample.so" 'make_hoge)) + (procedure libexample 'make_hoge)) (define hoge? - (procedure "libexample.so" 'is_hoge)) + (procedure libexample 'is_hoge)) (define hoge-value - (procedure "libexample.so" 'hoge_value)) + (procedure libexample 'hoge_value)) (check (procedure? make-hoge) => #t) From 25b1b645d3dd656e134caeadac4d6dd7575c24ae Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Oct 2024 01:26:38 +0900 Subject: [PATCH 18/19] Replace `CMAKE_INSTALL_NAME_DIR` with `CMAKE_INSTALL_RPATH` Signed-off-by: yamacir-kit --- CMakeLists.txt | 2 +- README.md | 6 +++--- VERSION | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d367b5093..f134baccb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -DNDEBUG ${${PROJECT_NAME}_RELEASE_PLUS}" set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-4") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) +set(CMAKE_INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR}") 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}) diff --git a/README.md b/README.md index 33f988b70..2b84694ca 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.242_amd64.deb +sudo apt install build/meevax_0.5.243_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.242.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.243.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.242_amd64.deb` +| `package` | Generate debian package `meevax_0.5.243_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index cd8d60286..5f5844a80 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.242 +0.5.243 From b95f964157070d727c89c1296bb123f8e97ba8a6 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Oct 2024 01:54:43 +0900 Subject: [PATCH 19/19] Update to set `CMAKE_INSTALL_RPATH` for MacOS only Signed-off-by: yamacir-kit --- CMakeLists.txt | 9 ++++++--- README.md | 6 +++--- VERSION | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f134baccb..53a995b25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,12 +27,15 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -DNDEBUG ${${PROJECT_NAME}_RELEASE_PLUS}" set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-4") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR}") 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) +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(CMAKE_INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR}") +endif() + # ---- Configure --------------------------------------------------------------- include(TestBigEndian) @@ -184,7 +187,7 @@ endif() enable_testing() -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") +if(CMAKE_SYSTEM_NAME STREQUAL Linux) find_program(${PROJECT_NAME}_MEMORY_CHECK_COMMAND valgrind) set(${PROJECT_NAME}_MEMORY_CHECK ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND} --error-exitcode=1 --leak-check=full --quiet --show-leak-kinds=all) else() @@ -217,7 +220,7 @@ endforeach() # ---- Additional Targets ------------------------------------------------------ -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") +if(CMAKE_SYSTEM_NAME STREQUAL Linux) execute_process(COMMAND nproc OUTPUT_VARIABLE ${PROJECT_NAME}_NPROC) add_custom_target(develop COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NPROC} diff --git a/README.md b/README.md index 2b84694ca..1bc798b53 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.243_amd64.deb +sudo apt install build/meevax_0.5.244_amd64.deb ``` or @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.243.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.244.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.243_amd64.deb` +| `package` | Generate debian package `meevax_0.5.244_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index 5f5844a80..0db6715bd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.243 +0.5.244