From 775a21cdcdd8bef5509206473dfdbbd8d4d715e9 Mon Sep 17 00:00:00 2001 From: Carlos Segarra Date: Wed, 24 Jul 2024 14:32:48 +0000 Subject: [PATCH] wip --- .gitmodules | 8 ++++ examples/grass | 1 + examples/grass-addons | 1 + tasks/__init__.py | 2 + tasks/grass.py | 97 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 160000 examples/grass create mode 160000 examples/grass-addons create mode 100644 tasks/grass.py diff --git a/.gitmodules b/.gitmodules index d157e52..ed63898 100644 --- a/.gitmodules +++ b/.gitmodules @@ -57,3 +57,11 @@ [submodule "examples/opencv"] path = examples/opencv url = https://github.com/opencv/opencv.git +[submodule "examples/grass-addons"] + path = examples/grass-addons + url = git@github.com:faasm/grass-addons.git + branch = faasm +[submodule "examples/grass"] + path = examples/grass + url = git@github.com:faasm/grass.git + branch = faasm diff --git a/examples/grass b/examples/grass new file mode 160000 index 0000000..50da15e --- /dev/null +++ b/examples/grass @@ -0,0 +1 @@ +Subproject commit 50da15eb4ae33f68dcec3ecba1d544bf877fb919 diff --git a/examples/grass-addons b/examples/grass-addons new file mode 160000 index 0000000..29ef0ea --- /dev/null +++ b/examples/grass-addons @@ -0,0 +1 @@ +Subproject commit 29ef0ea69233043539ac317276d35736f9725f79 diff --git a/tasks/__init__.py b/tasks/__init__.py index 3d1e6e2..fc54d15 100644 --- a/tasks/__init__.py +++ b/tasks/__init__.py @@ -7,6 +7,7 @@ from . import format_code from . import func from . import git +from . import grass from . import imagemagick from . import jwt from . import kernels @@ -27,6 +28,7 @@ format_code, func, git, + grass, imagemagick, jwt, kernels, diff --git a/tasks/grass.py b/tasks/grass.py new file mode 100644 index 0000000..786b04d --- /dev/null +++ b/tasks/grass.py @@ -0,0 +1,97 @@ +from faasmtools.build import get_faasm_build_env_dict +from faasmtools.compile_util import wasm_copy_upload +from invoke import task +from os.path import join +from subprocess import run +from tasks.env import EXAMPLES_DIR + + +@task(default=True) +def grass(ctx, clean=False, noconf=False, debug=False): + """ + Compile and install ImageMagick + """ + grass_dir = join(EXAMPLES_DIR, "grass") + + if clean: + run( + "make clean distclean", shell=True, cwd=grass_dir, check=True + ) + + build_env = get_faasm_build_env_dict() + build_env["GIT"] = "no" + + configure_cmd = [ + "GIT=no", + "./configure", + "CC={}".format(build_env["FAASM_WASM_CC"]), + "CXX={}".format(build_env["FAASM_WASM_CXX"]), + "CFLAGS='--target=wasm32-wasi {}'".format(build_env["FAASM_WASM_CFLAGS"]), + "LD={}".format(build_env["FAASM_WASM_CC"]), + "LDXX={}".format(build_env["FAASM_WASM_CXX"]), + "LDFLAGS='{}'".format( + build_env["FAASM_WASM_STATIC_LINKER_FLAGS"] + ), + "AR={}".format(build_env["FAASM_WASM_AR"]), + "RANLIB={}".format(build_env["FAASM_WASM_RANLIB"]), + "NM={}".format(build_env["FAASM_WASM_NM"]), + # "PKG_CONFIG_PATH={}".format(join(EXAMPLES_DIR, "libpng")), + "GIT=no", + "--prefix={}".format(build_env["FAASM_WASM_SYSROOT"]), + "--host={}".format(build_env["FAASM_WASM_TRIPLE"]), + "--disable-openmp", + "--disable-w11", + "--disable-shared", + "--without-tiff", + "--without-zstd", + "--enable-cross-compile", + # "--with-png=yes", + # "--enable-delegate-build", + # "--without-bzlib", + # "--without-dps", + # "--without-djvu", + # "--without-fftw", + # "--without-flif", + # "--without-fpx", + # "--without-fontconfig", + # "--without-freetype", + # "--without-gslib", + # "--without-gnu-ld", + # "--without-gvc", + # "--without-heic", + # "--without-jbig", + # "--without-lcms", + # "--without-lqr", + # "--without-magick-plus-plus", + # "--without-openexr", + # "--without-openjp2", + # "--without-pango", + # "--without-perl", + # "--without-raqm", + # "--without-raw", + # "--without-rsvg", + # "--without-threads", + # "--without-webp", + # "--without-wmf", + # "--without-x", + # "--without-xml", + ] + + configure_cmd = " ".join(configure_cmd) + if not noconf: + run(configure_cmd, shell=True, cwd=grass_dir, check=True, env=build_env) + +""" + run( + "make {} -j".format("V=1" if debug else ""), + shell=True, + cwd=grass_dir, + check=True, + ) + + # Instead of installing ImageMagick, we copy the self-contained binary + # (magick) to /usr/local/faasm/wasm/imagemagick/main/function.wasm + wasm_copy_upload( + "imagemagick", "main", join(grass_dir, "utilities", "magick") + ) +"""