Skip to content

Commit

Permalink
Merge pull request JuliaLang#18 from JuliaLang/master
Browse files Browse the repository at this point in the history
merge to d988b01 from upstream
  • Loading branch information
tkelman committed Mar 23, 2014
2 parents 83fb556 + d988b01 commit 76aabf0
Show file tree
Hide file tree
Showing 43 changed files with 644 additions and 253 deletions.
23 changes: 18 additions & 5 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ USE_INTEL_JITEVENTS = 0
# libc++ is standard on OS X 10.9, but not for earlier releases
USE_LIBCPP = 0

# Select the cpu architecture to target
# Current available options are "native" and "core2"
JULIA_CPU_TARGET = native

# we include twice to pickup user definitions better
ifeq (exists, $(shell [ -e $(JULIAHOME)/Make.user ] && echo exists ))
include $(JULIAHOME)/Make.user
Expand Down Expand Up @@ -208,6 +212,7 @@ endif
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
JCFLAGS = -std=gnu99 -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64
JCPPFLAGS =
JCXXFLAGS = -pipe $(fPIC) -fno-rtti
DEBUGFLAGS = -O0 -ggdb3 -DDEBUG -fstack-protector-all
SHIPFLAGS = -O3 -falign-functions
Expand All @@ -217,6 +222,7 @@ ifeq ($(USECLANG),1)
CC = $(CROSS_COMPILE)clang
CXX = $(CROSS_COMPILE)clang++
JCFLAGS = -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64
JCPPFLAGS =
JCXXFLAGS = -pipe $(fPIC) -fno-rtti
DEBUGFLAGS = -O0 -g -DDEBUG -fstack-protector-all
SHIPFLAGS = -O3
Expand All @@ -229,7 +235,7 @@ else
CC += $(STDLIBCPP_FLAG) -mmacosx-version-min=10.6
CXX += $(STDLIBCPP_FLAG) -mmacosx-version-min=10.6
endif
JCFLAGS += -D_LARGEFILE_SOURCE -D_DARWIN_USE_64_BIT_INODE=1
JCPPFLAGS += -D_LARGEFILE_SOURCE -D_DARWIN_USE_64_BIT_INODE=1
endif
endif

Expand All @@ -241,6 +247,14 @@ AS := $(CROSS_COMPILE)as
LD := $(CROSS_COMPILE)ld
RANLIB := $(CROSS_COMPILE)ranlib

ifeq ($(JULIA_CPU_TARGET),native)
JCPPFLAGS += -DJULIA_TARGET_NATIVE
else ifeq ($(JULIA_CPU_TARGET),core2)
JCPPFLAGS += -DJULIA_TARGET_CORE2
else
$(error Unknown cpu target architecture)
endif


# Calculate relative paths to libdir and private_libdir
build_libdir_rel = $(shell $(JULIAHOME)/contrib/relative_path.sh $(build_bindir) $(build_libdir))
Expand All @@ -250,7 +264,7 @@ build_private_libdir_rel = $(shell $(JULIAHOME)/contrib/relative_path.sh $(build
private_libdir_rel = $(shell $(JULIAHOME)/contrib/relative_path.sh $(bindir) $(private_libdir))

# if not absolute, then relative to the directory of the julia executable
JCFLAGS += "-DJL_SYSTEM_IMAGE_PATH=\"$(build_private_libdir_rel)/sys.ji\""
JCPPFLAGS += "-DJL_SYSTEM_IMAGE_PATH=\"$(build_private_libdir_rel)/sys.ji\""

# On Windows, we want shared library files to end up in $(build_bindir), instead of $(build_libdir)
ifeq ($(OS),WINNT)
Expand Down Expand Up @@ -321,7 +335,7 @@ endif
else
ifeq ($(OS),Darwin)
LIBUNWIND=$(build_libdir)/libosxunwind.a
JCFLAGS+=-DLIBOSXUNWIND
JCPPFLAGS+=-DLIBOSXUNWIND
else
LIBUNWIND=$(build_libdir)/libunwind-generic.a $(build_libdir)/libunwind.a
endif
Expand Down Expand Up @@ -485,8 +499,7 @@ endif
ifeq ($(OS), WINNT)
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(JULIAHOME)/src/julia.expmap \
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -lssp
JCFLAGS += -D_WIN32_WINNT=0x0600
JCXXFLAGS += -D_WIN32_WINNT=0x0600
JCPPFLAGS += -D_WIN32_WINNT=0x0600
JLDFLAGS = -Wl,--stack,8388608
ifeq ($(ARCH),i686)
JLDFLAGS += -Wl,--large-address-aware
Expand Down
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ $(build_sysconfdir)/julia/juliarc.jl: contrib/windows/juliarc.jl
endif

# use sys.ji if it exists, otherwise run two stages
$(build_private_libdir)/sys%ji: $(build_private_libdir)/sys%bc

$(build_private_libdir)/sys%o: $(build_private_libdir)/sys%bc
$(call spawn,$(LLVM_LLC)) -filetype=obj -relocation-model=pic -mattr=-bmi2,-avx2 -o $(call cygpath_w,$@) $(call cygpath_w,$<)
$(build_private_libdir)/sys%ji: $(build_private_libdir)/sys%o

.PRECIOUS: $(build_private_libdir)/sys%o

Expand All @@ -77,11 +74,11 @@ $(build_private_libdir)/sys%$(SHLIB_EXT): $(build_private_libdir)/sys%o
$$([ $(OS) = Darwin ] && echo -Wl,-undefined,dynamic_lookup || echo -Wl,--unresolved-symbols,ignore-all ) \
$$([ $(OS) = WINNT ] && echo -ljulia -lssp)

$(build_private_libdir)/sys0.bc:
$(build_private_libdir)/sys0.o:
@$(QUIET_JULIA) cd base && \
$(call spawn,$(JULIA_EXECUTABLE)) --build $(call cygpath_w,$(build_private_libdir)/sys0) sysimg.jl

$(build_private_libdir)/sys.bc: VERSION base/*.jl base/pkg/*.jl base/linalg/*.jl base/sparse/*.jl $(build_datarootdir)/julia/helpdb.jl $(build_datarootdir)/man/man1/julia.1 $(build_private_libdir)/sys0.$(SHLIB_EXT)
$(build_private_libdir)/sys.o: VERSION base/*.jl base/pkg/*.jl base/linalg/*.jl base/sparse/*.jl $(build_datarootdir)/julia/helpdb.jl $(build_datarootdir)/man/man1/julia.1 $(build_private_libdir)/sys0.$(SHLIB_EXT)
@$(QUIET_JULIA) cd base && \
$(call spawn,$(JULIA_EXECUTABLE)) --build $(call cygpath_w,$(build_private_libdir)/sys) \
-J$(call cygpath_w,$(build_private_libdir))/$$([ -e $(build_private_libdir)/sys.ji ] && echo sys.ji || echo sys0.ji) -f sysimg.jl \
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ Deprecated or removed

* `read` methods that modify a passed array are now called `read!` ([#5970])

* Reduction functions that accept a pre-allocated output array, including
`sum!`, `prod!`, `maximum!`, `minimum!`, `all!`, `any!` ([#6197])

* `infs` and `nans` are deprecated in favor of the more general `fill`.

[#4042]: https://github.com/JuliaLang/julia/issues/4042
[#5164]: https://github.com/JuliaLang/julia/issues/5164
[#4026]: https://github.com/JuliaLang/julia/issues/4026
Expand Down Expand Up @@ -329,6 +334,7 @@ Deprecated or removed
[#5778]: https://github.com/JuliaLang/julia/issues/5778
[#6169]: https://github.com/JuliaLang/julia/issues/6169
[#5970]: https://github.com/JuliaLang/julia/issues/5970
[#6197]: https://github.com/JuliaLang/julia/pull/6197

Julia v0.2.0 Release Notes
==========================
Expand Down
5 changes: 1 addition & 4 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@ end
fill(v, dims::Dims) = fill!(Array(typeof(v), dims), v)
fill(v, dims::Integer...) = fill!(Array(typeof(v), dims...), v)

for (fname, felt) in ((:zeros,:zero),
(:ones,:one),
(:infs,:inf),
(:nans,:nan))
for (fname, felt) in ((:zeros,:zero), (:ones,:one))
@eval begin
($fname){T}(::Type{T}, dims...) = fill!(Array(T, dims...), ($felt)(T))
($fname)(dims...) = fill!(Array(Float64, dims...), ($felt)(Float64))
Expand Down
7 changes: 7 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,13 @@ Set{T<:Number}(xs::T...) = Set{T}(xs)
@deprecate read(s::IO, a::Array) read!(s, a)
@deprecate read(s::IO, B::BitArray) read!(s, B)

@deprecate nans{T}(::Type{T}, dims...) fill(convert(T,NaN), dims)
@deprecate nans(dims...) fill(NaN, dims)
@deprecate nans{T}(x::AbstractArray{T}) fill(convert(T,NaN), size(x))
@deprecate infs{T}(::Type{T}, dims...) fill(convert(T,Inf), dims)
@deprecate infs(dims...) fill(Inf, dims)
@deprecate infs{T}(x::AbstractArray{T}) fill(convert(T,Inf), size(x))

# 0.3 discontinued functions

function nnz(X)
Expand Down
11 changes: 9 additions & 2 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export

# Types
AbstractMatrix,
AbstractSparseArray,
AbstractSparseMatrix,
AbstractSparseVector,
AbstractVector,
AbstractVecOrMat,
Array,
Expand Down Expand Up @@ -518,7 +520,6 @@ export
indexin,
indmax,
indmin,
infs,
invperm,
ipermute!,
ipermutedims,
Expand All @@ -529,11 +530,12 @@ export
logspace,
mapslices,
max,
maximum!,
maximum,
min,
minimum!,
minimum,
minmax,
nans,
ndims,
nfilled,
nonzeros,
Expand All @@ -548,6 +550,7 @@ export
permute!,
permutedims,
permutedims!,
prod!,
prod,
promote_shape,
randcycle,
Expand Down Expand Up @@ -581,6 +584,7 @@ export
strides,
sub,
sub2ind,
sum!,
sum,
sum_kbn,
vcat,
Expand Down Expand Up @@ -699,7 +703,9 @@ export
unshift!,

# collections
all!,
all,
any!,
any,
collect,
complement!,
Expand Down Expand Up @@ -871,6 +877,7 @@ export
hist,
hist2d,
histrange,
mean!,
mean,
median!,
median,
Expand Down
6 changes: 5 additions & 1 deletion base/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Pkg

export Git, Dir, GitHub, Types, Reqs, Cache, Read, Query, Resolve, Write, Generate, Entry
export dir, init, rm, add, available, installed, status, clone, checkout,
release, fix, update, resolve, register, tag, publish, generate
release, fix, update, resolve, register, tag, publish, generate, test

const DEFAULT_META = "git://github.com/JuliaLang/METADATA.jl"
const META_BRANCH = "metadata-v2"
Expand Down Expand Up @@ -62,6 +62,10 @@ build(pkgs::String...) = cd(Entry.build,[pkgs...])
generate(pkg::String, license::String; force::Bool=false) =
cd(Generate.package,pkg,license,force=force)


test() = cd(Entry.test)
test(pkgs::String...) = cd(Entry.test,String[pkgs...])

@deprecate release free
@deprecate fixup build
@deprecate fix pin
Expand Down
46 changes: 46 additions & 0 deletions base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -663,4 +663,50 @@ function updatehook(pkgs::Vector)
""")
end

@windows_only const JULIA = joinpath(JULIA_HOME, ENV["JULIA_EXE"])
@unix_only const JULIA = joinpath(JULIA_HOME, "julia-readline")

function test!(pkg::String, errs::Vector{String}, notests::Vector{String})
const reqs_path = abspath(pkg,"test","REQUIRE")
if isfile(reqs_path)
const tests_require = Reqs.parse(reqs_path)
if (!isempty(tests_require))
info("Computing test dependencies for $pkg...")
resolve(tests_require)
end
end
const test_path = abspath(pkg,"test","runtests.jl")
if isfile(test_path)
info("Testing $pkg")
cd(dirname(test_path)) do
try
run(`$JULIA $test_path`)
info("$pkg tests passed")
catch err
warnbanner(err, label="[ ERROR: $pkg ]")
push!(errs,pkg)
end
end
else
push!(notests,pkg)
end
resolve()
end

function test(pkgs::Vector{String})
errs = String[]
notests = String[]
for pkg in pkgs
test!(pkg,errs,notests)
end
if !isempty(errs) || !isempty(notests)
messages = String[]
isempty(errs) || push!(messages, "$(join(errs,", "," and ")) had test errors")
isempty(notests) || push!(messages, "$(join(notests,", "," and ")) did not provide a test/runtests.jl file")
error(join(messages, "and"))
end
end

test() = test(sort!(String[keys(installed())...]))

end # module
16 changes: 14 additions & 2 deletions base/pkg/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function package(
Generate.license(pkg,license,years,authors,force=force)
Generate.readme(pkg,user,force=force)
Generate.entrypoint(pkg,force=force)
Generate.tests(pkg,force=force)
Generate.travis(pkg,force=force)

msg = """
Expand Down Expand Up @@ -113,6 +114,18 @@ function readme(pkg::String, user::String=""; force::Bool=false)
end
end

function tests(pkg::String; force::Bool=false)
genfile(pkg,"test/runtests.jl",force) do io
print(io, """
using $pkg
using Base.Test
# write your own tests here
@test 1 == 1
""")
end
end

function travis(pkg::String; force::Bool=false)
genfile(pkg,".travis.yml",force) do io
print(io, """
Expand All @@ -131,8 +144,7 @@ function travis(pkg::String; force::Bool=false)
- sudo apt-get update -qq -y
- sudo apt-get install libpcre3-dev julia -y
script:
- julia -e 'Pkg.init(); run(`ln -s \$(pwd()) \$(Pkg.dir("$pkg"))`); Pkg.pin("$pkg"); Pkg.resolve()'
- julia -e 'using $pkg; @assert isdefined(:$pkg); @assert typeof($pkg) === Module'
- julia -e 'Pkg.init(); Pkg.clone(pwd()); Pkg.test("$pkg")'
""")
end
end
Expand Down
48 changes: 22 additions & 26 deletions base/printf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export @printf, @sprintf
### printf formatter generation ###

function gen(s::String)
args = {:(out::IO)}
args = {}
blk = Expr(:block, :(local neg, pt, len, exp))
for x in parse(s)
if isa(x,String)
Expand Down Expand Up @@ -748,43 +748,39 @@ end
### external printf interface ###

is_str_expr(ex) =
isa(ex,Expr) && ex.head==:macrocall && isa(ex.args[1],Symbol) &&
(ex.args[1] == :str || endswith(string(ex.args[1]),"_str"))
isa(ex,Expr) && (ex.head == :string || (ex.head == :macrocall && isa(ex.args[1],Symbol) &&
endswith(string(ex.args[1]),"str")))

macro printf(args...)
if length(args) == 0
error("@printf: called with zero arguments")
end
if !isa(args[1],String) && !(length(args) > 1 && isa(args[2],String))
if is_str_expr(args[1]) || length(args) > 1 && is_str_expr(args[2])
error("format must be a plain static string (no interpolation or prefix)")
end
error("first or second argument must be a format string")
end
local io, fmt
if isa(args[1],String)
io = :(Base.STDOUT)
fmt = args[1]
args = args[2:end]
else
io = args[1]
fmt = args[2]
args = args[3:end]
end
args = {io,args...}
function _printf(macroname, io, fmt, args)
isa(fmt, String) || error("$macroname: format must be a plain static string (no interpolation or prefix)")
sym_args, blk = gen(fmt)
if length(sym_args) != length(args)
error("@printf: wrong number of arguments")
error("$macroname: wrong number of arguments")
end
for i = length(args):-1:1
var = sym_args[i].args[1]
unshift!(blk.args, :($var = $(esc(args[i]))))
end
unshift!(blk.args, :(out = $io))
blk
end

macro printf(args...)
!isempty(args) || error("@printf: called with zero arguments")
if isa(args[1], String) || is_str_expr(args[1])
_printf("@printf", :STDOUT, args[1], args[2:end])
else
(length(args) >= 2 && (isa(args[2], String) || is_str_expr(args[2]))) ||
error("@printf: first or second argument must be a format string")
_printf("@printf", esc(args[1]), args[2], args[3:end])
end
end

macro sprintf(args...)
:(sprint(io->@printf(io,$(map(esc,args)...))))
!isempty(args) || error("@sprintf: called with zero arguments")
isa(args[1], String) || is_str_expr(args[1]) ||
error("@sprintf: first argument must be a format string")
:(sprint(io->$(_printf("@sprintf", :io, args[1], args[2:end]))))
end

end # module
Loading

0 comments on commit 76aabf0

Please sign in to comment.