{ftjam,jam}: migrate to by-name (#343849)

This commit is contained in:
Thiago Kenji Okada
2024-10-01 12:51:25 +01:00
committed by GitHub
4 changed files with 230 additions and 122 deletions
+117
View File
@@ -0,0 +1,117 @@
{
lib,
bison,
buildPackages,
fetchurl,
installShellFiles,
pkgsBuildTarget,
stdenv,
testers,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "ftjam";
version = "2.5.2";
src = fetchurl {
url = "https://downloads.sourceforge.net/project/freetype/ftjam/${finalAttrs.version}/ftjam-${finalAttrs.version}.tar.bz2";
hash = "sha256-6JdzUAqSkS3pGOn+v/q+S2vOedaa8ZRDX04DK4ptZqM=";
};
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
bison
installShellFiles
];
# Doesn't understand how to cross compile once bootstrapped, so we'll just use
# the Makefile for the bootstrapping portion
configurePlatforms = [
"build"
"target"
];
configureFlags = [
"CC=${buildPackages.stdenv.cc.targetPrefix}cc"
"--host=${stdenv.buildPlatform.config}"
];
makeFlags = [
"CC=${buildPackages.stdenv.cc.targetPrefix}cc"
];
env = {
LOCATE_TARGET = "bin.unix";
# Jam uses c89 conventions
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-std=c89";
};
enableParallelBuilding = true;
strictDeps = true;
# Jambase expects ar to have flags.
preConfigure = ''
export AR="$AR rc"
'';
# When cross-compiling, we need to set the preprocessor macros
# OSMAJOR/OSMINOR/OSPLAT to the values from the target platform, not the host
# platform. This looks a little ridiculous because the vast majority of build
# tools don't embed target-specific information into their binary, but in this
# case we behave more like a compiler than a make(1)-alike.
postPatch =
''
substituteInPlace Jamfile \
--replace "strip" "${stdenv.cc.targetPrefix}strip"
''
+ lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
cat >>jam.h <<EOF
#undef OSMAJOR
#undef OSMINOR
#undef OSPLAT
$(
${pkgsBuildTarget.targetPackages.stdenv.cc}/bin/${pkgsBuildTarget.targetPackages.stdenv.cc.targetPrefix}cc -E -dM jam.h | grep -E '^#define (OSMAJOR|OSMINOR|OSPLAT) '
)
EOF
'';
buildPhase = ''
runHook preBuild
make $makeFlags jam0
./jam0 -j$NIX_BUILD_CORES -sCC=${buildPackages.stdenv.cc.targetPrefix}cc jambase.c
./jam0 -j$NIX_BUILD_CORES
runHook postBuild
'';
# The configure script does not recognize --docdir; because of it, the outputs
# can't be split
installPhase = ''
runHook preInstall
installBin bin.unix/jam
install -Dm644 -t ''${!outputDoc}/share/doc/jam-${finalAttrs.version}/ *.html
runHook postInstall
'';
passthru = {
tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "jam -v";
};
};
meta = {
homepage = "https://freetype.org/jam/";
description = "FreeType's enhanced, backwards-compatible Jam clone";
license = lib.licenses.free;
mainProgram = "jam";
maintainers = with lib.maintainers; [
impl
AndersonTorres
];
platforms = lib.platforms.unix;
};
})
+113
View File
@@ -0,0 +1,113 @@
{
lib,
bison,
buildPackages,
fetchurl,
installShellFiles,
pkgsBuildTarget,
stdenv,
testers,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "jam";
version = "2.6.1";
src = fetchurl {
url = "https://swarm.workshop.perforce.com/downloads/guest/perforce_software/jam/jam-${finalAttrs.version}.tar";
hash = "sha256-rOayJ8GpmFk0/RPJwK5Pf/RBccbe2Lg7s9p15u/cs6c=";
};
outputs = [
"out"
"doc"
];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
bison
installShellFiles
];
makeFlags = [
"CC=${buildPackages.stdenv.cc.targetPrefix}cc"
];
env = {
LOCATE_TARGET = "bin.unix";
# Jam uses c89 conventions
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-std=c89";
};
enableParallelBuilding = true;
strictDeps = true;
# Jambase expects ar to have flags.
preConfigure = ''
export AR="$AR rc"
'';
# When cross-compiling, we need to set the preprocessor macros
# OSMAJOR/OSMINOR/OSPLAT to the values from the target platform, not the host
# platform. This looks a little ridiculous because the vast majority of build
# tools don't embed target-specific information into their binary, but in this
# case we behave more like a compiler than a make(1)-alike.
postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
cat >>jam.h <<EOF
#undef OSMAJOR
#undef OSMINOR
#undef OSPLAT
$(
${pkgsBuildTarget.targetPackages.stdenv.cc}/bin/${pkgsBuildTarget.targetPackages.stdenv.cc.targetPrefix}cc -E -dM jam.h | grep -E '^#define (OSMAJOR|OSMINOR|OSPLAT) '
)
EOF
'';
buildPhase = ''
runHook preBuild
make $makeFlags jam0
./jam0 -j$NIX_BUILD_CORES -sCC=${buildPackages.stdenv.cc.targetPrefix}cc jambase.c
./jam0 -j$NIX_BUILD_CORES
runHook postBuild
'';
installPhase = ''
runHook preInstall
installBin bin.unix/jam
install -Dm644 -t ''${!outputDoc}/share/doc/jam-${finalAttrs.version}/ *.html
runHook postInstall
'';
passthru = {
tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "jam -v";
};
};
meta = {
homepage = "https://swarm.workshop.perforce.com/projects/perforce_software-jam";
description = "Just Another Make";
longDescription = ''
Jam is a program construction tool, like make(1).
Jam recursively builds target files from source files, using dependency
information and updating actions expressed in the Jambase file, which is
written in jam's own interpreted language. The default Jambase is compiled
into jam and provides a boilerplate for common use, relying on a
user-provide file "Jamfile" to enumerate actual targets and sources.
'';
license = lib.licenses.free;
mainProgram = "jam";
maintainers = with lib.maintainers; [
impl
orivej
AndersonTorres
];
platforms = lib.platforms.unix;
};
})
@@ -1,118 +0,0 @@
{ lib, stdenv, fetchurl, bison, buildPackages, pkgsBuildTarget }:
let
mkJam = { pname, version, src, meta ? { } }: stdenv.mkDerivation {
inherit pname version src;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ bison ];
# Jam uses c89 conventions
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-std=c89";
# Jambase expects ar to have flags.
preConfigure = ''
export AR="$AR rc"
'';
# When cross-compiling, we need to set the preprocessor macros
# OSMAJOR/OSMINOR/OSPLAT to the values from the target platform, not the
# host platform. This looks a little ridiculous because the vast majority of
# build tools don't embed target-specific information into their binary, but
# in this case we behave more like a compiler than a make(1)-alike.
postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
cat >>jam.h <<EOF
#undef OSMAJOR
#undef OSMINOR
#undef OSPLAT
$(
${pkgsBuildTarget.targetPackages.stdenv.cc}/bin/${pkgsBuildTarget.targetPackages.stdenv.cc.targetPrefix}cc -E -dM jam.h \
| grep -E '^#define (OSMAJOR|OSMINOR|OSPLAT) '
)
EOF
'';
LOCATE_TARGET = "bin.unix";
buildPhase = ''
runHook preBuild
make $makeFlags jam0
./jam0 -j$NIX_BUILD_CORES -sCC=${buildPackages.stdenv.cc.targetPrefix}cc jambase.c
./jam0 -j$NIX_BUILD_CORES
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/doc/jam
cp bin.unix/jam $out/bin/jam
cp *.html $out/doc/jam
runHook postInstall
'';
enableParallelBuilding = true;
meta = with lib; {
license = licenses.free;
mainProgram = "jam";
platforms = platforms.unix;
} // meta;
};
in
{
jam = let
pname = "jam";
version = "2.6.1";
base = mkJam {
inherit pname version;
src = fetchurl {
url = "https://swarm.workshop.perforce.com/projects/perforce_software-jam/download/main/${pname}-${version}.tar";
sha256 = "19xkvkpycxfsncxvin6yqrql3x3z9ypc1j8kzls5k659q4kv5rmc";
};
meta = with lib; {
description = "Just Another Make";
homepage = "https://www.perforce.com/resources/documentation/jam";
maintainers = with maintainers; [ impl orivej ];
};
};
in base.overrideAttrs (oldAttrs: {
makeFlags = (oldAttrs.makeFlags or []) ++ [
"CC=${buildPackages.stdenv.cc.targetPrefix}cc"
];
});
ftjam = let
pname = "ftjam";
version = "2.5.2";
base = mkJam {
inherit pname version;
src = fetchurl {
url = "https://downloads.sourceforge.net/project/freetype/${pname}/${version}/${pname}-${version}.tar.bz2";
hash = "sha256-6JdzUAqSkS3pGOn+v/q+S2vOedaa8ZRDX04DK4ptZqM=";
};
meta = with lib; {
description = "FreeType's enhanced, backwards-compatible Jam clone";
homepage = "https://freetype.org/jam/";
maintainers = with maintainers; [ AndersonTorres impl ];
};
};
in base.overrideAttrs (oldAttrs: {
postPatch = (oldAttrs.postPatch or "") + ''
substituteInPlace Jamfile --replace strip ${stdenv.cc.targetPrefix}strip
'';
# Doesn't understand how to cross compile once bootstrapped, so we'll just
# use the Makefile for the bootstrapping portion.
configurePlatforms = [ "build" "target" ];
configureFlags = (oldAttrs.configureFlags or []) ++ [
"CC=${buildPackages.stdenv.cc.targetPrefix}cc"
"--host=${stdenv.buildPlatform.config}"
];
});
}
-4
View File
@@ -17942,10 +17942,6 @@ with pkgs;
jake = callPackage ../development/tools/jake { };
inherit (callPackage ../development/tools/build-managers/jam { })
jam
ftjam;
javacc = callPackage ../development/tools/parsing/javacc {
# Upstream doesn't support anything newer than Java 8.
# https://github.com/javacc/javacc/blob/c708628423b71ce8bc3b70143fa5b6a2b7362b3a/README.md#building-javacc-from-source