From d5cd766b06f0d0a35967c83c0cd072d8b11b335d Mon Sep 17 00:00:00 2001 From: Rudra Arora Date: Wed, 21 Jun 2023 15:04:19 +0100 Subject: [PATCH] sed command fix for BSD based sed in build**.sh --- build32.sh | 17 +++++++++++++++-- build64.sh | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/build32.sh b/build32.sh index c83af6214..d3593d588 100755 --- a/build32.sh +++ b/build32.sh @@ -12,8 +12,21 @@ cd ../../.. # Build the extensions cargo run --manifest-path tools/wasix-headers/Cargo.toml generate-libc cp -f libc-bottom-half/headers/public/wasi/api.h libc-bottom-half/headers/public/wasi/api_wasix.h -sed -i 's|__wasi__|__wasix__|g' libc-bottom-half/headers/public/wasi/api_wasix.h -sed -i 's|__wasi_api_h|__wasix_api_h|g' libc-bottom-half/headers/public/wasi/api_wasix.h + +OS=`uname -s` + +case $OS in + 'Linux') + sed -i 's|__wasi__|__wasix__|g' libc-bottom-half/headers/public/wasi/api_wasix.h + sed -i 's|__wasi_api_h|__wasix_api_h|g' libc-bottom-half/headers/public/wasi/api_wasix.h + ;; + 'Darwin') + sed -i '' 's|__wasi__|__wasix__|g' libc-bottom-half/headers/public/wasi/api_wasix.h + sed -i '' 's|__wasi_api_h|__wasix_api_h|g' libc-bottom-half/headers/public/wasi/api_wasix.h + ;; + *) ;; +esac + cp -f libc-bottom-half/sources/__wasilibc_real.c libc-bottom-half/sources/__wasixlibc_real.c # Build WASI diff --git a/build64.sh b/build64.sh index 3ec9b12f0..05b1af44c 100755 --- a/build64.sh +++ b/build64.sh @@ -9,11 +9,25 @@ git reset --hard git pull origin main || true cd ../../.. +OS=`uname -s` + # Build the extensions cargo run --manifest-path tools/wasix-headers/Cargo.toml generate-libc --64bit cp -f libc-bottom-half/headers/public/wasi/api.h libc-bottom-half/headers/public/wasi/api_wasix.h -sed -i 's|__wasi__|__wasix__|g' libc-bottom-half/headers/public/wasi/api_wasix.h -sed -i 's|__wasi_api_h|__wasix_api_h|g' libc-bottom-half/headers/public/wasi/api_wasix.h +OS=`uname -s` + +case $OS in + 'Linux') + sed -i 's|__wasi__|__wasix__|g' libc-bottom-half/headers/public/wasi/api_wasix.h + sed -i 's|__wasi_api_h|__wasix_api_h|g' libc-bottom-half/headers/public/wasi/api_wasix.h + ;; + 'Darwin') + sed -i '' 's|__wasi__|__wasix__|g' libc-bottom-half/headers/public/wasi/api_wasix.h + sed -i '' 's|__wasi_api_h|__wasix_api_h|g' libc-bottom-half/headers/public/wasi/api_wasix.h + ;; + *) ;; +esac + cp -f libc-bottom-half/sources/__wasilibc_real.c libc-bottom-half/sources/__wasixlibc_real.c # Build WASI @@ -21,8 +35,21 @@ mkdir -p build/temp rsync -rtvu --delete tools/wasix-headers/ build/temp cp -r -f tools/wasi-headers/WASI/phases/* build/temp/WASI/phases mv -f build/temp/WASI/phases/snapshot/witx/wasi_snapshot_preview1.witx build/temp/WASI/phases/snapshot/witx/wasix_v1.witx -sed -i 's|(field $buf_len $size)|(field $buf_len usize)|g' build/temp/WASI/phases/snapshot/witx/typenames.witx -sed -i 's|(param $buf_len $size)|(param $buf_len usize)|g' build/temp/WASI/phases/snapshot/witx/wasix_v1.witx + + + +case $OS in + 'Linux') + sed -i 's/(field $buf_len $size)/(field $buf_len usize)/g' build/temp/WASI/phases/snapshot/witx/typenames.witx + sed -i 's/(param $buf_len $size)/(param $buf_len usize)/g' build/temp/WASI/phases/snapshot/witx/wasix_v1.witx + ;; + 'Darwin') + sed -i '' 's/(field $buf_len $size)/(field $buf_len usize)/g' build/temp/WASI/phases/snapshot/witx/typenames.witx + sed -i '' 's/(param $buf_len $size)/(param $buf_len usize)/g' build/temp/WASI/phases/snapshot/witx/wasix_v1.witx + ;; + *) ;; +esac + cargo clean --manifest-path build/temp/Cargo.toml cargo run --manifest-path build/temp/Cargo.toml generate-libc --64bit cp -f libc-bottom-half/headers/public/wasi/api.h libc-bottom-half/headers/public/wasi/api_wasi.h