# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

CRATES="
adler-0.2.3
adler32-1.2.0
ahash-0.3.8
aho-corasick-0.7.15
ammonia-3.1.0
ansi_term-0.11.0
arrayvec-0.5.2
assert-json-diff-1.1.0
atty-0.2.14
autocfg-1.0.1
base64-0.13.0
bincode-1.3.1
bitflags-1.2.1
block-buffer-0.7.3
block-buffer-0.9.0
block-padding-0.1.5
bstr-0.2.14
bumpalo-3.4.0
byte-tools-0.3.1
bytecount-0.3.2
bytecount-0.6.2
bytemuck-1.4.1
byteorder-1.4.2
bytes-0.4.12
bytes-1.0.0
cc-1.0.66
cedarwood-0.4.4
cfg-if-0.1.10
cfg-if-1.0.0
chrono-0.4.19
chrono-tz-0.5.3
clap-2.33.3
color_quant-1.1.0
colored-1.9.3
const_fn-0.4.5
core-foundation-0.9.1
core-foundation-sys-0.8.2
cpuid-bool-0.1.2
crc32fast-1.2.1
crossbeam-channel-0.5.0
crossbeam-deque-0.8.0
crossbeam-epoch-0.9.1
crossbeam-utils-0.8.1
csv-1.1.5
csv-core-0.1.10
ctrlc-3.1.7
deflate-0.8.6
deunicode-0.4.3
difference-2.0.0
digest-0.8.1
digest-0.9.0
doc-comment-0.3.3
dtoa-0.4.7
either-1.6.1
elasticlunr-rs-2.3.9
encoding-0.2.33
encoding-index-japanese-1.20141219.5
encoding-index-korean-1.20141219.5
encoding-index-simpchinese-1.20141219.5
encoding-index-singlebyte-1.20141219.5
encoding-index-tradchinese-1.20141219.5
encoding_index_tests-0.1.4
encoding_rs-0.8.26
extend-0.1.2
fake-simd-0.1.2
filetime-0.2.13
flate2-1.0.19
fnv-1.0.7
foreign-types-0.3.2
foreign-types-shared-0.1.1
form_urlencoded-1.0.0
fsevent-0.4.0
fsevent-sys-2.0.1
fuchsia-zircon-0.3.3
fuchsia-zircon-sys-0.3.3
futf-0.1.4
futures-channel-0.3.9
futures-core-0.3.9
futures-io-0.3.9
futures-macro-0.3.9
futures-sink-0.3.9
futures-task-0.3.9
futures-util-0.3.9
generic-array-0.12.3
generic-array-0.14.4
getrandom-0.1.16
getrandom-0.2.1
gh-emoji-1.0.3
gif-0.11.1
glob-0.3.0
globset-0.4.6
globwalk-0.8.1
h2-0.3.0
hashbrown-0.8.2
heck-0.3.2
hermit-abi-0.1.17
html5ever-0.25.1
http-0.2.3
http-body-0.4.0
httparse-1.3.4
httpdate-0.3.2
humansize-1.1.0
hyper-0.14.2
hyper-tls-0.5.0
idna-0.2.0
ignore-0.4.17
image-0.23.12
indexmap-1.5.2
inotify-0.7.1
inotify-sys-0.1.4
iovec-0.1.4
ipnet-2.3.0
itoa-0.4.7
jieba-rs-0.5.1
jpeg-decoder-0.1.20
js-sys-0.3.46
kernel32-sys-0.2.2
lazy_static-1.4.0
lazycell-1.3.0
levenshtein_automata-0.1.1
lexical-core-0.7.4
libc-0.2.82
lindera-0.3.5
lindera-core-0.3.3
lindera-dictionary-0.3.3
lindera-fst-0.1.1
lindera-ipadic-0.3.3
line-wrap-0.1.1
linked-hash-map-0.5.4
log-0.4.11
mac-0.1.1
maplit-1.0.2
markup5ever-0.10.0
markup5ever_rcdom-0.1.0
matches-0.1.8
memchr-2.3.4
memoffset-0.6.1
mime-0.3.16
minify-html-0.4.1
miniz_oxide-0.3.7
miniz_oxide-0.4.3
mio-0.6.23
mio-0.7.7
mio-extras-2.0.6
miow-0.2.2
miow-0.3.6
mockito-0.28.0
native-tls-0.2.7
net2-0.2.37
new_debug_unreachable-1.0.4
nix-0.18.0
nom-5.1.2
nom-bibtex-0.3.0
nom-tracable-0.5.2
nom-tracable-macros-0.5.2
nom_locate-1.0.0
nom_locate-2.1.0
notify-4.0.15
ntapi-0.3.6
num-integer-0.1.44
num-iter-0.1.42
num-rational-0.3.2
num-traits-0.2.14
num_cpus-1.13.0
once_cell-1.5.2
onig-6.1.1
onig_sys-69.6.0
opaque-debug-0.2.3
opaque-debug-0.3.0
open-1.4.0
openssl-0.10.33
openssl-probe-0.1.2
openssl-sys-0.9.61
parse-zoneinfo-0.3.0
percent-encoding-2.1.0
pest-2.1.3
pest_derive-2.1.0
pest_generator-2.1.3
pest_meta-2.1.3
phf-0.8.0
phf_codegen-0.8.0
phf_generator-0.8.0
phf_shared-0.8.0
pin-project-0.4.27
pin-project-1.0.3
pin-project-internal-0.4.27
pin-project-internal-1.0.3
pin-project-lite-0.2.2
pin-utils-0.1.0
pkg-config-0.3.19
plist-1.0.1
png-0.16.8
ppv-lite86-0.2.10
precomputed-hash-0.1.1
proc-macro-error-1.0.4
proc-macro-error-attr-1.0.4
proc-macro-hack-0.5.19
proc-macro-nested-0.1.6
proc-macro2-1.0.24
pulldown-cmark-0.8.0
quick-error-1.2.3
quote-1.0.8
rand-0.7.3
rand-0.8.1
rand_chacha-0.2.2
rand_chacha-0.3.0
rand_core-0.5.1
rand_core-0.6.1
rand_hc-0.2.0
rand_hc-0.3.0
rand_pcg-0.2.1
rayon-1.5.0
rayon-core-1.9.0
redox_syscall-0.1.57
regex-1.4.3
regex-automata-0.1.9
regex-syntax-0.4.2
regex-syntax-0.6.22
relative-path-1.3.2
remove_dir_all-0.5.3
reqwest-0.11.0
roxmltree-0.13.1
rust-stemmers-1.2.0
ryu-1.0.5
safemem-0.3.3
same-file-1.0.6
sass-rs-0.2.2
sass-sys-0.4.21
schannel-0.1.19
scoped_threadpool-0.1.9
scopeguard-1.1.0
sct-0.6.0
security-framework-2.2.0
security-framework-sys-2.2.0
serde-1.0.118
serde_derive-1.0.118
serde_json-1.0.61
serde_urlencoded-0.6.1
serde_urlencoded-0.7.0
serde_yaml-0.8.15
sha-1-0.8.2
sha2-0.9.2
siphasher-0.3.3
slab-0.4.2
slotmap-0.4.0
slug-0.1.4
smallvec-1.6.1
socket2-0.3.19
spin-0.5.2
static_assertions-1.1.0
string_cache-0.8.1
string_cache_codegen-0.5.1
strsim-0.8.0
strum-0.18.0
strum_macros-0.18.0
svg_metadata-0.4.2
syn-1.0.58
syntect-4.5.0
tempfile-3.1.0
tendril-0.4.2
tera-1.6.1
termcolor-1.1.2
test-case-1.0.1
textwrap-0.11.0
thread_local-1.1.0
tiff-0.6.1
time-0.1.43
tinyvec-1.1.0
tinyvec_macros-0.1.0
tokio-1.0.1
tokio-native-tls-0.3.0
tokio-stream-0.1.1
tokio-util-0.6.0
toml-0.5.8
tower-service-0.3.0
tracing-0.1.22
tracing-core-0.1.17
tracing-futures-0.2.4
try-lock-0.2.3
typenum-1.12.0
ucd-trie-0.1.3
unic-char-property-0.9.0
unic-char-range-0.9.0
unic-common-0.9.0
unic-segment-0.9.0
unic-ucd-segment-0.9.0
unic-ucd-version-0.9.0
unicase-2.6.0
unicode-bidi-0.3.4
unicode-normalization-0.1.16
unicode-segmentation-1.7.1
unicode-width-0.1.8
unicode-xid-0.2.1
untrusted-0.7.1
url-2.2.0
utf-8-0.7.5
utf8-ranges-1.0.4
vcpkg-0.2.12
vec_map-0.8.2
version_check-0.9.2
walkdir-2.3.1
want-0.3.0
wasi-0.9.0+wasi-snapshot-preview1
wasi-0.10.1+wasi-snapshot-preview1
wasm-bindgen-0.2.69
wasm-bindgen-backend-0.2.69
wasm-bindgen-futures-0.4.19
wasm-bindgen-macro-0.2.69
wasm-bindgen-macro-support-0.2.69
wasm-bindgen-shared-0.2.69
web-sys-0.3.46
webpki-0.21.4
webpki-roots-0.21.0
weezl-0.1.3
winapi-0.2.8
winapi-0.3.9
winapi-build-0.1.1
winapi-i686-pc-windows-gnu-0.4.0
winapi-util-0.1.5
winapi-x86_64-pc-windows-gnu-0.4.0
winreg-0.7.0
ws-0.9.1
ws2_32-sys-0.2.1
xml-rs-0.8.3
xml5ever-0.16.1
xmlparser-0.13.3
yaml-rust-0.4.5
"

inherit cargo bash-completion-r1

DESCRIPTION="a fast static site generator in a single binary with everything built-in"
HOMEPAGE="https://www.getzola.org"
SRC_URI="https://github.com/getzola/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
	$(cargo_crate_uris ${CRATES})"

LICENSE="MIT"
SLOT="0"
KEYWORDS="amd64 ~arm64 ~ppc64 ~x86"
IUSE="libressl"

BDEPEND="
	>=virtual/rust-1.31.0
"

# sass-rs looks for the wrong .pc
# dev-libs/libsass:0=
RDEPEND="
	dev-libs/oniguruma:0=
	libressl? ( dev-libs/libressl:0= )
	!libressl? ( dev-libs/openssl:0= )
	sys-libs/zlib:0=
"

DEPEND="${RDEPEND}"

PATCHES=(
	"${FILESDIR}"/zola-0.13.0-dependencies.patch
)

src_prepare() {
	sed -i 's/rustls-tls/native-tls/' components/*/Cargo.toml || die

	default
}

src_compile() {
	export PKG_CONFIG_ALL_DYNAMIC=1
	export RUSTONIG_SYSTEM_LIBONIG=1

	cargo_src_compile
}