diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0ac4eb0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,134 @@ +name: "MetaCall Distributable Linux" + +on: + pull_request: + push: + tags: + - 'v*.*.*' + branches: + - master + workflow_dispatch: + # TODO: Implement support to automatically update the version of + # metacall/core when there is a tag on that repo that triggers this one + inputs: + ref: + description: "Version of metacall/core that triggered this workflow" + required: false + default: "" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + GHR_VERSION: 0.17.0 + # GITHUB_TOKEN - From default secrets + # GITHUB_REPOSITORY - Default variable + +jobs: + build: + name: Build and Package + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + build: [ + { mode: debug, suffix: "-dbg" }, + { mode: release, suffix: "" } + ] + arch: [amd64, 386] + + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + if: ${{ matrix.arch != 'amd64' }} + with: + platforms: all + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Build tarball + run: | + make PLATFORM=${{ matrix.arch }} BUILD=${{ matrix.build.mode }} base pull deps build + mv out/tarball.tar.gz out/metacall-tarball-linux-${{ matrix.arch }}${{ matrix.build.suffix }}.tar.gz + + - name: Upload tarball artifact + uses: actions/upload-artifact@v4 + with: + name: tarball-${{ matrix.arch }}-${{ matrix.build.mode }} + path: out/metacall-tarball-linux-${{ matrix.arch }}${{ matrix.build.suffix }}.tar.gz + + - name: Test + run: | + mv out/metacall-tarball-linux-${{ matrix.arch }}${{ matrix.build.suffix }}.tar.gz out/tarball.tar.gz + make PLATFORM=${{ matrix.arch }} BUILD=${{ matrix.build.mode }} test + + - name: Clear + run: | + set -exuo pipefail + make clear + + publish-github: + name: Publish on GitHub + runs-on: ubuntu-latest + needs: build + if: startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download tarball artifacts for all architectures + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: out/ + + - name: Load GHR binary + run: | + curl -sL https://github.com/tcnksm/ghr/releases/download/v${GHR_VERSION}/ghr_v${GHR_VERSION}_linux_amd64.tar.gz | tar zx + chmod +x ghr_v${GHR_VERSION}_linux_amd64/ghr + mv ghr_v${GHR_VERSION}_linux_amd64/ghr /usr/local/bin + + - name: Export variables + run: | + set -exo pipefail + echo "GH_REPO_OWNER=${GITHUB_REPOSITORY_OWNER}" >> $GITHUB_ENV + echo "GH_REPO_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV + echo "CI_COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV + export PREVIOUS_TAG=$(git describe HEAD^1 --abbrev=0 --tags) + echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV + echo "GIT_HISTORY<> $GITHUB_ENV + echo "$(git log --no-merges --format="- %s" ${PREVIOUS_TAG}..HEAD)" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + - name: Publish package to GitHub Releases + run: | + set -exo pipefail + if [[ "${PREVIOUS_TAG}" == "" ]]; then export GIT_HISTORY=$(git log --no-merges --format="- %s"); fi + export CI_COMMIT_TAG="${{ github.ref_name }}" + export RELEASE_DATE=$(date '+%Y-%m-%d') + echo "MetaCall Distributable Linux ${CI_COMMIT_TAG} [${RELEASE_DATE}] - ${GH_REPO_OWNER}/${GH_REPO_NAME}:${CI_COMMIT_SHA}" && echo "${GIT_HISTORY}" + ghr -t "${{ secrets.GITHUB_TOKEN }}" -u "${GH_REPO_OWNER}" -r "${GH_REPO_NAME}" -c "${CI_COMMIT_SHA}" -n "MetaCall Distributable Linux ${CI_COMMIT_TAG} [${RELEASE_DATE}]" -b "${GIT_HISTORY}" -replace "${CI_COMMIT_TAG}" "${PWD}/out/" + + install-test: + name: Trigger Install Test Workflow + runs-on: ubuntu-latest + needs: publish-github + if: startsWith(github.ref, 'refs/tags/v') + steps: + - uses: convictional/trigger-workflow-and-wait@v1.6.5 + with: + owner: metacall + repo: install + github_token: ${{ secrets.G_PERSONAL_ACCESS_TOKEN }} + workflow_file_name: test-linux.yml + wait_workflow: true + ref: master diff --git a/.gitignore b/.gitignore index 322a2d8..cc5e0dd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ out/* # GitHub Auth .netrc + +# VSCode +.vscode diff --git a/.guix-channel b/.guix-channel deleted file mode 100644 index 14ac9bb..0000000 --- a/.guix-channel +++ /dev/null @@ -1,34 +0,0 @@ -; -; MetaCall Distributable by Parra Studios -; Distributable infrastructure for MetaCall. -; -; Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; - -(channel - (version 0) - (dependencies - (channel - (name guix) - (url "https://git.savannah.gnu.org/git/guix.git") - (branch "master") - (commit "1a9ebe3b0aa12584624dfa811c480c636a56e1b4")) -; TODO: -; (channel -; (name nonguix) -; (url "https://gitlab.com/nonguix/nonguix.git") -; (branch "master") -; (commit "95adb6ec077dc4139cf7e1956ad5caa1ff08f92b")) - )) diff --git a/.netrc.template b/.netrc.template deleted file mode 100644 index 1e24d8d..0000000 --- a/.netrc.template +++ /dev/null @@ -1,6 +0,0 @@ -machine upload.github.com - login - password -machine api.github.com - login - password diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 67fa671..9d0a6c0 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,2 +1,3 @@ Tobias Geerinckx-Rice +Hadi Azami diff --git a/Dockerfile b/Dockerfile index d2dc96a..39c68df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,10 +27,11 @@ LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ vendor="MetaCall Inc." \ version="0.1" -COPY / /metacall/ +COPY . /metacall/ RUN chmod +x /metacall/scripts/build.sh \ && chmod +x /metacall/scripts/deps.sh \ - && mkdir -p /metacall/pack + && mkdir -p /metacall/pack \ + && mv /metacall/channels/channels.scm /root/.config/guix/channels.scm CMD ["sh"] diff --git a/LICENSE b/LICENSE index 953b6f9..d56ad81 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2016-2020 Vicente Eduardo Ferrer Garcia + Copyright 2016-2025 Vicente Eduardo Ferrer Garcia Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index 4ace3a7..fcfd76e 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,19 @@ # limitations under the License. # -.PHONY: all download base pull deps build test release help default +.PHONY: all download base pull deps build test help default + +# Define platform +ifdef PLATFORM +PLATFORM_ARGS := --platform=linux/${PLATFORM} +endif + +# Define build mode (debug or release, by default release) +ifdef BUILD +BUILD_ARGS := ${BUILD} +else +BUILD_ARGS := release +endif # Default target default: all @@ -42,116 +54,110 @@ help: @echo ' make deps Build dependency images for caching the runtimes.' @echo ' make build Build the tarball for all platforms and architectures.' @echo ' make test Run integration tests for the already built tarballs.' - @echo ' make release Releases the tarball into GitHub.' @echo ' make clear Clear all containers and images.' @echo ' make help Show verbose help.' @echo # Update MetaCall source download: - # Get latest tag from the repository +# Get latest tag from the repository $(eval LATEST_TAG := $(shell git ls-remote --tags https://github.com/metacall/core.git | sort -t '/' -k 3 -V | tail -n1 | sed 's/.*\///; s/\^{}//')) - # Download the source and extract the checksum +# Download the source and extract the checksum $(eval CHECKSUM := $(shell docker run --rm --privileged -it metacall/guix guix download https://github.com/metacall/core/archive/${LATEST_TAG}.tar.gz | tail -n1)) - # Get latest version +# Get latest version $(eval LATEST_VERSION := $(shell printf "${LATEST_TAG}" | tail -c +2)) - # Print version and checksum +# Print version and checksum @echo "${LATEST_VERSION} ${CHECKSUM}" - # Update MetaCall source with latest version +# Update MetaCall source with latest version @sed -i '/(name "metacall")/!b;n;c\ (version "${LATEST_VERSION}")' source/metacall.scm - # Update MetaCall source with checksum - @sed -i '/(uri (string-append "https:\/\/github.com\/metacall\/core\/archive\/v" version ".tar.gz"))/!b;n;c\ (sha256 (base32 "${CHECKSUM}"))' source/metacall.scm +# Update MetaCall source with checksum + @sed -i '/"https:\/\/github.com\/metacall\/core\/archive\/v" version ".tar.gz"))/!b;n;c\ (sha256 (base32 "${CHECKSUM}"))))' source/metacall.scm # Build base Docker image base: - # Clear the container - @docker stop metacall_distributable 2> /dev/null || true - @docker rm metacall_distributable 2> /dev/null || true - # Build the base image - @docker build -t metacall/distributable -f Dockerfile . +# Clear the container + @docker stop metacall_distributable_linux 2> /dev/null || true + @docker rm metacall_distributable_linux 2> /dev/null || true +# Build the base image + @docker buildx build ${PLATFORM_ARGS} -t metacall/distributable_linux --load -f Dockerfile . # Pull latest version of Guix pull: - # Clear the container - @docker stop metacall_distributable 2> /dev/null || true - @docker rm metacall_distributable 2> /dev/null || true - # Install the additional channels and pull - @docker run --privileged --name metacall_distributable metacall/distributable sh -c ' \ - mv /metacall/channels/channels.scm /root/.config/guix/channels.scm \ - && guix pull' - @docker commit metacall_distributable metacall/distributable - @docker rm -f metacall_distributable +# Clear the container + @docker stop metacall_distributable_linux 2> /dev/null || true + @docker rm metacall_distributable_linux 2> /dev/null || true +# Install the additional channels and pull + @docker run ${PLATFORM_ARGS} --privileged --name metacall_distributable_linux metacall/distributable_linux sh -c 'guix pull' + @docker commit metacall_distributable_linux metacall/distributable_linux + @docker rm -f metacall_distributable_linux @echo "Done" # Build deps deps: - # Clear the container - @docker stop metacall_distributable 2> /dev/null || true - @docker rm metacall_distributable 2> /dev/null || true - # Patch the source (metacall.scm) with latest version - @docker run -v `pwd`/source:/metacall/patch --privileged --name metacall_distributable metacall/distributable cp /metacall/patch/metacall.scm /metacall/source/metacall.scm - @docker commit metacall_distributable metacall/distributable - @docker rm -f metacall_distributable - # Patch the script (deps.sh) with latest version - @docker run -v `pwd`/scripts:/metacall/patch --privileged --name metacall_distributable metacall/distributable cp /metacall/patch/deps.sh /metacall/scripts/deps.sh - @docker commit metacall_distributable metacall/distributable - @docker rm -f metacall_distributable - # Build dependencies - @docker run --privileged --name metacall_distributable metacall/distributable /metacall/scripts/deps.sh - # Commit dependencies into the image - @docker commit metacall_distributable metacall/distributable - # Clear the container - @docker rm -f metacall_distributable +# Clear the container + @docker stop metacall_distributable_linux 2> /dev/null || true + @docker rm metacall_distributable_linux 2> /dev/null || true +# Patch the source (metacall.scm) with latest version + @docker run ${PLATFORM_ARGS} -v `pwd`/source:/metacall/patch --privileged --name metacall_distributable_linux metacall/distributable_linux cp /metacall/patch/metacall.scm /metacall/source/metacall.scm + @docker commit metacall_distributable_linux metacall/distributable_linux + @docker rm -f metacall_distributable_linux +# Patch the script (deps.sh) with latest version + @docker run ${PLATFORM_ARGS} -v `pwd`/scripts:/metacall/patch --privileged --name metacall_distributable_linux metacall/distributable_linux cp /metacall/patch/deps.sh /metacall/scripts/deps.sh + @docker commit metacall_distributable_linux metacall/distributable_linux + @docker rm -f metacall_distributable_linux +# Build dependencies + @docker run ${PLATFORM_ARGS} --privileged --name metacall_distributable_linux metacall/distributable_linux /metacall/scripts/deps.sh + @docker commit metacall_distributable_linux metacall/distributable_linux + @docker rm -f metacall_distributable_linux @echo "Done" # Build tarball build: - # Clear the container - @docker stop metacall_distributable 2> /dev/null || true - @docker rm metacall_distributable 2> /dev/null || true - # Patch the source (metacall.scm) with latest version - @docker run -v `pwd`/source:/metacall/patch --privileged --name metacall_distributable metacall/distributable cp /metacall/patch/metacall.scm /metacall/source/metacall.scm - @docker commit metacall_distributable metacall/distributable - @docker rm -f metacall_distributable - # Patch the script (build.sh) with latest version - @docker run -v `pwd`/scripts:/metacall/patch --privileged --name metacall_distributable metacall/distributable cp /metacall/patch/build.sh /metacall/scripts/build.sh - @docker commit metacall_distributable metacall/distributable - @docker rm -f metacall_distributable - # Build tarball and store it into out folder - @docker run --rm -v `pwd`/out:/metacall/pack --privileged --name metacall_distributable metacall/distributable /metacall/scripts/build.sh +# Clear the container + @docker stop metacall_distributable_linux 2> /dev/null || true + @docker rm metacall_distributable_linux 2> /dev/null || true +# Patch the source (metacall.scm) with latest version + @docker run ${PLATFORM_ARGS} -v `pwd`/source:/metacall/patch --privileged --name metacall_distributable_linux metacall/distributable_linux cp /metacall/patch/metacall.scm /metacall/source/metacall.scm + @docker commit metacall_distributable_linux metacall/distributable_linux + @docker rm -f metacall_distributable_linux +# Patch the script (build.sh) with latest version + @docker run ${PLATFORM_ARGS} -v `pwd`/scripts:/metacall/patch --privileged --name metacall_distributable_linux metacall/distributable_linux cp /metacall/patch/build.sh /metacall/scripts/build.sh + @docker commit metacall_distributable_linux metacall/distributable_linux + @docker rm -f metacall_distributable_linux +# Build tarball and store it into out folder + @docker run ${PLATFORM_ARGS} --rm -v `pwd`/out:/metacall/pack --privileged --name metacall_distributable_linux metacall/distributable_linux /metacall/scripts/build.sh ${BUILD_ARGS} @echo "Done" # Test tarballs test: - # Generate a unique id for invalidating the cache of test layers +# Generate a unique id for invalidating the cache of test layers $(eval CACHE_INVALIDATE := $(shell date +%s)) - # Run tests - @docker build --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_test:cli -f tests/cli/Dockerfile . - @docker build --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_test:c -f tests/c/Dockerfile . - @docker build --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_test:python -f tests/python/Dockerfile . - @docker build --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_test:node -f tests/node/Dockerfile . - @docker build --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_test:typescript -f tests/typescript/Dockerfile . - @echo "Done" - -# Release tarballs -release: - # Check if .netrc exists - @test -f `pwd`/.netrc || (echo "File .netrc does not exist, aborting release." && exit 1) - - # TODO - +# Run tests + @docker buildx build ${PLATFORM_ARGS} --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:backtrace -f tests/backtrace/Dockerfile . + @docker buildx build ${PLATFORM_ARGS} --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:c -f tests/c/Dockerfile . + @docker buildx build ${PLATFORM_ARGS} --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:typescript -f tests/typescript/Dockerfile . +# TODO: +# @docker buildx build ${PLATFORM_ARGS} --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:tsx -f tests/tsx/Dockerfile . + @docker buildx build ${PLATFORM_ARGS} --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:cli -f tests/cli/Dockerfile . + @docker buildx build ${PLATFORM_ARGS} --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:python -f tests/python/Dockerfile . + @docker buildx build ${PLATFORM_ARGS} --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:node -f tests/node/Dockerfile . + @docker buildx build ${PLATFORM_ARGS} --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:ruby -f tests/ruby/Dockerfile . +# Skip executable tests on debug because node, python, ruby... are compiled without address sanitizer and they produce false positives + @if [ "${BUILD_ARGS}" = "release" ]; then \ + docker buildx build ${PLATFORM_ARGS} --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:exe -f tests/exe/Dockerfile . ; \ + fi @echo "Done" # Clear images and containers clear: - # Clear the tarball +# Clear the tarball @rm -rf out/* && touch out/.gitkeep - # Clear the container - @docker stop metacall_distributable 2> /dev/null || true - @docker rm metacall_distributable 2> /dev/null || true - # Clear the images - @docker images | grep metacall/distributable_test | tr -s ' ' | cut -d ' ' -f 2 | xargs -I {} docker rmi metacall/distributable_test:{} 2> /dev/null || true - @docker rmi metacall/distributable 2> /dev/null || true +# Clear the container + @docker stop metacall_distributable_linux 2> /dev/null || true + @docker rm metacall_distributable_linux 2> /dev/null || true +# Clear the images + @docker images | grep metacall/distributable_linux_test | tr -s ' ' | cut -d ' ' -f 2 | xargs -I {} docker rmi metacall/distributable_linux_test:{} 2> /dev/null || true + @docker rmi metacall/distributable_linux 2> /dev/null || true # Empty target do nothing %: diff --git a/README.md b/README.md index 7c8ba04..12540a7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# MetaCall Distributable +# MetaCall Distributable Linux -Cross-platform and multi-arch redistributable for shipping MetaCall Core. +Linux redistributable for shipping MetaCall Core. ## How to Generate the Distributable Tarballs @@ -10,6 +10,14 @@ This will generate all tarballs in the `out` directory. All logs will be stored make &> dist.log & tail -f dist.log ``` +## How to Embed MetaCall as a Library from Distributable + +In order to use MetaCall as a library in your applications, you can easily link `libmetacall.so` from the folder `/gnu/lib`. In order to set up additional environment variables required by the runtimes or MetaCall itself, run the following command before your application: + +```sh +source /gnu/etc/profile +``` + ## How to Get the Hash from a Package Replace `$URL` by the URL of the source code tarball, for example: `https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz`. Then paste the resulting hash into the package definition in the `.scm` file. @@ -23,3 +31,9 @@ In order to update hash from MetaCall Core package, just run the following comma ```bash make download ``` + +## GitLab CI settings +Make sure to increase the job timeout to 2h+ (build job takes about a litle over an hour) in order to publish the tarball on GitHub as auto release you need to define the following variables in GitLab CI/CD settings, variable submenu: + +* `GH_TOKEN` - a GitHub access token (select repo scope) +* `GH_REPO` - a GitHub repo in the format of **OWNER/REPO** e.g. `metacall/distributable-linux` diff --git a/channels/channels.scm b/channels/channels.scm index 124c566..fa6c074 100644 --- a/channels/channels.scm +++ b/channels/channels.scm @@ -2,7 +2,7 @@ ; MetaCall Distributable by Parra Studios ; Distributable infrastructure for MetaCall. ; -; Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +; Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia ; ; Licensed under the Apache License, Version 2.0 (the "License"); ; you may not use this file except in compliance with the License. @@ -17,15 +17,15 @@ ; limitations under the License. ; -(list (channel - (name 'guix) - (url "https://git.savannah.gnu.org/git/guix.git") - (branch "master") - (commit "1a9ebe3b0aa12584624dfa811c480c636a56e1b4")) -; TODO: -; (channel -; (name 'nonguix) -; (url "https://gitlab.com/nonguix/nonguix.git") -; (branch "master") -; (commit "95adb6ec077dc4139cf7e1956ad5caa1ff08f92b")) - ) +(list + (channel + (name 'guix) + (url "https://codeberg.org/guix/guix.git") + (branch "master") + (commit "f0d4daa13f0b57f5c03af73d449b2c6dd3160d08") ; Mon Feb 17 14:29:21 2025 +0100 + (introduction + (make-channel-introduction + "f0d4daa13f0b57f5c03af73d449b2c6dd3160d08" ; Tue May 26 22:30:51 2020 +0200 + (openpgp-fingerprint + "BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC")))) ; git verify-commit +) diff --git a/scripts/build.sh b/scripts/build.sh index dfd95d0..5376f67 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,7 +4,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License") # you may not use this file except in compliance with the License. @@ -19,13 +19,45 @@ # limitations under the License. # +set -euxo pipefail + export GUILE_WARN_DEPRECATED='detailed' # Generate a portable package tarball -`# Build` guix build --fallback metacall -L /metacall/source \ -`# Test` `# && guix package -i metacall -L /metacall/source` \ -`# Lint` `# && guix lint metacall` \ -`# Pack uses --no-grafts option in order to avoid conflicts between duplicated versions` \ -`# Pack` && guix pack --no-grafts -S /gnu/bin=bin -RR metacall -L /metacall/source | tee build.log \ -`# Copy` && mv `cat build.log | grep "tarball-pack.tar.gz"` /metacall/pack/tarball.tar.gz \ -`# Exit` && exit 0 || exit 1 +# Uses --no-grafts option in order to avoid conflicts between duplicated versions + +# Debug +if [ "$1" == "debug" ]; then + # Comment out the current CMAKE_BUILD_TYPE + sed -i 's/"-DCMAKE_BUILD_TYPE/; "-DCMAKE_BUILD_TYPE/g' /metacall/source/metacall.scm + + # Patch the metacall.scm with debug build type and sanitizers + sed -i \ + -e '/"-DOPTION_BUILD_GUIX=ON"/a\' \ + -e ' "-DCMAKE_BUILD_TYPE=Debug"' \ + `# TODO: Add support for preloading address sanitizer in executables using MetaCall` \ + `# -e ' "-DCMAKE_BUILD_TYPE=Debug" "-DOPTION_BUILD_ADDRESS_SANITIZER=ON"'` \ + /metacall/source/metacall.scm + + # Remove the strip phase for maintaining the debug symbols + sed -i 's/#:strip-binaries? #t/#:strip-binaries? #f/' /metacall/source/metacall.scm +fi + +# Build +guix build metacall metacall-python-port --fallback -L /metacall/nonguix -L /metacall/source + +# Install +echo 'metacall' >> /metacall/source/metacall.scm +guix package --fallback --no-grafts -f /metacall/source/metacall.scm | tee build.log + +# Lint +guix lint -L /metacall/nonguix -L /metacall/source metacall || true + +# Pack +guix pack --no-grafts \ + -S /gnu/bin=bin -S /gnu/etc=etc -S /gnu/lib=lib -S /gnu/include=include -S /gnu/share=share \ + -RR metacall metacall-python-port nss-certs \ + -L /metacall/nonguix -L /metacall/source | tee build.log + +# Copy +mv `grep 'tarball-pack.tar.gz$' build.log` /metacall/pack/tarball.tar.gz diff --git a/scripts/deps.sh b/scripts/deps.sh index ea8ee19..0e15779 100755 --- a/scripts/deps.sh +++ b/scripts/deps.sh @@ -4,7 +4,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License") # you may not use this file except in compliance with the License. @@ -19,9 +19,21 @@ # limitations under the License. # +set -euxo pipefail + export GUILE_WARN_DEPRECATED='detailed' -# Build dependencies -`# Build (Node Build System)` guix build cherow node-addon-api typescript -L /metacall/source \ -`# Build (GNU Build System)` && guix build dynruby `# netcore-runtime netcore-sdk` -L /metacall/source \ -`# Exit` && exit 0 || exit 1 +# Clone nonguix (fix nonguix version) +guix shell git -- sh -c ' \ + rm -rf /metacall/nonguix \ + && git clone https://gitlab.com/nonguix/nonguix /metacall/nonguix \ + && cd /metacall/nonguix \ + && git checkout e0951349603581895e0ba61f0e7410368ea1902a \ +' + +# Build +guix build --fallback \ + nss-certs \ + `# dotnet codeanalysis-csharp codeanalysis-common codeanalysis-analyzers` \ + espree typescript \ + -L /metacall/nonguix -L /metacall/source diff --git a/source/metacall.scm b/source/metacall.scm index ee4b02e..3ad6c06 100644 --- a/source/metacall.scm +++ b/source/metacall.scm @@ -2,7 +2,7 @@ ; MetaCall Distributable by Parra Studios ; Distributable infrastructure for MetaCall. ; -; Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +; Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia ; ; Licensed under the Apache License, Version 2.0 (the "License"); ; you may not use this file except in compliance with the License. @@ -29,6 +29,8 @@ #:use-module (guix build-system gnu) #:use-module (guix build-system cmake) #:use-module (guix build-system node) + #:use-module (guix build-system trivial) + #:use-module (guix build-system python) #:use-module (guix build json) #:use-module (guix build union) #:use-module ((guix licenses) #:prefix license:) @@ -41,58 +43,55 @@ #:use-module (gnu packages python-xyz) ; Ruby Dependencies - #:use-module (gnu packages readline) - #:use-module (gnu packages tls) - #:use-module (gnu packages compression) - #:use-module (gnu packages libffi) - #:use-module (gnu packages dbm) - #:use-module (gnu packages ncurses) - #:use-module (gnu packages tcl) - #:use-module (guix utils) + #:use-module (gnu packages ruby) - ; NodeJS + ; NodeJS Dependencies + #:use-module (guix utils) + #:use-module ((guix build utils) #:select (alist-replace)) #:use-module (gnu packages node) - #:use-module (gnu packages base) - #:use-module (gnu packages xml) #:use-module (gnu packages adns) + #:use-module (gnu packages base) + #:use-module (gnu packages compression) #:use-module (gnu packages icu4c) #:use-module (gnu packages libevent) + #:use-module (gnu packages linux) #:use-module (gnu packages perl) #:use-module (gnu packages pkg-config) - #:use-module (gnu packages linux) - - ; Swig - #:use-module (gnu packages swig) + #:use-module (gnu packages python) + #:use-module (gnu packages tls) + #:use-module (gnu packages web) ; RapidJSON #:use-module (gnu packages web) ; NetCore Dependencies (TODO) + ; #:use-module (nongnu packages dotnet) ; #:use-module (nonguix build-system binary) - ; #:use-module (gnu packages gcc) - ; #:use-module (gnu packages linux) - ; #:use-module (gnu packages curl) - ; #:use-module (gnu packages tls) - ; #:use-module (gnu packages kerberos) - ; #:use-module (gnu packages compression) - ; #:use-module (gnu packages icu4c) - ; #:use-module (gnu packages mono) ; Cobol Dependencies #:use-module (gnu packages cobol) #:use-module (gnu packages multiprecision) + + ; RPC Dependencies + #:use-module (gnu packages curl) + + ; ; Backtrace Dependencies + #:use-module (guix git-download) + #:use-module (guix gexp) + #:use-module (gnu packages libunwind) + ; #:use-module (gnu packages elf) ) ; NodeJS Loader Dependencies -(define-public cherow +(define-public espree (package - (name "cherow") - (version "1.6.9") + (name "espree") + (version "9.4.0") (source (origin (method url-fetch) - (uri (string-append "https://registry.npmjs.org/cherow/-/cherow-" version ".tgz")) - (sha256 (base32 "1m397n6lzj49rhr8742c2cbcyqjrrxa56l197xvrx1sk4jgmzymf")) + (uri (string-append "https://github.com/metacall/core-bootstrap.js-guix-package/releases/download/v0.0.4/espree-" version ".tgz")) + (sha256 (base32 "1w8iy2wx6v7shr99jafi8mgcx7ma64x2mxx71kp1ixs19dg4pxr7")) ) ) (build-system node-build-system) @@ -101,42 +100,17 @@ #:phases (modify-phases %standard-phases (delete 'check) + (delete 'configure) (delete 'build) ) ) ) - (home-page "https://github.com/cherow/cherow") - (synopsis "A very fast and lightweight, self-hosted javascript parser.") - (description "A very fast and lightweight, standards-compliant, -self-hosted javascript parser with high focus on both performance and stability.") - (license license:expat) - ) -) - -; NodeJS Port Dependencies -(define-public node-addon-api - (package - (name "node-addon-api") - (version "1.7.1") - (source - (origin - (method url-fetch) - (uri (string-append "https://github.com/nodejs/node-addon-api/archive/" version ".tar.gz")) - (sha256 (base32 "0i3jc5ki4dlq8l2p1wn0rw1695kr47cjx1zlkzj6h4ymzyc0i1dk")) - ) - ) - (build-system node-build-system) - (arguments - `( - #:phases - (modify-phases %standard-phases - (delete 'check) - ) - ) - ) - (home-page "https://github.com/nodejs/node-addon-api/") - (synopsis "Module for using N-API from C++") - (description "This module contains a header-only C++ wrapper classes ...") + (home-page "https://github.com/eslint/espree") + (synopsis "An Esprima-compatible JavaScript parser.") + (description "Espree started out as a fork of Esprima v1.2.2, the last stable published released +of Esprima before work on ECMAScript 6 began. Espree is now built on top of Acorn, which has a modular +architecture that allows extension of core functionality. The goal of Espree is to produce output +that is similar to Esprima with a similar API so that it can be used in place of Esprima.") (license license:expat) ) ) @@ -145,12 +119,12 @@ self-hosted javascript parser with high focus on both performance and stability. (define-public typescript (package (name "typescript") - (version "3.9.7") + (version "4.2.3") (source (origin (method url-fetch) (uri (string-append "https://registry.npmjs.org/typescript/-/typescript-" version ".tgz")) - (sha256 (base32 "1h0naj9x5g4lhhq4aiiqid4mvnqimjijxyni9zgphc6df91sinvd")) + (sha256 (base32 "0jpi7za7ak0ba8bm300219vhrr4raacx6s8rz3czlwxim1byyn6g")) ) ) (build-system node-build-system) @@ -159,6 +133,7 @@ self-hosted javascript parser with high focus on both performance and stability. #:phases (modify-phases %standard-phases (delete 'check) + (delete 'configure) (delete 'build) ) ) @@ -172,263 +147,253 @@ for any host, on any OS. TypeScript compiles to readable, standards-based JavaSc ) ) -; Ruby -(define-public dynruby - (package - (name "dynruby") - (version "2.3.8") - (source - (origin - (method url-fetch) - (uri (string-append "http://cache.ruby-lang.org/pub/ruby/" - (version-major+minor version) - "/ruby-" version ".tar.xz")) - (sha256 - (base32 - "1zhxbjff08pvbnxvn58krns6q0p6g4977q6ykfn823gxhifn63wi")) - (modules '((guix build utils))) - (snippet `(begin - ;; Remove bundled libffi - (delete-file-recursively "ext/fiddle/libffi-3.2.1") - #t)))) - (build-system gnu-build-system) - (arguments - `(#:test-target "test" - #:tests? #f ; TODO: Enable tests by removing this line - #:configure-flags - (list - "--enable-shared" - ) - #:phases - (modify-phases %standard-phases - (add-before 'configure 'replace-bin-sh-and-remove-libffi - (lambda _ - (substitute* '("Makefile.in" - "ext/pty/pty.c" - "io.c" - "lib/mkmf.rb" - "process.c" - "test/rubygems/test_gem_ext_configure_builder.rb" - "test/rdoc/test_rdoc_parser.rb" - "test/ruby/test_rubyoptions.rb" - "test/ruby/test_process.rb" - "test/ruby/test_system.rb" - "tool/rbinstall.rb") - (("/bin/sh") (which "sh"))) - #t))))) - (inputs - `(("readline" ,readline) - ("openssl" ,openssl) - ("bzip2" ,bzip2) - ("libffi" ,libffi) - ("gdbm" ,gdbm) - ("libyaml" ,libyaml) - ("ncurses" ,ncurses) - ("tcl" ,tcl) - ("tk" ,tk) ; TODO: This still fails, Ruby is not able to locate Tk/Tcl lib - ("zlib" ,zlib))) - (native-search-paths - (list (search-path-specification - (variable "GEM_PATH") - (files (list (string-append "lib/ruby/vendor_ruby")))))) - (synopsis "Programming language interpreter") - (description "Ruby is a dynamic object-oriented programming language with -a focus on simplicity and productivity.") - (home-page "https://www.ruby-lang.org/") - (license license:ruby))) - -; ; NetCore SDK (https://dotnet.microsoft.com/download/dotnet-core/2.2) -; (define-public netcore-sdk +; NetCore Loader Dependencies (TODO) +; (define-public codeanalysis-csharp +; (package +; (name "codeanalysis-csharp") +; (version "3.2.1") +; (source +; (origin +; (method url-fetch) +; (uri (string-append "https://globalcdn.nuget.org/packages/microsoft.codeanalysis.csharp." version ".nupkg")) +; (sha256 (base32 "02kyh5xsr3ciw71afzyis91m18iys1kpndl6h6ykayg9w36z9rz7")) +; ) +; ) +; (build-system binary-build-system) +; (arguments +; `(#:phases +; (modify-phases %standard-phases +; (replace 'unpack +; (lambda* (#:key source #:allow-other-keys) +; (invoke "cp" source (string-append (getcwd) "/microsoft.codeanalysis.csharp.3.2.1.nupkg")) +; ) +; ) +; ) +; ) +; ) +; (home-page "https://www.nuget.org/packages/Microsoft.CodeAnalysis.CSharp") +; (synopsis ".NET Compiler Platform (Roslyn).") +; (description ".NET Compiler Platform (Roslyn).") +; (license license:expat) +; ) +; ) + +; (define-public codeanalysis-common ; (package -; (name "netcore-sdk") -; (version "2.2.207") +; (name "codeanalysis-common") +; (version "3.2.1") ; (source ; (origin ; (method url-fetch) -; (uri (string-append "https://download.visualstudio.microsoft.com/download/pr/" -; "022d9abf-35f0-4fd5-8d1c-86056df76e89/477f1ebb70f314054129a9f51e9ec8ec" -; "/dotnet-sdk-" -; version -; "-" -; "linux-x64" -; ".tar.gz")) -; (sha256 (base32 "1k98p9bs0flgcfw6xiqmyxs9ipvnqrjwr4zhxv1ikq79asczpdag")) +; (uri (string-append "https://globalcdn.nuget.org/packages/microsoft.codeanalysis.common." version ".nupkg")) +; (sha256 (base32 "1n3jc5fz78f7smzjanmq00iv3pdifnhkgmmsb9czrfbzc3v4c3d2")) ; ) ; ) ; (build-system binary-build-system) -; (supported-systems '("x86_64-linux")) ; (arguments -; '(#:phases -; (let ((old-patchelf (assoc-ref %standard-phases 'patchelf))) -; (modify-phases %standard-phases +; `(#:phases +; (modify-phases %standard-phases ; (replace 'unpack ; (lambda* (#:key source #:allow-other-keys) -; (invoke "tar" "xvf" source))) -; (replace 'patchelf -; (lambda args -; (apply old-patchelf (append args (list -; #:patchelf-plan -; (map (lambda (x) -; (list x (list "gcc:lib" "glibc" "lttng-ust" "libcurl" "openssl" "mit-krb5" "zlib" "icu4c" "libgdiplus"))) -; (append (find-files "." "\\.so$") '("dotnet"))) -; ))))))) -; #:system "x86_64-linux" -; #:install-plan -; '(("host" "host") -; ("shared" "shared") -; ("sdk" "sdk") -; ("dotnet" "dotnet") -; ("ThirdPartyNotices.txt" "share/doc/ThirdPartyNotices.txt")) +; (invoke "cp" source (string-append (getcwd) "/microsoft.codeanalysis.common.3.2.1.nupkg")) +; ) +; ) +; ) ; ) ; ) -; (inputs -; `(("gcc:lib" ,gcc "lib") -; ("glibc" ,glibc) -; ("lttng-ust" ,lttng-ust) -; ("libcurl" ,curl) -; ("openssl" ,openssl) -; ("mit-krb5" ,mit-krb5) -; ("zlib" ,zlib) -; ("icu4c" ,icu4c) -; ("libgdiplus" ,libgdiplus))) -; (home-page "https://dotnet.microsoft.com/") -; (synopsis ".NET Core SDK") -; (description ".NET Core is a free and open-source, managed computer software framework for Windows, -; Linux, and macOS operating systems. It is a cross-platform successor to .NET Framework. -; The project is primarily developed by Microsoft and released under the MIT License.") +; (home-page "https://www.nuget.org/packages/Microsoft.CodeAnalysis.Common") +; (synopsis ".NET Compiler Platform (Roslyn).") +; (description ".NET Compiler Platform (Roslyn).") ; (license license:expat) ; ) ; ) -; ; NetCore (https://dotnet.microsoft.com/download/dotnet-core/2.2) -; (define-public netcore-runtime +; (define-public codeanalysis-analyzers ; (package -; (name "netcore-runtime") -; ; (version "2.1.17") -; ; (source -; ; (origin -; ; (method url-fetch) -; ; (uri (string-append "https://download.visualstudio.microsoft.com/download/pr/" -; ; "a668ac5e-ffcc-419a-8c82-9e5feb7b2619/4108ef8aede75bbb569a359dff689c5c" -; ; "/dotnet-runtime-" -; ; version -; ; "-" -; ; "linux-x64" -; ; ".tar.gz")) -; ; (sha256 (base32 "0g7azv4f1acjsjxrqdwmsxhv6x7kgnb3kjrd624sjxq9j9ygmqpn")) -; ; ) -; ; ) -; (version "2.2.8") +; (name "codeanalysis-analyzers") +; (version "2.9.3") ; (source ; (origin ; (method url-fetch) -; (uri (string-append "https://download.visualstudio.microsoft.com/download/pr/" -; "3fbca771-e7d3-45bf-8e77-cfc1c5c41810/e118d44f5a6df21714abd8316e2e042b" -; "/dotnet-runtime-" -; version -; "-" -; "linux-x64" -; ".tar.gz")) -; (sha256 (base32 "0vwc96jwagqxw2ybfxb932vxsa8jbd6052yfn4v40zrxac6d6igf")) +; (uri (string-append "https://globalcdn.nuget.org/packages/microsoft.codeanalysis.analyzers." version ".nupkg")) +; (sha256 (base32 "1kskwc9gyd2sx3zwx52qwfsl7s0xhaclmlnxvjsb4jgvpydv3xii")) ; ) ; ) ; (build-system binary-build-system) -; (supported-systems '("x86_64-linux")) ; (arguments -; '(#:phases -; (let ((old-patchelf (assoc-ref %standard-phases 'patchelf))) -; (modify-phases %standard-phases +; `(#:phases +; (modify-phases %standard-phases ; (replace 'unpack ; (lambda* (#:key source #:allow-other-keys) -; (invoke "tar" "xvf" source))) -; (replace 'patchelf -; (lambda args -; (apply old-patchelf (append args (list -; #:patchelf-plan -; (map (lambda (x) -; (list x (list "gcc:lib" "glibc" "lttng-ust" "libcurl" "openssl" "mit-krb5" "zlib" "icu4c" "libgdiplus"))) -; (append (find-files "." "\\.so$") '("dotnet"))) -; ))))))) -; #:system "x86_64-linux" -; #:install-plan -; '(("host" "host") -; ("shared" "shared") -; ("dotnet" "dotnet") -; ("ThirdPartyNotices.txt" "share/doc/ThirdPartyNotices.txt")) +; (invoke "cp" source (string-append (getcwd) "/microsoft.codeanalysis.analyzers.2.9.3.nupkg")) +; ) +; ) +; ) ; ) ; ) -; (inputs -; `(("gcc:lib" ,gcc "lib") -; ("glibc" ,glibc) -; ("lttng-ust" ,lttng-ust) -; ("libcurl" ,curl) -; ("openssl" ,openssl) -; ("mit-krb5" ,mit-krb5) -; ("zlib" ,zlib) -; ("icu4c" ,icu4c) -; ("libgdiplus" ,libgdiplus))) -; (home-page "https://dotnet.microsoft.com/") -; (synopsis ".NET Core") -; (description ".NET Core is a free and open-source, managed computer software framework for Windows, -; Linux, and macOS operating systems. It is a cross-platform successor to .NET Framework. -; The project is primarily developed by Microsoft and released under the MIT License.") +; (home-page "https://www.nuget.org/packages/Microsoft.CodeAnalysis.Analyzers") +; (synopsis ".NET Compiler Platform (Roslyn).") +; (description ".NET Compiler Platform (Roslyn).") ; (license license:expat) ; ) ; ) -; TODO: MetaCall CLI should set some enviroment variables in order to make it work for Guixers -; See metacall/install CLI script for knowing the needed variables and paths +(define-public backward-cpp + (package + (name "backward-cpp") + (version "1.6") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/bombela/backward-cpp") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1b2h03iwfhcsg8i4f125mlrjf8l1y7qsr2gsbkv0z03i067lykns")))) + (arguments + (list + #:tests? #f + #:configure-flags + #~(list + "-DBACKWARD_TESTS=OFF" + "-DBACKWARD_SHARED=OFF"))) + (build-system cmake-build-system) + (synopsis "Stack trace pretty printer for C++") + (description + "Backward-cpp is a stack trace pretty printer for C++. +It can print annotated stack traces using debug info in the executable.") + (home-page "https://github.com/bombela/backward-cpp") + (license license:expat))) + +(define-public plthook + (package + (name "plthook") + (version "0.1.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/metacall/plthook") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "07fxkd5mv6v02a4if2lz7rq236m5nfifrly8vjy6774zhn8zzs61")))) + (build-system trivial-build-system) + (arguments + (list + #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (let ((out #$output) + (src #$source)) + (mkdir-p out) + (copy-recursively src out)) + #t))) + (synopsis "Hook function calls by replacing PLT (Procedure Linkage Table) entries.") + (description + "A utility library to hook library function calls issued by specified object files (executable and libraries). +This modifies PLT (Procedure Linkage Table) entries in ELF format used on most Unixes +or IAT (Import Address Table) entries in PE format used on Windows.") + (home-page "https://github.com/metacall/plthook") + (license license:expat))) ; MetaCall (define-public metacall (package (name "metacall") - (version "0.2.18") + (version "0.9.15") (source (origin (method url-fetch) - (uri (string-append "https://github.com/metacall/core/archive/v" version ".tar.gz")) - (sha256 (base32 "12cj9ks20dnadw3dqgay3646vdnvm7dw9nlpa07f3nqvaxd691ay")) - ) - ) + (uri (string-append + "https://github.com/metacall/core/archive/v" version ".tar.gz")) + (sha256 (base32 "08f8fh2f7j747wawcxlaxlcfcr7w1bbpbiqcpmzn8s4zpcrw95pk")))) + (build-system cmake-build-system) (arguments `( #:phases - ; TODO: This may be hidding a CMake bug with rpath on all ports, so this must be reviewed in the future + ; TODO: This may be hidding a CMake bug with rpath on all ports, + ; so this must be reviewed in the future (modify-phases %standard-phases (add-before 'configure 'runpath-workaround (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (setenv "LDFLAGS" (string-append "-Wl,-rpath=" out "/lib")) #t))) - (add-before 'configure 'setenv - ; TODO: Workaround for HOME directory, move this to netcore build system in the future - (lambda _ - ; (let ((home (string-append (getenv "NIX_BUILD_TOP") "/dotnet-home"))) - (let ((home "/tmp") - (packages "/tmp/.nuget/packages")) - (setenv "DOTNET_SKIP_FIRST_TIME_EXPERIENCE" "true") - (setenv "HOME" home) - (mkdir-p home) - (mkdir-p packages)) - #t)) - (add-after 'build 'build-node-loader-bootstrap-cherow +; TODO +; (add-before 'configure 'dotnet-packages +; (lambda* (#:key inputs #:allow-other-keys) +; (let ( +; (global-pkgs "/tmp/.nuget/packages") +; (additional-pkgs "/tmp/.nuget/nupkgs") +; ) +; (setenv "NUGET_PACKAGES" global-pkgs) +; (setenv "DOTNET_SKIP_FIRST_TIME_EXPERIENCE" "true") +; (setenv "HOME" "/tmp") +; (setenv "DOTNET_ROOT" +; (string-append (assoc-ref inputs "dotnet") "/share/dotnet")) +; (mkdir-p global-pkgs) +; (mkdir-p additional-pkgs) +; ; TODO: Avoid harcoded versions of CodeAnalysis +; (invoke "cp" (string-append (assoc-ref inputs "codeanalysis-csharp") +; "/microsoft.codeanalysis.csharp.3.2.1.nupkg") additional-pkgs) +; (invoke "cp" (string-append (assoc-ref inputs "codeanalysis-common") +; "/microsoft.codeanalysis.common.3.2.1.nupkg") additional-pkgs) +; (invoke "cp" (string-append (assoc-ref inputs "codeanalysis-analyzers") +; "/microsoft.codeanalysis.analyzers.2.9.3.nupkg") additional-pkgs) +; (with-output-to-file +; "source/loaders/cs_loader/netcore/source/NuGet.Config" +; (lambda () +; (format #t " +; +; +; +; +; +; +; +; +; +; +; +; " (string-append (assoc-ref inputs "dotnet") "/share/dotnet/shared/Microsoft.NETCore.App/5.0.4/")))) +; #t))) + (add-after 'build 'build-node-loader-bootstrap-espree (lambda* (#:key inputs #:allow-other-keys) - (let* ((output (string-append (getcwd) "/node_modules/cherow")) - (cherow (string-append (assoc-ref inputs "cherow") "/lib/node_modules/cherow/dist/commonjs/cherow.min.js"))) + (let* ((output (string-append (getcwd) "/node_modules/espree")) + (espree (string-append + (assoc-ref inputs "espree") "/lib/node_modules/espree"))) (mkdir-p output) - (copy-file cherow (string-append output "/index.js"))) + (copy-recursively espree output)) #t)) (add-after 'build 'build-ts-loader-bootstrap-typescript (lambda* (#:key inputs #:allow-other-keys) (let* ((output (string-append (getcwd) "/node_modules/typescript")) - (typescript (string-append (assoc-ref inputs "typescript") "/lib/node_modules/typescript"))) + (typescript (string-append + (assoc-ref inputs "typescript") "/lib/node_modules/typescript"))) (mkdir-p output) (copy-recursively typescript output)) - #t))) + #t)) + (add-after 'install 'symlink-debug-executable + (lambda* (#:key outputs #:allow-other-keys) + (let ((source-file (string-append (assoc-ref outputs "out") "/bin/metacallclid")) + (symlink-target (string-append (assoc-ref outputs "out") "/bin/metacallcli"))) + (when (file-exists? source-file) + (symlink source-file symlink-target))))) + (add-after 'install 'symlink-debug-library + (lambda* (#:key outputs #:allow-other-keys) + (let ((source-file (string-append (assoc-ref outputs "out") "/lib/libmetacalld.so")) + (symlink-target (string-append (assoc-ref outputs "out") "/lib/libmetacall.so"))) + (when (file-exists? source-file) + (symlink source-file symlink-target)))))) + ; TODO: Enable tests #:tests? #f + ; Disable/Enable stripping in order to let debug symbols for debugging + #:strip-binaries? #t #:configure-flags (list ; Disable developer warnings @@ -437,20 +402,29 @@ a focus on simplicity and productivity.") ; Disable all unreproductible operations "-DOPTION_BUILD_GUIX=ON" - ; Build wiht release mode - "-DCMAKE_BUILD_TYPE=Release" + ; Build with release mode + "-DCMAKE_BUILD_TYPE=RelWithDebInfo" + ; "-DCMAKE_BUILD_TYPE=Release" + + ; ; Build with debug mode + ; "-DCMAKE_BUILD_TYPE=Debug" + ; "-DOPTION_BUILD_ADDRESS_SANITIZER=ON" - ; Disable stack-smashing protection and source fortify in order to improve libc portability / compatibility + ; Disable stack-smashing protection and source fortify + ; in order to improve libc portability / compatibility "-DOPTION_BUILD_SECURITY=OFF" - ; Distributable libs - "-DOPTION_BUILD_DIST_LIBS=ON" + ; Disable examples + "-DOPTION_BUILD_EXAMPLES=OFF" - ; Examples - "-DOPTION_BUILD_EXAMPLES=ON" + ; Detours + "-DOPTION_BUILD_DETOURS=ON" + "-DOPTION_BUILD_DETOURS_PLTHOOK=ON" + (string-append "-DPLTHook_SOURCE_DIR=" (assoc-ref %build-inputs "plthook")) + + ; Fork safety + "-DOPTION_FORK_SAFE=ON" - ; TODO: Enable fork safety - "-DOPTION_FORK_SAFE=OFF" ; TODO: Enable tests "-DOPTION_BUILD_TESTS=OFF" @@ -476,35 +450,49 @@ a focus on simplicity and productivity.") "-DOPTION_BUILD_LOADERS_FILE=ON" "-DOPTION_BUILD_LOADERS_NODE=ON" "-DOPTION_BUILD_LOADERS_TS=ON" - "-DOPTION_BUILD_LOADERS_CS=OFF" ; TODO: Implement C# Loader + "-DOPTION_BUILD_LOADERS_CS=OFF" ; TODO: ON "-DOPTION_BUILD_LOADERS_JS=OFF" ; TODO: Implement V8 Loader "-DOPTION_BUILD_LOADERS_COB=ON" - - ; NodeJS Addon API - (string-append "-DNODEJS_ADDON_API_INCLUDE_DIR=" (assoc-ref %build-inputs "node-addon-api") "/lib/node_modules/node-addon-api") - - ; TODO: Avoid harcoded versions of Ruby - (string-append "-DRUBY_EXECUTABLE=" (assoc-ref %build-inputs "dynruby") "/bin/ruby") - (string-append "-DRUBY_INCLUDE_DIR=" (assoc-ref %build-inputs "dynruby") "/include/ruby-2.3.0") - (string-append "-DRUBY_LIBRARY=" (assoc-ref %build-inputs "dynruby") "/lib/libruby.so") - (string-append "-DRUBY_VERSION=" "2.3.8") - - ; TODO: Avoid harcoded versions of NodeJS - (string-append "-DNODEJS_EXECUTABLE=" (assoc-ref %build-inputs "node") "/bin/node") - (string-append "-DNODEJS_INCLUDE_DIR=" (assoc-ref %build-inputs "node") "/include/node") - (string-append "-DNODEJS_LIBRARY=" (assoc-ref %build-inputs "libnode") "/lib/libnode.so.64") - "-DNODEJS_CMAKE_DEBUG=ON" - "-DNODEJS_SHARED_UV=ON" - - ; ; TODO: Avoid harcoded versions of NetCore - ; (string-append "-DDOTNET_COMMAND=" (assoc-ref %build-inputs "netcore-sdk") "/dotnet") - ; ; (string-append "-DDOTNET_CORE_PATH=" (assoc-ref %build-inputs "netcore-runtime") "/shared/Microsoft.NETCore.App/2.1.17/") - ; (string-append "-DDOTNET_CORE_PATH=" (assoc-ref %build-inputs "netcore-runtime") "/shared/Microsoft.NETCore.App/2.2.8/") - - ; TODO: Avoid harcoded versions of Cobol - (string-append "-DCOBOL_EXECUTABLE=" (assoc-ref %build-inputs "gnucobol") "/bin/cobc") - (string-append "-DCOBOL_INCLUDE_DIR=" (assoc-ref %build-inputs "gnucobol") "/include") - (string-append "-DCOBOL_LIBRARY=" (assoc-ref %build-inputs "gnucobol") "/lib/libcob.so.4.0.0") + "-DOPTION_BUILD_LOADERS_RPC=ON" + + ; Ruby Loader + (string-append "-DRuby_EXECUTABLE=" + (assoc-ref %build-inputs "ruby") "/bin/ruby") + (string-append "-DRuby_INCLUDE_DIRS=" + (assoc-ref %build-inputs "ruby") "/include/ruby-3.3.0") + (string-append "-DRuby_LIBRARY=" + (assoc-ref %build-inputs "ruby") "/lib/libruby.so") + (string-append "-DRuby_VERSION=" "3.3.3") + + ; NodeJS Loader + (string-append "-DNodeJS_EXECUTABLE=" + (assoc-ref %build-inputs "node") "/bin/node") + (string-append "-DNodeJS_INCLUDE_DIR=" + (assoc-ref %build-inputs "node") "/include/node") + (string-append "-DNodeJS_LIBRARY=" + (assoc-ref %build-inputs "libnode") "/lib/libnode.so.127") + "-DNodeJS_CMAKE_DEBUG=ON" + "-DNodeJS_SHARED_UV=ON" + + ; TODO + ; (string-append "-DDOTNET_COMMAND=" + ; (assoc-ref %build-inputs "dotnet") "/share/dotnet/dotnet") + ; (string-append "-DDOTNET_CORE_PATH=" + ; (assoc-ref %build-inputs "dotnet") + ; "/share/dotnet/shared/Microsoft.NETCore.App/5.0.4/") + ; "-DDOTNET_ADDITIONAL_PACKAGES=/tmp/.nuget/nupkgs/" + + ; Cobol Loader + (string-append "-DCOBOL_EXECUTABLE=" + (assoc-ref %build-inputs "gnucobol") "/bin/cobc") + (string-append "-DCOBOL_INCLUDE_DIR=" + (assoc-ref %build-inputs "gnucobol") "/include") + (string-append "-DCOBOL_LIBRARY=" + (assoc-ref %build-inputs "gnucobol") "/lib/libcob.so") + + ; RPC Loader + (string-append "-DCURL_INCLUDE_DIR=" + (assoc-ref %build-inputs "curl") "/include/curl") ; TODO: Finish all loaders "-DOPTION_BUILD_SCRIPTS_JS=OFF" @@ -512,48 +500,150 @@ a focus on simplicity and productivity.") ; Ports "-DOPTION_BUILD_PORTS=ON" "-DOPTION_BUILD_PORTS_PY=ON" - "-DOPTION_BUILD_PORTS_RB=ON" "-DOPTION_BUILD_PORTS_NODE=ON" "-DOPTION_BUILD_PORTS_TS=OFF" ; TODO: Not implemented yet "-DOPTION_BUILD_PORTS_CS=ON" + "-DOPTION_BUILD_PORTS_RB=ON" + + ; Enable backtrace support + "-DBACKWARD_TESTS=OFF" + "-DSTACK_DETAILS_AUTO_DETECT=OFF" + "-DSTACK_WALKING_UNWIND=OFF" + "-DSTACK_WALKING_LIBUNWIND=ON" + (string-append "-DBACKWARD_LIBRARIES=" (assoc-ref %build-inputs "libunwind") "/lib/libunwind.so") + (string-append "-DBACKWARD_INCLUDE_DIRS=" (assoc-ref %build-inputs "libunwind") "/include") + ; "-DSTACK_DETAILS_DWARF=ON" + ; (string-append "-DBACKWARD_LIBRARIES=" + ; (assoc-ref %build-inputs "libdwarf") "/lib/libdwarf.so" ";" + ; (assoc-ref %build-inputs "libelf") "/lib/libelf.so") + ; (string-append "-DBACKWARD_INCLUDE_DIRS=" + ; (assoc-ref %build-inputs "libdwarf") "/include/libdwarf-0" ";" + ; (assoc-ref %build-inputs "libelf") "/include") + (string-append "-DBackwardCpp_SOURCE=" (assoc-ref %build-inputs "backward-cpp") "/lib/backward") + "-DBACKWARD_SHARED=OFF" + "-DOPTION_BUILD_PLUGINS_BACKTRACE=ON" ; Disable coverage - "-DOPTION_COVERAGE=OFF" + "-DOPTION_COVERAGE=OFF"))) - ; Python Port (Swig) requires conversion between constant to non-constant char pointer - "-DCMAKE_CXX_FLAGS=-fpermissive" - ) - ) - ) (propagated-inputs `( - ("python" ,python) ; Python Loader dependency - ("dynruby" ,dynruby) ; Ruby Loader dependency - ("node" ,node) ; NodeJS NPM exports + ("python" ,python-3) ; Python Loader dependency + ("ruby" ,ruby-3.3) ; Ruby Loader dependency + ("node" ,node-lts) ; NodeJS Loader dependency ("libnode" ,libnode) ; NodeJS Loader dependency ("libuv" ,libuv) ; NodeJS Loader dependency - ("cherow" ,cherow) ; NodeJS Loader dependency + ("espree" ,espree) ; NodeJS Loader dependency ("typescript" ,typescript) ; TypeScript Loader dependency ("gnucobol" ,gnucobol) ; Cobol Loader dependency ("gmp" ,gmp) ; Cobol Loader dependency - ; ("netcore-runtime" ,netcore-runtime) ; NetCore Loader dependency - ; ("netcore-sdk" ,netcore-sdk) ; NetCore Loader dependency - ) - ) + ; TODO + ; ("dotnet" ,dotnet) ; NetCore Loader dependency + ; ("codeanalysis-csharp" ,codeanalysis-csharp) ; NetCore Loader dependency + ; ("codeanalysis-common" ,codeanalysis-common) ; NetCore Loader dependency + ; ("codeanalysis-analyzers" ,codeanalysis-analyzers) ; NetCore Loader dependency + ("curl" ,curl) ; RPC Loader Dependency + ("libunwind", libunwind))) ; Backtrace Plugin dependency + ; ("libdwarf", libdwarf) ; Backtrace Plugin dependency + ; ("libelf", libelf))) ; Backtrace Plugin dependency + (native-inputs `( ("rapidjson" ,rapidjson) ; RapidJSON Serial dependency - ("python2-gyp" ,python2-gyp) ; For building NodeJS Port - ("node-addon-api" ,node-addon-api) ; For building NodeJS Port - ("swig" ,swig) ; For building ports - ) - ) + ("plthook" ,plthook) ; PLTHook dependency + ("backward-cpp", backward-cpp))) ; Backtrace Plugin dependency + + ; Set all environment variables for subsequent packages + (search-paths + (list + ; MetaCall + (search-path-specification + (variable "LOADER_LIBRARY_PATH") + (files '("lib"))) + (search-path-specification + (variable "SERIAL_LIBRARY_PATH") + (files '("lib"))) + (search-path-specification + (variable "DETOUR_LIBRARY_PATH") + (files '("lib"))) + (search-path-specification + (variable "PORT_LIBRARY_PATH") + (files '("lib"))) + (search-path-specification + (variable "CONFIGURATION_PATH") + (file-type 'regular) + (files '("configurations/global.json"))) + ; Python + (search-path-specification + (variable "PYTHONTZPATH") + (files (list "share/zoneinfo"))) + ; PYTHONPATH is incompatible with Guix Python + ; but we require it for tarball installation + (search-path-specification + (variable "PYTHONPATH") + (files (list (string-append + "lib/python" + (version-major+minor (package-version python-3)) + "/site-packages")))) + ; NodeJS + (search-path-specification + (variable "NODE_PATH") + (files '("lib/node_modules"))) + ; Ruby + (search-path-specification + (variable "GEM_PATH") + (files (list (string-append "lib/ruby/vendor_ruby")))) + (search-path-specification + (variable "GEM_HOME") + (files (list (string-append "lib/ruby/vendor_ruby")))) + (search-path-specification + (variable "BUNDLE_PATH") + (files (list (string-append "lib/ruby/vendor_ruby")))) + ; GCC + (search-path-specification + (variable "C_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CPLUS_INCLUDE_PATH") + (files '("include/c++" "include"))) + (search-path-specification + (variable "LIBRARY_PATH") + (files '("lib" "lib64"))))) + + ; TODO: + ; + ; Dynamic Linker Path + ; #:use-module ((gnu packages bootstrap) #:select (glibc-dynamic-linker)) + ; + ; (search-path-specification + ; (variable "GLIBC_LD_LIBRARY_PATH") + ; (file-type 'regular) + ; (files '(glibc-dynamic-linker))) + + (native-search-paths search-paths) + (home-page "https://metacall.io/") - (synopsis "Inter-language foreign function interface call library.") + (synopsis "Inter-language foreign function interface call library") (description "METACALL is a library that allows calling functions, methods or procedures between programming languages. With METACALL you can transparently execute code from / to any programming language, for example, call Python code from NodeJS code.") - (license license:asl2.0) - ) -) + (license license:asl2.0))) + +; MetaCall Python Port +; TODO: Can it be unified with metacall package? +; https://www.futurile.net/2024/07/23/guix-package-structure-build-system-phases/ +(define-public metacall-python-port + (package + (inherit metacall) + (name "metacall-python-port") + (build-system python-build-system) + (arguments + `(#:tests? #f + #:phases (modify-phases %standard-phases + (add-before 'build 'change-directory + (lambda _ + (chdir "source/ports/py_port"))) + (delete 'test) + (delete 'sanity-check)))) + (inputs (list metacall)))) diff --git a/tests/backtrace/Dockerfile b/tests/backtrace/Dockerfile new file mode 100644 index 0000000..4d0741f --- /dev/null +++ b/tests/backtrace/Dockerfile @@ -0,0 +1,74 @@ +# +# MetaCall Distributable by Parra Studios +# Distributable infrastructure for MetaCall. +# +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM debian:trixie-slim AS c_test + +# Image descriptor +LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ + copyright.address="vic798@gmail.com" \ + maintainer.name="Vicente Eduardo Ferrer Garcia" \ + maintainer.address="vic798@gmail.com" \ + vendor="MetaCall Inc." \ + version="0.1" + +SHELL ["/bin/bash", "-c"] + +RUN apt-get update \ + && apt-get install --no-install-recommends -y build-essential + +COPY out/tarball.tar.gz / + +RUN cd / \ + && tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \ + && rm tarball.tar.gz + +COPY tests/backtrace/test.c / + +COPY tests/scripts/ /scripts/ + +WORKDIR /scripts + +ARG CACHE_INVALIDATE + +RUN echo "Running tests ${CACHE_INVALIDATE}" \ + && set -exo pipefail \ + && source /gnu/etc/profile \ + && export LDLIB_PATH="`find /gnu/store/ -type f -wholename '*-glibc-*/lib/ld-*.so*' | head -n 1`" \ + && export LOADER_SCRIPT_PATH="/scripts/" \ + && cd / \ + && gcc \ + -I/gnu/include \ + test.c \ + -B$(dirname ${LDLIB_PATH}) \ + -Wl,--dynamic-linker=${LDLIB_PATH} \ + -Wl,-rpath=/gnu/lib \ + -L/gnu/lib \ + -lmetacall \ + && if [ -f /gnu/bin/metacallclid ]; then \ + export LIBASAN_PATH="`find /gnu/store/ -name 'libasan.so' | head -n 1`" \ + && export LIBUBSAN_PATH="`find /gnu/store/ -name 'libubsan.so' | head -n 1`" \ + && export LD_PRELOAD="${LIBASAN_PATH} ${LIBUBSAN_PATH}" \ + && export ASAN_OPTIONS="halt_on_error=0"; \ + fi \ + && ./a.out &> output.txt \ + || cat output.txt \ + && grep output.txt \ + -e 'Stack trace (most recent call last)' + +ENTRYPOINT ["sh", "-c"] diff --git a/tests/backtrace/test.c b/tests/backtrace/test.c new file mode 100644 index 0000000..f657a8c --- /dev/null +++ b/tests/backtrace/test.c @@ -0,0 +1,54 @@ +/* + * MetaCall Distributable by Parra Studios + * Distributable infrastructure for MetaCall. + * + * Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +static int cleanup(int code) +{ + metacall_destroy(); + + return code; +} + +int main(int argc, char *argv[]) +{ + struct metacall_log_stdio_type log_stdio = { stdout }; + + printf("%s\n", metacall_print_info()); + + if (metacall_log(METACALL_LOG_STDIO, (void *)&log_stdio) != 0) + { + return cleanup(1); + } + + if (metacall_initialize() != 0) + { + return cleanup(2); + } + + /* Backtrace */ + { + char *segfault = (void *)&cleanup; + *segfault = 34; + } + + return cleanup(0); +} diff --git a/tests/c/Dockerfile b/tests/c/Dockerfile index 35787a9..f8baa6f 100644 --- a/tests/c/Dockerfile +++ b/tests/c/Dockerfile @@ -2,7 +2,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ # limitations under the License. # -FROM gcc:9.2.0 AS c_test +FROM debian:trixie-slim AS c_test # Image descriptor LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ @@ -27,36 +27,45 @@ LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ vendor="MetaCall Inc." \ version="0.1" +SHELL ["/bin/bash", "-c"] + +RUN apt-get update \ + && apt-get install --no-install-recommends -y build-essential + COPY out/tarball.tar.gz / RUN cd / \ - && tar -xzf tarball.tar.gz \ + && tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \ && rm tarball.tar.gz COPY tests/c/test.c / COPY tests/scripts/ /scripts/ +WORKDIR /scripts + ARG CACHE_INVALIDATE RUN echo "Running tests ${CACHE_INVALIDATE}" \ + && set -exo pipefail \ + && source /gnu/etc/profile \ + && export LDLIB_PATH="`find /gnu/store/ -type f -wholename '*-glibc-*/lib/ld-*.so*' | head -n 1`" \ && export LOADER_SCRIPT_PATH="/scripts/" \ - && export METACALL_PATH="/gnu/store/`ls /gnu/store/ | grep metacall | head -n 1`" \ - && export LDLIB_PATH="`find /gnu/store/ -type f -wholename '*-glibc-*/lib/ld-*.so' | head -n 1`" \ - && export LOADER_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export SERIAL_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export DETOUR_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export PORT_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export CONFIGURATIONS_PATH="${METACALL_PATH}/configurations/global.json" \ && cd / \ && gcc \ - -I$METACALL_PATH/include \ + -I/gnu/include \ test.c \ -B$(dirname ${LDLIB_PATH}) \ -Wl,--dynamic-linker=${LDLIB_PATH} \ - -Wl,-rpath=${METACALL_PATH}/lib \ - -L$METACALL_PATH/lib \ + -Wl,-rpath=/gnu/lib \ + -L/gnu/lib \ -lmetacall \ + && if [ -f /gnu/bin/metacallclid ]; then \ + export LIBASAN_PATH="`find /gnu/store/ -name 'libasan.so' | head -n 1`" \ + && export LIBUBSAN_PATH="`find /gnu/store/ -name 'libubsan.so' | head -n 1`" \ + && export LD_PRELOAD="${LIBASAN_PATH} ${LIBUBSAN_PATH}" \ + && export ASAN_OPTIONS="halt_on_error=0"; \ + fi \ && ./a.out | grep \ -e 'Hello World' \ -e 'abc' \ diff --git a/tests/c/test.c b/tests/c/test.c index 2e530ea..5b69a79 100644 --- a/tests/c/test.c +++ b/tests/c/test.c @@ -2,7 +2,7 @@ * MetaCall Distributable by Parra Studios * Distributable infrastructure for MetaCall. * - * Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia + * Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,10 +25,7 @@ static int cleanup(int code) { - if (metacall_destroy() != 0) - { - return code != 0 ? -code : -255; - } + metacall_destroy(); return code; } @@ -37,7 +34,7 @@ int main(int argc, char *argv[]) { struct metacall_log_stdio_type log_stdio = { stdout }; - printf(metacall_print_info()); + printf("%s\n", metacall_print_info()); if (metacall_log(METACALL_LOG_STDIO, (void *)&log_stdio) != 0) { diff --git a/tests/cli/Dockerfile b/tests/cli/Dockerfile index 1265d4e..b3cf64f 100644 --- a/tests/cli/Dockerfile +++ b/tests/cli/Dockerfile @@ -2,7 +2,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,36 +30,43 @@ LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ COPY out/tarball.tar.gz / RUN cd / \ - && tar -xzf tarball.tar.gz \ + && tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \ && rm tarball.tar.gz COPY tests/scripts/ /scripts/ +WORKDIR /scripts + ARG CACHE_INVALIDATE RUN echo "Running tests ${CACHE_INVALIDATE}" \ + && set -exo pipefail \ && export LOADER_SCRIPT_PATH="/scripts/" \ - && export METACALL_PATH="/gnu/store/`ls /gnu/store/ | grep metacall | head -n 1`" \ - && export LOADER_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export SERIAL_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export DETOUR_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export PORT_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export CONFIGURATIONS_PATH="${METACALL_PATH}/configurations/global.json" \ - && ${METACALL_PATH}/metacallcli test.mock \ - && ${METACALL_PATH}/metacallcli mult.rb \ - && ${METACALL_PATH}/metacallcli sum.py \ + && source /gnu/etc/profile \ + && export ASAN_OPTIONS="halt_on_error=0" \ + && metacallcli test.mock \ + && metacallcli mult.rb \ + && metacallcli sum.py \ && printf "load mock test.mock\ninspect\nexit" \ - | ${METACALL_PATH}/metacallcli \ + | metacallcli \ | grep -e 'function three_str(a_str, b_str, c_str)' \ && printf "load rb mult.rb\ninspect\nexit" \ - | ${METACALL_PATH}/metacallcli \ + | metacallcli \ | grep -e 'function add(a, b)' -e 'function mult(a, b)' \ && printf "load py sum.py\ninspect\nexit" \ - | ${METACALL_PATH}/metacallcli \ - | grep -e 'function sum(a, b, c)' + | metacallcli \ + | grep -e 'function sum(a, b, c)' \ + && metacallcli port-test.js \ + | grep "Node.js port works" \ + && metacallcli port-test.py \ + | grep "Python port works" -# | grep -e 'function sum(a, b, c)' \ +# TODO: C# Loader # && printf "load cs say.cs\ninspect\nexit" \ -# | ${METACALL_PATH}/metacallcli || cat /root/metacall.log +# | metacallcli + +# TODO: Ruby Port +# && metacallcli port-test.rb \ +# | grep "Ruby port works" ENTRYPOINT ["sh", "-c"] diff --git a/tests/exe/Dockerfile b/tests/exe/Dockerfile new file mode 100644 index 0000000..62ddcb6 --- /dev/null +++ b/tests/exe/Dockerfile @@ -0,0 +1,62 @@ +# +# MetaCall Distributable by Parra Studios +# Distributable infrastructure for MetaCall. +# +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM debian:trixie-slim AS exe_test + +# Image descriptor +LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ + copyright.address="vic798@gmail.com" \ + maintainer.name="Vicente Eduardo Ferrer Garcia" \ + maintainer.address="vic798@gmail.com" \ + vendor="MetaCall Inc." \ + version="0.1" + +SHELL ["/bin/bash", "-c"] + +RUN apt-get update \ + && apt-get install --no-install-recommends -y python3 nodejs ruby + +COPY out/tarball.tar.gz / + +RUN cd / \ + && tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \ + && rm tarball.tar.gz + +COPY tests/scripts/ /scripts/ + +WORKDIR /scripts + +ARG CACHE_INVALIDATE + +RUN echo "Running tests ${CACHE_INVALIDATE}" \ + && set -exo pipefail \ + && source /gnu/etc/profile \ + && whereis node \ + && ls -la /usr/bin/node \ + && /usr/bin/node port-test.js | grep \ + -e 'Node.js port works' \ + && whereis python3 \ + && ls -la /usr/bin/python3 \ + && /usr/bin/python3 port-test.py | grep \ + -e 'Python port works' + # \ + # && ruby port-test.rb | grep \ + # -e 'Ruby port works' + +ENTRYPOINT ["sh", "-c"] diff --git a/tests/node/Dockerfile b/tests/node/Dockerfile index 0684f97..1cfa1aa 100644 --- a/tests/node/Dockerfile +++ b/tests/node/Dockerfile @@ -2,7 +2,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,32 +30,31 @@ LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ COPY out/tarball.tar.gz / RUN cd / \ - && tar -xzf tarball.tar.gz \ + && tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \ && rm tarball.tar.gz COPY tests/scripts/ /scripts/ COPY tests/node/test.js /scripts/ +WORKDIR /scripts + ARG CACHE_INVALIDATE RUN echo "Running tests ${CACHE_INVALIDATE}" \ - && export PATH="/gnu/bin:${PATH}" \ - && npm install metacall - -RUN export LOADER_SCRIPT_PATH="/scripts/" \ - && export METACALL_PATH="/gnu/store/`ls /gnu/store/ | grep metacall | head -n 1`" \ - && export LOADER_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export SERIAL_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export DETOUR_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export PORT_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export CONFIGURATIONS_PATH="${METACALL_PATH}/configurations/global.json" \ + && set -exo pipefail \ + && source /gnu/etc/profile \ + && export LOADER_SCRIPT_PATH="/scripts/" \ && export NODE_ENV=debug \ - && printf 'load node test.js\ncall mock()\nexit' | ${METACALL_PATH}/metacallcli \ + && export ASAN_OPTIONS="halt_on_error=0" \ + && printf 'load node test.js\ncall mock()\nexit' | metacallcli \ | grep \ -e 'Hello World' \ - && printf 'load node test.js\ncall python()\nexit' | ${METACALL_PATH}/metacallcli \ + && printf 'load node test.js\ncall python()\nexit' | metacallcli \ + | grep \ + -e '366667' \ + && metacallcli port-test.js \ | grep \ - -e '366667' + -e 'Node.js port works' ENTRYPOINT ["sh", "-c"] diff --git a/tests/node/test.js b/tests/node/test.js index d800399..79e5c8b 100644 --- a/tests/node/test.js +++ b/tests/node/test.js @@ -4,7 +4,7 @@ * MetaCall Distributable by Parra Studios * Distributable infrastructure for MetaCall. * - * Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia + * Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/python/Dockerfile b/tests/python/Dockerfile index bf24e33..f86ce5a 100644 --- a/tests/python/Dockerfile +++ b/tests/python/Dockerfile @@ -2,7 +2,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,27 +30,24 @@ LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ COPY out/tarball.tar.gz / RUN cd / \ - && tar -xzf tarball.tar.gz \ + && tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \ && rm tarball.tar.gz COPY tests/scripts/ /scripts/ COPY tests/python/script.py /scripts/ +WORKDIR /scripts + ARG CACHE_INVALIDATE RUN echo "Running tests ${CACHE_INVALIDATE}" \ - && export PATH="/gnu/bin:${PATH}" \ - && /gnu/bin/pip3 install metacall - -RUN export LOADER_SCRIPT_PATH="/scripts/" \ - && export METACALL_PATH="/gnu/store/`ls /gnu/store/ | grep metacall | head -n 1`" \ - && export LOADER_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export SERIAL_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export DETOUR_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export PORT_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export CONFIGURATIONS_PATH="${METACALL_PATH}/configurations/global.json" \ - && printf 'load py script.py\ninspect\ncall test()\nexit' | ${METACALL_PATH}/metacallcli \ + && set -exo pipefail \ + && source /gnu/etc/profile \ + && pip3 install metacall \ + && export LOADER_SCRIPT_PATH="/scripts/" \ + && export ASAN_OPTIONS="halt_on_error=0" \ + && printf 'load py script.py\ninspect\ncall test()\nexit' | metacallcli \ | grep \ -e 'Hello World' diff --git a/tests/python/script.py b/tests/python/script.py index 57a9467..0c0d58c 100644 --- a/tests/python/script.py +++ b/tests/python/script.py @@ -4,7 +4,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/ruby/Dockerfile b/tests/ruby/Dockerfile new file mode 100644 index 0000000..570ae42 --- /dev/null +++ b/tests/ruby/Dockerfile @@ -0,0 +1,55 @@ +# +# MetaCall Distributable by Parra Studios +# Distributable infrastructure for MetaCall. +# +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM busybox:1.31.1 AS ruby_test + +# Image descriptor +LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ + copyright.address="vic798@gmail.com" \ + maintainer.name="Vicente Eduardo Ferrer Garcia" \ + maintainer.address="vic798@gmail.com" \ + vendor="MetaCall Inc." \ + version="0.1" + +COPY out/tarball.tar.gz / + +RUN cd / \ + && tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \ + && rm tarball.tar.gz + +COPY tests/ruby/script.rb /scripts/ +COPY tests/ruby/Gemfile /scripts/ + +WORKDIR /scripts + +ARG CACHE_INVALIDATE + +RUN echo "Running tests ${CACHE_INVALIDATE}" \ + && set -exo pipefail \ + && source /gnu/etc/profile \ + && gem install open-uri \ + && bundle install --verbose \ + && bundle config path \ + && export LOADER_SCRIPT_PATH="/scripts/" \ + && export ASAN_OPTIONS="halt_on_error=0" \ + && metacallcli script.rb \ + | grep \ + -e 'Ruby simple test' + +ENTRYPOINT ["sh", "-c"] diff --git a/tests/ruby/Gemfile b/tests/ruby/Gemfile new file mode 100644 index 0000000..8a0ca57 --- /dev/null +++ b/tests/ruby/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org/' + +gem 'xml-simple' diff --git a/tests/ruby/script.rb b/tests/ruby/script.rb new file mode 100644 index 0000000..a25d394 --- /dev/null +++ b/tests/ruby/script.rb @@ -0,0 +1,80 @@ +#!/usr/bin/env ruby + +# +# MetaCall Distributable by Parra Studios +# Distributable infrastructure for MetaCall. +# +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Debug load path +puts $LOAD_PATH + +puts "Ruby simple test" + +# TODO: +# +# Ruby 2.7 +# +# + metacallcli script.rb +# # +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/openssl/buffering.rb:1 +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/openssl/ssl.rb:13:in `require' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/openssl/ssl.rb:13:in `' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/openssl.rb:21:in `require' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/openssl.rb:21:in `' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/net/https.rb:23:in `require' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/net/https.rb:23:in `' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/open-uri.rb:321:in `require' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/open-uri.rb:321:in `open_http' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/open-uri.rb:764:in `buffer_open' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/open-uri.rb:235:in `block in open_loop' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/open-uri.rb:233:in `catch' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/open-uri.rb:233:in `open_loop' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/open-uri.rb:174:in `open_uri' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/open-uri.rb:744:in `open' +# /gnu/store/6669014b1cf15njllsd0ryir5d0gp5ch-ruby-2.7.8/lib/ruby/2.7.0/open-uri.rb:50:in `open' +# eval:25:in `' +# eval:1:in `
' +# Error: Ruby evaluation failed script.rb +# +################################################################################################################ +# +# Ruby 3.2 & 3.3 +# +# # +# /gnu/store/75dz8nhrawcahgxnjjxpfazmkq6pmcxh-ruby-3.2.3/lib/ruby/3.2.0/uri/common.rb:21:in `' +# /gnu/store/75dz8nhrawcahgxnjjxpfazmkq6pmcxh-ruby-3.2.3/lib/ruby/3.2.0/uri/common.rb:15:in `'# /gnu/store/75dz8nhrawcahgxnjjxpfazmkq6pmcxh-ruby-3.2.3/lib/ruby/3.2.0/uri.rb:94:in `require_relative' +# /gnu/store/75dz8nhrawcahgxnjjxpfazmkq6pmcxh-ruby-3.2.3/lib/ruby/3.2.0/uri.rb:94:in `' +# /gnu/store/75dz8nhrawcahgxnjjxpfazmkq6pmcxh-ruby-3.2.3/lib/ruby/3.2.0/open-uri.rb:2:in `require' +# eval:23:in `require' +# eval:23:in `'uby/3.2.0/open-uri.rb:2:in `' +# eval:1:in `
' +# +################################################################################################################ +# +# Code: +# +# require 'open-uri' +# +# URI.open('http://www.ruby-lang.org/') {|f| +# f.each_line {|line| p line} +# } +################################################################################################################ + +# TODO: Ruby cannot find gems installed by bundle +#require 'xmlsimple' +#result = XmlSimple.xml_in(html) +#p result diff --git a/tests/scripts/fib.ts b/tests/scripts/fib.ts index 9200f98..d4247d6 100644 --- a/tests/scripts/fib.ts +++ b/tests/scripts/fib.ts @@ -2,7 +2,7 @@ * MetaCall Distributable by Parra Studios * Distributable infrastructure for MetaCall. * -* Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +* Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/scripts/mult.rb b/tests/scripts/mult.rb index b2ac54d..b3a291f 100644 --- a/tests/scripts/mult.rb +++ b/tests/scripts/mult.rb @@ -4,7 +4,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/scripts/port-test.js b/tests/scripts/port-test.js new file mode 100644 index 0000000..2b0dbee --- /dev/null +++ b/tests/scripts/port-test.js @@ -0,0 +1,25 @@ +#!/usr/bin/env node + +/* + * MetaCall Distributable by Parra Studios + * Distributable infrastructure for MetaCall. + * + * Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +const { metacall } = require('metacall'); + +console.log("Node.js port works"); diff --git a/tools/release.sh b/tests/scripts/port-test.py old mode 100755 new mode 100644 similarity index 83% rename from tools/release.sh rename to tests/scripts/port-test.py index f6d7f20..c93020d --- a/tools/release.sh +++ b/tests/scripts/port-test.py @@ -1,12 +1,12 @@ -#!/bin/sh +#!/usr/bin/env python3 # # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # -# Licensed under the Apache License, Version 2.0 (the "License") +# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # @@ -19,4 +19,6 @@ # limitations under the License. # -# TODO +import metacall + +print("Python port works") diff --git a/tests/scripts/port-test.rb b/tests/scripts/port-test.rb new file mode 100644 index 0000000..4cfe568 --- /dev/null +++ b/tests/scripts/port-test.rb @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby + +# +# MetaCall Distributable by Parra Studios +# Distributable infrastructure for MetaCall. +# +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'metacall' + +puts "Ruby port works" diff --git a/tests/scripts/say.cs b/tests/scripts/say.cs index 75644ba..a53708a 100644 --- a/tests/scripts/say.cs +++ b/tests/scripts/say.cs @@ -2,7 +2,7 @@ * MetaCall Distributable by Parra Studios * Distributable infrastructure for MetaCall. * -* Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +* Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/scripts/sum.py b/tests/scripts/sum.py index 1913a6b..5095c24 100644 --- a/tests/scripts/sum.py +++ b/tests/scripts/sum.py @@ -4,7 +4,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/tsx/Dockerfile b/tests/tsx/Dockerfile new file mode 100644 index 0000000..841f239 --- /dev/null +++ b/tests/tsx/Dockerfile @@ -0,0 +1,57 @@ +# +# MetaCall Distributable by Parra Studios +# Distributable infrastructure for MetaCall. +# +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM busybox:1.31.1 AS tsx_test + +# Image descriptor +LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ + copyright.address="vic798@gmail.com" \ + maintainer.name="Vicente Eduardo Ferrer Garcia" \ + maintainer.address="vic798@gmail.com" \ + vendor="MetaCall Inc." \ + version="0.1" + +COPY out/tarball.tar.gz / + +RUN cd / \ + && tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \ + && rm tarball.tar.gz + +COPY tests/tsx/test.tsx /scripts/ +COPY tests/tsx/tsconfig.json /scripts/ +COPY tests/tsx/package.json /scripts/ +COPY tests/tsx/package-lock.json /scripts/ + +# Needed in order to load the tsconfig.json +WORKDIR /scripts + +ARG CACHE_INVALIDATE + +RUN echo "Running tests ${CACHE_INVALIDATE}" \ + && set -exo pipefail \ + && source /gnu/etc/profile \ + && export LOADER_SCRIPT_PATH="/scripts/" \ + && export NODE_ENV=debug \ + && export ASAN_OPTIONS="halt_on_error=0" \ + && npm install \ + && printf 'load ts test.tsx\ninspect\ncall hello("world")\nexit' | metacallcli \ + | grep \ + -e '

Hello world

' + +ENTRYPOINT ["sh", "-c"] diff --git a/tests/tsx/package-lock.json b/tests/tsx/package-lock.json new file mode 100644 index 0000000..2f4aa09 --- /dev/null +++ b/tests/tsx/package-lock.json @@ -0,0 +1,120 @@ +{ + "name": "templating-tsx", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "templating-tsx", + "version": "1.0.0", + "license": "Apache-2.0", + "dependencies": { + "react": "^17.0.2", + "react-dom": "^17.0.2" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", + "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", + "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "scheduler": "^0.20.2" + } + }, + "node_modules/scheduler": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", + "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + } + }, + "dependencies": { + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "react": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", + "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, + "react-dom": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", + "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "scheduler": "^0.20.2" + } + }, + "scheduler": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", + "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + } + } +} diff --git a/tests/tsx/package.json b/tests/tsx/package.json new file mode 100644 index 0000000..1a182f9 --- /dev/null +++ b/tests/tsx/package.json @@ -0,0 +1,13 @@ +{ + "name": "templating-tsx", + "version": "1.0.0", + "main": "templating.tsx", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "license": "Apache-2.0", + "dependencies": { + "react": "^17.0.2", + "react-dom": "^17.0.2" + } +} diff --git a/tests/tsx/test.tsx b/tests/tsx/test.tsx new file mode 100644 index 0000000..b4827c4 --- /dev/null +++ b/tests/tsx/test.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import { renderToString } from 'react-dom/server'; + +export function hello(text: string): string { + return renderToString(

{`Hello ${text}`}

); +} diff --git a/tests/tsx/tsconfig.json b/tests/tsx/tsconfig.json new file mode 100644 index 0000000..aa4a87b --- /dev/null +++ b/tests/tsx/tsconfig.json @@ -0,0 +1,12 @@ +{ + "include": [ + "templating.tsx" + ], + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "esModuleInterop": true, + "jsx": "react", + "lib": ["es2016", "dom"] + } +} diff --git a/tests/typescript/Dockerfile b/tests/typescript/Dockerfile index 058933e..c376230 100644 --- a/tests/typescript/Dockerfile +++ b/tests/typescript/Dockerfile @@ -2,7 +2,7 @@ # MetaCall Distributable by Parra Studios # Distributable infrastructure for MetaCall. # -# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia +# Copyright (C) 2016 - 2025 Vicente Eduardo Ferrer Garcia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ # limitations under the License. # -FROM busybox:1.31.1 AS node_test +FROM busybox:1.31.1 AS ts_test # Image descriptor LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ @@ -30,28 +30,21 @@ LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \ COPY out/tarball.tar.gz / RUN cd / \ - && tar -xzf tarball.tar.gz \ + && tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \ && rm tarball.tar.gz -COPY tests/scripts/ /scripts/ +COPY tests/scripts/fib.ts /scripts/ -COPY tests/node/test.js /scripts/ +WORKDIR /scripts ARG CACHE_INVALIDATE RUN echo "Running tests ${CACHE_INVALIDATE}" \ - && export PATH="/gnu/bin:${PATH}" \ - && npm install metacall - -RUN export LOADER_SCRIPT_PATH="/scripts/" \ - && export METACALL_PATH="/gnu/store/`ls /gnu/store/ | grep metacall | head -n 1`" \ - && export LOADER_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export SERIAL_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export DETOUR_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export PORT_LIBRARY_PATH="${METACALL_PATH}/lib" \ - && export CONFIGURATIONS_PATH="${METACALL_PATH}/configurations/global.json" \ + && export LOADER_SCRIPT_PATH="/scripts/" \ && export NODE_ENV=debug \ - && printf 'load ts fib.ts\ncall fibonacci(10)\nexit' | ${METACALL_PATH}/metacallcli \ + && source /gnu/etc/profile \ + && export ASAN_OPTIONS="halt_on_error=0" \ + && printf 'load ts fib.ts\ncall fibonacci(10)\nexit' | metacallcli \ | grep \ -e '89'