Skip to content

Commit

Permalink
Merge 476d195 into 4e11361
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch authored Feb 18, 2017
2 parents 4e11361 + 476d195 commit 8b95129
Show file tree
Hide file tree
Showing 11 changed files with 438 additions and 79 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
*.jl.cov
*.jl.mem
deps/x86*
deps/x86*
*.dll
deps/deps.jl
deps/DevIL.lib
deps/ILU.lib
deps/ILUT.lib
deps/downloads/
deps/include/
deps/unicode/
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
language: julia
sudo: required
os:
- linux
- osx
julia:
- release
- nightly
- 0.5
notifications:
email: false
# uncomment the following lines to override the default test script
#script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.build("DevIL"); Pkg.test("DevIL"; coverage=true)'
after_success:
# push coverage results to Coveralls
- julia -e 'cd(Pkg.dir("DevIL")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("DevIL")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[![Coverage Status](https://coveralls.io/repos/github/JuliaGL/DevIL.jl/badge.svg)](https://coveralls.io/github/JuliaGL/DevIL.jl)
[![codecov](https://codecov.io/gh/JuliaGL/DevIL.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaGL/DevIL.jl)


[![Build Status](https://travis-ci.org/JuliaGL/DevIL.jl.svg?branch=master)](https://travis-ci.org/JuliaGL/DevIL.jl)
[![Build status](https://ci.appveyor.com/api/projects/status/jxwo3cbl0lroxewc/branch/master?svg=true)](https://ci.appveyor.com/project/SimonDanisch/devil-jl/branch/master)

# DevIL

DevIL / OpenIL binding for Julia
Expand All @@ -8,7 +15,7 @@ Currently only IL is bound, ILU and ILUT are not.

## Usage

For usage information & documentation please visit
For usage information & documentation please visit
http://openil.sourceforge.net/

## Essentials
Expand Down
8 changes: 6 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
julia 0.5-

julia 0.5
FixedPointNumbers
ColorTypes
ImageCore
BinDeps
@osx Homebrew
31 changes: 31 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
environment:
matrix:
- JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"

branches:
only:
- master
- /release-.*/

notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: false

install:
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$("http://s3.amazonaws.com/"+$env:JULIAVERSION),
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"DevIL\"); Pkg.build(\"DevIL\")"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"DevIL\")"
56 changes: 35 additions & 21 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
using BinDeps
@BinDeps.setup
libnames = ["devil", "libdevil1c2", "libdevil-dev", "DevIL", "libIL", "libIL.so.1"]
libdevil = library_dependency("libdevil", aliases = libnames)

# get library through Homebrew, if available
@static if is_apple()
if Pkg.installed("Homebrew") == nothing
error("Homebrew package not installed, please run Pkg.add(\"Homebrew\")")
end
using Homebrew
provides(Homebrew.HB, "devil", libdevil, os = :Darwin)
end

# download a pre-compiled binary (built by GLFW)
@static if is_windows()
ts = Int(floor(time()))
if Sys.ARCH == :x86_64
# 64-bit version is not available in an end-user package, so we download the SDK
srcUrl = "http://downloads.sourceforge.net/project/openil/DevIL%20Windows%20SDK/1.7.8/DevIL-SDK-x64-1.7.8.zip?r=&ts=$ts&use_mirror=auto_select"
fileName = "DevIL-SDK-x64-1.7.8.zip"
elseif Sys.ARCH == :x86
srcUrl = "http://downloads.sourceforge.net/project/openil/DevIL%20Win32/1.7.8/DevIL-EndUser-x86-1.7.8.zip?r=&ts=$ts&use_mirror=auto_select"
fileName = "DevIL-EndUser-x86-1.7.8.zip"
else
error("DevIL: Unsupported Windows architecture")
end

dstDir = Pkg.dir("DevIL", "deps", string(Sys.ARCH))
if (!isdir(dstDir))
mkdir(dstDir)
end
dstFile = dstDir * "\\" * fileName
download(srcUrl, dstFile)
run(`"$JULIA_HOME\\7z.exe" e "$dstFile" *.dll -o"$dstDir" -y`)
rm(dstFile)
ts = floor(Int, time())
url = if Sys.ARCH == :x86_64
# 64-bit version is not available in an end-user package, so we download the SDK
"http://downloads.sourceforge.net/project/openil/DevIL%20Windows%20SDK/1.7.8/DevIL-SDK-x64-1.7.8.zip?r=&ts=$ts&use_mirror=auto_select"
elseif Sys.ARCH == :x86
"http://downloads.sourceforge.net/project/openil/DevIL%20Win32/1.7.8/DevIL-EndUser-x86-1.7.8.zip?r=&ts=$ts&use_mirror=auto_select"
else
error("DevIL: Unsupported Windows architecture: $(Sys.ARCH)")
end
archive = "unicode"
libpath = ""
uri = URI(url)
provides(Binaries, uri, libdevil, unpacked_dir = archive, installed_libpath = libpath, os = :Windows)
end

@static if is_linux()
run(`sudo apt-get install libdevil1c2`)
provides(AptGet, "libdevil-dev", libdevil)
provides(Pacman, "libdevil-dev", libdevil)
provides(Yum, "DevIL", libdevil)
end

function main()
@BinDeps.install Dict("libdevil" => "libdevil")
end
main() # move in function to get better stack traces
25 changes: 15 additions & 10 deletions src/DevIL.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
__precompile__()

module DevIL

const libIL = Libdl.find_library(["libIL", "DevIL"],
["/usr/lib/x86_64-linux-gnu", Pkg.dir("DevIL", "deps", string(Sys.ARCH))])
using FixedPointNumbers, ColorTypes

include(joinpath("..", "deps", "deps.jl"))
# Stolen from getCFun macro
macro ilFunc(cFun)
arguments = map(function (arg)
if isa(arg, Symbol)
arg = Expr(:(::), arg)
end
return arg
end, cFun.args[1].args[2:end])
arguments = map(cFun.args[1].args[2:end]) do arg
if isa(arg, Symbol)
arg = Expr(:(::), arg)
end
return arg
end

# Get info out of arguments of `cFun`
argumentNames = map(arg->arg.args[1], arguments)
Expand All @@ -22,7 +21,7 @@ macro ilFunc(cFun)
# Construct the result.
cName = cFun.args[1].args[1]
cSym = Expr(:quote, cName)
symAndLib = :($cSym, $libIL)
symAndLib = :($cSym, libdevil)

body = Expr(:ccall, symAndLib, returnType, Expr(:tuple, inputTypes...), argumentNames...)
func = Expr(:function, Expr(:call, cName, argumentNames...), body)
Expand All @@ -41,5 +40,11 @@ macro ilConst(assignment)
end

include("IL.jl")
include("fileio.jl")

function __init__()
ilInit()
atexit(ilShutDown)
end

end # module
77 changes: 42 additions & 35 deletions src/IL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ typealias ILclampd Cdouble
typealias ILint64 Int64
typealias ILuint64 UInt64

typealias ILchar Cchar
typealias ILstring Ptr{Cchar}
typealias ILconst_string Ptr{Cchar}
if is_windows()
typealias ILchar Cwchar_t
typealias ILstring Cwstring
typealias ILconst_string Cwstring
else
typealias ILchar Cchar
typealias ILstring Cstring
typealias ILconst_string Cstring
end

export ILenum, ILboolean, ILbitfield, ILbyte, ILshort, ILint, ILsizei, ILubyte, ILushort, ILuint, ILfloat, ILclampf, ILdouble, ILclampd, ILint64, ILuint64, ILchar, ILstring, ILconst_string

Expand All @@ -28,7 +34,7 @@ export ILenum, ILboolean, ILbitfield, ILbyte, ILshort, ILint, ILsizei, ILubyte,
#! Data formats \link Formats Formats\endlink
@ilConst IL_COLOUR_INDEX = 0x1900
@ilConst IL_COLOR_INDEX = 0x1900
@ilConst IL_ALPHA = 0x1906
@ilConst IL_ALPHA = 0x1906
@ilConst IL_RGB = 0x1907
@ilConst IL_RGBA = 0x1908
@ilConst IL_BGR = 0x80E0
Expand Down Expand Up @@ -150,36 +156,37 @@ export ILenum, ILboolean, ILbitfield, ILbyte, ILshort, ILint, ILsizei, ILubyte,


# Error Types
@ilConst IL_NO_ERROR = 0x0000
@ilConst IL_INVALID_ENUM = 0x0501
@ilConst IL_OUT_OF_MEMORY = 0x0502
@ilConst IL_FORMAT_NOT_SUPPORTED = 0x0503
@ilConst IL_INTERNAL_ERROR = 0x0504
@ilConst IL_INVALID_VALUE = 0x0505
@ilConst IL_ILLEGAL_OPERATION = 0x0506
@ilConst IL_ILLEGAL_FILE_VALUE = 0x0507
@ilConst IL_INVALID_FILE_HEADER = 0x0508
@ilConst IL_INVALID_PARAM = 0x0509
@ilConst IL_COULD_NOT_OPEN_FILE = 0x050A
@ilConst IL_INVALID_EXTENSION = 0x050B
@ilConst IL_FILE_ALREADY_EXISTS = 0x050C
@ilConst IL_OUT_FORMAT_SAME = 0x050D
@ilConst IL_STACK_OVERFLOW = 0x050E
@ilConst IL_STACK_UNDERFLOW = 0x050F
@ilConst IL_INVALID_CONVERSION = 0x0510
@ilConst IL_BAD_DIMENSIONS = 0x0511
@ilConst IL_FILE_READ_ERROR = 0x0512 # 05/12/2002: Addition by Sam.
@ilConst IL_FILE_WRITE_ERROR = 0x0512

@ilConst IL_LIB_GIF_ERROR = 0x05E1
@ilConst IL_LIB_JPEG_ERROR = 0x05E2
@ilConst IL_LIB_PNG_ERROR = 0x05E3
@ilConst IL_LIB_TIFF_ERROR = 0x05E4
@ilConst IL_LIB_MNG_ERROR = 0x05E5
@ilConst IL_LIB_JP2_ERROR = 0x05E6
@ilConst IL_LIB_EXR_ERROR = 0x05E7
@ilConst IL_UNKNOWN_ERROR = 0x05FF

@enum(ILerror,
IL_NO_ERROR = 0x0000,
IL_INVALID_ENUM = 0x0501,
IL_OUT_OF_MEMORY = 0x0502,
IL_FORMAT_NOT_SUPPORTED = 0x0503,
IL_INTERNAL_ERROR = 0x0504,
IL_INVALID_VALUE = 0x0505,
IL_ILLEGAL_OPERATION = 0x0506,
IL_ILLEGAL_FILE_VALUE = 0x0507,
IL_INVALID_FILE_HEADER = 0x0508,
IL_INVALID_PARAM = 0x0509,
IL_COULD_NOT_OPEN_FILE = 0x050A,
IL_INVALID_EXTENSION = 0x050B,
IL_FILE_ALREADY_EXISTS = 0x050C,
IL_OUT_FORMAT_SAME = 0x050D,
IL_STACK_OVERFLOW = 0x050E,
IL_STACK_UNDERFLOW = 0x050F,
IL_INVALID_CONVERSION = 0x0510,
IL_BAD_DIMENSIONS = 0x0511,
IL_FILE_READ_WRITE_ERROR= 0x0512, # 05/12/2002: Addition by Sam.
#IL_FILE_WRITE_ERROR = 0x0512,

IL_LIB_GIF_ERROR = 0x05E1,
IL_LIB_JPEG_ERROR = 0x05E2,
IL_LIB_PNG_ERROR = 0x05E3,
IL_LIB_TIFF_ERROR = 0x05E4,
IL_LIB_MNG_ERROR = 0x05E5,
IL_LIB_JP2_ERROR = 0x05E6,
IL_LIB_EXR_ERROR = 0x05E7,
IL_UNKNOWN_ERROR = 0x05FF
)

# Origin Definitions
@ilConst IL_ORIGIN_SET = 0x0600
Expand Down Expand Up @@ -416,7 +423,7 @@ IL_SAVEPROC(f::Function) = cfunction(f, ILenum, (ILconst_string,))
@ilFunc ilGetBooleanv(Mode::ILenum, Param::Ptr{ILboolean})::Void
@ilFunc ilGetData()::Ptr{ILubyte}
@ilFunc ilGetDXTCData(Buffer::Ptr{Void}, BufferSize::ILuint, DXTCFormat::ILenum)::ILuint
@ilFunc ilGetError()::ILenum
@ilFunc ilGetError()::ILerror
@ilFunc ilGetInteger(Mode::ILenum)::ILint
@ilFunc ilGetIntegerv(Mode::ILenum, Param::Ptr{ILint})::Void
@ilFunc ilGetLumpPos()::ILuint
Expand Down
Loading

0 comments on commit 8b95129

Please sign in to comment.