2023-03-08 16:32:21 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, makeWrapper, pcre2, coreutils, which, openssl, libxml2, cmake, z3, substituteAll, python3,
|
2020-04-24 23:36:52 +00:00
|
|
|
cc ? stdenv.cc, lto ? !stdenv.isDarwin }:
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
stdenv.mkDerivation (rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "ponyc";
|
2022-04-27 09:35:20 +00:00
|
|
|
version = "0.50.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ponylang";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2022-04-27 09:35:20 +00:00
|
|
|
sha256 = "sha256-FnzlFTiJrqoUfnys+q9is6OH9yit5ExDiRszQ679QbY=";
|
2020-10-07 09:15:18 +00:00
|
|
|
|
|
|
|
fetchSubmodules = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
ponygbenchmark = fetchFromGitHub {
|
|
|
|
owner = "google";
|
|
|
|
repo = "benchmark";
|
2022-01-13 20:06:32 +00:00
|
|
|
rev = "v1.5.4";
|
|
|
|
sha256 = "1dbjdjzkpbsq3jl9ksyg8mw759vkac8qzq1557m73ldnavbhz48x";
|
2020-10-07 09:15:18 +00:00
|
|
|
};
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
nativeBuildInputs = [ cmake makeWrapper which python3 ];
|
2021-01-15 22:18:51 +00:00
|
|
|
buildInputs = [ libxml2 z3 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
# Sandbox disallows network access, so disabling problematic networking tests
|
|
|
|
patches = [
|
|
|
|
./disable-tests.patch
|
|
|
|
(substituteAll {
|
|
|
|
src = ./make-safe-for-sandbox.patch;
|
2022-01-13 20:06:32 +00:00
|
|
|
googletest = fetchFromGitHub {
|
|
|
|
owner = "google";
|
|
|
|
repo = "googletest";
|
|
|
|
rev = "release-1.10.0";
|
|
|
|
sha256 = "1zbmab9295scgg4z2vclgfgjchfjailjnvzc6f5x9jvlsdi3dpwz";
|
2020-10-07 09:15:18 +00:00
|
|
|
};
|
|
|
|
})
|
2023-03-08 16:32:21 +00:00
|
|
|
(fetchpatch {
|
|
|
|
name = "remove-decnet-header.patch";
|
|
|
|
url = "https://github.com/ponylang/ponyc/commit/e5b9b5daec5b19415d519b09954cbd3cf5f34220.patch";
|
|
|
|
hash = "sha256-60cOhBBwQxWLwEx+svtFtJ7POQkHzJo2LDPRJ5L/bNk=";
|
|
|
|
})
|
2020-10-07 09:15:18 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
mkdir -p source/build/build_libs/gbenchmark-prefix/src
|
2021-06-06 07:54:09 +00:00
|
|
|
cp -r "$ponygbenchmark"/ source/build/build_libs/gbenchmark-prefix/src/benchmark
|
|
|
|
chmod -R u+w source/build/build_libs/gbenchmark-prefix/src/benchmark
|
2020-10-07 09:15:18 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
dontConfigure = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Patching Vendor LLVM
|
|
|
|
patchShebangs --host build/build_libs/gbenchmark-prefix/src/benchmark/tools/*.py
|
2022-01-13 20:06:32 +00:00
|
|
|
patch -d lib/llvm/src/ -p1 < lib/llvm/patches/2020-07-28-01-c-exports.diff
|
2020-10-07 09:15:18 +00:00
|
|
|
substituteInPlace packages/process/_test.pony \
|
|
|
|
--replace '"/bin/' '"${coreutils}/bin/' \
|
|
|
|
--replace '=/bin' "${coreutils}/bin"
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace src/libponyc/pkg/package.c \
|
|
|
|
--replace "/usr/local/lib" "" \
|
|
|
|
--replace "/opt/local/lib" ""
|
2020-10-07 09:15:18 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
preBuild = ''
|
|
|
|
make libs build_flags=-j$NIX_BUILD_CORES
|
|
|
|
make configure build_flags=-j$NIX_BUILD_CORES
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
makeFlags = [
|
|
|
|
"PONYC_VERSION=${version}"
|
|
|
|
"prefix=${placeholder "out"}"
|
|
|
|
]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ "bits=64" ]
|
|
|
|
++ lib.optionals (stdenv.isDarwin && (!lto)) [ "lto=no" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=redundant-move" "-Wno-error=implicit-fallthrough" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
installPhase = "make config=release prefix=$out "
|
|
|
|
+ lib.optionalString stdenv.isDarwin "bits=64 "
|
|
|
|
+ lib.optionalString (stdenv.isDarwin && (!lto)) "lto=no "
|
2020-04-24 23:36:52 +00:00
|
|
|
+ '' install
|
|
|
|
wrapProgram $out/bin/ponyc \
|
|
|
|
--prefix PATH ":" "${stdenv.cc}/bin" \
|
|
|
|
--set-default CC "$CC" \
|
2021-02-17 17:02:09 +00:00
|
|
|
--prefix PONYPATH : "${lib.makeLibraryPath [ pcre2 openssl (placeholder "out") ]}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Stripping breaks linking for ponyc
|
|
|
|
dontStrip = true;
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Pony is an Object-oriented, actor-model, capabilities-secure, high performance programming language";
|
|
|
|
homepage = "https://www.ponylang.org";
|
|
|
|
license = licenses.bsd2;
|
2020-11-09 15:59:12 +00:00
|
|
|
maintainers = with maintainers; [ kamilchm patternspandemic redvers ];
|
2023-03-08 16:32:21 +00:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
})
|