diff --git a/recipes/emscripten-activation/LICENSE b/recipes/emscripten-activation/LICENSE new file mode 100644 index 0000000000000..9aab6814c6ea8 --- /dev/null +++ b/recipes/emscripten-activation/LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2012, Anaconda, Inc. +Copyright (c) 2015-2019, conda-forge +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/recipes/emscripten-activation/activate.sh b/recipes/emscripten-activation/activate.sh new file mode 100644 index 0000000000000..e2d090ce5f5f7 --- /dev/null +++ b/recipes/emscripten-activation/activate.sh @@ -0,0 +1,54 @@ +if [ -z ${CONDA_FORGE_EMSCRIPTEN_ACTIVATED+x} ]; then + + export CONDA_FORGE_EMSCRIPTEN_ACTIVATED=1 + + export EMSDK_PYTHON=${CONDA_PREFIX}/bin/python3 + + export CONDA_EMSDK_DIR=${CONDA_PREFIX}/opt/emsdk + + # clear all prexisting cmake args / CC / CXX / AR / RANLIB + export CC="emcc" + export CXX="em++" + export AR="emar" + export RANLIB="emranlib" + + export CMAKE_ARGS="" + + # set the emscripten toolchain + export CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=$CONDA_EMSDK_DIR/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" + + # conda prefix path + export CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_PREFIX_PATH=$PREFIX" + + # install prefix + export CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=$PREFIX" + + # find root path mode package + export CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON" + + # fpic + export CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true" + + # useful variables + export PY_SIDE_LD_FLAGV + + # basics + export OPTFLAGS_USED="-O2" + export DBGFLAGS_USED="-g0" + + # basics ld + export LDFLAGS_BASE="-sMODULARIZE=1 -sLINKABLE=1 -sEXPORT_ALL=1 -sWASM=1 -sLZ4=1" + export LDFLAGS_BASE="${OPTFLAGS_USED} ${DBGFLAGS_USED} ${LDFLAGS_BASE}" + + # basics cflags + export CFLAGS_BASE="-fPIC" + export CFLAGS_BASE="${OPTFLAGS_USED} ${DBGFLAGS_USED} ${CFLAGS_BASE}" + + # side module + export SIDE_MODULE_LDFLAGS="${LDFLAGS_BASE} -s SIDE_MODULE=1" + export SIDE_MODULE_CFLAGS="${CFLAGS_BASE} -I${PREFIX}/include" + + # wasm bigint + export LDFLAGS="$LDFLAGS -sWASM_BIGINT" + +fi diff --git a/recipes/emscripten-activation/conda_build_config.yaml b/recipes/emscripten-activation/conda_build_config.yaml new file mode 100644 index 0000000000000..9c8026f99249d --- /dev/null +++ b/recipes/emscripten-activation/conda_build_config.yaml @@ -0,0 +1,12 @@ +CBUILD: + - x86_64-conda-linux-gnu + +CHOST: + - wasm32-unknown-emscripten + +cross_target_platform: + - emscripten-wasm32 + +# needs clang 19 +channel_sources: + - conda-forge/label/llvm_rc,conda-forge diff --git a/recipes/emscripten-activation/deactivate.sh b/recipes/emscripten-activation/deactivate.sh new file mode 100644 index 0000000000000..300da889b17b6 --- /dev/null +++ b/recipes/emscripten-activation/deactivate.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +unset CONDA_FORGE_EMSCRIPTEN_ACTIVATED +unset PY_SIDE_LD_FLAGV +unset OPTFLAGS_USED +unset DBGFLAGS_USED +unset LDFLAGS_BASE +unset CFLAGS_BASE +unset SIDE_MODULE_LDFLAGS +unset SIDE_MODULE_CFLAGS diff --git a/recipes/emscripten-activation/install_emscripten.sh b/recipes/emscripten-activation/install_emscripten.sh new file mode 100644 index 0000000000000..1212d73397b70 --- /dev/null +++ b/recipes/emscripten-activation/install_emscripten.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -ex + +# Copy the [de]activate scripts to $PREFIX/etc/conda/[de]activate.d. +# This will allow them to be run on environment activation. +for CHANGE in "activate" "deactivate" +do + mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d" + envsubst '$PKG_VERSION' < "${RECIPE_DIR}/${CHANGE}.sh" > "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh" +done + +mkdir -p ${PREFIX}/bin +cp "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh" ${PREFIX}/bin/activate_emscripten.sh diff --git a/recipes/emscripten-activation/install_emscripten_impl.sh b/recipes/emscripten-activation/install_emscripten_impl.sh new file mode 100644 index 0000000000000..82d178e27d1bd --- /dev/null +++ b/recipes/emscripten-activation/install_emscripten_impl.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -ex + +pushd "${PREFIX}"/bin + for BINARY in "em++" "em-config" "emar" "embuilder" "emcc" "emcmake" "emconfigure" "emmake" "emranlib" "emrun" "emscons" "emsize" "emstrip" "emsymbolizer"; do + ln -s $BINARY ${CHOST}-$BINARY + if [[ "${CBUILD}" != ${CHOST} ]]; then + ln -s $BINARY ${CBUILD}-$BINARY + fi + done +popd diff --git a/recipes/emscripten-activation/meta.yaml b/recipes/emscripten-activation/meta.yaml new file mode 100644 index 0000000000000..dad1f9ae6f49a --- /dev/null +++ b/recipes/emscripten-activation/meta.yaml @@ -0,0 +1,64 @@ +{% set version = "3.1.58" %} +# emscripten expects specific clang version, see +# https://github.com/emscripten-core/emscripten/blob/3.1.58/tools/shared.py#L62 +{% set clang_version = 19 %} + +package: + name: emscripten-activation + version: {{ version }} + +build: + number: 0 + skip: true # [win] + +outputs: + - name: emscripten_impl_{{ cross_target_platform }} + script: install_emscripten_impl.sh # [unix] + requirements: + - emscripten ={{ version }} + - clang {{ clang_version }} + - clangxx {{ clang_version }} + test: + commands: + - {{ CBUILD }}-emcc --version # [unix] + - {{ CHOST }}-emcc --version # [unix] + + - name: emscripten_{{ cross_target_platform }} + script: install_emscripten.sh # [unix] + run_exports: + strong: + - {{ pin_subpackage("emscripten-abi", max_pin="x.x.x") }} + requirements: + build: + - gettext + run: + - {{ pin_subpackage("emscripten_impl_" ~ cross_target_platform, exact=True) }} + test: + files: + - testfile.c + commands: + - emcc ./testfile.c + - node a.out.js + + - name: emscripten-abi + build: + noarch: generic + test: + commands: + - echo "emscripten abi is built." + +about: + home: https://emscripten.org + license: BSD-3-Clause + license_file: LICENSE + summary: An LLVM-to-WebAssembly Compiler + description: Emscripten compiles C and C++ to WebAssembly using LLVM and Binaryen. Emscripten output can run on the Web, in Node.js, and in wasm runtimes. + dev_url: https://github.com/emscripten-core/emscripten + doc_url: https://emscripten.org/ + +extra: + recipe-maintainers: + - DerThorsten + - wolfv + - h-vetinari + - conda-forge/emscripten diff --git a/recipes/emscripten-activation/testfile.c b/recipes/emscripten-activation/testfile.c new file mode 100644 index 0000000000000..5f9c40e408b41 --- /dev/null +++ b/recipes/emscripten-activation/testfile.c @@ -0,0 +1,15 @@ +/* + * Copyright 2011 The Emscripten Authors. All rights reserved. + * Emscripten is available under two separate licenses, the MIT license and the + * University of Illinois/NCSA Open Source License. Both these licenses can be + * found in the LICENSE file. + */ + +#include + +int main() { + printf("hello, world!\n"); + return 0; +} + +