Commit Graph

50 Commits

Author SHA1 Message Date
0b174a7e8a Remove Windows-specific invocation of MagickCore-config 2024-09-18 11:16:29 +08:00
b92bed025f Add pkg-config as fallback for MagickCore-config
Fixes nlfiedler/magick-rust#131
2024-08-26 12:59:06 +10:00
2377d7b872 Prevent using the bash command when using MSVC
This is to prevent a nasty issue where on fresh installations of Windows, the `bash` command returns with success and prints a prompt to install WSL, which gets mistaken for MagickCore-config output.
2024-07-24 22:34:38 +08:00
6a84932ffe Rewrite of bindgen ParseCallbacks 2024-07-24 21:46:17 +08:00
3b1b7a502e Added Eq to enums 2024-07-24 21:45:40 +08:00
e7e7f5eb87 Fix linking errors by including MagickCore as well 2024-07-24 21:20:55 +08:00
7494c1d174 Redesign types module
Now we are using more functionality given to us by rust-bindgen instead of maintaining enum mappings ourselves:
* Rustified enums can be generated automatically by using the EnumVariation::Rust style in rust-bindgen
* Redundant suffixes can be removed through implementing ParseCallbacks::enum_variant_name
* The redundant FromRust trait was removed and replaced with the standard From and Into traits
2024-07-24 19:32:32 +08:00
d50f01b49f build: requires ImageMagick 7.1.1-26
With the addition of the OffIfOpaque alpha channel option, this crate now
requires ImageMagick 7.1.1-26 or later. However, the build.rs cannot specify
the -26 so 7.1.1 is as specific as it gets for now.

cargo test passes
2024-07-04 10:03:20 -07:00
9262b51d62 chore: add copyright headers everywhere 2024-05-25 11:20:27 -07:00
a72253ed25 Directly link to MSYS2's .dll.a files 2023-11-29 16:07:26 +08:00
168abe5547 Support build on MSYS2 2023-11-29 12:15:11 +08:00
8edd324f0b Use C++ compiler on Windows if needed 2023-11-08 16:49:49 +08:00
ef1867e9f9 chore: fix some clippy warnings 2023-09-17 14:45:35 -07:00
08fb952056 fix: builds on FreeBSD once again
The resource limis feature seems to be available only on certain platforms,
so the set_resource_limit() function and its test are enabled only on the
platforms that are known to be supported (linux and macos).

cargo test passes
2023-01-28 21:59:56 -08:00
409a583b22 feat: std error compatible error 2021-12-25 02:49:43 +08:00
8f9526e5ae chore: update dependencies and bindgen usage
cargo test passes
2021-06-28 18:27:27 -07:00
c65027800d Update imagemmagick checks to support 7.1
On Arch Linux, imagemagick is currently at 7.1.0. I tried increasing the
max version and the version used in the Dockerfile to 7.1 and it appears
to compile and tests pass. Version used for local testing:

```
Linux 5.12.12-arch1-1 #1 SMP PREEMPT Fri, 18 Jun 2021 21:59:22 +0000 x86_64 GNU/Linux

Version: ImageMagick 7.1.0-1 Q16 x86_64 2021-06-21 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib cairo djvu fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png raqm raw rsvg tiff webp wmf x xml zip zlib
```
2021-06-28 14:14:35 -07:00
9422825322 fix: in Rust 1.51 panic! takes only string literals
Seems that Rust 2021 will require that panic! macro takes only a string
literal, so format! and variables are out.

cargo test passes
2021-03-27 11:22:50 -07:00
480421aa65 fix path_separator on windows can not build 2021-03-11 14:25:32 +08:00
d82484e7de Set environment variable with magickcore config flags 2020-10-11 13:18:19 -05:00
e387f40bf0 Add quantum depth 2020-10-10 17:46:38 -05:00
43edd76429 Update to latest bindgen release
The behavior around size_t changed so added a flag to temporarily avoid the
issue until it becomes a real problem later on.

cargo test passes
2020-05-21 08:17:08 -07:00
92b12900ab fix multiple redefined values on linux build
841  | pub const FP_ZERO: u32 = 2;
     | --------------------------- previous definition of the value `FP_ZERO` here
...
8117 | pub const FP_ZERO: _bindgen_ty_2 = 2;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `FP_ZERO` redefined here

Signed-off-by: Nikola Pajkovsky <nikola.pajkovsky@livesporttv.cz>
2020-05-21 11:42:08 +02:00
f286c631b9 Format code using 'cargo fmt' 2019-08-17 21:48:01 +05:30
bd34f145a2 Ran cargo fmt on the code base, looks better
cargo test passes
2018-10-06 15:38:33 -07:00
8a4fced836 Update to latest release of bindgen
Note that all of the enum definitions changed (again?), and now they are
flattened into the 'bindings' namespace. This breaks the API in a way that
is relatively easy to fix, albeit annoying. Attempts to change the enum
generation using default_enum_style() resulted in endless compiler errors.

cargo test passes
2018-10-06 15:37:41 -07:00
9b780bc5f1 Hide more types to fix build (#29) 2017-12-22 21:49:32 +02:00
c2e519f19f Some tidying up 2017-10-08 17:10:56 -07:00
66a2f0cef4 Parametrize build via environment variables
build.rs now recognizes next environment variables:
IMAGE_MAGICK_DIR - installation directory
IMAGE_MAGICK_LIB_DIRS - list of lib dirs split by ":"
IMAGE_MAGICK_INCLUDE_DIRS - list of include dirs split by ":"
IMAGE_MAGICK_LIBS - list of the libs to link to
IMAGE_MAGICK_STATIC - if set to value other than 0, link statically
2017-10-06 20:24:51 +03:00
e5a5472b1e update build.rs 2017-08-19 16:01:51 +07:00
14f78e3734 Fix pkg-config invocation in build.rs
It seems that pkg-config ignores the --max-version option when combined with
certain other options. As such, that check was not really working. Since the
pkg-config Rust crate always passes those certain other options, it is
necessary to invoke the pkg-config command directly from build.rs instead.

cargo test passes
2017-07-10 21:32:59 -07:00
acabbafa08 Downgrade rust-bindgen to 0.25.5
There is an issue when building on Linux when using 0.26.0 or higher, so
keep to a version that still works on Mac and Linux.

cargo test passes
2017-07-08 21:30:42 -07:00
1436145cb5 Tag new release with small API addition
Also, update bindgen version and format some of the comments and
documentation.

cargo test passes
2017-07-07 20:38:01 -07:00
d39972da88 Split the pkg-config version and flags checks
Apparently, on RHEL 6.7, pkg-config doesn't let you check versions and
output flags in the same command run.
2017-04-10 08:13:36 -06:00
e7054d3e35 Use the rust-bindgen crate properly
Using the changes from @gadomski along with some additional work, to get the
generated bindings working again. Works on macOS and FreeBSD 11. A couple of
hacks are needed for FreeBSD, but nothing too serious.

Changed to use the libc prefix, and changed to use the generated enums.

Fixes #22, #15, and #14

cargo test passes
2017-04-08 16:03:58 -07:00
4507d07c9c Update to the bingen crate 2017-04-07 06:24:00 -06:00
b22e97c908 Hack the MagickWand bindings
Using rust-bindgen to generate the bindings for the MagickWand library is
extremely difficult with the new versions of rust-bindgen. The old versions
of the generated bindings will be used for now, and nothing will be
generated at build time.

cargo test passes
2017-04-06 19:58:58 -07:00
2eccf1e91b Ensure pkg-config present when generating bindings
Not all systems have pkg-config installed by default.

cargo test passes
2016-10-20 08:51:25 -07:00
b63f25c550 Enforce MagickWand version in build.rs
It is very easy to overlook the version of MagickWand mentioned in the
README, so make sure the build system enforces it.

Fixes #19

cargo test passes
2016-10-16 11:00:06 -07:00
dd4becddd7 Hack to get build working on FreeBSD again
Due to a bug in rust-bindgen, use the bindings as generated on the Mac
for the same version of MagickWand as found on FreeBSD. That is, when
build.rs is invoked on a FreeBSD system, it will use the Mac-generated
bindings.rs rather than pulling down rust-bindgen and invoking it to
generate the bindings on the fly. See issue #385 in the rust-bindgen
project for details.

cargo test passes
2016-09-20 20:03:28 -07:00
7563231707 Remove /usr/local/lib from rustc link search
If /usr/local/lib is in the search path, a Homebrew installed libJPEG
can end up conflicting with the system libJPEG as such:

```
$ otool -L /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
/System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO:
... snip ...
    /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib (compatibility version 1.0.0, current version 1.0.0)
... snip ...
```

```
$ cargo clean && cargo test
... snip ...
Doc-tests magick_rust
dyld: Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /usr/local/lib/libJPEG.dylib
 in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
```

Removing the /usr/local/lib link search path allows successful
compilation and testing on my OSX 10.11.6, with jpeg 8d installed into
/usr/local/lib via Homebrew. I realize this might be a problem with my
setup and not a universal issue, but as Homebrew is so common I thought
I'd submit this patch anyways.
2016-08-25 07:54:49 -06:00
eec7998d25 Use new rust-bindgen crate for faster builds
Rather than cloning the bindgen repository and building from source, use
the packaged crate. The result is the rebuilds are much, much faster.
Also, had to make numerous changes for the new version of bindgen.

cargo test passes
2016-08-14 21:23:05 -07:00
96071ca377 Use Result.expect() in the suitable cases 2016-07-14 19:12:27 -07:00
df6f812cf9 fix ldflags in build.rs 2016-05-17 22:18:17 +03:00
c08a093dc3 cross-compile support for build.rs 2016-05-16 18:57:06 +03:00
85a4b97b70 place generated files in OUT_DIR 2016-05-11 16:52:15 +03:00
3732fd5747 Report missing MagickWand-config in build.rs
Since build.rs requires MagickWand-config, make an effort to determine
if the executable is available or not, and panic with a clear course of
action. Otherwise the error is rather cryptic.

Fixes #3

cargo test passes
2016-03-23 18:00:52 -07:00
856a9e7c78 Handle building on macos a little better
First, only add the special environment variable when building on Mac OS
X. Second, look for the path to ensure the Xcode command line tools are
installed, and panic if that is not the case.

cargo test passes
2016-03-22 20:56:09 -07:00
04e1052266 Automatically build ImageMagick bindings
Leave the generated bindings out of the source repository and instead
have Cargo automatically build them if they are missing. This allows the
version of MagickWand to be incorporated into the bindings
automatically. For instance, in Homebrew the version is 6.Q16, while on
FreeBSD 10.2 it is 6.9, and only be generating the bindings for each
system can we ensure a smooth compilation process.
2016-01-25 19:58:43 -08:00
0474886c14 Include path to MagickWand for easier building 2015-12-23 11:34:51 -08:00