Unverified Commit d27ba659 authored by Ulrik Strid's avatar Ulrik Strid Committed by GitHub
Browse files

Merge pull request #330847 from superherointj/remove-bs-platform

bs-platform: remove
parents 5627cbe0 1b7f1644
Loading
Loading
Loading
Loading
+0 −66
Original line number Diff line number Diff line
# This file is based on https://github.com/turboMaCk/bs-platform.nix/blob/master/build-bs-platform.nix
# to make potential future updates simpler

{ lib, stdenv, ninja, runCommand, nodejs, python3,
  ocaml-version, version, src,
  patches ? [],
  ocaml ? (import ./ocaml.nix {
    version = ocaml-version;
    inherit lib stdenv;
    src = "${src}/ocaml";
  }),
  custom-ninja ? (ninja.overrideAttrs (attrs: {
    src = runCommand "ninja-patched-source" {} ''
      mkdir -p $out
      tar zxvf ${src}/vendor/ninja.tar.gz -C $out
    '';
    patches = [];
  })),
  ...
}:

let
  bin_folder = if stdenv.isDarwin then "darwin" else "linux";
in

stdenv.mkDerivation rec {
  inherit src version patches;
  pname = "bs-platform";

  BS_RELEASE_BUILD = "true";

  # BuckleScript's idiosyncratic build process only builds artifacts required
  # for editor-tooling to work when this environment variable is set:
  # https://github.com/BuckleScript/bucklescript/blob/7.2.0/scripts/install.js#L225-L227
  BS_TRAVIS_CI = "1";

  buildInputs = [ nodejs python3 custom-ninja ];

  prePatch = ''
    sed -i 's:./configure.py --bootstrap:python3 ./configure.py --bootstrap:' ./scripts/install.js
    mkdir -p ./native/${ocaml-version}/bin
    ln -sf ${ocaml}/bin/*  ./native/${ocaml-version}/bin
  '';

  # avoid building the development version, will break aarch64 build
  dontConfigure = true;

  buildPhase = ''
    # This is an unfortunate name, but it's actually how to build a release
    # binary for BuckleScript
    npm run postinstall
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp -rf jscomp lib ${bin_folder} vendor odoc_gen native bsb bsc bsrefmt $out
    mkdir -p $out/lib/ocaml
    cp jscomp/runtime/js.* jscomp/runtime/*.cm* $out/lib/ocaml
    cp jscomp/others/*.ml jscomp/others/*.mli jscomp/others/*.cm* $out/lib/ocaml
    cp jscomp/stdlib-406/*.ml jscomp/stdlib-406/*.mli jscomp/stdlib-406/*.cm* $out/lib/ocaml
    cp bsconfig.json package.json $out
    ln -s $out/bsb $out/bin/bsb
    ln -s $out/bsc $out/bin/bsc
    ln -s $out/bsrefmt $out/bin/bsrefmt
  '';
}
+0 −27
Original line number Diff line number Diff line
{ lib, stdenv, runCommand, fetchFromGitHub, ninja, nodejs, python3, ... }:
let
  build-bs-platform = import ./build-bs-platform.nix;
in
(build-bs-platform rec {
  inherit lib stdenv runCommand fetchFromGitHub ninja nodejs python3;
  version = "8.2.0";
  ocaml-version = "4.06.1";

  patches = [ ./jscomp-release-ninja.patch ];

  src = fetchFromGitHub {
    owner = "BuckleScript";
    repo = "bucklescript";
    rev = version;
    sha256 = "1hql7sxps1k17zmwyha6idq6nw20abpq770l55ry722birclmsmf";
    fetchSubmodules = true;
  };
}).overrideAttrs (attrs: {
  meta = with lib; {
    description = "JavaScript backend for OCaml focused on smooth integration and clean generated code";
    homepage = "https://bucklescript.github.io";
    license = licenses.lgpl3;
    maintainers = with maintainers; [ turbomack gamb ];
    platforms = platforms.all;
  };
})
+0 −16
Original line number Diff line number Diff line
 jscomp/others/release.ninja | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jscomp/others/release.ninja b/jscomp/others/release.ninja
index 9ea6d11c5..a91ed9c80 100644
--- a/jscomp/others/release.ninja
+++ b/jscomp/others/release.ninja
@@ -30,7 +30,7 @@ build others/js_json.cmj : cc_cmi others/js_json.ml | others/js_array2.cmj other
 build others/js_json.cmi : cc others/js_json.mli | others/js_dict.cmi others/js_null.cmi others/js_string.cmj others/js_types.cmi runtime
 build others/js_list.cmj : cc_cmi others/js_list.ml | others/js_array2.cmj others/js_list.cmi others/js_vector.cmj runtime
 build others/js_list.cmi : cc others/js_list.mli | others/js_vector.cmi runtime
-build others/js_mapperRt.cmj : cc_cmi others/js_mapperRt.ml | others/js_mapperRt.cmi runtime
+build others/js_mapperRt.cmj : cc_cmi others/js_mapperRt.ml | others/js_array2.cmj others/js_mapperRt.cmi runtime
 build others/js_mapperRt.cmi : cc others/js_mapperRt.mli | runtime
 build others/js_math.cmi others/js_math.cmj : cc others/js_math.ml | others/js_int.cmj runtime
 build others/js_null.cmj : cc_cmi others/js_null.ml | others/js_exn.cmj others/js_null.cmi runtime
 No newline at end of file
+0 −23
Original line number Diff line number Diff line
{ lib, stdenv, src, version }:
stdenv.mkDerivation rec {
  inherit src version;
  pname = "ocaml-bs";
  configurePhase = ''
    ./configure -prefix $out
  '';

  # Workaround ocaml-4.06 limitation of duplicate definitions.
  #   ld: libcamlrun.a(minor_gc.o):/build/ocaml/byterun/caml/major_gc.h:67: multiple definition of
  #     `caml_major_ring'; libcamlrun.a(stacks.o):/build/ocaml/byterun/caml/major_gc.h:67: first defined here
  # Match -fcommon workaround in ocaml-4.06 itself.
  env.NIX_CFLAGS_COMPILE = "-fcommon";

  buildPhase = ''
    make -j9 world.opt
  '';

  meta = with lib; {
    branch = "4.06";
    platforms = platforms.all;
  };
}
+0 −2
Original line number Diff line number Diff line
@@ -4360,8 +4360,6 @@ with pkgs;
  burpsuite = callPackage ../tools/networking/burpsuite { };
  bs-platform = callPackage ../development/compilers/bs-platform { };
  ciano = callPackage ../applications/graphics/ciano {
    inherit (pantheon) granite;
    python = python3;