1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 installShellFiles,
6 nix-update-script,
7 versionCheckHook,
8}:
9
10stdenv.mkDerivation (finalAttrs: {
11 pname = "cppfront";
12 version = "0.8.1";
13
14 src = fetchFromGitHub {
15 owner = "hsutter";
16 repo = "cppfront";
17 tag = "v${finalAttrs.version}";
18 hash = "sha256-QYjon2EpNexYa2fl09AePkpq0LkRVBOQM++eldcVMvI=";
19 };
20
21 nativeBuildInputs = [
22 installShellFiles
23 ];
24
25 # Remove with next release
26 postPatch = ''
27 substituteInPlace source/version.info \
28 --replace-fail "0.8.0" "0.8.1"
29 '';
30
31 dontConfigure = true;
32
33 buildPhase = ''
34 runHook preBuild
35
36 $CXX source/cppfront.cpp -std=c++20 -o cppfront
37
38 runHook postBuild
39 '';
40
41 installPhase = ''
42 runHook preInstall
43
44 installBin cppfront
45 cp -r include $out/include
46
47 runHook postInstall
48 '';
49
50 nativeInstallCheckInputs = [
51 versionCheckHook
52 ];
53 versionCheckProgramArg = "-version";
54 doInstallCheck = true;
55
56 passthru = {
57 updateScript = nix-update-script { };
58
59 tests.hello-world = stdenv.mkDerivation (finalAttrs': {
60 pname = "${finalAttrs.pname}-hello-world-test";
61 inherit (finalAttrs) version src;
62
63 sourceRoot = "${finalAttrs'.src.name}/regression-tests";
64
65 nativeBuildInputs = [
66 finalAttrs.finalPackage
67 installShellFiles
68 ];
69
70 postBuild = ''
71 cppfront pure2-hello.cpp2
72 $CXX -std=c++20 -o pure2-hello{,.cpp}
73 '';
74
75 postInstall = ''
76 installBin pure2-hello
77 '';
78
79 doInstallCheck = true;
80 postInstallCheck = ''
81 $out/bin/pure2-hello | grep '^Hello \[world\]$' > /dev/null
82 '';
83
84 meta = {
85 inherit (finalAttrs.meta) maintainers platforms;
86 mainProgram = "pure2-hello";
87 };
88 });
89 };
90
91 meta = {
92 description = "Experimental compiler from a potential C++ 'syntax 2' (Cpp2) to today's 'syntax 1' (Cpp1)";
93 homepage = "https://hsutter.github.io/cppfront/";
94 changelog = "https://github.com/hsutter/cppfront/releases/tag/${finalAttrs.src.tag}";
95 mainProgram = "cppfront";
96 license = with lib.licenses; [
97 asl20
98 llvm-exception
99 ];
100 maintainers = with lib.maintainers; [
101 marcin-serwin
102 ];
103 platforms = lib.platforms.all;
104 };
105})