diff --git a/.gitignore b/.gitignore index d93f853e29..c779341a62 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ tags *.eo.legacy.h *.eo.hh *.eo.impl.hh +*.eo.js.cc *.eo.lua *.luac .dir-locals.el diff --git a/Makefile.am b/Makefile.am index 8363720df2..2e90bf3cd5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -172,6 +172,14 @@ if HAVE_ELUA pkgconfig_DATA += pc/elua.pc endif +if HAVE_JS +pkgconfig_DATA += \ +pc/eolian-js.pc \ +pc/efl-js.pc \ +pc/eo-js.pc \ +pc/eina-js.pc +endif + if BUILD_ENGINE_SOFTWARE_X11 pkgconfig_DATA += pc/evas-software-x11.pc endif diff --git a/configure.ac b/configure.ac index 08976a5645..6e5953b321 100644 --- a/configure.ac +++ b/configure.ac @@ -1051,6 +1051,191 @@ EFL_EVAL_PKGS([EINA_CXX]) EFL_LIB_END([Eina_Cxx]) #### End of Eina CXX +AC_ARG_WITH([js], + [AS_HELP_STRING([--with-js=@<:@nodejs/libv8/libuv/none@:>@],[enable JavaScript bindings using nodejs or libv8/libuv as build dependencies. The libuv option implies libv8. @<:@default=none@:>@])], + [want_js="${withval}"], [want_js="none"]) + +EFLJS_CXXFLAGS="" +AC_LANG_PUSH([C++]) +case "$want_js" in + nodejs) + AC_CHECK_HEADERS([node/v8.h nodejs/deps/v8/v8.h nodejs/deps/v8/include/v8.h nodejs/src/v8.h v8.h], + [ + v8_header=AC_header + v8_header_define=AS_TR_CPP([HAVE_]AC_header) + EFLJS_CXXFLAGS="$EFLJS_CXXFLAGS -D$v8_header_define" + break + ] + [AC_MSG_ERROR([Could not find v8 include headers from nodejs.])]) + AC_CHECK_HEADERS([node/node.h nodejs/deps/node/node.h nodejs/deps/node/include/node.h nodejs/src/node.h node.h], + [ + node_header_define=AS_TR_CPP([HAVE_]AC_header) + EFLJS_CXXFLAGS="$EFLJS_CXXFLAGS -D$node_header_define" + break + ] + [AC_MSG_ERROR([Could not find node include headers from nodejs.])]) + AC_CHECK_HEADERS([node/uv.h nodejs/deps/uv/uv.h nodejs/deps/uv/include/uv.h nodejs/src/uv.h uv.h], + [ + uv_header_define=AS_TR_CPP([HAVE_]AC_header) + EFLJS_CXXFLAGS="$EFLJS_CXXFLAGS -D$uv_header_define" + break + ] + [AC_MSG_ERROR([Could not find uv include headers from nodejs.])]) + ;; + libv8) + AC_CHECK_HEADERS([v8.h], + [ + v8_header=AC_header + break + ] + [AC_MSG_ERROR([Could not find v8 include headers from libv8.])]) + ;; + libuv) + AC_CHECK_HEADERS([v8.h], + [ + v8_header=AC_header + break + ] + [AC_MSG_ERROR([Could not find v8 include headers from libv8.])]) + AC_CHECK_HEADERS([uv.h], + [break] + [AC_MSG_ERROR([Could not find uv include headers from libuv.])]) + ;; + none) + ;; + *) AC_MSG_ERROR([Invalid javascript dependency (${want_js}): must be none, nodejs, libv8 or libuv]) ;; +esac + +have_v8_global="no" +have_v8_create_params="no" +if test "$want_js" != "none" ; then +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include "$v8_header" + ]], + [[ +v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = nullptr; + ]]) + ], + [ + AC_DEFINE(HAVE_V8_CREATE_PARAMS, 1, [Define to 1 if you must pass create_params explicitly.]) + have_v8_create_params="yes" + AC_MSG_NOTICE([checking for v8::Isolate::CreateParams... yes]) + ], + [ + AC_MSG_NOTICE([checking for v8::Isolate::CreateParams... no]) + ]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include "$v8_header" +#include + ]], + [[ + static_assert((std::is_same< ::v8::Global, ::v8::UniquePersistent>::value), ""); + ]]) + ], + [ + AC_DEFINE(HAVE_V8_GLOBAL, 1, [Define to 1 if you must pass create_params explicitly.]) + have_v8_global="yes" + AC_MSG_NOTICE([checking for v8::Global class... yes]) + ], + [ + AC_MSG_NOTICE([checking for v8::Global class... no]) + ]) +fi +AM_CONDITIONAL([HAVE_V8_CREATE_PARAMS], [test "x${have_v8_create_params}" = "xyes"]) +AM_CONDITIONAL([HAVE_V8_GLOBAL], [test "x${have_v8_global}" = "xyes"]) +AC_SUBST([HAVE_V8_CREATE_PARAMS]) +AC_SUBST([HAVE_V8_GLOBAL]) +AC_LANG_POP([C++]) + +AM_CONDITIONAL([HAVE_NODEJS], [test "x${want_js}" = "xnodejs"]) +AC_DEFINE_IF([HAVE_NODEJS], [test "x${want_js}" = "xnodejs"], + [1], [Using NodeJS]) +AC_SUBST([want_js]) +AC_SUBST([HAVE_NODEJS]) + +have_js="no" +if test "x${want_js}" != "xnone" ; then + have_js="yes" +fi +AM_CONDITIONAL([HAVE_JS], [test "x${have_js}" = "xyes"]) +AC_DEFINE_IF([HAVE_JS], [test "x${have_js}" = "xyes"], [1], [Compiling bindings for JavaScript]) +AC_SUBST([HAVE_JS]) + +AM_CONDITIONAL([HAVE_LIBUV], [test "x${want_js}" = "xnodejs" -o "x${want_js}" = "xlibuv"]) +AC_DEFINE_IF([HAVE_LIBUV], [test "x${want_js}" = "xnodejs" -o "x${want_js}" = "xlibuv"], + [1], [Compiling libuv event loop integration]) +AC_SUBST([HAVE_LIBUV]) + +# For efljspack mime handling +AM_CONDITIONAL([HAVE_XDG_DATA_HOME], [test "x${XDG_DATA_HOME}" != "x"]) +AM_COND_IF([HAVE_XDG_DATA_HOME], [AC_SUBST([XDG_DATA_HOME])], [AC_SUBST([XDG_DATA_HOME], "$HOME/.local/share")]) + +#### Eina JS +EFL_LIB_START_OPTIONAL([Eina_Js], [test "x${have_js}" = "xyes"]) +EFL_INTERNAL_DEPEND_PKG([EINA_JS], [Eina]) +EFL_INTERNAL_DEPEND_PKG([EINA_JS], [Eo]) +EFL_ADD_CFLAGS([EINA_JS], [${EFL_PTHREAD_CFLAGS}]) +EFL_EVAL_PKGS([EINA_JS]) + +EFL_LIB_END_OPTIONAL([Eina_Js]) +#### End of Eina JS + +#### Ecore JS +EFL_LIB_START_OPTIONAL([Ecore_Js], [test "x${have_js}" = "xyes"]) + +EFL_INTERNAL_DEPEND_PKG([ECORE_JS], [ecore]) +EFL_INTERNAL_DEPEND_PKG([ECORE_JS], [ecore_file]) +EFL_ADD_CFLAGS([ECORE_JS], [${EFL_PTHREAD_CFLAGS}]) +EFL_EVAL_PKGS([ECORE_JS]) + +EFL_LIB_END_OPTIONAL([Ecore_Js]) +#### End of Ecore JS + +#### Eio JS +EFL_LIB_START_OPTIONAL([Eio_Js], [test "x${have_js}" = "xyes"]) + +EFL_INTERNAL_DEPEND_PKG([EIO_JS], [eio]) +EFL_ADD_CFLAGS([EIO_JS], [${EFL_PTHREAD_CFLAGS}]) +EFL_EVAL_PKGS([EIO_JS]) + +EFL_LIB_END_OPTIONAL([Eio_Js]) +#### End of Eio JS + +#### Ethumb JS +EFL_LIB_START_OPTIONAL([Ethumb_Js], [test "x${have_js}" = "xyes"]) + +EFL_INTERNAL_DEPEND_PKG([ETHUMB_JS], [ethumb]) +EFL_INTERNAL_DEPEND_PKG([ETHUMB_JS], [ethumb_client]) +EFL_ADD_CFLAGS([ETHUMB_JS], [${EFL_PTHREAD_CFLAGS}]) +EFL_EVAL_PKGS([ETHUMB_JS]) + +EFL_LIB_END_OPTIONAL([Ethumb_Js]) +#### End of Ethumb JS + +#### Eldbus JS +EFL_LIB_START_OPTIONAL([Eldbus_Js], [test "x${have_js}" = "xyes"]) + +EFL_INTERNAL_DEPEND_PKG([ELDBUS_JS], [eldbus]) +EFL_ADD_CFLAGS([ELDBUS_JS], [${EFL_PTHREAD_CFLAGS}]) +EFL_EVAL_PKGS([ELDBUS_JS]) + +EFL_LIB_END_OPTIONAL([Eldbus_Js]) +#### End of Eldbus JS + +#### Eo JS +EFL_LIB_START_OPTIONAL([Eo_Js], [test "x${have_js}" = "xyes"]) + +EFL_INTERNAL_DEPEND_PKG([EO_JS], [eina]) +EFL_ADD_CFLAGS([EO_JS], [${EFL_PTHREAD_CFLAGS}]) +EFL_EVAL_PKGS([EO_JS]) + +EFL_LIB_END_OPTIONAL([Eo_Js]) +#### End of Eo JS + #### Eo EFL_LIB_START([Eo]) @@ -1244,6 +1429,15 @@ EFL_INTERNAL_DEPEND_PKG([EOLIAN], [eina]) EFL_LIB_END([Eolian]) #### End of Eolian +EFL_LIB_START_OPTIONAL([Eolian_Js], [test "${have_js}" = "yes"]) + +EFL_INTERNAL_DEPEND_PKG([EOLIAN_JS], [eina]) +EFL_INTERNAL_DEPEND_PKG([EOLIAN_JS], [eolian]) + +EFL_LIB_END_OPTIONAL([Eolian_Js]) +#### End of Eolian + + EFL_LIB_START([Eolian_Cxx]) ### Default values @@ -2322,6 +2516,17 @@ AC_ARG_ENABLE([g-main-loop], fi ], [want_g_main_loop="no"]) +AC_ARG_ENABLE([libuv], + [AS_HELP_STRING([--enable-libuv],[enable ecore_main_loop based on libuv. @<:@default=disabled@:>@])], + [ + if test "x${enableval}" = "xyes" ; then + want_libuv="yes" + CFOPT_WARNING="xyes" + else + want_libuv="no" + fi + ], + [want_libuv="no"]) AC_ARG_ENABLE([gstreamer], [AS_HELP_STRING([--enable-gstreamer],[enable gstreamer 0.10 support. @<:@default=disabled@:>@])], @@ -2410,6 +2615,7 @@ EFL_OPTIONAL_DEPEND_PKG([ECORE], [${want_systemd}], [SYSTEMD], [libsystemd]) EFL_ADD_FEATURE([ECORE], [systemd-daemon], [${want_systemd}]) EFL_ADD_FEATURE([ECORE], [glib]) EFL_ADD_FEATURE([ECORE], [g-main-loop]) +EFL_ADD_FEATURE([ECORE], [libuv]) want_glib_integration_always=no if test "x${with_glib}" = "xalways" ; then @@ -2419,6 +2625,9 @@ fi if test "x${want_g_main_loop}" = "xyes" ; then AC_DEFINE([USE_G_MAIN_LOOP], [1], [Use g_main_loop in ecore]) + if test "x${want_js}" = "xnodejs" -o "x${want_js}" = "xlibuv" ; then + AC_MSG_ERROR([Can't define glib and libuv integration together]) + fi fi # not EFL_OPTIONAL_DEPEND_PKG() because it's only used for ecore examples @@ -4007,7 +4216,7 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [emile]) ECORE_EVAS_MODULE([extn], [${want_ecore_evas_extn}]) ECORE_EVAS_MODULE([ews], [yes]) ECORE_EVAS_MODULE([fb], [${want_fb}]) -ECORE_EVAS_MODULE([drm], [${want_drm}], +ECORE_EVAS_MODULE([drm], [${want_drm}], [EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_drm}], [ecore-drm])]) ECORE_EVAS_MODULE([gl-drm], [${want_gl_drm}], [EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_gl_drm}], [ecore-drm])]) @@ -4677,6 +4886,63 @@ EFL_ADD_LIBS([ELOCATION], [-lm]) EFL_LIB_END([Elocation]) #### End of Elocation + + +#### Efl_Js +EFL_LIB_START_OPTIONAL([Efl_Js], [test "x${have_js}" = "xyes"]) + +### Default values + +### Additional options to configure + +### Checks for programs + +### Checks for libraries +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Eina]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Eo]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Ecore]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Eet]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Ecore_Evas]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Ecore_Con]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Ecore_Audio]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Efl]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Evas]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Edje]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Emotion]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Eldbus]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Emile]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Ethumb_Client]) +EFL_INTERNAL_DEPEND_PKG([EFL_JS], [Eio]) + +AM_COND_IF([HAVE_NODEJS], [], [ EFL_ADD_LIBS([EFL_JS], [-lv8]) ]) + +EFL_EVAL_PKGS([EFL_JS]) + +AM_COND_IF([HAVE_NODEJS], [EFLJS_CXXFLAGS="$EFLJS_CXXFLAGS -DHAVE_NODEJS"], []) +AM_COND_IF([HAVE_LIBUV], [EFLJS_CXXFLAGS="$EFLJS_CXXFLAGS -DHAVE_LIBUV"], []) +AM_COND_IF([HAVE_JS], [EFLJS_CXXFLAGS="$EFLJS_CXXFLAGS -DHAVE_JS"], []) + +AM_COND_IF([HAVE_V8_CREATE_PARAMS], [EFLJS_CXXFLAGS="$EFLJS_CXXFLAGS -DHAVE_V8_CREATE_PARAMS"], []) +AM_COND_IF([HAVE_V8_GLOBAL], [EFLJS_CXXFLAGS="$EFLJS_CXXFLAGS -DHAVE_V8_GLOBAL"], []) +AC_SUBST([EFLJS_CXXFLAGS]) + +### Checks for header files + +### Checks for types + +### Checks for structures + +### Checks for compiler characteristics + +### Checks for linker characteristics + +### Checks for library functions + +### Check availability + +EFL_LIB_END_OPTIONAL([Efl_Js]) +#### End of Efl_Js + ### Add Wayland server library if test is enabled if test "x${want_tests}" = "xyes" -a "x${want_wayland}" = "xyes"; then EFL_DEPEND_PKG([ECORE_WAYLAND_SRV], [WAYLAND], [wayland-server >= 1.8.0]) @@ -4809,6 +5075,10 @@ pc/eo.pc pc/eo-cxx.pc pc/eolian.pc pc/eolian-cxx.pc +pc/eina-js.pc +pc/efl-js.pc +pc/eolian-js.pc +pc/eo-js.pc pc/efl.pc pc/efl-cxx.pc pc/evas-fb.pc @@ -4991,6 +5261,8 @@ echo " Cryptography..: ${build_crypto}" echo " X11...........: ${with_x11}" echo " OpenGL........: ${with_opengl}" echo " C++11.........: ${have_cxx11}" +echo " JavaScript....: ${want_js}" +echo " JavaScript flg: $EINA_JS_LIBS" echo "Eina............: yes (${features_eina} unwind=$have_unwind)" echo "Eo..............: yes (${features_eo})" echo "Eolian..........: yes (${features_eolian})" @@ -5052,6 +5324,7 @@ echo " CPPFLAGS......: $CPPFLAGS" echo " CFLAGS........: $CFLAGS" echo " CXXFLAGS......: $CXXFLAGS" echo " LDFLAGS.......: $LDFLAGS" +echo " EFLJS_CXXFLAGS: $EFLJS_CXXFLAGS" if test "x${with_binary_edje_cc}" != "x"; then echo " edje_cc.......: ${with_binary_edje_cc}" diff --git a/pc/.gitignore b/pc/.gitignore index c6b8eb4447..1858516cab 100644 --- a/pc/.gitignore +++ b/pc/.gitignore @@ -28,6 +28,7 @@ /efreet.pc /eina.pc /eina-cxx.pc +/eina-js.pc /eet-cxx.pc /eio.pc /eio-cxx.pc @@ -36,6 +37,7 @@ /embryo.pc /emotion.pc /eo.pc +/eo-js.pc /ephysics.pc /escape.pc /ethumb.pc @@ -57,6 +59,7 @@ /evil.pc /eolian.pc /eolian-cxx.pc +/eolian-js.pc /eo-cxx.pc /evas-cxx.pc /ecore-cxx.pc diff --git a/pc/efl-js.pc.in b/pc/efl-js.pc.in new file mode 100644 index 0000000000..0c1e00c00c --- /dev/null +++ b/pc/efl-js.pc.in @@ -0,0 +1,15 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datarootdir=@datarootdir@ +datadir=@datadir@ +want_js=@want_js@ + +Name: EFL JavaScript +Description: JavaScript C++ helpers for data structures +Version: @PACKAGE_VERSION@ +Requires.private: @requirements_pc_eina@ +Libs.private: @requirements_libs_eina@ +Libs: -L${libdir} -lefl_js +Cflags: -I${includedir}/efl-js-@VMAJ@ @EFLJS_CXXFLAGS@ diff --git a/pc/eina-js.pc.in b/pc/eina-js.pc.in new file mode 100644 index 0000000000..6aab608ceb --- /dev/null +++ b/pc/eina-js.pc.in @@ -0,0 +1,14 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datarootdir=@datarootdir@ +datadir=@datadir@ +want_js=@want_js@ + +Name: Eina JavaScript +Description: JavaScript C++ helpers for data structures +Version: @PACKAGE_VERSION@ +Requires.private: @requirements_pc_eina@ +Libs.private: @requirements_libs_eina@ +Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eina-@VMAJ@ -I${includedir}/eina-js-@VMAJ@ \ No newline at end of file diff --git a/pc/eo-js.pc.in b/pc/eo-js.pc.in new file mode 100644 index 0000000000..3dedf5c265 --- /dev/null +++ b/pc/eo-js.pc.in @@ -0,0 +1,15 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datarootdir=@datarootdir@ +datadir=@datadir@ +eoincludedir=@datadir@/eolian/include +eolian_flags=-I${eoincludedir}/eo-@VMAJ@ + +Name: Eo JavaScript +Description: JavaScript C++ helpers for bindings for EFL's generic object system. +Version: @PACKAGE_VERSION@ +Requires.private: @requirements_pc_eo@ +Libs.private: @requirements_libs_eo@ +Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eo-@VMAJ@ -I${includedir}/eo-js-@VMAJ@ \ No newline at end of file diff --git a/pc/eolian-js.pc.in b/pc/eolian-js.pc.in new file mode 100644 index 0000000000..2dbc1cac73 --- /dev/null +++ b/pc/eolian-js.pc.in @@ -0,0 +1,14 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datarootdir=@datarootdir@ +datadir=@datadir@ + +Name: Eolian-JS +Description: EFL's JavaScript bindings generator. +Version: @VERSION@ +Require.private: @requirements_pc_eolian@ +Libs: -L${libdir} +Libs.private: @requirements_libs_eolian@ +Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eolian-js-@VMAJ@ diff --git a/pc/evas.pc.in b/pc/evas.pc.in index 4fd66b99d3..c49c058635 100644 --- a/pc/evas.pc.in +++ b/pc/evas.pc.in @@ -13,4 +13,4 @@ Requires.private: @requirements_pc_evas@ Version: @VERSION@ Libs: -L${libdir} -levas Libs.private: @requirements_libs_evas@ -Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/evas-@VMAJ@ +Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/evas-@VMAJ@ -I${includedir}/evas-@VMAJ@/canvas diff --git a/src/Makefile.am b/src/Makefile.am index 6ac8dc7580..248711bc34 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ check_PROGRAMS = TESTS = EXTRA_DIST = +GENERATED_JS_BINDINGS = EFL_INSTALL_EXEC_HOOK= @@ -76,6 +77,21 @@ include Makefile_Eio_Cxx.am include Makefile_Elua.am include Makefile_Elocation.am +if HAVE_JS +AM_V_CP = $(am__v_CP_@AM_V@) +am__v_CP_ = $(am__v_CP_@AM_DEFAULT_V@) +am__v_CP_0 = @echo " CP " $@; +CP = cp +if EFL_ENABLE_TESTS +if HAVE_NODEJS +AM_TESTS_ENVIRONMENT = NODE_PATH='$(abs_builddir)/lib/efl_js:$(abs_builddir)/tests/eolian_js:$(abs_builddir)/tests/efl_js'; export NODE_PATH; +endif +endif +endif + +include Makefile_Eolian_Js.am +include Makefile_Efl_Js.am + .PHONY: benchmark examples BENCHMARK_SUBDIRS = \ diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am index b7e0b6b74d..13e5473a21 100644 --- a/src/Makefile_Ecore.am +++ b/src/Makefile_Ecore.am @@ -271,3 +271,13 @@ installed_ecoreluadir = $(datadir)/elua/modules/ecore nodist_installed_ecorelua_DATA = $(generated_ecore_lua_all) endif + +if HAVE_JS + +generated_ecore_js_bindings = $(ecore_eolian_files:%.eo=%.eo.js.cc) + +CLEANFILES += $(generated_ecore_js_bindings) + +GENERATED_JS_BINDINGS += $(generated_ecore_js_bindings) + +endif diff --git a/src/Makefile_Ecore_Audio.am b/src/Makefile_Ecore_Audio.am index ccce8f7fc0..b500118736 100644 --- a/src/Makefile_Ecore_Audio.am +++ b/src/Makefile_Ecore_Audio.am @@ -104,4 +104,15 @@ nodist_installed_ecoreaudiolua_DATA = $(generated_ecore_audio_lua_all) endif +if HAVE_JS + +generated_ecore_audio_js_bindings = $(ecore_audio_eolian_files:%.eo=%.eo.js.cc) + +CLEANFILES += $(generated_ecore_audio_js_bindings) + +GENERATED_JS_BINDINGS += $(generated_ecore_audio_js_bindings) + endif + +endif + diff --git a/src/Makefile_Ecore_Con.am b/src/Makefile_Ecore_Con.am index 87ad889b26..544e6d949f 100644 --- a/src/Makefile_Ecore_Con.am +++ b/src/Makefile_Ecore_Con.am @@ -143,3 +143,13 @@ installed_ecoreconluadir = $(datadir)/elua/modules/ecore_con nodist_installed_ecoreconlua_DATA = $(generated_ecore_con_lua_all) endif + +if HAVE_JS + +generated_ecore_con_js_bindings = $(ecore_con_eolian_files:%.eo=%.eo.js.cc) + +CLEANFILES += $(generated_ecore_con_js_bindings) + +GENERATED_JS_BINDINGS += $(generated_ecore_con_js_bindings) + +endif diff --git a/src/Makefile_Ecore_Js.am b/src/Makefile_Ecore_Js.am new file mode 100644 index 0000000000..df5ac2f5b1 --- /dev/null +++ b/src/Makefile_Ecore_Js.am @@ -0,0 +1,19 @@ + +### Library + +if HAVE_JS +installed_ecorejsheadersdir = $(includedir)/ecore-js-@VMAJ@ +dist_installed_ecorejsheaders_DATA = \ +bindings/js/ecore_js/Ecore_Js.hh \ +bindings/js/ecore_js/ecore_js_init.hh \ +bindings/js/ecore_js/ecore_js_mainloop.hh \ +bindings/js/ecore_js/ecore_js_timer.hh \ +bindings/js/ecore_js/ecore_js_event.hh \ +bindings/js/ecore_js/ecore_js_job.hh \ +bindings/js/ecore_js/ecore_js_idle.hh \ +bindings/js/ecore_js/ecore_js_animator.hh \ +bindings/js/ecore_js/ecore_js_poller.hh \ +bindings/js/ecore_js/ecore_js_throttle.hh \ +bindings/js/ecore_js/ecore_js_file.hh +endif + diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am index ca0eefc463..4fa0ecf09f 100644 --- a/src/Makefile_Edje.am +++ b/src/Makefile_Edje.am @@ -130,7 +130,7 @@ if HAVE_WIN32 USE_EDJE_BIN_LIBS = -L$(top_builddir)/src/lib/evil @USE_EDJE_LIBS@ else USE_EDJE_BIN_LIBS = @USE_EDJE_LIBS@ -endif +endif bin_PROGRAMS += \ bin/edje/edje_cc \ @@ -334,3 +334,13 @@ installed_edjeluadir = $(datadir)/elua/modules/edje nodist_installed_edjelua_DATA = $(generated_edje_lua_all) endif + +if HAVE_JS + +generated_edje_js_bindings = $(edje_eolian_files:%.eo=%.eo.js.cc) + +CLEANFILES += $(generated_edje_js_bindings) + +GENERATED_JS_BINDINGS += $(generated_edje_js_bindings) + +endif diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index f6b1c288c6..9e59bf22bf 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -80,6 +80,16 @@ nodist_installed_efllua_DATA = $(generated_efl_lua_all) endif +if HAVE_JS + +generated_efl_js_bindings = $(efl_eolian_files:%.eo=%.eo.js.cc) + +CLEANFILES += $(generated_efl_js_bindings) + +GENERATED_JS_BINDINGS += $(generated_efl_js_bindings) + +endif + ### Binary bin_PROGRAMS += \ diff --git a/src/Makefile_Efl_Js.am b/src/Makefile_Efl_Js.am new file mode 100644 index 0000000000..e993120a64 --- /dev/null +++ b/src/Makefile_Efl_Js.am @@ -0,0 +1,333 @@ +if HAVE_JS + +if HAVE_NODEJS + +noinst_lib_LTLIBRARIES = lib/efl_js/libefl_node_js.la +noinst_libdir = $(libdir)/efl_js + +$(top_builddir)/src/lib/efl_js/efl.node: lib/efl_js/libefl_node_js.la + $(AM_V_CP)$(CP) $(top_builddir)/src/lib/efl_js/.libs/libefl_node_js.so $(top_builddir)/src/lib/efl_js/efl.node + +eflnodedir = $(libdir)/node_modules +eflnode_DATA = $(top_builddir)/src/lib/efl_js/efl.node + +CLEANFILES += ${eflnodedir_DATA} +EXTRA_DIST += ${eflnodedir_DATA} + +efljsmimedir = @XDG_DATA_HOME@/mime/packages +efljsmime_DATA = bin/efl_js/efljslaunch.xml + +efljsdesktopdir = @XDG_DATA_HOME@/applications +efljsdesktop_DATA = bin/efl_js/efljslaunch.desktop + +bin_SCRIPTS += \ + bin/efl_js/efljslaunch \ + bin/efl_js/efljspack + +else + +bin_PROGRAMS += bin/efl_js/eflv8js + +bin_efl_js_eflv8js_SOURCES = \ + bin/efl_js/launcher_main.cc + +bin_efl_js_eflv8js_CPPFLAGS = \ + -I$(top_builddir)/src/lib/efl \ + -I$(top_srcdir)/src/bindings/js/efl_js \ + -I$(top_srcdir)/src/bindings/js/eina_js \ + -I$(top_srcdir)/src/bindings/js/eo_js \ + @CHECK_CFLAGS@ \ + @EINA_CXX_CFLAGS@ \ + @EO_CXX_CFLAGS@ \ + @EMILE_CFLAGS@ \ + @ECORE_CFLAGS@ \ + @EET_CFLAGS@ \ + @EO_CFLAGS@ \ + @EFL_JS_CFLAGS@ \ + @EINA_JS_CFLAGS@ \ + @EO_JS_CFLAGS@ + +bin_efl_js_eflv8js_LDFLAGS = \ + -lv8 \ + @USE_EFL_JS_INTERNAL_LIBS@ + +bin_efl_js_eflv8js_LDADD = \ + @USE_EFL_JS_LIBS@ + +endif + +bindings/js/efl_js/eolian_js_bindings.cc: $(GENERATED_JS_BINDINGS) + @echo @ECHO_E@ "#ifdef HAVE_CONFIG_H" > $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include \"config.h\"" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#endif\n" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include " >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include " >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include " >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include " >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include " >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include " >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include " >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include " >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include " >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @echo @ECHO_E@ "#include \n" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc + @for i in $(GENERATED_JS_BINDINGS); do echo "#include <$$i>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc; done + +CLEANFILES += bindings/js/efl_js/eolian_js_bindings.cc + +## Install Ecore-JS headers +installed_ecorejsheadersdir = $(includedir)/ecore-js-@VMAJ@ +dist_installed_ecorejsheaders_DATA = \ +bindings/js/ecore_js/Ecore_Js.hh + +## Install Eio-JS headers +installed_eiojsheadersdir = $(includedir)/eio-js-@VMAJ@ +dist_installed_eiojsheaders_DATA = \ +bindings/js/eio_js/Eio_Js.hh + +## Install Ethumb-JS headers +installed_ethumbjsheadersdir = $(includedir)/ethumb-js-@VMAJ@ +dist_installed_ethumbjsheaders_DATA = \ +bindings/js/ethumb_js/Ethumb_Js.hh + +## Install Eldbus-JS headers +installed_eldbusjsheadersdir = $(includedir)/eldbus-js-@VMAJ@ +dist_installed_eldbusjsheaders_DATA = \ +bindings/js/eldbus_js/Eldbus_Js.hh + +## Install Eo-JS headers +installed_eojsmainheadersdir = $(includedir)/eo-js-@VMAJ@ +dist_installed_eojsmainheaders_DATA = \ +bindings/js/eo_js/eo_js_call_function.hh \ +bindings/js/eo_js/eo_js_constructor.hh \ +bindings/js/eo_js/eo_js_direction.hh \ +bindings/js/eo_js/eo_js_event.hh \ +bindings/js/eo_js/eo_js_namespace.hh \ +bindings/js/eo_js/eo_js_struct.hh \ +bindings/js/eo_js/eo_js_construct_from_eo.hh \ +bindings/js/eo_js/Eo_Js.hh + +## Install Eina-JS headers +installed_einajsheadersdir = $(includedir)/eina-js-@VMAJ@ +dist_installed_einajsheaders_DATA = \ +bindings/js/eina_js/Eina_Js.hh \ +bindings/js/eina_js/eina_js_accessor.hh \ +bindings/js/eina_js/eina_js_array.hh \ +bindings/js/eina_js/eina_js_compatibility.hh \ +bindings/js/eina_js/eina_js_container.hh \ +bindings/js/eina_js/eina_js_error.hh \ +bindings/js/eina_js/eina_js_get_value_from_c.hh \ +bindings/js/eina_js/eina_js_get_value.hh \ +bindings/js/eina_js/eina_js_iterator.hh \ +bindings/js/eina_js/eina_js_list.hh \ +bindings/js/eina_js/eina_js_log.hh \ +bindings/js/eina_js/eina_js_node.hh \ +bindings/js/eina_js/eina_js_value.hh + +installed_efljsheadersdir = $(includedir)/efl-js-@VMAJ@ +dist_installed_efljsheaders_DATA = \ +bindings/js/efl_js/Efl_Js.hh + +lib_LTLIBRARIES += lib/efl_js/libefl_js.la + +lib_efl_js_libefl_js_la_SOURCES = \ +bindings/js/eina_js/eina_js_container.cc \ +bindings/js/eina_js/eina_js_value.cc \ +bindings/js/eina_js/eina_js_error.cc \ +bindings/js/eina_js/eina_js_accessor.cc \ +bindings/js/eina_js/eina_js_log.cc \ +bindings/js/eina_js/eina_js_iterator.cc \ +bindings/js/eina_js/eina_js_compatibility.cc \ +bindings/js/ecore_js/ecore_js_init.cc \ +bindings/js/ecore_js/ecore_js_mainloop.cc \ +bindings/js/ecore_js/ecore_js_timer.cc \ +bindings/js/ecore_js/ecore_js_event.cc \ +bindings/js/ecore_js/ecore_js_job.cc \ +bindings/js/ecore_js/ecore_js_idle.cc \ +bindings/js/ecore_js/ecore_js_animator.cc \ +bindings/js/ecore_js/ecore_js_poller.cc \ +bindings/js/ecore_js/ecore_js_throttle.cc \ +bindings/js/eldbus_js/eldbus_js_core.cc \ +bindings/js/eldbus_js/eldbus_js_connection.cc \ +bindings/js/eldbus_js/eldbus_js_message.cc \ +bindings/js/eldbus_js/eldbus_js_object_mapper.cc \ +bindings/js/eio_js/eio_js.cc \ +bindings/js/ethumb_js/ethumb_js_client.cc + +nodist_lib_efl_js_libefl_js_la_SOURCES = \ +bindings/js/efl_js/eolian_js_bindings.cc + +bindings/js/efl_js/efl_js.cc $(lib_efl_js_libefl_js_la_SOURCES): $(generated_ecore_cxx_all) $(generated_eo_cxx_bindings) $(generated_efl_cxx_all) + +lib_efl_js_libefl_js_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/lib/efl \ +-I$(top_builddir)/src/lib/efl/interfaces/ \ +-I$(top_builddir)/src/lib/evas/canvas/ \ +-I$(top_srcdir)/src/bindings/js/eina_js \ +-I$(top_srcdir)/src/bindings/js/ecore_js \ +-I$(top_srcdir)/src/bindings/js/eo_js \ +-I$(top_srcdir)/src/bindings/js/eldbus_js \ +-I$(top_srcdir)/src/bindings/js/eio_js \ +-I$(top_srcdir)/src/bindings/js/ethumb_js \ +@EFL_JS_CFLAGS@ \ +@EO_JS_CFLAGS@ \ +@ECORE_CXX_CFLAGS@ \ +@EO_CXX_CFLAGS@ \ +@ECORE_JS_CFLAGS@ \ +@EINA_JS_CFLAGS@ \ +@ELDBUS_JS_CFLAGS@ \ +@EIO_JS_CFLAGS@ \ +@ETHUMB_JS_CFLAGS@ \ +@EINA_CXX_CFLAGS@ +lib_efl_js_libefl_js_la_LIBADD = @EFL_JS_LIBS@ +lib_efl_js_libefl_js_la_DEPENDENCIES = @EFL_JS_INTERNAL_LIBS@ +lib_efl_js_libefl_js_la_LIBTOOLFLAGS = --tag=disable-static +lib_efl_js_libefl_js_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@ + +if HAVE_NODEJS +lib_efl_js_libefl_node_js_la_SOURCES = \ +bindings/js/efl_js/efl_js.cc + +lib_efl_js_libefl_node_js_la_CPPFLAGS = $(lib_efl_js_libefl_js_la_CPPFLAGS) +lib_efl_js_libefl_node_js_la_LIBADD = @USE_EFL_JS_LIBS@ +lib_efl_js_libefl_node_js_la_DEPENDENCIES = @USE_EFL_JS_INTERNAL_LIBS@ +lib_efl_js_libefl_node_js_la_LIBTOOLFLAGS = --tag=disable-static +lib_efl_js_libefl_node_js_la_LDFLAGS = +else +lib_efl_js_libefl_js_la_SOURCES += \ +bindings/js/efl_js/efl_js.cc +endif + +if EFL_ENABLE_TESTS + +SUITE_RUNNER_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/bindings/js/eina_js \ +-I$(top_srcdir)/src/bindings/js/eo_js \ +-DTESTS_WD=\"`pwd`\" \ +-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/efl_js\" \ +-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/efl_js\" \ +-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/efl_js\" \ +@CHECK_CFLAGS@ \ +@EFL_JS_CFLAGS@ \ +@EINA_CXX_CFLAGS@ \ +@EO_CXX_CFLAGS@ \ +@EO_CFLAGS@ \ +@ECORE_CFLAGS@ \ +@ECORE_CXX_CFLAGS@ \ +@ECORE_JS_CFLAGS@ \ +@EINA_JS_CFLAGS@ + +if HAVE_NODEJS +TESTS += tests/efl_js/eina_js_suite.js \ +tests/efl_js/eina_js_containers_suite.js \ +tests/efl_js/ecore_js_suite.js \ +tests/efl_js/eldbus_js_suite.js \ +tests/efl_js/ethumb_js_suite.js \ +tests/efl_js/eio_js_suite.js \ +tests/efl_js/benchmark_js_suite.js + +check_LTLIBRARIES += tests/efl_js/libbenchmark_object.la + +tests/efl_js/eina_js_suite.js tests/efl_js/eina_js_containers_suite.js tests/efl_js/ecore_js_suite.js tests/efl_js/eldbus_js_suite.js tests/efl_js/eio_js_suite.js tests/efl_js/ethumb_js_suite.js: $(top_builddir)/src/lib/efl_js/efl.node + +tests/efl_js/benchmark_object.node: tests/efl_js/libbenchmark_object.la + $(AM_V_CP)$(CP) $(top_builddir)/src/tests/efl_js/.libs/libbenchmark_object.so $(top_builddir)/src/tests/efl_js/benchmark_object.node +tests/efl_js/benchmark_js_suite.js: $(top_builddir)/src/lib/efl_js/efl.node tests/efl_js/benchmark_object.node + +tests_efl_js_libbenchmark_object_la_SOURCES = tests/efl_js/benchmark_object_impl.cc +tests_efl_js_libbenchmark_object_la_CPPFLAGS = \ +-I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/bindings/js/efl_js \ +-I$(top_builddir)/src/tests/efl_js \ +-I$(top_srcdir)/src/bindings/js/eina_js \ +-I$(top_srcdir)/src/bindings/js/eo_js \ +-DTESTS_WD=\"`pwd`\" \ +-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/efl_js\" \ +-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/efl_js\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/efl_js\" \ +-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/efl_js\" \ +@CHECK_CFLAGS@ @EOLIAN_CXX_CFLAGS@ @EINA_JS_CFLAGS@ @EO_JS_CFLAGS@ \ +@EOLIAN_CFLAGS@ @EINA_CFLAGS@ @EO_CFLAGS@ @ECORE_CFLAGS@ @EINA_CXX_CFLAGS@ \ +@EO_JS_CFLAGS@ @EO_CXX_CFLAGS@ +tests_efl_js_libbenchmark_object_la_LIBADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ +tests_efl_js_libbenchmark_object_la_LDFLAGS = -rpath $(abs_top_builddir)/tests/efl_js @EFL_LTLIBRARY_FLAGS@ +tests_efl_js_libbenchmark_object_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ +tests_efl_js_libbenchmark_object_la_LIBTOOLFLAGS = --tag=disable-static + +tests/efl_js/tests_efl_js_libbenchmark_object_la-benchmark_object_impl.l$(OBJEXT): tests/efl_js/benchmark_object.eo.js.cc tests/efl_js/benchmark_object.eo.c tests/efl_js/benchmark_object.eo.h +else +check_PROGRAMS += \ +tests/efl_js/eina_js_suite \ +tests/efl_js/eina_js_containers_suite \ +tests/efl_js/ecore_js_suite \ +tests/efl_js/eldbus_js_suite \ +tests/efl_js/ethumb_js_suite \ +tests/efl_js/eio_js_suite \ +tests/efl_js/benchmark_js_suite +TESTS += tests/efl_js/eina_js_suite \ +tests/efl_js/ecore_js_suite \ +tests/efl_js/eldbus_js_suite \ +tests/efl_js/ethumb_js_suite \ +tests/efl_js/eio_js_suite \ +tests/efl_js/benchmark_js_suite + +tests_efl_js_eina_js_suite_SOURCES = \ +tests/efl_js/eina_js_suite.cc + +tests_efl_js_eina_js_suite_CPPFLAGS = $(SUITE_RUNNER_CPPFLAGS) +tests_efl_js_eina_js_suite_LDADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ +tests_efl_js_eina_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ + +tests_efl_js_eina_js_containers_suite_SOURCES = \ +tests/efl_js/eina_js_containers_suite.cc + +tests_efl_js_eina_js_containers_suite_CPPFLAGS = $(SUITE_RUNNER_CPPFLAGS) +tests_efl_js_eina_js_containers_suite_LDADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ +tests_efl_js_eina_js_containers_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ + +tests_efl_js_ecore_js_suite_SOURCES = \ +tests/efl_js/ecore_js_suite.cc + +tests_efl_js_ecore_js_suite_CPPFLAGS = $(SUITE_RUNNER_CPPFLAGS) +tests_efl_js_ecore_js_suite_LDADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ +tests_efl_js_ecore_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ + +tests_efl_js_eldbus_js_suite_SOURCES = \ +tests/efl_js/eldbus_js_suite.cc + +tests_efl_js_eldbus_js_suite_CPPFLAGS = $(SUITE_RUNNER_CPPFLAGS) +tests_efl_js_eldbus_js_suite_LDADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ +tests_efl_js_eldbus_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ + +tests_efl_js_ethumb_js_suite_SOURCES = \ +tests/efl_js/ethumb_js_suite.cc + +tests_efl_js_ethumb_js_suite_CPPFLAGS = $(SUITE_RUNNER_CPPFLAGS) +tests_efl_js_ethumb_js_suite_LDADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ +tests_efl_js_ethumb_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ + +tests_efl_js_eio_js_suite_SOURCES = \ +tests/efl_js/eio_js_suite.cc + +tests_efl_js_eio_js_suite_CPPFLAGS = $(SUITE_RUNNER_CPPFLAGS) +tests_efl_js_eio_js_suite_LDADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ +tests_efl_js_eio_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ + +tests_efl_js_benchmark_js_suite_SOURCES = \ +tests/efl_js/benchmark_js_suite.cc + +tests_efl_js_benchmark_js_suite_CPPFLAGS = $(SUITE_RUNNER_CPPFLAGS) +tests_efl_js_benchmark_js_suite_LDADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ +tests_efl_js_benchmark_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ +endif +endif + + +endif diff --git a/src/Makefile_Eina_Cxx.am b/src/Makefile_Eina_Cxx.am index 70ef18a7bd..e9f7c13eb9 100644 --- a/src/Makefile_Eina_Cxx.am +++ b/src/Makefile_Eina_Cxx.am @@ -14,6 +14,7 @@ bindings/eina_cxx/eina_clone_allocators.hh \ bindings/eina_cxx/eina_error.hh \ bindings/eina_cxx/eina_eo_concrete_fwd.hh \ bindings/eina_cxx/eina_fold.hh \ +bindings/eina_cxx/eina_function.hh \ bindings/eina_cxx/eina_inarray.hh \ bindings/eina_cxx/eina_inlist.hh \ bindings/eina_cxx/eina_integer_sequence.hh \ @@ -21,7 +22,9 @@ bindings/eina_cxx/eina_iterator.hh \ bindings/eina_cxx/eina_lists_auxiliary.hh \ bindings/eina_cxx/eina_list.hh \ bindings/eina_cxx/eina_log.hh \ +bindings/eina_cxx/eina_logical.hh \ bindings/eina_cxx/eina_optional.hh \ +bindings/eina_cxx/eina_pp.hh \ bindings/eina_cxx/eina_ptrarray.hh \ bindings/eina_cxx/eina_ptrlist.hh \ bindings/eina_cxx/eina_range_types.hh \ @@ -31,6 +34,7 @@ bindings/eina_cxx/eina_string_view.hh \ bindings/eina_cxx/eina_thread.hh \ bindings/eina_cxx/eina_throw.hh \ bindings/eina_cxx/eina_tuple.hh \ +bindings/eina_cxx/eina_tuple_c.hh \ bindings/eina_cxx/eina_tuple_unwrap.hh \ bindings/eina_cxx/eina_type_traits.hh \ bindings/eina_cxx/eina_value.hh diff --git a/src/Makefile_Emotion.am b/src/Makefile_Emotion.am index f16a4a4c3d..4da5224060 100644 --- a/src/Makefile_Emotion.am +++ b/src/Makefile_Emotion.am @@ -347,3 +347,14 @@ installed_emotionluadir = $(datadir)/elua/modules/emotion nodist_installed_emotionlua_DATA = $(generated_emotion_lua_all) endif + +# TODO: gives undefined reference to emotion_object_class_get() +if HAVE_JS + +generated_emotion_js_bindings = $(emotion_eolian_files:%.eo=%.eo.js.cc) + +CLEANFILES += $(generated_emotion_js_bindings) + +GENERATED_JS_BINDINGS += $(generated_emotion_js_bindings) + +endif diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index 57b096e795..51924feeff 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -197,3 +197,13 @@ endif EXTRA_DIST += tests/eo/eunit_tests.h lib/eo/eo_ptr_indirection.x + +if HAVE_JS + +generated_eo_js_bindings = $(eo_eolian_files:%.eo=%.eo.js.cc) + +CLEANFILES += $(generated_eo_js_bindings) + +GENERATED_JS_BINDINGS += $(generated_eo_js_bindings) + +endif diff --git a/src/Makefile_Eolian_Js.am b/src/Makefile_Eolian_Js.am new file mode 100644 index 0000000000..32cf893bf6 --- /dev/null +++ b/src/Makefile_Eolian_Js.am @@ -0,0 +1,123 @@ + +if HAVE_JS + +### Binary +bin_PROGRAMS += bin/eolian_js/eolian_js + +bin_eolian_js_eolian_js_SOURCES = \ + bin/eolian_js/main.cc + +bin_eolian_js_eolian_js_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/bin/eolian_js \ +-I$(top_srcdir)/src/bindings/js/eina_js \ +-I$(top_srcdir)/src/bindings/js/eo_js \ +@EOLIAN_JS_CFLAGS@ \ +@EINA_CXX_CFLAGS@ \ +@EOLIAN_CXX_CFLAGS@ + +bin_eolian_js_eolian_js_LDADD = @USE_EO_LIBS@ @USE_EOLIAN_LIBS@ +bin_eolian_js_eolian_js_DEPENDENCIES = @USE_EO_INTERNAL_LIBS@ @USE_EOLIAN_INTERNAL_LIBS@ + +include Makefile_Eolian_Js_Helper.am + +### Unit tests + +if EFL_ENABLE_TESTS +if HAVE_NODEJS + +TESTS += tests/eolian_js/eolian_js_suite.js + +check_LTLIBRARIES += tests/eolian_js/libeolian_js_suite.la + +tests/eolian_js/eolian_js_suite.js: tests/eolian_js/eolian_js_suite_mod.node +tests/eolian_js/eolian_js_suite_mod.node: tests/eolian_js/libeolian_js_suite.la + $(AM_V_CP)$(CP) $(top_builddir)/src/tests/eolian_js/.libs/libeolian_js_suite.so $(top_builddir)/src/tests/eolian_js/eolian_js_suite_mod.node + +tests_eolian_js_libeolian_js_suite_la_SOURCES = \ +tests/eolian_js/eolian_js_suite.cc \ +tests/eolian_js/eolian_js_test_eolian_js_binding.cc \ +tests/eolian_js/eolian_js_test_constructor_method_impl.c \ +tests/eolian_js/eolian_js_test_test_object_impl.c + +tests_eolian_js_libeolian_js_suite_la_CPPFLAGS = \ +-I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/bin/eolian_js \ +-I$(top_srcdir)/src/bindings/js/eina_js \ +-I$(top_srcdir)/src/bindings/js/eo_js \ +-I$(top_builddir)/src/tests/eolian_js \ +-DTESTS_WD=\"`pwd`\" \ +-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/eolian_js\" \ +-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/eolian_js\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/eolian_js\" \ +-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian_js\" \ +@CHECK_CFLAGS@ @EOLIAN_CXX_CFLAGS@ @EINA_JS_CFLAGS@ @EO_JS_CFLAGS@ \ +@EOLIAN_CFLAGS@ @EINA_CFLAGS@ @EO_CFLAGS@ @ECORE_CFLAGS@ @EINA_CXX_CFLAGS@ \ +@EO_JS_CFLAGS@ @EO_CXX_CFLAGS@ +tests_eolian_js_libeolian_js_suite_la_LIBADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ +tests_eolian_js_libeolian_js_suite_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ +tests_eolian_js_libeolian_js_suite_la_CFLAGS = $(tests_eolian_js_libeolian_js_suite_la_CXXFLAGS) +tests_eolian_js_libeolian_js_suite_la_LIBTOOLFLAGS = --tag=disable-static +tests_eolian_js_libeolian_js_suite_la_LDFLAGS = -rpath $(abs_top_builddir)/tests/eolian_js @EFL_LTLIBRARY_FLAGS@ + +# if compiler_o_lo == yes, lo, otherwise $(OBJEXT) + +tests/eolian_js/tests_eolian_js_libeolian_js_suite_la-eolian_js_test_eolian_js_binding.l$(OBJEXT): tests/eolian_js/constructor_method_class.eo.js.cc tests/eolian_js/constructor_method_class.eo.h tests/eolian_js/test_object.eo.js.cc tests/eolian_js/test_object.eo.h +tests/eolian_js/tests_eolian_js_libeolian_js_suite_la-eolian_js_test_constructor_method_impl.l$(OBJEXT): tests/eolian_js/constructor_method_class.eo.c +tests/eolian_js/tests_eolian_js_libeolian_js_suite_la-eolian_js_test_test_object_impl.l$(OBJEXT): tests/eolian_js/test_object.eo.c + +CLEANFILES += \ +tests/eolian_js/constructor_method_class.eo.js.cc \ +tests/eolian_js/constructor_method_class.eo.c \ +tests/eolian_js/constructor_method_class.eo.h \ +tests/eolian_js/test_object.eo.js.cc \ +tests/eolian_js/test_object.eo.c \ +tests/eolian_js/test_object.eo.h +else +check_PROGRAMS += tests/eolian_js/eolian_js_suite +TESTS += tests/eolian_js/eolian_js_suite + +tests_eolian_js_eolian_js_suite_SOURCES = \ +tests/eolian_js/eolian_js_suite.cc \ +tests/eolian_js/eolian_js_test_eolian_js_binding.cc \ +tests/eolian_js/eolian_js_test_constructor_method_impl.c \ +tests/eolian_js/eolian_js_test_test_object_impl.c + +tests/eolian_js/tests_eolian_js_eolian_js_suite-eolian_js_test_eolian_js_binding.$(OBJEXT): tests/eolian_js/constructor_method_class.eo.js.cc tests/eolian_js/constructor_method_class.eo.h tests/eolian_js/test_object.eo.js.cc tests/eolian_js/test_object.eo.h +tests/eolian_js/tests_eolian_js_eolian_js_suite-eolian_js_test_constructor_method_impl.$(OBJEXT): tests/eolian_js/constructor_method_class.eo.c +tests/eolian_js/tests_eolian_js_eolian_js_suite-eolian_js_test_test_object_impl.$(OBJEXT): tests/eolian_js/test_object.eo.c + +CLEANFILES += \ +tests/eolian_js/constructor_method_class.eo.js.cc \ +tests/eolian_js/constructor_method_class.eo.c \ +tests/eolian_js/constructor_method_class.eo.h \ +tests/eolian_js/test_object.eo.js.cc \ +tests/eolian_js/test_object.eo.c \ +tests/eolian_js/test_object.eo.h + +tests_eolian_js_eolian_js_suite_CPPFLAGS = \ +-I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/bin/eolian_js \ +-I$(top_srcdir)/src/bindings/js/eina_js \ +-I$(top_srcdir)/src/bindings/js/eo_js \ +-I$(top_builddir)/src/tests/eolian_js \ +-I$(top_srcdir)/src/tests/efl_js \ +-DTESTS_WD=\"`pwd`\" \ +-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/eolian_js\" \ +-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/eolian_js\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/eolian_js\" \ +-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian_js\" \ +@CHECK_CFLAGS@ @EOLIAN_CXX_CFLAGS@ @EINA_JS_CFLAGS@ @EO_JS_CFLAGS@ @EFL_JS_CFLAGS@ \ +@EOLIAN_CFLAGS@ @EINA_CFLAGS@ @EO_CFLAGS@ @ECORE_CFLAGS@ @EINA_CXX_CFLAGS@ \ +@EO_JS_CFLAGS@ @EO_CXX_CFLAGS@ @EFL_JS_CFLAGS@ + +tests_eolian_js_eolian_js_suite_LDADD = \ +@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ @USE_EVAS_LIBS@ @USE_EFL_JS_LIBS@ +tests_eolian_js_eolian_js_suite_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ @USE_EVAS_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ +endif +endif + +endif + + + diff --git a/src/Makefile_Eolian_Js_Helper.am b/src/Makefile_Eolian_Js_Helper.am new file mode 100644 index 0000000000..fcc523153f --- /dev/null +++ b/src/Makefile_Eolian_Js_Helper.am @@ -0,0 +1,18 @@ +#if HAVE_EOLIAN_JS +#EOLIAN_JS = @eolian_js@ +#_EOLIAN_JS_DEP = @eolian_js@ +#else +EOLIAN_JS = EFL_RUN_IN_TREE=1 $(top_builddir)/src/bin/eolian_js/eolian_js${EXEEXT} +_EOLIAN_JS_DEP = bin/eolian_js/eolian_js${EXEEXT} +#endif + +AM_V_EOLJS = $(am__v_EOLJS_@AM_V@) +am__v_EOLJS_ = $(am__v_EOLJS_@AM_DEFAULT_V@) +am__v_EOLJS_0 = @echo " EOLJS " $@; + +SUFFIXES += .eo.js.cc + +%.eo.js.cc: %.eo $(_EOLIAN_JS_DEP) + $(AM_V_EOLJS)$(EOLIAN_JS) $(EOLIAN_FLAGS) -o $@ $< + +CLEANFILES += $(BUILT_SOURCES) diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 3f7dd3941b..ebc5480151 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -2221,3 +2221,13 @@ $(NULL) installed_evasfiltersdir = $(datadir)/evas/filters/lua dist_installed_evasfilters_DATA = $(evas_filters_lua) + +if HAVE_JS + +generated_evas_js_bindings = $(evas_eolian_files:%.eo=%.eo.js.cc) + +CLEANFILES += $(generated_evas_js_bindings) + +GENERATED_JS_BINDINGS += $(generated_evas_js_bindings) + +endif diff --git a/src/bin/efl_js/efljslaunch b/src/bin/efl_js/efljslaunch new file mode 100755 index 0000000000..785c30e3e3 --- /dev/null +++ b/src/bin/efl_js/efljslaunch @@ -0,0 +1,139 @@ +#!/bin/sh +':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@" + +// Core node modules +var path = require('path'); +var os = require('os'); +var zlib = require('zlib'); +var child_process = require('child_process'); + +// 3rd party modules +var fs = require('fs-extra'); +var getopt = require('node-getopt'); +var tar = require('tar'); + +function make_error_cb(message) +{ + return function(e) { + console.error("Error %s: %s", message, e); + process.exit(1); + }; +} + +function remove_files(options) +{ + if (options.verbose) + console.log("Removing temporary files"); + + fs.remove(options.project_folder); +} + +function run_project(options) +{ + if (options.verbose) + console.log("Running the project"); + + var current_dir = process.cwd(); + process.chdir(options.project_root); + + var proc = child_process.fork(options.metadata.Entry); + proc.on('exit', function(code){ + if (options.verbose) + console.log('Child exited with code %s', code); + process.chdir(current_dir); + if (!options.keep) + remove_files(options); + }); + +} + +function unpack_project_data(options) +{ + if (options.verbose) + console.log("Unpacking project sources and assets"); + + var datafile = path.join(options.project_folder, "data.tar.gz"); + var project_root = path.join(options.project_folder, "root"); + + options.project_root = project_root; + + var input = fs.createReadStream(datafile); + var unzipper = zlib.createGunzip(); + var extractor = tar.Extract({path: project_root, strip: 0}); + + input.on('error', make_error_cb("reading package data file.")); + extractor.on('error', make_error_cb("unpacking package data file.")); + if (!("only-extract" in options)) + extractor.on('end', function(){ run_project(options); }); + + input.pipe(unzipper) + unzipper.pipe(extractor); +} + +function read_metadata(options) +{ + if (options.verbose) + console.log("Reading project metadata"); + + var project_folder = options.project_folder; + var metadata = JSON.parse(fs.readFileSync(path.join(project_folder, "meta.json"))); + + if (options.verbose) + console.log("Project: %s\nVersion: %s\nEntry point: %s", metadata.Name, metadata.Version, metadata.Entry); + if ("only-dump" in options) + process.exit(0); + + options.metadata = metadata; + + unpack_project_data(options); +} + +function extract(filename, options) +{ + if (options.verbose) + console.log("Extracting ", filename, "with options ", options); + + var project_id = path.basename(filename, ".epk"); + var project_folder = path.join(options['temp-dir'], project_id); + + options.project_folder = project_folder; + options.project_id = project_id; + + var input = fs.createReadStream(filename); + var extractor = tar.Extract({path: options['temp-dir'], strip: 0}); + + input.on('error', make_error_cb("reading package file.")); + extractor.on('error', make_error_cb("unpacking package file.")); + extractor.on('end', function(){ read_metadata(options); }); + + input.pipe(extractor); +} + +function main() { + var options = getopt.create([ + ['d', 'only-dump', 'Only dump information about the package'], + ['e', 'only-extract', 'Only extract the package, do not run'], + ['h', 'help', 'Display this help'], + ['k', 'keep', 'Do not remove the files after exiting'], + ['t', 'temp-dir=ARG', 'Temporary dir to extract files'], + ['v', 'verbose', 'Print information messages'], + ]).bindHelp().parseSystem(); + + var filename = options.argv[0]; + if (filename === undefined) + { + console.error("Must provide a package file."); + process.exit(1); + } + + if (!('temp-dir' in options.options)) + { + options.options["temp-dir"] = path.join(os.tmpdir(), "efljs_apps"); + if (options.verbose) + console.log("Defaulting temp dir to ", options.options["temp-dir"]); + } + + extract(filename, options.options); +} + +main(); diff --git a/src/bin/efl_js/efljslaunch.desktop b/src/bin/efl_js/efljslaunch.desktop new file mode 100644 index 0000000000..53371cba97 --- /dev/null +++ b/src/bin/efl_js/efljslaunch.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=EFL JS package launcher +Exec=efljslaunch %f +Type=Application +Categories=EFL +Terminal=true +MimeType=application/x-efljspackage; diff --git a/src/bin/efl_js/efljslaunch.xml b/src/bin/efl_js/efljslaunch.xml new file mode 100644 index 0000000000..b1db6841b2 --- /dev/null +++ b/src/bin/efl_js/efljslaunch.xml @@ -0,0 +1,7 @@ + + + + EFL JS package + + + \ No newline at end of file diff --git a/src/bin/efl_js/efljspack b/src/bin/efl_js/efljspack new file mode 100755 index 0000000000..50e27b6ac4 --- /dev/null +++ b/src/bin/efl_js/efljspack @@ -0,0 +1,251 @@ +#!/bin/sh +':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@" + +var zlib = require('zlib'); +var path = require('path'); + +// external dependencies +var fs = require('fs-extra'); +var tar = require('tar'); +var fstream = require('fstream'); +var getopt = require('node-getopt'); + +/* + * Packing a project. + * The efljs package has a similar format to debian packages. It is a + * tar package containing two files: + * + * meta.txt: Metadata information about this package. + * data.tar.gz: Gzipped data, with the project tree ready to be decompressed + * and run by the package launcher. + * + * During the build, a out/ directory is created in the project root to + * store the package and temporary files. + */ + +// Creates a stub .project file and packs it. +function pack_single(sourcepath, options) +{ + if (options.verbose) + console.log("Creating project file for single file app", sourcepath); + + var dir_name = path.dirname(fs.realpathSync(sourcepath)); + var filename = path.basename(sourcepath); + var projectRegex = /^(.*).js$/g; + var project_name = projectRegex.exec(filename)[1]; + + if (!validade_project_name(project_name)) + { + console.error("Invalid project name. Must start with a letter."); + process.exit(0); + } + + var project_filename = path.join(dir_name, project_name + ".project"); + + var fd = fs.openSync(project_filename, 'w'); + + var jsonData = {}; + + jsonData["Name"] = project_name; + jsonData["Entry"] = filename; + jsonData["Sources"] = [[filename, '.']]; + jsonData["Version"] = "0.1"; + + fs.writeSync(fd, JSON.stringify(jsonData, null, 2)); + + fs.closeSync(fd); + + pack_project(project_filename, options); + +} + +function generate_build_info(configuration, project_file, options) +{ + build_info = {}; + + // project == project_dir + // /out == build_dir + // /data == data_dir + // /name-version == package_dir + + build_info.package_id = configuration.Name + "-" + configuration.Version; + build_info.project_dir = path.dirname(project_file); + build_info.build_dir = path.join(build_info.project_dir, "out"); + build_info.data_dir = path.join(build_info.build_dir, "data"); + build_info.package_dir = path.join(build_info.build_dir, build_info.package_id); + build_info.data_file = path.join(build_info.package_dir, "data.tar.gz"); + build_info.package_file = path.join(build_info.build_dir, build_info.package_id + ".epk") + build_info.metadata_file = path.join(build_info.package_dir, "meta.json"); + + if (options.verbose) + { + console.log("Project id: ", build_info.package_id); + console.log("Project source dir: ", build_info.project_dir); + console.log("Project build dir: ", build_info.build_dir); + console.log("Project data dir:", build_info.data_dir); + console.log("Project package dir:", build_info.package_dir); + } + + return build_info; + +} + +// Project names must start with a letter and contain only +// letters, digits and underscores. +function validade_project_name(name) +{ + return (/^[a-zA-Z][\w-]*$/).test(name) +} + +function pack_project(project_file, options) +{ + if (options.verbose) + console.log("Packing project from project file ", project_file); + + var configuration = JSON.parse(fs.readFileSync(project_file)); + + if (!validade_project_name(configuration.Name)) + { + console.error("Invalid project name. Must start with a letter."); + process.exit(0); + } + + var build_info = generate_build_info(configuration, project_file, options); + + try + { + fs.mkdirSync(build_info.build_dir); + fs.mkdirSync(build_info.data_dir); + fs.mkdirSync(build_info.package_dir); + } + catch (e) + { + console.warn("Warning: Project output directories not empty."); + } + + create_metadata_file(configuration, build_info, options); + + // If not explicitly named on configuration, add the entire directory + if (!('Sources' in configuration)) + { + generate_source_list(configuration, build_info.project_dir, options); + } + + create_project_tree(configuration.Sources, build_info, options); + + pack_data_dir(build_info, options); +} + +function create_project_tree(sources, build_info, options) +{ + for (var i = sources.length - 1; i >= 0; i--) { + if (options.verbose) + console.log("Adding file ", sources[i], "to package."); + var source_file = path.join(build_info.project_dir, sources[i][0]); + var destination_dir = path.join(build_info.data_dir, sources[i][1]); + var destination_filename = path.basename(source_file); + var destination_file = path.join(destination_dir, destination_filename); + + fs.copySync(source_file, destination_file); + }; +} + +function generate_source_list(configuration, project_dir, options) +{ + console.log("Generating source list for project dir", build_info.project_dir); + var dir_entries = fs.readdirSync(project_dir); + var sources = []; + + dir_entries.forEach(function(entry){ + if (entry == "out") + return; + sources.push([entry, "."]); + }); + configuration.Sources = sources; +} + +function create_metadata_file(configuration, build_info, options) +{ + if (options.verbose) + console.log("Creating metadata file", build_info.metadata_file); + + var metadata = {}; + + metadata.Name = configuration.Name; + metadata.Entry = configuration.Entry; + metadata.Version = configuration.Version; + + var output = fs.createWriteStream(build_info.metadata_file); + output.write(JSON.stringify(metadata, null, 2)); + output.close(); +} + +function pack_data_dir(build_info, options) +{ + if (options.verbose) + console.log("Packing data..."); + + pack_directory(build_info.data_dir, build_info.data_file, true, true, function(){ + if (options.verbose) + console.log("Packed data"); + pack_final_package(build_info, options); + }); +} + +function pack_final_package(build_info, options) +{ + if (options.verbose) + console.log("Creating package ", build_info.package_file); + pack_directory(build_info.package_dir, build_info.package_file, false, false, function(){ + if (options.verbose) + console.log("Created project package."); + }); +} + +function pack_directory(source_dir, target_file, strip_base_dir, should_gzip, callback) +{ + var output = fs.createWriteStream(target_file); + var packer = tar.Pack({fromBase: strip_base_dir == true}); + if (callback != undefined) + output.on('close', callback); + + var reader = fstream.Reader({path: source_dir, type: "Directory"}); + var destStr = reader.pipe(packer); + if(should_gzip) + destStr = destStr.pipe(zlib.createGzip()); + destStr.pipe(output); +} + +function main() +{ + + var options = getopt.create([ + ['v', 'verbose', 'Explain what is being done'], + ['h', 'help', 'Display this help'] + ]).bindHelp().parseSystem(); + + filename = options.argv[0]; + + if (typeof filename === 'undefined') + { + console.error('Must provide a valid js or project file.'); + process.exit(1); + } + + if (endsWith(filename, ".js")) + { + pack_single(filename, options.options); + } + else if (endsWith(filename, ".project")) + { + pack_project(filename, options.options); + } +} + +main(); + +//// Helper functions +function endsWith(str, suffix) +{ + return str.indexOf(suffix, str.length - suffix.length) !== -1; +} diff --git a/src/bin/efl_js/launcher_main.cc b/src/bin/efl_js/launcher_main.cc new file mode 100644 index 0000000000..680f16ca52 --- /dev/null +++ b/src/bin/efl_js/launcher_main.cc @@ -0,0 +1,156 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include +// #include + +using namespace std; +using namespace v8; + +const char PATH_SEPARATOR = +#ifdef _WIN32 + '\\'; +#else + '/'; +#endif + +static std::string get_file_contents(const char *filename) { + std::ifstream in(filename, std::ios::in); + if (in) { + std::ostringstream contents; + contents << in.rdbuf(); + in.close(); + return contents.str(); + } else { + throw(errno); + } +} + +static std::string get_filename(std::string path) +{ + int beginIdx = path.rfind(PATH_SEPARATOR); + return path.substr(beginIdx + 1); +} + +static void show_usage(std::string name) +{ + std::cerr << "Usage: " << get_filename(name) << " [SOURCE]\n" << std::endl + << "Options:" << std::endl + << "\t-h, --help\t\t Show this help message" << std::endl; +} + +/* + * Basic console.log implementation with space-separated values, + * no substitution + */ +void Log(const FunctionCallbackInfo& args) +{ + Isolate* isolate = Isolate::GetCurrent(); + HandleScope scope(isolate); + + for (int i=0; i < args.Length(); i++) + { + if (i != 0) + std::cout << " "; + String::Utf8Value string(args[i]); + std::cout << *string; + } + + std::cout << std::endl; + + args.GetReturnValue().Set(v8::Null(isolate)); +} + + +int main(int argc, char* argv[]) +{ + + std::string script_source; + char *filename = 0; + + for (int i=1; i < argc; i++) + { + if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) + { + show_usage(argv[0]); + return 0; + } + else + { + filename = argv[i]; + } + } + + if (!filename) + { + std::cerr << "Error: No source provided." << std::endl; + show_usage(argv[0]); + return 1; + } + + try + { + script_source = get_file_contents(filename); + } catch (int errno) + { + perror("Error: "); + return 1; + } + + + efl::eina::js::compatibility_initialize(); + v8::V8::SetFlagsFromCommandLine(&argc, const_cast(argv), true); + + v8::Isolate* isolate = efl::eina::js::compatibility_isolate_new(); + { + Isolate::Scope isolate_scope(isolate); + HandleScope handleScope(isolate); + + Local context = Context::New(isolate, NULL); + Context::Scope context_scope(context); + context->Enter(); + + // Setup the console and log + Local console = Object::New(isolate); + Local log = FunctionTemplate::New(isolate, Log); + console->Set(String::NewFromUtf8(isolate, "log"), log->GetFunction()); + + Local global = context->Global(); + global->Set(String::NewFromUtf8(isolate, "console"), console); + + // Set up the efl exports; Needed to enter the context before this + // due to creating Objects instead of Objects Templates + // WIP: Commented out due to potential missing v8 platform implementation issues + // Local efl_exports = Object::New(isolate); + // global->Set(String::NewFromUtf8(isolate, "efl"), efl_exports); + // efl_js::init(efl_exports); + + // And now the user's script + Local source = String::NewFromUtf8(isolate, script_source.c_str()); + + Local