Skip to content

Commit c62cb57

Browse files
committed
1.0 Support
1 parent 06cfb1f commit c62cb57

28 files changed

+832
-857
lines changed

.travis.yml

+72-58
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,78 @@
1+
language: julia
2+
os:
3+
- linux
4+
- osx
5+
julia:
6+
- 0.7
7+
- 1.0
8+
- nightly
9+
matrix:
10+
allow_failures:
11+
- julia: nightly
12+
fast_finish: true
13+
notifications:
14+
email: false
115
sudo: false
216
addons:
3-
apt:
4-
sources:
5-
- ubuntu-toolchain-r-test
6-
- george-edison55-precise-backports
7-
packages:
8-
- cmake
9-
- cmake-data
10-
- gcc-6
11-
- g++-6
12-
- binutils
13-
- gfortran
14-
- libblas-dev
15-
- liblapack-dev
16-
- libgmp-dev
17-
- libmpfr-dev
18-
19-
matrix:
20-
include:
21-
- language: julia
22-
julia: 0.6
23-
os: linux
24-
- language: julia
25-
julia: nightly
26-
os: linux
27-
- language: julia
28-
julia: 0.6
29-
os: osx
30-
allow_failures:
31-
- language: julia
32-
julia: nightly
33-
os: linux
17+
apt:
18+
sources:
19+
- ubuntu-toolchain-r-test
20+
- george-edison55-precise-backports
21+
packages:
22+
- cmake
23+
- cmake-data
24+
- gcc-6
25+
- g++-6
26+
- binutils
27+
- gfortran
28+
- libblas-dev
29+
- liblapack-dev
30+
- libgmp-dev
31+
- libmpfr-dev
3432
cache:
35-
directories:
36-
- $(julia -e 'println(Pkg.dir())')/Cxx/deps/src
37-
- $(julia -e 'println(Pkg.dir())')/Cxx/deps/build
38-
- ~/usr
33+
directories:
34+
- $TRAVIS_BUILD_DIR/deps/src
35+
- $TRAVIS_BUILD_DIR/deps/build
36+
- ~/usr
3937
before_cache:
40-
- rm ~/.julia/0.5/Cxx/deps/build/bootstrap.o
41-
- rm -rf ~/.julia/0.5/deps/usr
42-
install:
43-
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="g++-6" CC="gcc-6"; fi
44-
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export CXX="clang++" CC="clang"; fi
45-
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then export PATH="$HOME/usr/bin:$PATH"; fi
46-
- export THE_PKG_DIR=`julia -e 'println(Pkg.dir())'`
38+
- rm $TRAVIS_BUILD_DIR/deps/build/bootstrap.o
39+
- rm -rf $TRAVIS_BUILD_DIR/deps/usr
40+
before_script:
41+
- |
42+
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
43+
export CXX="g++-6" CC="gcc-6"
44+
export PATH="$HOME/usr/bin:$PATH"
45+
else
46+
export CXX="clang++" CC="clang"
47+
fi
48+
- |
49+
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ ! -f $HOME/usr/bin/ld ]; then
50+
wget https://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.gz
51+
tar xzf binutils-2.27.tar.gz
52+
(cd binutils-2.27 && ./configure --prefix=$HOME/usr && make && make install)
53+
fi
54+
- mkdir -p $TRAVIS_BUILD_DIR/../Cxx-cache && cp -R $TRAVIS_BUILD_DIR $TRAVIS_BUILD_DIR/../Cxx-cache
55+
- julia -e 'using InteractiveUtils; versioninfo()'
4756
script:
48-
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ ! -f $HOME/usr/bin/ld ]; then
49-
wget https://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.gz;
50-
tar xzf binutils-2.27.tar.gz;
51-
(cd binutils-2.27 && ./configure --prefix=$HOME/usr && make && make install);
52-
fi;
53-
- julia -e 'versioninfo()'
54-
- mv $THE_PKG_DIR/Cxx $THE_PKG_DIR/Cxx-cache
55-
- julia -e 'Pkg.clone(pwd())'
56-
- mv $THE_PKG_DIR/Cxx-cache/deps/src $THE_PKG_DIR/Cxx/deps/src || true
57-
- mv $THE_PKG_DIR/Cxx-cache/deps/build $THE_PKG_DIR/Cxx/deps/build || true
58-
- if [ ! -f $HOME/early_abort ]; then PREBUILT_CI_BINARIES=1 julia -e 'Pkg.build("Cxx")' || false; fi
59-
- if [ ! -f $HOME/early_abort ]; then julia -e 'Pkg.test("Cxx"; coverage=true)' || false; fi
57+
- julia --project=. -e 'using Pkg; Pkg.instantiate()'
58+
- mv $TRAVIS_BUILD_DIR/../Cxx-cache/deps/src $TRAVIS_BUILD_DIR/deps/src || true
59+
- mv $TRAVIS_BUILD_DIR/../Cxx-cache/deps/build $TRAVIS_BUILD_DIR/deps/build || true
60+
- |
61+
if [ ! -f $HOME/early_abort ]; then
62+
PREBUILT_CI_BINARIES=1 julia --project=. -e 'using Pkg; Pkg.build()' || false
63+
fi
64+
- |
65+
if [ ! -f $HOME/early_abort ]; then
66+
julia --project=. -e 'Pkg.test(coverage=true)' || false
67+
fi
6068
after_success:
61-
- julia -e 'cd(Pkg.dir("Cxx")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
62-
- julia -e 'cd(Pkg.dir("Cxx")); Pkg.add("Documenter"); include(joinpath("docs", "make.jl"))'
63-
notifications:
64-
email: false
69+
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
70+
jobs:
71+
include:
72+
- stage: "Documentation"
73+
julia: 1.0
74+
os: linux
75+
script:
76+
- julia --project=docs/ -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd()))'
77+
- julia --project=docs/ docs/make.jl
78+
after_success: skip

Project.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name = "Cxx"
2+
uuid = "a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2"
3+
4+
[deps]
5+
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
6+
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
7+
8+
[extras]
9+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
10+
11+
[targets]
12+
test = ["Test"]

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ The Julia C++ Foreign Function Interface (FFI) and REPL.
1111

1212
### Installation
1313

14-
You will need to install Julia v0.6 (or later).
15-
1614
#### Build requirements
1715

1816
In addition to the [system requirements](https://github.com/JuliaLang/julia#required-build-tools-and-external-libraries) to build julia itself, the following are required:
@@ -22,8 +20,9 @@ In addition to the [system requirements](https://github.com/JuliaLang/julia#requ
2220

2321
#### Building Cxx
2422

25-
Launch julia (version 0.6 or later), and in the terminal type
23+
Launch julia (version 1.0 or later), and in the terminal type
2624
```julia
25+
using Pkg
2726
Pkg.add("Cxx")
2827
```
2928

REQUIRE

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
julia 0.6
2-
Compat 0.27.0
1+
julia 0.7

deps/build.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using Compat
1+
using Libdl
22

33
if haskey(ENV, "PREBUILT_CI_BINARIES") && ENV["PREBUILT_CI_BINARIES"] == "1"
44
# Try to download pre-built binaries
55
if !isdir("build") || length(readdir("build")) == 0
6-
os_tag = Compat.Sys.isapple() ? "osx" : "linux"
6+
os_tag = Sys.isapple() ? "osx" : "linux"
77
run(`rm -rf build/ src/`)
88
filename = "llvm-$(os_tag)-$(Base.libllvm_version).tgz"
99
run(`wget https://s3.amazonaws.com/julia-cxx/$filename`)
@@ -13,7 +13,7 @@ end
1313

1414
#in case we have specified the path to the julia installation
1515
#that contains the headers etc, use that
16-
BASE_JULIA_BIN = get(ENV, "BASE_JULIA_BIN", JULIA_HOME)
16+
BASE_JULIA_BIN = get(ENV, "BASE_JULIA_BIN", Sys.BINDIR)
1717
BASE_JULIA_SRC = get(ENV, "BASE_JULIA_SRC", joinpath(BASE_JULIA_BIN, "..", ".."))
1818

1919
#write a simple include file with that path
@@ -32,23 +32,23 @@ close(f)
3232
println("Tuning for julia installation at $BASE_JULIA_BIN with sources possibly at $BASE_JULIA_SRC")
3333

3434
# Try to autodetect C++ ABI in use
35-
llvm_path = (Compat.Sys.isapple() && VersionNumber(Base.libllvm_version) >= v"3.8") ? "libLLVM" : "libLLVM-$(Base.libllvm_version)"
35+
llvm_path = (Sys.isapple() && VersionNumber(Base.libllvm_version) >= v"3.8") ? "libLLVM" : "libLLVM-$(Base.libllvm_version)"
3636

3737
llvm_lib_path = Libdl.dlpath(llvm_path)
38-
old_cxx_abi = searchindex(open(read, llvm_lib_path),Vector{UInt8}("_ZN4llvm3sys16getProcessTripleEv"),0) != 0
38+
old_cxx_abi = findfirst("_ZN4llvm3sys16getProcessTripleEv", String(open(read, llvm_lib_path))) !== nothing
3939
old_cxx_abi && (ENV["OLD_CXX_ABI"] = "1")
4040

4141
llvm_config_path = joinpath(BASE_JULIA_BIN,"..","tools","llvm-config")
4242
if isfile(llvm_config_path)
43-
info("Building julia source build")
43+
@info "Building julia source build"
4444
ENV["LLVM_CONFIG"] = llvm_config_path
4545
delete!(ENV,"LLVM_VER")
4646
else
47-
info("Building julia binary build")
47+
@info "Building julia binary build"
4848
ENV["LLVM_VER"] = Base.libllvm_version
4949
ENV["JULIA_BINARY_BUILD"] = "1"
5050
ENV["PATH"] = string(JULIA_HOME,":",ENV["PATH"])
5151
end
5252

53-
make = Compat.Sys.isbsd() && !Compat.Sys.isapple() ? `gmake` : `make`
54-
run(`$make -j$(Sys.CPU_CORES) -f BuildBootstrap.Makefile BASE_JULIA_BIN=$BASE_JULIA_BIN BASE_JULIA_SRC=$BASE_JULIA_SRC`)
53+
make = Sys.isbsd() && !Sys.isapple() ? `gmake` : `make`
54+
run(`$make -j$(Sys.CPU_THREADS) -f BuildBootstrap.Makefile BASE_JULIA_BIN=$BASE_JULIA_BIN BASE_JULIA_SRC=$BASE_JULIA_SRC`)

docs/Project.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
4+
[compat]
5+
Documenter = "~0.19"

docs/make.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ makedocs(
1818
deploydocs(
1919
repo = "github.com/Keno/Cxx.jl.git",
2020
target = "build",
21-
julia = "0.6",
21+
julia = "1.0",
2222
deps = nothing,
2323
make = nothing,
2424
)

src/Cxx.jl

+47-16
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,29 @@
140140
#
141141
__precompile__(true)
142142
module Cxx
143+
144+
module CxxCore
143145
pathfile = joinpath(dirname(@__FILE__), "..", "deps", "path.jl")
144146
isfile(pathfile) || error("path.jl not generated. Try running Pkg.build(\"Cxx\")")
145147
include(pathfile)
146148

147149
using Base.Meta
148150
using Core: svec
149151

150-
using Compat
151-
using Compat.TypeUtils
152-
using Compat.Sys: isapple, isbsd, islinux, isunix, iswindows
152+
using Base.Sys: isapple, isbsd, islinux, isunix, iswindows
153153

154+
# These are re-exported from Cxx
154155
export cast,
155156
@cxx_str, @cxx_mstr, @icxx_str, @icxx_mstr, @cxxt_str,
156157
@cxx, @cxxnew, @jpcpp_str, @exception, @cxxm,
157158
addHeaderDir, defineMacro, cxxinclude, cxxparse, new_clang_instance,
158159
C_User, C_System, C_ExternCSystem
159160

161+
# These are internal but useful for hacking
162+
export CppValue, CppRef, CppPtr, cpptype, CxxQualType, CppBaseType,
163+
CppTemplate, CxxBuiltinTypes, CxxBuiltinTs, CxxException, CppFptr, CppMFptr
164+
165+
160166
include("cxxtypes.jl")
161167
include("clanginstances.jl")
162168
include("clangwrapper.jl")
@@ -167,49 +173,74 @@ include("cxxmacro.jl")
167173
include("cxxstr.jl")
168174
include("utils.jl")
169175
include("exceptions.jl")
170-
include("autowrap.jl")
171176

172177
# In precompilation mode, we do still need clang, so do it manually
173178
__init__()
174179

175-
include("CxxREPL/replpane.jl")
176-
177180
end
178181

182+
# Make these available as Cxx.
183+
import .CxxCore: __default_compiler__, instance, compiler
184+
185+
# This is meant to be overriden before using Cxx in the current
186+
# module if one wants to use a compiler with non standard options.
187+
import .CxxCore: __current_compiler__
188+
export __current_compiler__
189+
190+
# Re-export these
191+
import .CxxCore: cast,
192+
@cxx_str, @icxx_str, @cxxt_str,
193+
@cxx, @cxxnew, @pcpp_str, @jpcpp_str, @exception, @cxxm,
194+
addHeaderDir, defineMacro, cxxinclude, cxxparse, new_clang_instance,
195+
C_User, C_System, C_ExternCSystem
196+
export cast,
197+
@cxx_str, @icxx_str, @cxxt_str,
198+
@cxx, @cxxnew, @pcpp_str, @jpcpp_str, @exception, @cxxm,
199+
addHeaderDir, defineMacro, cxxinclude, cxxparse, new_clang_instance,
200+
C_User, C_System, C_ExternCSystem
201+
202+
include("CxxREPL/replpane.jl")
203+
179204
# C++ standard library helpers
180205
module CxxStd
181206

182-
using Cxx
183-
using Compat
207+
using ..CxxCore
208+
using ..Cxx
184209
include("show.jl")
210+
include("autowrap.jl")
185211
include("std.jl")
186212

187213
end
188214

215+
# Use as Cxx.
216+
import .CxxStd: @list
217+
189218
module CxxREPLInit
190-
using Cxx
191-
using Cxx.CxxREPL
219+
using ..CxxCore
220+
using ..CxxREPL
192221
function __init__()
193222
if isdefined(Base, :active_repl)
194-
CxxREPL.RunCxxREPL(Cxx.__current_compiler__)
223+
CxxREPL.RunCxxREPL(CxxCore.__current_compiler__)
195224
end
196225
end
197226
end
198227

199228
module CxxExceptionInit
200-
using Cxx
229+
using ..CxxCore
201230
__init__() = ccall(:jl_generating_output, Cint, ()) == 0 &&
202-
eval(:(Cxx.setup_exception_callback()))
231+
eval(:(CxxCore.setup_exception_callback()))
203232
end
204233

205234
module CxxDumpPCH
206-
using Cxx
235+
using ..CxxCore
207236
# Now that we've loaded Cxx, save everything we just did into a PCH
208237
if ccall(:jl_generating_output, Cint, ()) != 0
209-
append!(Cxx.GlobalPCHBuffer, Cxx.decouple_pch(Cxx.instance(Cxx.__current_compiler__)))
238+
append!(CxxCore.GlobalPCHBuffer, CxxCore.decouple_pch(CxxCore.instance(CxxCore.__current_compiler__)))
210239
end
211240
end
212241

213242
if ccall(:jl_generating_output, Cint, ()) != 0
214-
Cxx.reset_init!()
243+
CxxCore.reset_init!()
244+
end
245+
215246
end

0 commit comments

Comments
 (0)