Skip to content

Commit

Permalink
Add build support for pipy gui mode (flomesh-io#15)
Browse files Browse the repository at this point in the history
* Add build support for Pipy GUI mode

Co-authored-by: Kevein Liu <kevein@flomesh.cn>
  • Loading branch information
khas-flomesh and keveinliu authored Jun 6, 2021
1 parent f6d6eb2 commit 36eeb87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ ENV CC clang

COPY . /pipy

RUN apk add --no-cache --virtual .build-deps openssh-client git cmake clang alpine-sdk linux-headers
RUN apk add --no-cache --virtual .build-deps openssh-client git cmake clang alpine-sdk linux-headers zlib zlib-dev

RUN rm -fr pipy/build \
&& mkdir pipy/build \
&& cd pipy/build \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& cd pipy/gui \
&& npm install \
&& npm run build \
&& cd ../build \
&& cmake -DPIPY_GUI=ON -DCMAKE_BUILD_TYPE=Release .. \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& mkdir ${pkg_confdir} \
&& cp /pipy/bin/pipy ${pkg_bindir} \
Expand Down
19 changes: 18 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ if $BUILD_ONLY && $TEST_ONLY ; then
usage
fi

function version_compare() {
if [ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$1" ]; then
true
else
return 125
fi
}

CMAKE=
function __build_deps_check() {
if [ ! -z $(command -v cmake3) ]; then
Expand All @@ -110,6 +118,12 @@ function __build_deps_check() {
fi
clang --version 2>&1 > /dev/null && clang++ --version 2>&1 > /dev/null && export __CLANG_EXIST=true
if [ "x"$CMAKE = "x" ] || ! $__CLANG_EXIST ; then echo "Command \`cmake\` or \`clang\` not found." && exit -1; fi
__NODE_VERSION=`node --version 2> /dev/null`
version_compare "v12" "$__NODE_VERSION"
if [ $? -ne 0 ]; then
echo "NodeJS is too old, the minimal requirement is NodeJS 12."
exit -1
fi
}

function build() {
Expand All @@ -120,10 +134,13 @@ function build() {
git pull origin $BRANCH
export CC=clang
export CXX=clang++
cd ${PIPY_DIR}/gui
npm install
npm run build
mkdir ${PIPY_DIR}/build 2>&1 > /dev/null || true
rm -fr ${PIPY_DIR}/build/*
cd ${PIPY_DIR}/build
$CMAKE -DCMAKE_BUILD_TYPE=Release $PIPY_DIR
$CMAKE -DPIPY_GUI=ON -DCMAKE_BUILD_TYPE=Release $PIPY_DIR
make -j${__NPROC}
if [ $? -eq 0 ];then
echo "pipy now is in ${PIPY_DIR}/bin"
Expand Down

0 comments on commit 36eeb87

Please sign in to comment.