build: Add Meson files for use as a subproject

This commit is contained in:
Rachel 2024-12-30 16:51:38 -08:00
parent efe833458c
commit 87a2307170
4 changed files with 150 additions and 0 deletions

27
cli/meson.build Normal file
View File

@ -0,0 +1,27 @@
# Copyright 2024 <lhearachel@proton.me>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cli_sources = files(
'src/narc.c',
'src/narc_create.c',
'src/narc_extract.c',
'src/narc_help.c',
'src/narc_info.c',
'src/narc_yank.c',
'src/strbuild.c',
'src/strutil.c',
'src/strvec.c',
)
cli_includes = include_directories('include')

45
lib/meson.build Normal file
View File

@ -0,0 +1,45 @@
# Copyright 2024 <lhearachel@proton.me>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
lib_sources = files(
# check API
'src/check/narc_check.c',
'src/check/narc_check_fatb.c',
'src/check/narc_check_fimg.c',
'src/check/narc_check_fntb.c',
'src/check/narc_check_header.c',
'src/check/narc_check_header_fsize.c',
'src/check/narc_check_vfs.c',
# dump API
'src/dump/narc_dump.c',
# error API
'src/error/narc_strerror.c',
# files API
'src/files/narc_files_getext.c',
'src/files/narc_files_getimg.c',
# load API
'src/load/narc_load.c',
# pack API
'src/pack/narc_pack.c',
'src/pack/narc_pack_file.c',
'src/pack/narc_pack_halt.c',
'src/pack/narc_pack_start.c',
)
lib_includes = include_directories('include')

63
meson.build Normal file
View File

@ -0,0 +1,63 @@
# Copyright 2024 <lhearachel@proton.me>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
project(
'narc',
'c',
license: 'Apache-2.0',
license_files: 'LICENSE',
meson_version: '>=1.5.0',
version: '0.1.0',
default_options: {
'buildtype': 'release', # O3
'warning_level': '3', # all, extra, pedantic
'c_std': 'c99',
},
)
native = get_option('native')
install = native and meson.is_cross_build() ? false : true
subdir('lib')
subdir('cli')
libnarc = shared_library(
'narc',
lib_sources,
include_directories: lib_includes,
install: true,
install_mode: 'rwxr-xr-x',
version: meson.project_version(),
)
libnarc_dep = declare_dependency(
include_directories: lib_includes,
link_with: libnarc,
)
narc_exe = executable(
'narc',
sources: [
cli_sources,
lib_sources,
],
include_directories: [
cli_includes,
lib_includes,
],
install: true,
install_mode: 'rwxr-xr-x',
)
meson.override_find_program('narc', narc_exe)

15
meson.options Normal file
View File

@ -0,0 +1,15 @@
# Copyright 2024 <lhearachel@proton.me>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
option('native', type: 'boolean', value: true)