Skip to content

Commit

Permalink
1.0 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Nov 20, 2018
1 parent 06cfb1f commit c62cb57
Show file tree
Hide file tree
Showing 28 changed files with 832 additions and 857 deletions.
130 changes: 72 additions & 58 deletions .travis.yml
@@ -1,64 +1,78 @@
language: julia
os:
- linux
- osx
julia:
- 0.7
- 1.0
- nightly
matrix:
allow_failures:
- julia: nightly
fast_finish: true
notifications:
email: false
sudo: false
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- cmake
- cmake-data
- gcc-6
- g++-6
- binutils
- gfortran
- libblas-dev
- liblapack-dev
- libgmp-dev
- libmpfr-dev

matrix:
include:
- language: julia
julia: 0.6
os: linux
- language: julia
julia: nightly
os: linux
- language: julia
julia: 0.6
os: osx
allow_failures:
- language: julia
julia: nightly
os: linux
apt:
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- cmake
- cmake-data
- gcc-6
- g++-6
- binutils
- gfortran
- libblas-dev
- liblapack-dev
- libgmp-dev
- libmpfr-dev
cache:
directories:
- $(julia -e 'println(Pkg.dir())')/Cxx/deps/src
- $(julia -e 'println(Pkg.dir())')/Cxx/deps/build
- ~/usr
directories:
- $TRAVIS_BUILD_DIR/deps/src
- $TRAVIS_BUILD_DIR/deps/build
- ~/usr
before_cache:
- rm ~/.julia/0.5/Cxx/deps/build/bootstrap.o
- rm -rf ~/.julia/0.5/deps/usr
install:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="g++-6" CC="gcc-6"; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export CXX="clang++" CC="clang"; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then export PATH="$HOME/usr/bin:$PATH"; fi
- export THE_PKG_DIR=`julia -e 'println(Pkg.dir())'`
- rm $TRAVIS_BUILD_DIR/deps/build/bootstrap.o
- rm -rf $TRAVIS_BUILD_DIR/deps/usr
before_script:
- |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
export CXX="g++-6" CC="gcc-6"
export PATH="$HOME/usr/bin:$PATH"
else
export CXX="clang++" CC="clang"
fi
- |
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ ! -f $HOME/usr/bin/ld ]; then
wget https://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.gz
tar xzf binutils-2.27.tar.gz
(cd binutils-2.27 && ./configure --prefix=$HOME/usr && make && make install)
fi
- mkdir -p $TRAVIS_BUILD_DIR/../Cxx-cache && cp -R $TRAVIS_BUILD_DIR $TRAVIS_BUILD_DIR/../Cxx-cache
- julia -e 'using InteractiveUtils; versioninfo()'
script:
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ ! -f $HOME/usr/bin/ld ]; then
wget https://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.gz;
tar xzf binutils-2.27.tar.gz;
(cd binutils-2.27 && ./configure --prefix=$HOME/usr && make && make install);
fi;
- julia -e 'versioninfo()'
- mv $THE_PKG_DIR/Cxx $THE_PKG_DIR/Cxx-cache
- julia -e 'Pkg.clone(pwd())'
- mv $THE_PKG_DIR/Cxx-cache/deps/src $THE_PKG_DIR/Cxx/deps/src || true
- mv $THE_PKG_DIR/Cxx-cache/deps/build $THE_PKG_DIR/Cxx/deps/build || true
- if [ ! -f $HOME/early_abort ]; then PREBUILT_CI_BINARIES=1 julia -e 'Pkg.build("Cxx")' || false; fi
- if [ ! -f $HOME/early_abort ]; then julia -e 'Pkg.test("Cxx"; coverage=true)' || false; fi
- julia --project=. -e 'using Pkg; Pkg.instantiate()'
- mv $TRAVIS_BUILD_DIR/../Cxx-cache/deps/src $TRAVIS_BUILD_DIR/deps/src || true
- mv $TRAVIS_BUILD_DIR/../Cxx-cache/deps/build $TRAVIS_BUILD_DIR/deps/build || true
- |
if [ ! -f $HOME/early_abort ]; then
PREBUILT_CI_BINARIES=1 julia --project=. -e 'using Pkg; Pkg.build()' || false
fi
- |
if [ ! -f $HOME/early_abort ]; then
julia --project=. -e 'Pkg.test(coverage=true)' || false
fi
after_success:
- julia -e 'cd(Pkg.dir("Cxx")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia -e 'cd(Pkg.dir("Cxx")); Pkg.add("Documenter"); include(joinpath("docs", "make.jl"))'
notifications:
email: false
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
jobs:
include:
- stage: "Documentation"
julia: 1.0
os: linux
script:
- julia --project=docs/ -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd()))'
- julia --project=docs/ docs/make.jl
after_success: skip
12 changes: 12 additions & 0 deletions Project.toml
@@ -0,0 +1,12 @@
name = "Cxx"
uuid = "a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -11,8 +11,6 @@ The Julia C++ Foreign Function Interface (FFI) and REPL.

### Installation

You will need to install Julia v0.6 (or later).

#### Build requirements

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:
Expand All @@ -22,8 +20,9 @@ In addition to the [system requirements](https://github.com/JuliaLang/julia#requ

#### Building Cxx

Launch julia (version 0.6 or later), and in the terminal type
Launch julia (version 1.0 or later), and in the terminal type
```julia
using Pkg
Pkg.add("Cxx")
```

Expand Down
3 changes: 1 addition & 2 deletions REQUIRE
@@ -1,2 +1 @@
julia 0.6
Compat 0.27.0
julia 0.7
18 changes: 9 additions & 9 deletions deps/build.jl
@@ -1,9 +1,9 @@
using Compat
using Libdl

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

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

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

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

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

llvm_config_path = joinpath(BASE_JULIA_BIN,"..","tools","llvm-config")
if isfile(llvm_config_path)
info("Building julia source build")
@info "Building julia source build"
ENV["LLVM_CONFIG"] = llvm_config_path
delete!(ENV,"LLVM_VER")
else
info("Building julia binary build")
@info "Building julia binary build"
ENV["LLVM_VER"] = Base.libllvm_version
ENV["JULIA_BINARY_BUILD"] = "1"
ENV["PATH"] = string(JULIA_HOME,":",ENV["PATH"])
end

make = Compat.Sys.isbsd() && !Compat.Sys.isapple() ? `gmake` : `make`
run(`$make -j$(Sys.CPU_CORES) -f BuildBootstrap.Makefile BASE_JULIA_BIN=$BASE_JULIA_BIN BASE_JULIA_SRC=$BASE_JULIA_SRC`)
make = Sys.isbsd() && !Sys.isapple() ? `gmake` : `make`
run(`$make -j$(Sys.CPU_THREADS) -f BuildBootstrap.Makefile BASE_JULIA_BIN=$BASE_JULIA_BIN BASE_JULIA_SRC=$BASE_JULIA_SRC`)
5 changes: 5 additions & 0 deletions docs/Project.toml
@@ -0,0 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "~0.19"
2 changes: 1 addition & 1 deletion docs/make.jl
Expand Up @@ -18,7 +18,7 @@ makedocs(
deploydocs(
repo = "github.com/Keno/Cxx.jl.git",
target = "build",
julia = "0.6",
julia = "1.0",
deps = nothing,
make = nothing,
)
63 changes: 47 additions & 16 deletions src/Cxx.jl
Expand Up @@ -140,23 +140,29 @@
#
__precompile__(true)
module Cxx

module CxxCore
pathfile = joinpath(dirname(@__FILE__), "..", "deps", "path.jl")
isfile(pathfile) || error("path.jl not generated. Try running Pkg.build(\"Cxx\")")
include(pathfile)

using Base.Meta
using Core: svec

using Compat
using Compat.TypeUtils
using Compat.Sys: isapple, isbsd, islinux, isunix, iswindows
using Base.Sys: isapple, isbsd, islinux, isunix, iswindows

# These are re-exported from Cxx
export cast,
@cxx_str, @cxx_mstr, @icxx_str, @icxx_mstr, @cxxt_str,
@cxx, @cxxnew, @jpcpp_str, @exception, @cxxm,
addHeaderDir, defineMacro, cxxinclude, cxxparse, new_clang_instance,
C_User, C_System, C_ExternCSystem

# These are internal but useful for hacking
export CppValue, CppRef, CppPtr, cpptype, CxxQualType, CppBaseType,
CppTemplate, CxxBuiltinTypes, CxxBuiltinTs, CxxException, CppFptr, CppMFptr


include("cxxtypes.jl")
include("clanginstances.jl")
include("clangwrapper.jl")
Expand All @@ -167,49 +173,74 @@ include("cxxmacro.jl")
include("cxxstr.jl")
include("utils.jl")
include("exceptions.jl")
include("autowrap.jl")

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

include("CxxREPL/replpane.jl")

end

# Make these available as Cxx.
import .CxxCore: __default_compiler__, instance, compiler

# This is meant to be overriden before using Cxx in the current
# module if one wants to use a compiler with non standard options.
import .CxxCore: __current_compiler__
export __current_compiler__

# Re-export these
import .CxxCore: cast,
@cxx_str, @icxx_str, @cxxt_str,
@cxx, @cxxnew, @pcpp_str, @jpcpp_str, @exception, @cxxm,
addHeaderDir, defineMacro, cxxinclude, cxxparse, new_clang_instance,
C_User, C_System, C_ExternCSystem
export cast,
@cxx_str, @icxx_str, @cxxt_str,
@cxx, @cxxnew, @pcpp_str, @jpcpp_str, @exception, @cxxm,
addHeaderDir, defineMacro, cxxinclude, cxxparse, new_clang_instance,
C_User, C_System, C_ExternCSystem

include("CxxREPL/replpane.jl")

# C++ standard library helpers
module CxxStd

using Cxx
using Compat
using ..CxxCore
using ..Cxx
include("show.jl")
include("autowrap.jl")
include("std.jl")

end

# Use as Cxx.
import .CxxStd: @list

module CxxREPLInit
using Cxx
using Cxx.CxxREPL
using ..CxxCore
using ..CxxREPL
function __init__()
if isdefined(Base, :active_repl)
CxxREPL.RunCxxREPL(Cxx.__current_compiler__)
CxxREPL.RunCxxREPL(CxxCore.__current_compiler__)
end
end
end

module CxxExceptionInit
using Cxx
using ..CxxCore
__init__() = ccall(:jl_generating_output, Cint, ()) == 0 &&
eval(:(Cxx.setup_exception_callback()))
eval(:(CxxCore.setup_exception_callback()))
end

module CxxDumpPCH
using Cxx
using ..CxxCore
# Now that we've loaded Cxx, save everything we just did into a PCH
if ccall(:jl_generating_output, Cint, ()) != 0
append!(Cxx.GlobalPCHBuffer, Cxx.decouple_pch(Cxx.instance(Cxx.__current_compiler__)))
append!(CxxCore.GlobalPCHBuffer, CxxCore.decouple_pch(CxxCore.instance(CxxCore.__current_compiler__)))
end
end

if ccall(:jl_generating_output, Cint, ()) != 0
Cxx.reset_init!()
CxxCore.reset_init!()
end

end

0 comments on commit c62cb57

Please sign in to comment.