Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix build script #79

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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',
Expand Down
17 changes: 15 additions & 2 deletions modules/packages/packaging/lwnode-modules.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
100 changes: 53 additions & 47 deletions packaging/lwnode.spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ BuildRequires: libasan
%{!?target: %define target lwnode}
%{!?lib_type: %define lib_type shared} # <shared|static>
%{!?static_escargot: %define static_escargot 0}
%{!?debug: %define debug 0}

%description
Lightweight Node.js is a memory efficient Node.js implementation,
Expand Down Expand Up @@ -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
##############################################
Expand All @@ -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
Expand All @@ -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
18 changes: 15 additions & 3 deletions tools/build-modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
"
}

Expand All @@ -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
Expand Down Expand Up @@ -106,6 +112,9 @@ while [[ $# -gt 0 ]]; do
--os=*)
TARGET_OS="${1#*=}"
;;
--arch=*)
TARGET_ARCH="${1#*=}"
;;
--clean-after)
CLEAN_AFTER=true
;;
Expand All @@ -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
Loading