1{ lib, stdenv, cmake, python3, fetchFromGitHub, emscripten,
2 gtest, lit, nodejs, filecheck
3}:
4
5stdenv.mkDerivation rec {
6 pname = "binaryen";
7 version = "112";
8
9 src = fetchFromGitHub {
10 owner = "WebAssembly";
11 repo = "binaryen";
12 rev = "version_${version}";
13 hash = "sha256-xVumVmiLMHJp3SItE8eL8OBPeq58HtOOiK9LL8SP4CQ=";
14 };
15
16 nativeBuildInputs = [ cmake python3 ];
17
18 preConfigure = ''
19 if [ $doCheck -eq 1 ]; then
20 sed -i '/googletest/d' third_party/CMakeLists.txt
21 else
22 cmakeFlagsArray=($cmakeFlagsArray -DBUILD_TESTS=0)
23 fi
24 '';
25
26 nativeCheckInputs = [ gtest lit nodejs filecheck ];
27 checkPhase = ''
28 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib python3 ../check.py $tests
29 '';
30
31 tests = [
32 "version" "wasm-opt" "wasm-dis"
33 "crash" "dylink" "ctor-eval"
34 "wasm-metadce" "wasm-reduce" "spec"
35 "lld" "wasm2js" "validator"
36 "example" "unit"
37 # "binaryenjs" "binaryenjs_wasm" # not building this
38 "lit" "gtest"
39 ];
40 doCheck = stdenv.isLinux;
41
42 meta = with lib; {
43 homepage = "https://github.com/WebAssembly/binaryen";
44 description = "Compiler infrastructure and toolchain library for WebAssembly, in C++";
45 platforms = platforms.all;
46 maintainers = with maintainers; [ asppsa ];
47 license = licenses.asl20;
48 };
49
50 passthru.tests = {
51 inherit emscripten;
52 };
53}