|
| 1 | +from faasmtools.build import get_faasm_build_env_dict |
| 2 | +from faasmtools.compile_util import wasm_copy_upload |
| 3 | +from invoke import task |
| 4 | +from os.path import join |
| 5 | +from subprocess import run |
| 6 | +from tasks.env import EXAMPLES_DIR |
| 7 | + |
| 8 | + |
| 9 | +@task(default=True) |
| 10 | +def grass(ctx, clean=False, noconf=False, debug=False): |
| 11 | + """ |
| 12 | + Compile and install ImageMagick |
| 13 | + """ |
| 14 | + grass_dir = join(EXAMPLES_DIR, "grass") |
| 15 | + |
| 16 | + if clean: |
| 17 | + run( |
| 18 | + "make clean distclean", shell=True, cwd=grass_dir, check=True |
| 19 | + ) |
| 20 | + |
| 21 | + build_env = get_faasm_build_env_dict() |
| 22 | + build_env["GIT"] = "no" |
| 23 | + |
| 24 | + configure_cmd = [ |
| 25 | + "GIT=no", |
| 26 | + "./configure", |
| 27 | + "CC={}".format(build_env["FAASM_WASM_CC"]), |
| 28 | + "CXX={}".format(build_env["FAASM_WASM_CXX"]), |
| 29 | + "CFLAGS='--target=wasm32-wasi {}'".format(build_env["FAASM_WASM_CFLAGS"]), |
| 30 | + "LD={}".format(build_env["FAASM_WASM_CC"]), |
| 31 | + "LDXX={}".format(build_env["FAASM_WASM_CXX"]), |
| 32 | + "LDFLAGS='{}'".format( |
| 33 | + build_env["FAASM_WASM_STATIC_LINKER_FLAGS"] |
| 34 | + ), |
| 35 | + "AR={}".format(build_env["FAASM_WASM_AR"]), |
| 36 | + "RANLIB={}".format(build_env["FAASM_WASM_RANLIB"]), |
| 37 | + "NM={}".format(build_env["FAASM_WASM_NM"]), |
| 38 | + # "PKG_CONFIG_PATH={}".format(join(EXAMPLES_DIR, "libpng")), |
| 39 | + "GIT=no", |
| 40 | + "--prefix={}".format(build_env["FAASM_WASM_SYSROOT"]), |
| 41 | + "--host={}".format(build_env["FAASM_WASM_TRIPLE"]), |
| 42 | + "--disable-openmp", |
| 43 | + "--disable-w11", |
| 44 | + "--disable-shared", |
| 45 | + "--without-tiff", |
| 46 | + "--without-zstd", |
| 47 | + "--enable-cross-compile", |
| 48 | + # "--with-png=yes", |
| 49 | + # "--enable-delegate-build", |
| 50 | + # "--without-bzlib", |
| 51 | + # "--without-dps", |
| 52 | + # "--without-djvu", |
| 53 | + # "--without-fftw", |
| 54 | + # "--without-flif", |
| 55 | + # "--without-fpx", |
| 56 | + # "--without-fontconfig", |
| 57 | + # "--without-freetype", |
| 58 | + # "--without-gslib", |
| 59 | + # "--without-gnu-ld", |
| 60 | + # "--without-gvc", |
| 61 | + # "--without-heic", |
| 62 | + # "--without-jbig", |
| 63 | + # "--without-lcms", |
| 64 | + # "--without-lqr", |
| 65 | + # "--without-magick-plus-plus", |
| 66 | + # "--without-openexr", |
| 67 | + # "--without-openjp2", |
| 68 | + # "--without-pango", |
| 69 | + # "--without-perl", |
| 70 | + # "--without-raqm", |
| 71 | + # "--without-raw", |
| 72 | + # "--without-rsvg", |
| 73 | + # "--without-threads", |
| 74 | + # "--without-webp", |
| 75 | + # "--without-wmf", |
| 76 | + # "--without-x", |
| 77 | + # "--without-xml", |
| 78 | + ] |
| 79 | + |
| 80 | + configure_cmd = " ".join(configure_cmd) |
| 81 | + if not noconf: |
| 82 | + run(configure_cmd, shell=True, cwd=grass_dir, check=True, env=build_env) |
| 83 | + |
| 84 | +""" |
| 85 | + run( |
| 86 | + "make {} -j".format("V=1" if debug else ""), |
| 87 | + shell=True, |
| 88 | + cwd=grass_dir, |
| 89 | + check=True, |
| 90 | + ) |
| 91 | +
|
| 92 | + # Instead of installing ImageMagick, we copy the self-contained binary |
| 93 | + # (magick) to /usr/local/faasm/wasm/imagemagick/main/function.wasm |
| 94 | + wasm_copy_upload( |
| 95 | + "imagemagick", "main", join(grass_dir, "utilities", "magick") |
| 96 | + ) |
| 97 | +""" |
0 commit comments