Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 61 lines (51 sloc) 2.174 kb
9f89da6 @jonforums Add native and cross compiling CMake build support
jonforums authored
1 # transform mruby's standard lib into a C library
b5dcb71 First cmake build system. Works on Linux.
Beoran authored
2
3 file(GLOB MRBLIB_SRC_RB "*.rb")
4
9f89da6 @jonforums Add native and cross compiling CMake build support
jonforums authored
5 if(CMAKE_CROSSCOMPILING)
6 # create native tools and `mrblib.ctmp` required to build `mrblib.c`
7 include(ExternalProject)
8 ExternalProject_Add(mruby-native
9 DOWNLOAD_COMMAND ""
10 SOURCE_DIR "${CMAKE_SOURCE_DIR}"
11 CONFIGURE_COMMAND "${CMAKE_COMMAND}" "${CMAKE_SOURCE_DIR}"
12 INSTALL_COMMAND ""
13 BINARY_DIR "${CMAKE_BINARY_DIR}/native"
14 )
b5dcb71 First cmake build system. Works on Linux.
Beoran authored
15
9f89da6 @jonforums Add native and cross compiling CMake build support
jonforums authored
16 # aggregate mruby's standard library as a single C file
17 add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrblib.c"
18 DEPENDS mruby-native init_mrblib.c "${CMAKE_BINARY_DIR}/native/mrblib/mrblib.ctmp"
19 COMMAND "${CMAKE_BINARY_DIR}/native/tools/xpcat/xpcat"
20 -o "${CMAKE_CURRENT_BINARY_DIR}/mrblib.c"
21 "${CMAKE_CURRENT_SOURCE_DIR}/init_mrblib.c"
22 "${CMAKE_BINARY_DIR}/native/mrblib/mrblib.ctmp"
23 )
24 else()
25 # generate a single rb file from all existing ones
26 add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrblib.rbtmp"
27 DEPENDS xpcat
28 COMMAND xpcat -o "${CMAKE_CURRENT_BINARY_DIR}/mrblib.rbtmp" ${MRBLIB_SRC_RB}
29 )
30
31 # mruby compile and generate C byte array representation
32 add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrblib.ctmp"
33 DEPENDS mrbc "${CMAKE_CURRENT_BINARY_DIR}/mrblib.rbtmp"
34 COMMAND mrbc -Bmrblib_irep -o"${CMAKE_CURRENT_BINARY_DIR}/mrblib.ctmp"
35 "${CMAKE_CURRENT_BINARY_DIR}/mrblib.rbtmp"
36 )
37
38 # aggregate mruby's standard library as a single C file
39 add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrblib.c"
40 DEPENDS xpcat init_mrblib.c "${CMAKE_CURRENT_BINARY_DIR}/mrblib.ctmp"
41 COMMAND xpcat -o "${CMAKE_CURRENT_BINARY_DIR}/mrblib.c"
42 "${CMAKE_CURRENT_SOURCE_DIR}/init_mrblib.c"
43 "${CMAKE_CURRENT_BINARY_DIR}/mrblib.ctmp"
44 )
45 endif()
46
47
48 # generate final static libmruby archive library
49 add_library(libmruby_static STATIC
c403458 @jonforums Remove unnecessary mrblib object build target
jonforums authored
50 mrblib.c
9f89da6 @jonforums Add native and cross compiling CMake build support
jonforums authored
51 $<TARGET_OBJECTS:mruby_object>
52 )
53 set_target_properties(libmruby_static PROPERTIES OUTPUT_NAME mruby)
54
55 install(TARGETS libmruby_static
56 LIBRARY DESTINATION lib
57 ARCHIVE DESTINATION lib
58 )
59
60 # vim: ts=2 sts=2 sw=2 et
Something went wrong with that request. Please try again.