3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-05-25 11:26:22 +00:00

Migrate build system to CMake

See #5895 for details.

This commit does not include CI or documentation changes.
This commit is contained in:
Catherine 2026-05-12 05:33:04 +00:00
parent 9d0cdb8551
commit 9b087b4aa7
207 changed files with 5202 additions and 2294 deletions

66
nix/cross/tcl.nix Normal file
View file

@ -0,0 +1,66 @@
{
fetchurl,
lib,
pkgsBuildHost,
stdenv,
}:
# Due to changes within the Tcl's TomMath vendored dependency, newer versions break building Yosys
# on Windows.
let
version = "8.6.16";
libver = lib.replaceString "." "" (lib.versions.majorMinor version);
in
stdenv.mkDerivation {
pname = "tcl";
inherit version;
src = fetchurl {
url = "mirror://sourceforge/tcl/tcl${version}-src.tar.gz";
hash = "sha256-kcuPphdxxjwmLvtVMFm3x61nV6+lhXr2Jl5LC9wqFKU=";
};
preConfigure = ''
cd win
'';
makeFlags = [
"TCL_EXE=${lib.getExe' pkgsBuildHost.tcl "tclsh"}"
];
# We only care for a subset of Tcl, this improves build times.
buildFlags = [
"binaries"
"doc"
];
installTargets = [
"install-binaries"
"install-libraries"
"install-private-headers"
];
enableParallelBuilding = true;
postInstall = ''
mkdir -p $out/lib/pkgconfig
cat >$out/lib/pkgconfig/tcl.pc <<EOF
# tcl pkg-config source file
prefix=$out
exec_prefix=$out
libdir=$out/lib
includedir=\''${prefix}/include
libfile=libtcl${libver}.a
Name: Tool Command Language
Description: Tcl is a powerful, easy-to-learn dynamic programming language, suitable for a wide range of uses.
URL: https://www.tcl-lang.org/
Version: ${version}
Libs: -L\''${libdir} -ltcl${libver} -ltclstub${libver}
Libs.private: -luserenv -lws2_32 -lnetapi32
Cflags: -I\''${includedir} -DUSE_TCL_STUBS
EOF
'';
}

51
nix/cross/win-overlay.nix Normal file
View file

@ -0,0 +1,51 @@
(final: prev: {
# Fix for static linking.
readline = prev.readline.overrideAttrs (
oldAttrs:
prev.lib.attrsets.optionalAttrs prev.stdenv.hostPlatform.isMinGW {
NIX_CFLAGS_COMPILE = "-DNEED_EXTERN_PC=1";
}
);
tcl = if final.stdenv.hostPlatform.isMinGW then final.callPackage ./tcl.nix { } else prev.tcl;
# Create a pc file for termcap, since readline expects it.
termcap = prev.termcap.overrideAttrs (
oldAttrs:
prev.lib.attrsets.optionalAttrs prev.stdenv.hostPlatform.isMinGW {
postInstall = oldAttrs.postInstall + ''
mkdir -p $dev/lib/pkgconfig/
cat >$dev/lib/pkgconfig/termcap.pc <<EOF
prefix=$out
libdir=\''${prefix}/lib
includedir=$dev/include
Name: Termcap
Description: GNU Termcap library and data base that enables programs to use display terminals in a terminal-independent manner
URL: https://www.gnu.org/software/termutils/
Version: ${oldAttrs.version}
Libs: -L\''${libdir} -ltermcap
Cflags -I\''${includedir}
EOF
'';
}
);
# Use pthreads on Windows.
threads = final.lib.optionalAttrs final.stdenv.targetPlatform.isMinGW {
model = "posix";
package = null;
};
windows = prev.windows.overrideScope (
finalScope: prevScope: {
# Make sure we actually have pthreads available.
mingw_w64 = prevScope.mingw_w64.overrideAttrs (oldAttrs: {
configureFlags = oldAttrs.configureFlags ++ [
"--with-libraries=winpthreads"
];
});
}
);
})

15
nix/cross/win32.nix Normal file
View file

@ -0,0 +1,15 @@
{
pkgs,
overlays ? [ ],
}:
import pkgs.path {
inherit (pkgs.stdenv.hostPlatform) system;
crossSystem = pkgs.lib.systems.examples.mingw32 // {
isStatic = true;
};
overlays = overlays ++ [
(import ./win-overlay.nix)
];
}

15
nix/cross/win64.nix Normal file
View file

@ -0,0 +1,15 @@
{
pkgs,
overlays ? [ ],
}:
import pkgs.path {
inherit (pkgs.stdenv.hostPlatform) system;
crossSystem = pkgs.lib.systems.examples.mingwW64 // {
isStatic = true;
};
overlays = overlays ++ [
(import ./win-overlay.nix)
];
}

53
nix/pkgs/yosys.nix Normal file
View file

@ -0,0 +1,53 @@
{
bison,
cmake,
flex,
gtest,
lib,
libffi,
pkg-config,
python3,
readline,
ninja,
stdenv,
tcl,
zlib,
src,
rev,
...
}:
stdenv.mkDerivation {
name = "yosys";
inherit src;
nativeBuildInputs = [
bison
cmake
flex
pkg-config
python3
ninja
];
buildInputs = [
gtest
libffi
readline
tcl
zlib
];
cmakeFlags = [
(lib.cmakeBool "YOSYS_SKIP_ABC_SUBMODULE_CHECK" true)
(lib.cmakeFeature "YOSYS_CHECKOUT_INFO" rev)
];
enableParallelBuilding = true;
meta = with lib; {
description = "Yosys Open SYnthesis Suite";
homepage = "https://yosyshq.net/yosys/";
license = licenses.isc;
};
}