Skip to content

Commit 2f59b25

Browse files
authored
Merge pull request #344 from yamacir-kit/cleanup
Cleanup
2 parents 9c7ef3d + baeaa98 commit 2f59b25

38 files changed

+695
-857
lines changed

CMakeLists.txt

+37-28
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -pipe") # NOTE: -march=nativ
2828
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
2929
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
3030

31-
# ---- Configure README --------------------------------------------------------
31+
# ---- Configure ---------------------------------------------------------------
3232

3333
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/configure/README.md)
3434
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/README.md
3535
${CMAKE_CURRENT_SOURCE_DIR}/README.md)
3636
endif()
3737

38-
# ---- Configure Headers -------------------------------------------------------
39-
4038
string(TIMESTAMP ${PROJECT_NAME}_BUILD_DATE "%Y/%m/%d-%H:%M:%S")
4139

4240
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
@@ -96,7 +94,7 @@ target_include_directories(kernel PUBLIC
9694
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
9795

9896
target_link_libraries(kernel PRIVATE stdc++fs
99-
PUBLIC ${CMAKE_DL_LIBS}
97+
PRIVATE ${CMAKE_DL_LIBS}
10098
PUBLIC gmp)
10199

102100
set_target_properties(
@@ -146,14 +144,6 @@ install(EXPORT ${PROJECT_NAME}-config
146144
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
147145
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
148146

149-
# ---- Target uninstall --------------------------------------------------------
150-
151-
add_custom_target(uninstall
152-
COMMAND sudo rm -rf ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}
153-
COMMAND sudo rm -rf ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
154-
COMMAND sudo rm -rf ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME}*
155-
COMMAND sudo rm -rf ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
156-
157147
# ---- Target package ----------------------------------------------------------
158148

159149
set(CPACK_GENERATOR DEB)
@@ -171,23 +161,42 @@ include(CPack)
171161

172162
enable_testing()
173163

174-
set(MEMCHECK valgrind --error-exitcode=1 # = EXIT_FAILURE
175-
--leak-check=full
176-
--quiet
177-
--show-leak-kinds=all)
178-
179-
macro(define_test TEST_NAME)
164+
macro(check TEST_NAME)
180165
add_test(NAME ${TEST_NAME}
181-
COMMAND ${MEMCHECK}
182-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/meevax
166+
COMMAND valgrind --error-exitcode=1 # = EXIT_FAILURE
167+
--leak-check=full
168+
--quiet
169+
--show-leak-kinds=all
170+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meevax
183171
${CMAKE_CURRENT_SOURCE_DIR}/test/${TEST_NAME}.ss)
184172
endmacro()
185173

186-
define_test(abandoned)
187-
define_test(chibi-basic)
188-
define_test(low-level-macro-facility)
189-
define_test(numerical-operations)
190-
define_test(r4rs)
191-
define_test(r4rs-appendix)
192-
define_test(r7rs)
193-
define_test(sicp-1)
174+
check(abandoned)
175+
check(chibi-basic)
176+
check(low-level-macro-facility)
177+
check(numerical-operations)
178+
check(r4rs)
179+
check(r4rs-appendix)
180+
check(r7rs)
181+
check(sicp-1)
182+
183+
file(GLOB ${PROJECT_NAME}_TEST_CXX ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp)
184+
foreach(FILEPATH IN LISTS ${PROJECT_NAME}_TEST_CXX)
185+
get_filename_component(FILENAME ${FILEPATH} NAME_WE)
186+
add_executable(assert-${FILENAME} ${FILEPATH})
187+
target_link_libraries(assert-${FILENAME} PRIVATE kernel)
188+
add_test(NAME assert-${FILENAME}
189+
COMMAND valgrind --error-exitcode=1 # = EXIT_FAILURE
190+
--leak-check=full
191+
--quiet
192+
--show-leak-kinds=all
193+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assert-${FILENAME})
194+
endforeach()
195+
196+
# ---- Target all+ -------------------------------------------------------------
197+
198+
execute_process(COMMAND nproc OUTPUT_VARIABLE NPROC)
199+
200+
add_custom_target(all+ COMMAND make all -j ${NPROC}
201+
COMMAND ${CMAKE_CTEST_COMMAND} -j ${NPROC}
202+
COMMAND ${CMAKE_CPACK_COMMAND})

LICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,27 @@
176176

177177
END OF TERMS AND CONDITIONS
178178

179+
APPENDIX: How to apply the Apache License to your work.
180+
181+
To apply the Apache License to your work, attach the following
182+
boilerplate notice, with the fields enclosed by brackets "[]"
183+
replaced with your own identifying information. (Don't include
184+
the brackets!) The text should be enclosed in the appropriate
185+
comment syntax for the file format. We also recommend that a
186+
file or class name and description of purpose be included on the
187+
same "printed page" as the copyright notice for easier
188+
identification within third-party archives.
189+
190+
Copyright [yyyy] [name of copyright owner]
191+
192+
Licensed under the Apache License, Version 2.0 (the "License");
193+
you may not use this file except in compliance with the License.
194+
You may obtain a copy of the License at
195+
196+
http://www.apache.org/licenses/LICENSE-2.0
197+
198+
Unless required by applicable law or agreed to in writing, software
199+
distributed under the License is distributed on an "AS IS" BASIS,
200+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201+
See the License for the specific language governing permissions and
202+
limitations under the License.

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ subset of **R7RS Scheme** implementation.
4747

4848
There is no stable version.
4949

50-
Development HEAD: 0.3.517.
50+
Development HEAD: 0.3.545.
5151

5252
### Characteristic Features
5353

@@ -90,7 +90,6 @@ An subset of R7RS-small.
9090
- GNU Make
9191
- GNU Binutils
9292
- [**GNU Multiple Precision Arithmetic Library** (GMP)](https://gmplib.org/)
93-
- [**Boost C++ Libraries**](https://www.boost.org/) (1.65.1 or later)
9493

9594
<br/>
9695

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.517
1+
0.3.545

benchmark/ack.ss

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
((= n 0) (ack (- m 1) 1))
44
(else (ack (- m 1) (ack m (- n 1))))))
55

6-
(define m 3)
7-
(define n 7)
8-
9-
(ack m n)
6+
(ack 3 7)
107

118
(exit)

benchmark/tarai.ss

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(define (tarai x y z)
2+
(if (not (< y x)) y
3+
(tarai (tarai (- x 1) y z)
4+
(tarai (- y 1) z x)
5+
(tarai (- z 1) x y))))
6+
7+
(tarai 10 5 0)
8+
9+
(exit)

configure/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ An subset of R7RS-small.
9090
- GNU Make
9191
- GNU Binutils
9292
- [**GNU Multiple Precision Arithmetic Library** (GMP)](https://gmplib.org/)
93-
- [**Boost C++ Libraries**](https://www.boost.org/) (1.65.1 or later)
9493

9594
<br/>
9695

example/CMakeLists.txt

+6-32
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,17 @@
11
cmake_minimum_required(VERSION 3.10.2) # Ubuntu 18.04 LTS Default
22

3-
project(test VERSION 0.0.0 LANGUAGES CXX)
3+
project(example VERSION 0.0.0 LANGUAGES CXX)
44

55
set(CMAKE_CXX_STANDARD 17)
66

7-
find_package(Boost REQUIRED)
87
find_package(Meevax REQUIRED) # NOTE: case-insensitive
98

10-
set(MEMCHECK valgrind --error-exitcode=1
11-
--leak-check=full
12-
--quiet
13-
--show-leak-kinds=all)
9+
add_library(${PROJECT_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.cpp)
1410

15-
macro(define_library LIBRARY_NAME)
16-
add_library(${LIBRARY_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/lib/${LIBRARY_NAME}.cpp)
17-
target_link_libraries(${LIBRARY_NAME} PRIVATE Meevax::kernel)
18-
endmacro()
19-
20-
define_library(example-1)
21-
22-
macro(define_cxx_example TEST_NAME)
23-
add_executable(${TEST_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/${TEST_NAME}.cpp)
24-
target_link_libraries(${TEST_NAME} PRIVATE Boost::boost
25-
PRIVATE Meevax::kernel)
26-
add_test(NAME ${TEST_NAME}
27-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
28-
COMMAND ${MEMCHECK} ./${TEST_NAME})
29-
endmacro()
11+
target_link_libraries(${PROJECT_NAME} PRIVATE Meevax::kernel)
3012

3113
enable_testing()
3214

33-
define_cxx_example(test-collector)
34-
define_cxx_example(test-list)
35-
define_cxx_example(test-r7rs)
36-
37-
macro(define_meevax_example EXAMPLE_NAME)
38-
add_test(NAME ${EXAMPLE_NAME}
39-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
40-
COMMAND ${MEMCHECK} meevax ${EXAMPLE_NAME}.ss)
41-
endmacro()
42-
43-
define_meevax_example(foreign-function)
15+
add_test(NAME ${PROJECT_NAME}
16+
COMMAND meevax ${PROJECT_NAME}.ss
17+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

example/lib/example-1.cpp example/example.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,31 @@ using namespace meevax; // NOTE: DIRTY HACK
44

55
extern "C"
66
{
7-
PROCEDURE(length_of_arguments)
7+
let length_of_arguments(let const& xs)
88
{
99
return make<exact_integer>(length(xs));
1010
}
1111

12-
PROCEDURE(dummy_procedure)
12+
let dummy_procedure(let const& xs)
1313
{
1414
std::cout << "\n; calling C++ function via foreign-function-interface." << std::endl;
1515

16-
std::size_t count { 0 };
16+
std::size_t count = 0;
1717

1818
for (let const& each : xs)
1919
{
2020
std::cout << "; [" << count++ << "] is " << each << " (C++ typename " << each.type().name() << ")" << std::endl;
2121
}
2222

23-
for (let const& each : xs)
23+
for (let const& x : xs)
2424
{
25-
if (each.is<exact_integer>())
25+
if (x.is<exact_integer>())
2626
{
2727
std::cout << "; return incremented left-most integer object." << std::endl;
28-
return make<exact_integer>(static_cast<int>(each.as<exact_integer>()) + 1);
28+
29+
auto value = static_cast<int>(x.as<exact_integer>());
30+
31+
return make<exact_integer>(++value);
2932
}
3033
}
3134

example/example.ss

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(define dummy-procedure (foreign-function "build/libexample.so" "dummy_procedure"))
2+
3+
(check (foreign-function? dummy-procedure) => #t)
4+
(check (dummy-procedure 'hoge 42 #(1 2 3) 3.14) => 43)
5+
6+
(define length-of-arguments (foreign-function "build/libexample.so" "length_of_arguments"))
7+
8+
(check (foreign-function? length-of-arguments) => #t)
9+
(check (length-of-arguments 'hoge 42 #(1 2 3) 3.14) => 4)
10+
11+
(exit (check-passed? check:correct))

example/foreign-function.ss

-10
This file was deleted.

0 commit comments

Comments
 (0)