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

feat: remove zsh dependency #930

Merged
merged 7 commits into from
Sep 24, 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
24 changes: 10 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install -y vim zsh luajit lua-cjson
sudo apt-get install -y vim luajit lua-cjson
pip3 install meson ninja
- name: Build with command ${{ matrix.command }}
run: |
Expand All @@ -128,7 +128,7 @@ jobs:
- uses: hendrikmuhs/ccache-action@v1.2
- name: install dependencies
run: |
sudo apt install -yq zsh jq musl-tools musl-dev libreadline-dev
sudo apt install -yq jq musl-tools musl-dev libreadline-dev
- name: Build x86_64 with musl-system
run: |
make -f build/musl-linux.mk CCACHE=1
Expand All @@ -152,7 +152,7 @@ jobs:
- uses: hendrikmuhs/ccache-action@v1.2
- name: install dependencies
run : |
sudo apt install -y zsh jq gcc-mingw-w64 g++-mingw-w64
sudo apt install -y jq gcc-mingw-w64 g++-mingw-w64
- name: Build x86_64 windows .exe
run: |
make -f build/win-exe.mk CCACHE=1
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:
python-version: '3.10'
- run: |
pip3 install meson ninja
sudo apt-get install -qy zsh libreadline-dev
sudo apt-get install -qy libreadline-dev
- run: |
make -f build/linux.mk deps zencode-exec CCACHE=1
cp zencode-exec /usr/local/bin/
Expand Down Expand Up @@ -226,7 +226,7 @@ jobs:
toolchain: ${{ matrix.rust }}
- run: |
pip3 install meson ninja
sudo apt-get install -qy zsh libreadline-dev
sudo apt-get install -qy libreadline-dev
- run: |
make -f build/linux.mk CCACHE=1
cp zencode-exec /usr/local/bin/
Expand All @@ -246,7 +246,7 @@ jobs:
# with:
# fetch-depth: 0
# - uses: numworks/setup-arm-toolchain@2021-10
# - run: sudo apt install zsh qemu-system-arm
# - run: sudo apt install qemu-system-arm
# - name: Download cmsis
# run: |
# curl -LO https://github.com/ARM-software/CMSIS_5/archive/refs/tags/5.7.0.tar.gz
Expand Down Expand Up @@ -282,7 +282,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get -qy update
sudo apt-get install -qy zsh meson ninja-build
sudo apt-get install -qy meson ninja-build
- name: Install yarn dependencies
run: |
yarn --cwd bindings/javascript
Expand Down Expand Up @@ -322,12 +322,8 @@ jobs:
- name: Install dependencies on Linux
run: |
sudo apt update
sudo apt install -yq zsh cmake libreadline-dev
sudo apt install -yq cmake libreadline-dev
if: runner.os == 'Linux'
- name: Install dependencies on Apple/OSX
run: |
brew install zsh
if: runner.os == 'macOS'
- name: Build zencode-exec on Linux
run: |
cd ../..
Expand Down Expand Up @@ -398,7 +394,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get -qy update
sudo apt-get install -qy zsh meson ninja-build
sudo apt-get install -qy meson ninja-build
- name: Install yarn dependencies
run: |
yarn --cwd bindings/javascript
Expand Down Expand Up @@ -435,7 +431,7 @@ jobs:
build/release-intro.md
- name: Install build deps
run: |
sudo apt install -qy zsh tree jq cmake make gcc g++ musl-tools musl-dev meson clang gcc-mingw-w64 g++-mingw-w64 libreadline-dev ccache
sudo apt install -qy tree jq cmake make gcc g++ musl-tools musl-dev meson clang gcc-mingw-w64 g++-mingw-w64 libreadline-dev ccache
- name: Build x86_64 with musl-system
run: |
make -f build/musl-linux.mk CCACHE=1
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

FROM alpine:latest

ADD . /
COPY lib /lib
COPY src /src
COPY build /build
COPY Makefile Makefile

RUN apk add --no-cache zsh linux-headers build-base cmake readline-dev
RUN apk add --no-cache linux-headers build-base cmake readline-dev
RUN make linux
RUN cp /src/zenroom /usr/local/bin/zenroom

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ ready to deploy.

## Build

Dependencies: makefile, cmake, zsh, gcc, libreadline-dev, xxd
Dependencies: makefile, cmake, gcc, libreadline-dev, xxd

Optional: musl-libc, emscripten for wasm builds

Expand Down
71 changes: 29 additions & 42 deletions build/embed-lualibs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/usr/bin/env zsh
#!/usr/bin/env sh

[[ ! -z "$MESON_SOURCE_ROOT" ]] && {
[ -n "$MESON_SOURCE_ROOT" ] && {
cd "$MESON_SOURCE_ROOT"
cd ..
}

[[ -d src/lua ]] || {
print "error - directory not found: src/lua"
return 1
[ -d src/lua ] || {
echo "error - directory not found: src/lua"
exit 1
}

pwd=`pwd`
pwd=$(pwd)
dst=${pwd}/src/lualibs_detected.c
opts="${1}"
# script to take all extensions in src/lua and embed them inside
# zenroom as strings

compile_flag=""
[[ "$opts" == "compile" ]] && compile_flag="#define LUA_COMPILED 1"
[ "$opts" = "compile" ] && compile_flag="#define LUA_COMPILED 1"

cat <<EOF > ${dst}
// This file is generated by running build/embed-lualibs
Expand All @@ -30,62 +30,49 @@ ${compile_flag}
const unsigned int fakelen = 0;
#else
EOF
libs=`find src/lua -type f -name '*.lua'`
libs=$(find src/lua -type f -name '*.lua')

# emscripten doesn't supports embedding this way
# will use --preload-file instead

typeset -A emptyarray=()
extarray=()
c=0
zen_extensions=""
[ -r luac45 ] || {
curl -Ls -o luac54 https://github.com/dyne/luabinaries/releases/latest/download/luac54
chmod +x luac54
}
for i in ${(f)libs}; do
p=`basename $i`
n=${p[(ws:.:)1]}

for i in ${libs}; do
p=$(basename $i)
n=$(echo "$p" | cut -d'.' -f1)
f="lualib_${n}.c"
print "+ $i $opts"
tmp=`mktemp -d`
if [[ "$opts" = "compile" ]]; then
echo "+ $i $opts"
tmp=$(mktemp -d)
if [ "$opts" = "compile" ]; then
./luac54 -o ${tmp}/${n} $i
else
cp $i ${tmp}/${n}
fi
pushd $tmp
print >> ${dst}
print "// $i" >> ${dst}
cd $tmp
echo "// $i" >> ${dst}
xxd -i ${n} >> ${dst}
if [[ "`uname -s`" =~ "Linux" ]]; then
sed -i 's/^unsigned/const unsigned/' ${dst}
else
sed -e 's/^unsigned/const unsigned/' -i '' "${dst}"
if [ "$(uname -s)" = "Linux" ]; then
sed -i 's/^unsigned/const unsigned/' ${dst}
else
sed -e 's/^unsigned/const unsigned/' -i '' "${dst}"
fi
print >> ${dst}
popd
echo "" >> ${dst}
cd - > /dev/null
rm -rf $tmp
ext="{\"${n}\", &${n}_len, (const char *)${n}},"
extarray+=($ext)
emptyarray+=($ext "{\"${n}\", &fakelen, \"/$p\"},")
c=$(( c + 1 ))
ext_nes="{\"${n}\", &${n}_len, (const char *)${n}},"
ext_es="{\"${n}\", &fakelen, \"/$p\"},"
zen_extensions="${zen_extensions}\n#ifndef __EMSCRIPTEN__\n${ext_nes}\n#else\n${ext_es}\n#endif"
done

cat <<EOF >> ${dst}
#endif // __EMSCRIPTEN__

zen_extension_t zen_extensions[] = {
EOF
for i in $extarray; do
cat <<EOF >> ${dst}
#ifndef __EMSCRIPTEN__
$i
#else
${emptyarray[$i]}
#endif
EOF
done
cat <<EOF >> ${dst}
{ NULL, NULL, NULL }
$(printf "%b" "$zen_extensions")
{ NULL, NULL, NULL }
};
EOF
2 changes: 1 addition & 1 deletion docs/pages/how-to-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It also compiles to a Windows 64-bit native and fully static executable. At last
<!-- tabs:start -->
#### **Devuan / Debian / Ubuntu**
```bash
apt-get install -y git build-essential cmake zsh xxd libreadline-dev
apt-get install -y git build-essential cmake xxd libreadline-dev
```
<!-- tabs:end -->

Expand Down
Loading