Skip to content

Commit

Permalink
Build libarchive with cmake if it can't be found
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Oct 19, 2020
1 parent 82e2359 commit 05f1f70
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
apt:
packages:
- ninja-build
- libarchive-dev
install:
- source ~/virtualenv/python3.6/bin/activate
- pip install meson
Expand All @@ -32,7 +31,7 @@ jobs:
packages:
- ninja
- llvm
- libarchive
- cmake
update: true
script:
- xcodebuild -project iSH.xcodeproj -scheme iSH -sdk iphoneos CODE_SIGNING_ALLOWED=NO
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ You'll need these things to build the project:
- Meson (`pip install meson`)
- Clang and LLD (on mac, `brew install llvm`, on linux, `sudo apt install clang lld` or `sudo pacman -S clang lld` or whatever)
- sqlite3 (this is so common it may already be installed on linux and is definitely already installed on mac. if not, do something like `sudo apt install libsqlite3-dev`)
- Either libarchive (from your package manager) or cmake (to build a bundled libarchive)

## Build for iOS

Expand Down
14 changes: 14 additions & 0 deletions deps/script/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
libarchive = dependency('libarchive', method: 'pkg-config', required: false)
if not libarchive.found()
# try homebrew
libarchive_lib = cc.find_library('libarchive', dirs: ['/usr/local/opt/libarchive/lib'], required: false)
if libarchive_lib.found()
libarchive = declare_dependency(dependencies: [libarchive_lib], include_directories: include_directories(['/usr/local/opt/libarchive/include']))
endif
endif
if not libarchive.found()
warning('no system libarchive found, building with cmake')
cmake = import('cmake')
libarchive = cmake.subproject('libarchive').dependency('archive_static')
endif

4 changes: 3 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
project('ish', 'c',
default_options: ['default_library=static', 'c_std=gnu11', 'warning_level=2'])
default_options: ['default_library=static', 'c_std=gnu11', 'warning_level=2'],
subproject_dir: 'deps')
cc = meson.get_compiler('c')

if cc.get_id() == 'clang'
Expand Down Expand Up @@ -34,6 +35,7 @@ threads = dependency('threads')
librt = cc.find_library('rt', required: false)
libm = cc.find_library('m', required: false)
sqlite3 = cc.find_library('sqlite3')
subdir('deps/script')

dependencies = [librt, libm, threads, sqlite3]

Expand Down
21 changes: 5 additions & 16 deletions tools/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,8 @@ if unicorn.found()
configure_file(input: 'ptraceomatic-gdb.gdb', output: 'unicornomatic-gdb.gdb', copy: true)
endif

libarchive = dependency('libarchive', required: false)
if not libarchive.found()
# homebrew
libarchive_lib = cc.find_library('libarchive', dirs: ['/usr/local/opt/libarchive/lib'], required: false)
if libarchive_lib.found()
libarchive = declare_dependency(dependencies: [libarchive_lib], include_directories: include_directories(['/usr/local/opt/libarchive/include']))
endif
endif

if libarchive.found()
fakefsify = executable('fakefsify', ['fakefsify.c', 'fakefs.c'], dependencies: [ish, libarchive])
custom_target('unfakefsify',
build_by_default: true,
command: ['ln', '-sf', 'fakefsify', '@OUTPUT@'],
output: 'unfakefsify')
endif
fakefsify = executable('fakefsify', ['fakefsify.c', 'fakefs.c'], dependencies: [ish, libarchive])
custom_target('unfakefsify',
build_by_default: true,
command: ['ln', '-sf', 'fakefsify', '@OUTPUT@'],
output: 'unfakefsify')

0 comments on commit 05f1f70

Please sign in to comment.