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

Implement FileIO API #1

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cf5a820
include precompile
SimonDanisch Sep 25, 2015
b8971ef
use bindeps for unix
SimonDanisch Sep 25, 2015
40c74f6
better travis
SimonDanisch Sep 25, 2015
4c94226
fix undefined BinDeps
SimonDanisch Sep 25, 2015
284eda2
didn't save
SimonDanisch Sep 25, 2015
6681507
add homebrew deps
SimonDanisch Sep 25, 2015
890b2b3
refined build for linux
SimonDanisch Sep 26, 2015
cf1b76f
add appveyor
SimonDanisch Sep 26, 2015
046e5be
more debug info
SimonDanisch Sep 26, 2015
76d6365
make test fail if build fails
SimonDanisch Sep 26, 2015
d8d970a
use WORD_SIZE instead of Sys.ARCH
SimonDanisch Sep 26, 2015
843f76a
try out better build
SimonDanisch Sep 26, 2015
7111686
enable sudo for linux
SimonDanisch Sep 26, 2015
77fb9fa
use ZipFile for decompression
SimonDanisch Sep 26, 2015
557a01e
clean up build
SimonDanisch Feb 1, 2017
34d9ef5
update to 0.5
SimonDanisch Feb 1, 2017
fdd0a45
use bindeps all the way
SimonDanisch Feb 1, 2017
854764b
disrespect windows 32
SimonDanisch Feb 1, 2017
9602de9
try this hack for stack traces
SimonDanisch Feb 1, 2017
1c9256f
implement fileio interface
SimonDanisch Feb 2, 2017
1841981
correct order
SimonDanisch Feb 2, 2017
73360f9
fix build
SimonDanisch Feb 2, 2017
f9d06c5
fix bindeps
SimonDanisch Feb 2, 2017
93bcd1a
try other name
SimonDanisch Feb 2, 2017
2f633cc
fix tests
SimonDanisch Feb 2, 2017
c0bfd40
add badges
SimonDanisch Feb 2, 2017
6858b06
0.6 is a hot mess right now
SimonDanisch Feb 2, 2017
79d7214
added save
SimonDanisch Feb 2, 2017
03d3def
make tests pass
SimonDanisch Feb 3, 2017
198f5bd
remove try catch
SimonDanisch Feb 3, 2017
36127f5
fix windows
SimonDanisch Feb 17, 2017
476d195
try this
SimonDanisch Feb 18, 2017
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
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