forked from enlightenment/efl
To configure efl sources with bindings to use in nodejs add ––with-js=nodejs in configure flags to generate node files $ configure --with-js=nodejs and compile normally with: $ make $ make install To use, you have to require efl: efl = require('efl') The bindings is divided in two parts: generated and manually written. The generation uses the Eolian library for parsing Eo files and generate C++ code that is compiled against V8 interpreter library to create a efl.node file that can be required in a node.js instance. @featuredevs/felipealmeida/js
parent
1a3cb45f1c
commit
a3db1dddd3
141 changed files with 20314 additions and 137 deletions
@ -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@ |
@ -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@ |
@ -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@ |
@ -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@ |
@ -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 |
||||
|
@ -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 <Efl.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc |
||||
@echo @ECHO_E@ "#include <Efl_Config.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc |
||||
@echo @ECHO_E@ "#include <Ecore.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc |
||||
@echo @ECHO_E@ "#include <Eo.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc |
||||
@echo @ECHO_E@ "#include <Ecore_Con.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc |
||||
@echo @ECHO_E@ "#include <Ecore_Audio.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc |
||||
@echo @ECHO_E@ "#include <Evas.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc |
||||
@echo @ECHO_E@ "#include <Edje.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc |
||||
@echo @ECHO_E@ "#include <Ecore_Con_Eet.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc |
||||
@echo @ECHO_E@ "#include <Emotion.h>\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 |
@ -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 |
||||
|
||||
|
||||
|
@ -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) |
@ -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(); |
@ -0,0 +1,7 @@ |
||||
[Desktop Entry] |
||||
Name=EFL JS package launcher |
||||
Exec=efljslaunch %f |
||||
Type=Application |
||||
Categories=EFL |
||||
Terminal=true |
||||
MimeType=application/x-efljspackage; |
@ -0,0 +1,7 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> |
||||
<mime-type type="application/x-efljspackage"> |
||||
<comment xml:lang="en">EFL JS package</comment> |
||||
<glob pattern="*.epk"/> |
||||
</mime-type> |
||||
</mime-info> |
@ -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); |
||||
}; |
||||
} |
||||