add build option to disable repl, use feature objects
parent
71f45b2f07
commit
371ef9e912
19
README.md
19
README.md
|
@ -73,8 +73,8 @@ utilized in the outside native code.
|
||||||
There are no dependencies (other than a suitable compiler and the standard
|
There are no dependencies (other than a suitable compiler and the standard
|
||||||
library).
|
library).
|
||||||
|
|
||||||
Libostd is built using Meson. Therefore, you need to install Meson and then
|
Libcubescript is built using `meson`. After installing it, you can do
|
||||||
you can compile it as usual. Typically, this will be something like
|
something like this:
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
|
@ -82,15 +82,22 @@ meson ..
|
||||||
ninja all
|
ninja all
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
Link the libcubescript library together with your application and everything
|
Link the `libcubescript` library together with your application and everything
|
||||||
should just work. It also builds the REPL.
|
should just work. It also builds the REPL by default.
|
||||||
|
|
||||||
The project also bundles the linenoise line editing library which has been
|
The project also bundles the `linenoise` line editing library which has been
|
||||||
modified to compile cleanly as C++ (with the same flags as libcubescript).
|
modified to compile cleanly as C++ (with the same flags as `libcubescript`).
|
||||||
It's used strictly for the REPL only (you don't need it to build libcubescript
|
It's used strictly for the REPL only (you don't need it to build libcubescript
|
||||||
itself). The version in the repository tracks Git revision
|
itself). The version in the repository tracks Git revision
|
||||||
https://github.com/antirez/linenoise/commit/c894b9e59f02203dbe4e2be657572cf88c4230c3.
|
https://github.com/antirez/linenoise/commit/c894b9e59f02203dbe4e2be657572cf88c4230c3.
|
||||||
|
|
||||||
|
For the REPL (when not disabled with `-Drepl=disabled`) you have a choice of
|
||||||
|
two line editing libraries. The `readline` library can be used (but is always
|
||||||
|
disabled by default, so you need to enable it manually). On Unix-like systems,
|
||||||
|
`linenoise` can be used (and is fully featured) and is enabled by default; on
|
||||||
|
Windows it's disabled. There is also a fallback without any line editing, used
|
||||||
|
when you don't have either (but then there is no line editing or history).
|
||||||
|
|
||||||
## Licensing
|
## Licensing
|
||||||
|
|
||||||
See COPYING.md for licensing information.
|
See COPYING.md for licensing information.
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
|
option('repl',
|
||||||
|
type: 'feature',
|
||||||
|
value: 'auto',
|
||||||
|
description: 'Enable the REPL (command line tool)'
|
||||||
|
)
|
||||||
|
|
||||||
option('readline',
|
option('readline',
|
||||||
type: 'boolean',
|
type: 'feature',
|
||||||
value: false,
|
value: 'auto',
|
||||||
description: 'Use GNU readline for the REPL'
|
description: 'Use GNU readline for the REPL'
|
||||||
)
|
)
|
||||||
|
|
||||||
option('linenoise',
|
option('linenoise',
|
||||||
type: 'boolean',
|
type: 'feature',
|
||||||
value: true,
|
value: 'auto',
|
||||||
description: 'Use linenoise for the REPL'
|
description: 'Use linenoise for the REPL'
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,18 +5,30 @@ repl_src = [
|
||||||
repl_deps = [libcubescript]
|
repl_deps = [libcubescript]
|
||||||
repl_flags = []
|
repl_flags = []
|
||||||
|
|
||||||
if get_option('readline')
|
if get_option('readline').enabled()
|
||||||
repl_deps += [dependency('readline')]
|
use_readline = true
|
||||||
repl_flags = ['-DCS_REPL_USE_READLINE']
|
use_linenoise = false
|
||||||
elif get_option('linenoise')
|
elif get_option('linenoise').enabled()
|
||||||
repl_src += ['linenoise.cc']
|
use_readline = false
|
||||||
repl_flags = ['-DCS_REPL_USE_LINENOISE']
|
use_linenoise = true
|
||||||
|
elif get_option('linenoise').auto()
|
||||||
|
use_readline = false
|
||||||
|
use_linenoise = (host_machine.system() != 'windows')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
executable('cubescript',
|
if not get_option('repl').disabled()
|
||||||
repl_src,
|
if use_readline
|
||||||
dependencies: repl_deps,
|
repl_deps += [dependency('readline')]
|
||||||
include_directories: libcubescript_includes + [include_directories('.')],
|
repl_flags = ['-DCS_REPL_USE_READLINE']
|
||||||
cpp_args: extra_cxxflags + repl_flags,
|
elif use_linenoise
|
||||||
install: true
|
repl_src += ['linenoise.cc']
|
||||||
)
|
repl_flags = ['-DCS_REPL_USE_LINENOISE']
|
||||||
|
endif
|
||||||
|
executable('cubescript',
|
||||||
|
repl_src,
|
||||||
|
dependencies: repl_deps,
|
||||||
|
include_directories: libcubescript_includes + [include_directories('.')],
|
||||||
|
cpp_args: extra_cxxflags + repl_flags,
|
||||||
|
install: true
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
Loading…
Reference in New Issue