diff --git a/configure.py b/configure.py index 57ec99779e..609777d091 100755 --- a/configure.py +++ b/configure.py @@ -140,6 +140,8 @@ def main(opts): # 3. prepare gyp arguments target_os = ('tizen' if opts.tizen else 'linux') gen_build_dir = os.path.join(ROOT_DIR, 'out', target_os) + if opts.tizen: + gen_build_dir = os.path.join(gen_build_dir, opts.arch) gyp_args += ['--depth=.'] gyp_args += ['--generator-output=' + gen_build_dir] gyp_args += ['-Goutput_dir=' + gen_build_dir] @@ -255,6 +257,14 @@ def setupCLIOptions(parser): help='Debug build (%default)', ) + lwnode_optgroup.add_option( + '--arch', + dest='arch', + choices=['arm', 'x32', 'x64'], + default='x64', + help='Target architecture (%default)', + ) + lwnode_optgroup.add_option( '-v', '--verbose', diff --git a/modules/packages/packaging/lwnode-modules.spec b/modules/packages/packaging/lwnode-modules.spec index db2b320151..89db260fcd 100644 --- a/modules/packages/packaging/lwnode-modules.spec +++ b/modules/packages/packaging/lwnode-modules.spec @@ -40,6 +40,19 @@ BuildRequires: pkgconfig(tpk-manifest-handlers) %define target_modules_path %{target_lwnode_path}/node_modules %define local_modules_path modules/packages +%ifarch armv7l armv7hl +%define tizen_arch arm +%endif +%ifarch aarch64 +%define tizen_arch arm64 +%endif +%ifarch i686 +%define tizen_arch x32 +%endif +%ifarch x86_64 +%define tizen_arch x64 +%endif + %description lwnode modules @@ -62,7 +75,7 @@ rpmbuild --version echo "Build Modules:" %{modules_list} echo $CFLAGS -./tools/build-modules.sh %{?modules_list} --os=tizen --clean-after +./tools/build-modules.sh %{?modules_list} --os=tizen --arch=%{tizen_arch} --clean-after ############################################## ## Install @@ -72,7 +85,7 @@ echo $CFLAGS rm -rf %{buildroot} mkdir -p %{buildroot}%{target_modules_path} -cp -rf out/modules/tizen/* %{buildroot}%{target_modules_path} +cp -rf out/modules/tizen/%{tizen_arch}/* %{buildroot}%{target_modules_path} %clean rm -fr ./*.list diff --git a/packaging/lwnode.spec b/packaging/lwnode.spec index 0c720b7004..ee5384b68c 100644 --- a/packaging/lwnode.spec +++ b/packaging/lwnode.spec @@ -70,6 +70,7 @@ BuildRequires: libasan %{!?target: %define target lwnode} %{!?lib_type: %define lib_type shared} # %{!?static_escargot: %define static_escargot 0} +%{!?debug: %define debug 0} %description Lightweight Node.js is a memory efficient Node.js implementation, @@ -108,37 +109,44 @@ rpmbuild --version echo "Build Target:" %{target} echo $CFLAGS -%if "%{target}" == "lwnode" - %define target_src out/tizen/Release - %define target_lib %{target_src}/lib +%if 0%{?debug} == 1 + %define target_src out/tizen/%{tizen_arch}/Debug + %define debug_config --debug --escargot-debugger +%else + %define target_src out/tizen/%{tizen_arch}/Release +%endif - %if 0%{?asan} == 1 - %define asan_config --nopt --enable-asan - %endif +%define target_lib %{target_src}/lib - %if "%{lib_type}" == "shared" - %define lib_type_config --nopt --shared - %endif +%if 0%{?asan} == 1 + %define asan_config --nopt --enable-asan +%endif - %if 0%{?static_escargot} == 1 - %define jsengine_config --escargot-lib-type static_lib - %endif +%if "%{lib_type}" == "shared" + %define lib_type_config --nopt --shared +%endif - %if (0%{?tizen_version_major} == 4) && (0%{?tizen_version_minor} == 0) - %define external_libs_config --nopt --shared-zlib --nopt --shared-cares - %else - %define external_libs_config --nopt --shared-zlib --nopt --shared-cares \\\ - --nopt --shared-openssl --nopt --shared-nghttp2 - %endif +%if 0%{?static_escargot} == 1 + %define jsengine_config --escargot-lib-type static_lib +%endif - # building lwnode executable - ./configure.py --tizen --verbose --revision='%{?revision}' \ - --nopt --dest-cpu='%{tizen_arch}' \ - %{?lib_type_config} %{?asan_config} \ - %{?external_libs_config} %{?jsengine_config} - ninja -C %{target_src} %{target} +%if (0%{?tizen_version_major} == 4) && (0%{?tizen_version_minor} == 0) + %define external_libs_config --nopt --shared-zlib --nopt --shared-cares +%else + %define external_libs_config --nopt --shared-zlib --nopt --shared-cares \\\ + --nopt --shared-openssl --nopt --shared-nghttp2 %endif +# building lwnode executable +./configure.py --tizen --verbose \ + --nopt --dest-cpu='%{tizen_arch}' \ + --arch='%{tizen_arch}' \ + %{?lib_type_config} %{?asan_config} \ + %{?external_libs_config} %{?jsengine_config} \ + %{?debug_config} +ninja -C %{target_src} %{target} + + ############################################## ## Install ############################################## @@ -150,21 +158,20 @@ mkdir -p %{buildroot}%{_libdir} rm -f %{target_lib}/*.tmp %{target_lib}/*.TOC -%if "%{target}" == "lwnode" - %if 0%{?static_escargot} == 0 - strip -v -g %{target_src}/gen/escargot/libescargot.so - cp %{target_src}/gen/escargot/libescargot.so %{buildroot}%{_libdir} - %endif - %if "%{lib_type}" == "shared" - strip -v -g %{target_lib}/liblwnode.so* - cp %{target_lib}/liblwnode.so* %{buildroot}%{_libdir} - %endif - %if %{?debug_symbols:0}%{!?debug_symbols:1} - strip -v -g %{target_src}/%{target} - %endif - cp %{target_src}/%{target} %{buildroot}%{_bindir} - cp %{target_src}/%{target}.dat %{buildroot}%{_bindir} +%if 0%{?static_escargot} == 0 + strip -v -g %{target_src}/gen/escargot/libescargot.so + cp %{target_src}/gen/escargot/libescargot.so %{buildroot}%{_libdir} +%endif +%if "%{lib_type}" == "shared" + strip -v -g %{target_lib}/liblwnode.so* + cp %{target_lib}/liblwnode.so* %{buildroot}%{_libdir} +%endif +%if %{?debug_symbols:0}%{!?debug_symbols:1} + strip -v -g %{target_src}/%{target} %endif +cp %{target_src}/%{target} %{buildroot}%{_bindir} +cp %{target_src}/%{target}.dat %{buildroot}%{_bindir} + %clean rm -fr ./*.list @@ -183,14 +190,13 @@ rm -fr ./*.manifest %files %manifest packaging/%{name}.manifest %defattr(-,root,root,-) -%if "%{target}" == "lwnode" - %if 0%{?static_escargot} == 0 - %{_libdir}/libescargot.so - %endif - %if "%{lib_type}" == "shared" - %{_libdir}/liblwnode.so* - %endif - %{_bindir}/%{target}.dat - %{_bindir}/%{target} +%if 0%{?static_escargot} == 0 + %{_libdir}/libescargot.so +%endif +%if "%{lib_type}" == "shared" + %{_libdir}/liblwnode.so* %endif +%{_bindir}/%{target}.dat +%{_bindir}/%{target} + %license LICENSE LICENSE.Apache-2.0 LICENSE.NodeJS LICENSE.MIT LICENSE.BSD-2-Clause LICENSE.BSD-3-Clause LICENSE.BOEHM-GC LICENSE.ICU LICENSE.LGPL-2.1+ LICENSE.Zlib diff --git a/tools/build-modules.sh b/tools/build-modules.sh index 60b6785a11..8d54c8886b 100755 --- a/tools/build-modules.sh +++ b/tools/build-modules.sh @@ -14,6 +14,7 @@ # limitations under the License. TARGET_OS="linux" +TARGET_ARCH = "arm" PROJECT_ROOT_PATH=$PWD PACKAGES_ROOT_PATH=$PROJECT_ROOT_PATH/modules/packages @@ -42,8 +43,9 @@ usage() { echo " options: --os) target os (linux/tizen) + --arch) target arch for only tizen (arm/x32/x64) " - echo "example) build-modules.sh hello-world,tizen-device-api --os=tizen + echo "example) build-modules.sh hello-world,tizen-device-api --os=tizen --arch=arm " } @@ -68,9 +70,13 @@ check_build_result() { } build_module() { - fancy_echo "build [$1]" + fancy_echo "build [$1]\n" - local out_path=$BUILD_OUT_ROOT_PATH/$TARGET_OS/$1 + local out_path=$BUILD_OUT_ROOT_PATH/$TARGET_OS + if [[ "$TARGET_OS" = "tizen" ]] ; then + out_path=$out_path/$TARGET_ARCH + fi + out_path=$out_path/$1 local module_path=$PACKAGES_ROOT_PATH/$1 local definitions="-DBUILDING_NODE_EXTENSION;-DLWNODE" mkdir -p $out_path @@ -106,6 +112,9 @@ while [[ $# -gt 0 ]]; do --os=*) TARGET_OS="${1#*=}" ;; + --arch=*) + TARGET_ARCH="${1#*=}" + ;; --clean-after) CLEAN_AFTER=true ;; @@ -119,4 +128,7 @@ while [[ $# -gt 0 ]]; do done fancy_echo "target os: $TARGET_OS" +if [[ "$TARGET_OS" = "tizen" ]] ; then + fancy_echo "target arch: $TARGET_ARCH" +fi find_and_build_modules $MODULES_LIST