Browse Source

mesonize libcubescript

master
Daniel Kolesa 2 years ago
parent
commit
e58c69bc99
7 changed files with 111 additions and 46 deletions
  1. +1
    -0
      .gitignore
  2. +0
    -46
      Makefile
  3. +35
    -0
      meson.build
  4. +11
    -0
      meson_options.txt
  5. +38
    -0
      src/meson.build
  6. +4
    -0
      subprojects/libostd.wrap
  7. +22
    -0
      tools/meson.build

+ 1
- 0
.gitignore View File

@ -1,3 +1,4 @@
subprojects/libostd
*.o
*.core
*.so

+ 0
- 46
Makefile View File

@ -1,46 +0,0 @@
OSTD_PATH = ../libostd
LIBCS_CXXFLAGS = \
-std=c++1z -Wall -Wextra -Wshadow -Wold-style-cast -Iinclude -Isrc -g \
-fvisibility=hidden -I$(OSTD_PATH)
LIBCS_LDFLAGS = $(OSTD_PATH)/libostd.a
LIBCS_OBJ = \
src/cubescript.o \
src/cs_gen.o \
src/cs_vm.o \
src/cs_val.o \
src/cs_util.o \
src/lib_str.o \
src/lib_math.o \
src/lib_list.o
LIBCS_LIB = libcubescript.a
.cc.o:
$(CXX) $(CXXFLAGS) $(LIBCS_CXXFLAGS) -c -o $@ $<
all: library repl
library: $(LIBCS_LIB)
$(LIBCS_LIB): $(LIBCS_OBJ)
ar rcs $(LIBCS_LIB) $(LIBCS_OBJ)
repl: $(LIBCS_LIB) tools/repl.cc tools/linenoise.cc tools/linenoise.hh
$(CXX) $(CXXFLAGS) $(LIBCS_CXXFLAGS) \
-DCS_REPL_USE_LINENOISE tools/linenoise.cc tools/repl.cc \
$(LDFLAGS) $(LIBCS_LDFLAGS) -o repl $(LIBCS_LIB)
clean:
rm -f $(LIBCS_LIB) $(LIBCS_OBJ) repl
src/cubescript.o: include/cubescript/cubescript.hh include/cubescript/cubescript_conf.hh src/cs_vm.hh
src/cs_gen.o: include/cubescript/cubescript.hh include/cubescript/cubescript_conf.hh src/cs_vm.hh src/cs_util.hh
src/cs_vm.o: include/cubescript/cubescript.hh include/cubescript/cubescript_conf.hh src/cs_vm.hh src/cs_util.hh
src/cs_val.o: include/cubescript/cubescript.hh include/cubescript/cubescript_conf.hh src/cs_vm.hh src/cs_util.hh
src/cs_util.o: include/cubescript/cubescript.hh include/cubescript/cubescript_conf.hh src/cs_util.hh
src/lib_str.o: include/cubescript/cubescript.hh include/cubescript/cubescript_conf.hh
src/lib_math.o: include/cubescript/cubescript.hh include/cubescript/cubescript_conf.hh
src/lib_list.o: include/cubescript/cubescript.hh include/cubescript/cubescript_conf.hh src/cs_util.hh

+ 35
- 0
meson.build View File

@ -0,0 +1,35 @@
project('libcubescript', ['cpp'],
version: '0.1.0',
default_options: ['buildtype=plain', 'cpp_std=c++17'],
meson_version: '>=0.46'
)
dir_prefix = get_option('prefix')
dir_include = join_paths(dir_prefix, get_option('includedir'))
dir_data = join_paths(dir_prefix, get_option('datadir'))
dir_lib = join_paths(dir_prefix, get_option('libdir'))
dir_package_include = join_paths(dir_include, 'cubescript')
libcubescript_includes = [include_directories('include')]
tgt_compiler_id = meson.get_compiler('cpp').get_id()
if tgt_compiler_id == 'gcc' or tgt_compiler_id == 'clang'
extra_cxxflags = ['-Wextra', '-Wshadow', '-Wold-style-cast']
else
extra_cxxflags = []
endif
subdir('src')
subdir('tools')
pkg = import('pkgconfig')
pkg.generate(
libraries: libcubescript_lib,
version: meson.project_version(),
name: 'libcubescript',
filebase: 'libcubescript',
url: 'https://git.octaforge.org/octaforge/libcubescript',
description: 'OctaForge C++ utility library'
)

+ 11
- 0
meson_options.txt View File

@ -0,0 +1,11 @@
option('readline',
type: 'boolean',
value: false,
description: 'Use GNU readline for the REPL'
)
option('linenoise',
type: 'boolean',
value: true,
description: 'Use linenoise for the REPL'
)

+ 38
- 0
src/meson.build View File

@ -0,0 +1,38 @@
libcubescript_header_src = [
'../include/cubescript/cubescript.hh',
'../include/cubescript/cubescript_conf.hh'
]
libcubescript_src = [
'cs_gen.cc',
'cs_util.cc',
'cs_val.cc',
'cs_vm.cc',
'cubescript.cc',
'lib_list.cc',
'lib_math.cc',
'lib_str.cc'
]
libostd_dep = dependency('libostd', fallback: ['libostd', 'libostd_static'])
libcubescript_lib = both_libraries('cubescript',
libcubescript_src,
dependencies: libostd_dep,
include_directories: libcubescript_includes + [include_directories('.')],
cpp_args: extra_cxxflags,
install: true,
version: meson.project_version()
)
libcubescript = declare_dependency(
include_directories: libcubescript_includes,
link_with: libcubescript_lib.get_shared_lib()
)
libcubescript_static = declare_dependency(
include_directories: libcubescript_includes,
link_with: libcubescript_lib.get_static_lib()
)
install_headers(libcubescript_header_src, install_dir: dir_package_include)

+ 4
- 0
subprojects/libostd.wrap View File

@ -0,0 +1,4 @@
[wrap-git]
directory = libostd
url = https://git.octaforge.org/OctaForge/libostd.git
revision = head

+ 22
- 0
tools/meson.build View File

@ -0,0 +1,22 @@
repl_src = [
'repl.cc'
]
repl_deps = [libostd_dep, libcubescript]
repl_flags = []
if get_option('readline')
repl_deps += [dependency('readline')]
repl_flags = ['-DCS_REPL_USE_READLINE']
elif get_option('linenoise')
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
)

Loading…
Cancel
Save