From cdee9d91349ba53a23244d1f3ea5061c8c074975 Mon Sep 17 00:00:00 2001 From: "Sunrim KIM (keen)" <3han5chou7@gmail.com> Date: Sun, 20 Jul 2014 17:54:08 +0900 Subject: [PATCH] make contribs independant of the directory structure of picrin --- contrib/10.partcont/CMakeLists.txt | 2 +- contrib/10.pretty-print/CMakeLists.txt | 2 +- contrib/10.regexp/CMakeLists.txt | 5 ++++- {cmake => contrib/10.regexp/cmake}/FindREGEX.cmake | 0 contrib/10.regexp/t/test.scm | 11 +++++++++++ contrib/20.for/CMakeLists.txt | 2 +- contrib/CMakeLists.txt | 3 ++- 7 files changed, 20 insertions(+), 5 deletions(-) rename {cmake => contrib/10.regexp/cmake}/FindREGEX.cmake (100%) create mode 100644 contrib/10.regexp/t/test.scm diff --git a/contrib/10.partcont/CMakeLists.txt b/contrib/10.partcont/CMakeLists.txt index 65f16fb2..bedbbd75 100644 --- a/contrib/10.partcont/CMakeLists.txt +++ b/contrib/10.partcont/CMakeLists.txt @@ -1,2 +1,2 @@ -file(GLOB PARTCONT_FILES ${PROJECT_SOURCE_DIR}/contrib/10.partcont/piclib/*.scm) +file(GLOB PARTCONT_FILES ${PICRIN_CONTRIB_DIR}/10.partcont/piclib/*.scm) list(APPEND PICLIB_CONTRIB_LIBS ${PARTCONT_FILES}) diff --git a/contrib/10.pretty-print/CMakeLists.txt b/contrib/10.pretty-print/CMakeLists.txt index cf0327da..c5353018 100644 --- a/contrib/10.pretty-print/CMakeLists.txt +++ b/contrib/10.pretty-print/CMakeLists.txt @@ -1 +1 @@ -list(APPEND PICLIB_CONTRIB_LIBS ${PROJECT_SOURCE_DIR}/contrib/10.pretty-print/pretty-print.scm) +list(APPEND PICLIB_CONTRIB_LIBS ${PICRIN_CONTRIB_DIR}/10.pretty-print/pretty-print.scm) diff --git a/contrib/10.regexp/CMakeLists.txt b/contrib/10.regexp/CMakeLists.txt index 6ab06aaa..aa177aaa 100644 --- a/contrib/10.regexp/CMakeLists.txt +++ b/contrib/10.regexp/CMakeLists.txt @@ -1,11 +1,14 @@ # regex +set(PICRIN_REGEX_DIR ${PICRIN_CONTRIB_DIR}/10.regexp) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PICRIN_REGEX_DIR}/cmake/") + find_package(REGEX) if (REGEX_FOUND) add_definitions(${REGEX_DEFINITIONS}) include_directories(${REGEX_INCLUDE_DIR}) - file(GLOB PICRIN_REGEX_SOURCES ${PROJECT_SOURCE_DIR}/contrib/10.regexp/src/*.c) + file(GLOB PICRIN_REGEX_SOURCES ${PICRIN_REGEX_DIR}/src/*.c) list(APPEND PICRIN_CONTRIB_INITS regexp) list(APPEND PICRIN_CONTRIB_LIBRARIES ${REGEX_LIBRARIES}) diff --git a/cmake/FindREGEX.cmake b/contrib/10.regexp/cmake/FindREGEX.cmake similarity index 100% rename from cmake/FindREGEX.cmake rename to contrib/10.regexp/cmake/FindREGEX.cmake diff --git a/contrib/10.regexp/t/test.scm b/contrib/10.regexp/t/test.scm new file mode 100644 index 00000000..b2a76f49 --- /dev/null +++ b/contrib/10.regexp/t/test.scm @@ -0,0 +1,11 @@ +(import (scheme base) + (picrin test) + (picrin regexp)) + +(test #t (regexp? (regexp "simple"))) +(test #f (regexp? "it\\s[s]e+ms\\s(reg)?exp")) +(test-values '(("abcd") ("b")) (regexp-match (regexp "a(b)cd") "abdacabcd")) +(test '("a" "b" "c" "d") (regexp-split (regexp ",") "a,b,c,d")) +(test '("a" "b" "c" "d") (regexp-split (regexp "\.+") "a.b....c.....d")) +(test "newline tab spase " (regexp-replace (regexp "\\s") " " "newline +tab space ")) diff --git a/contrib/20.for/CMakeLists.txt b/contrib/20.for/CMakeLists.txt index ebe66a42..9b0f64f0 100644 --- a/contrib/20.for/CMakeLists.txt +++ b/contrib/20.for/CMakeLists.txt @@ -1,2 +1,2 @@ -file(GLOB FOR_FILES ${PROJECT_SOURCE_DIR}/contrib/20.for/piclib/*.scm) +file(GLOB FOR_FILES ${PICRIN_CONTRIB_DIR}/20.for/piclib/*.scm) list(APPEND PICLIB_CONTRIB_LIBS ${FOR_FILES}) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 11050d90..50c586de 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -1,4 +1,5 @@ -file(GLOB CONTRIBS ${PROJECT_SOURCE_DIR}/contrib/*/CMakeLists.txt) +set(PICRIN_CONTRIB_DIR ${PROJECT_SOURCE_DIR}/contrib) +file(GLOB CONTRIBS ${PICRIN_CONTRIB_DIR}/*/CMakeLists.txt) list(SORT CONTRIBS) foreach(contrib ${CONTRIBS}) include(${contrib})