Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Simplify iniparser import #2883

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions jni/prepare_iniparser.sh

This file was deleted.

47 changes: 13 additions & 34 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('nntrainer', 'c', 'cpp',
version: '0.5.0',
license: ['apache-2.0'],
meson_version: '>=0.50.0',
meson_version: '>=0.55.0',
default_options: [
'werror=true',
'warning_level=1',
Expand Down Expand Up @@ -346,39 +346,18 @@ libm_dep = cxx.find_library('m') # cmath library
libdl_dep = cxx.find_library('dl') # DL library
thread_dep = dependency('threads') # pthread for tensorflow-lite

iniparser_dep = dependency('iniparser', required : false, version : '>=4.1') # iniparser
if get_option('platform') == 'android'
message('preparing iniparser')
run_command(meson.source_root() / 'jni' / 'prepare_iniparser.sh', meson.build_root(), check: true)
iniparser_root = meson.build_root() / 'iniparser'
iniparser_dep = declare_dependency(include_directories: [ 'iniparser/src' ])
endif

if not iniparser_dep.found()
message('falling back to find libiniparser library and header files')
libiniparser_dep = cxx.find_library('iniparser')
sysroot = run_command(
cxx.cmd_array() + ['-print-sysroot']
).stdout().split('\n')[0]

if sysroot.startswith('/')
sysroot_inc_cflags_template = '-I@0@/usr/include@1@'
sysroot_inc = sysroot_inc_cflags_template.format(sysroot, '')
add_project_arguments(sysroot_inc, language: ['c', 'cpp'])
sysroot_inc_cflags_iniparser = sysroot_inc_cflags_template.format(sysroot,
'/iniparser')
else
sysroot_inc_cflags_iniparser = '-I/usr/include/iniparser'
endif

if libiniparser_dep.found() and cxx.has_header('iniparser.h', \
args : sysroot_inc_cflags_iniparser)
iniparser_dep = declare_dependency (dependencies : libiniparser_dep,
compile_args : sysroot_inc_cflags_iniparser)
else
error('Failed to resolve dependency on iniparser')
endif
endif
# CMake module
cmake = import('cmake')

# iniparser
iniparser_root = meson.source_root() / 'subprojects' / 'iniparser'
iniparser_options = cmake.subproject_options()
iniparser_options.add_cmake_defines({'BUILD_DOCS': false})
iniparser_options.add_cmake_defines({'BUILD_EXAMPLES': false})
iniparser_options.add_cmake_defines({'BUILD_TESTING': false})
iniparser_options.add_cmake_defines({'BUILD_SHARED_LIBS': false})
iniparser_subproject = cmake.subproject('iniparser', options: iniparser_options, required: true)
iniparser_dep = iniparser_subproject.dependency('iniparser-static')

if get_option('platform') == 'android'
message('preparing ml api')
Expand Down
4 changes: 4 additions & 0 deletions subprojects/iniparser.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[wrap-git]
url = https://github.com/ndevilla/iniparser.git
directory=iniparser
revision = v4.2.4
Loading