Skip to content

Commit

Permalink
add julia_version.h for version define in C API and dll export
Browse files Browse the repository at this point in the history
add void for 0-argument function declarations

change julia_version.h to header
  • Loading branch information
Yu Gong committed Dec 22, 2014
1 parent 04893a1 commit 9fc5bfd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ ifeq ($(OS),WINNT)
endif
$(INSTALL_F) $(build_includedir)/uv* $(DESTDIR)$(includedir)/julia
endif
$(INSTALL_F) src/julia.h src/options.h src/support/*.h $(DESTDIR)$(includedir)/julia
$(INSTALL_F) src/julia.h src/julia_version.h src/options.h src/support/*.h $(DESTDIR)$(includedir)/julia
# Copy system image
$(INSTALL_F) $(build_private_libdir)/sys.ji $(DESTDIR)$(private_libdir)
$(INSTALL_M) $(build_private_libdir)/sys.$(SHLIB_EXT) $(DESTDIR)$(private_libdir)
Expand Down
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
/libjulia-release.a
/libjulia-release.so
/libjulia-release.dylib
/julia_version.h
15 changes: 14 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SRCS = \
jltypes gf ast builtins module codegen disasm debuginfo interpreter \
alloc dlload sys init task array dump toplevel jl_uv jlapi profile llvm-simdloop

HEADERS = julia.h julia_internal.h options.h $(wildcard support/*.h) $(LIBUV_INC)/uv.h
HEADERS = julia.h julia_internal.h julia_version.h options.h $(wildcard support/*.h) $(LIBUV_INC)/uv.h

FLAGS = \
-D_GNU_SOURCE -Iflisp -Isupport \
Expand Down Expand Up @@ -87,6 +87,18 @@ $(BUILDDIR)/flisp/libflisp.a: flisp/*.h flisp/*.c $(BUILDDIR)/support/libsupport
$(BUILDDIR)/flisp/libflisp-debug.a: flisp/*.h flisp/*.c $(BUILDDIR)/support/libsupport-debug.a
$(MAKE) -C flisp debug BUILDDIR='$(abspath $(BUILDDIR)/flisp)'

julia_version.h: ../VERSION
@echo "// This is an autogenerated header file" > $@
@echo "#ifndef JULIA_VERSION_H" >> $@
@echo "#define JULIA_VERSION_H" >> $@
@echo "#define JULIA_VERSION_STRING" \"$(JULIA_VERSION)\" >> $@
@echo $(JULIA_VERSION) | awk 'BEGIN {FS="[.,-]"} \
{print "#define JULIA_VERSION_MAJOR " $$1 "\n" \
"#define JULIA_VERSION_MINOR " $$2 "\n" \
"#define JULIA_VERSION_PATCH " $$3 ; \
if (NF<4) print "#define JULIA_VERSION_IS_RELEASE 1" ; else print "#define JULIA_VERSION_IS_RELEASE 0"}' >> $@
@echo "#endif" >> $@

ifneq ($(USEMSVC), 1)
CXXLD = $(CXX) -shared
else
Expand Down Expand Up @@ -121,6 +133,7 @@ clean:
-rm -f $(build_shlibdir)/libjulia*
-rm -f $(BUILDDIR)/julia_flisp.boot $(BUILDDIR)/julia_flisp.boot.inc
-rm -f $(BUILDDIR)/*.dbg.obj $(BUILDDIR)/*.o *~ $(BUILDDIR)/*.$(SHLIB_EXT) $(BUILDDIR)/*.a *#
-rm -f $(BUILDDIR)/julia_version.h

clean-flisp:
-$(MAKE) -C flisp clean BUILDDIR='$(abspath $(BUILDDIR)/flisp)'
Expand Down
25 changes: 25 additions & 0 deletions src/jlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,31 @@ DLLEXPORT jl_value_t *jl_get_image_file(void)
return jl_cstr_to_string(jl_compileropts.image_file);
}

DLLEXPORT const int jl_ver_major(void)
{
return JULIA_VERSION_MAJOR;
}

DLLEXPORT const int jl_ver_minor(void)
{
return JULIA_VERSION_MINOR;
}

DLLEXPORT const int jl_ver_patch(void)
{
return JULIA_VERSION_PATCH;
}

DLLEXPORT const int jl_ver_is_release(void)
{
return JULIA_VERSION_IS_RELEASE;
}

DLLEXPORT const char* jl_ver_string(void)
{
return JULIA_VERSION_STRING;
}

#ifdef __cplusplus
}
#endif
9 changes: 9 additions & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,15 @@ extern DLLEXPORT jl_compileropts_t jl_compileropts;
#define JL_COMPILEROPT_DUMPBITCODE_ON 1
#define JL_COMPILEROPT_DUMPBITCODE_OFF 2

// Version information
#include "julia_version.h"

DLLEXPORT extern const int jl_ver_major(void);
DLLEXPORT extern const int jl_ver_minor(void);
DLLEXPORT extern const int jl_ver_patch(void);
DLLEXPORT extern const int jl_ver_is_release(void);
DLLEXPORT extern const char* jl_ver_string(void);

#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions test/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,9 @@ for major=0:3, minor=0:3, patch=0:3
@test x < thismajor(x) ? nextmajor(x) == thismajor(x) : thismajor(x) < nextmajor(x)
end
end

# julia_version.h version test

@test VERSION.major == ccall(:jl_ver_major,Int,())
@test VERSION.minor == ccall(:jl_ver_minor,Int,())
@test VERSION.patch == ccall(:jl_ver_patch,Int,())

0 comments on commit 9fc5bfd

Please sign in to comment.