open-watcom-v2: init at unstable 2021-11-30 (#124000)

authored by Christoph Neidahl and committed by GitHub 113f047a 1e189a4f

+253 -1
+1
pkgs/development/compilers/open-watcom-bin/default.nix pkgs/development/compilers/open-watcom/bin.nix
··· 87 87 stdenvNoCC.mkDerivation rec { 88 88 pname = "open-watcom-bin"; 89 89 version = "1.9"; 90 + name = "${pname}-unwrapped-${version}"; 90 91 91 92 src = fetchurl { 92 93 url = "http://ftp.openwatcom.org/install/open-watcom-c-linux-${version}";
+119
pkgs/development/compilers/open-watcom/v2.nix
··· 1 + { stdenv 2 + , lib 3 + , fetchFromGitHub 4 + 5 + # Docs cause an immense increase in build time, up to 2 additional hours 6 + , withDocs ? false 7 + , dosbox 8 + , ghostscript 9 + , withGUI ? false 10 + }: 11 + 12 + stdenv.mkDerivation rec { 13 + pname = "open-watcom-v2"; 14 + version = "unstable-2021-11-30"; 15 + name = "${pname}-unwrapped-${version}"; 16 + 17 + src = fetchFromGitHub { 18 + owner = "open-watcom"; 19 + repo = "open-watcom-v2"; 20 + rev = "982c958eb4840e1c6a98773ba0600f652500f5a7"; 21 + sha256 = "18dp9nd1gjnpd1870149v67vzxbna25l6zi052z1r51xvaqwc3cx"; 22 + }; 23 + 24 + postPatch = '' 25 + patchShebangs *.sh 26 + 27 + for dateSource in cmnvars.sh bld/wipfc/configure; do 28 + substituteInPlace $dateSource \ 29 + --replace '`date ' '`date -ud "@$SOURCE_DATE_EPOCH" ' 30 + done 31 + 32 + substituteInPlace bld/watcom/h/banner.h \ 33 + --replace '__DATE__' "\"$(date -ud "@$SOURCE_DATE_EPOCH" +'%b %d %Y')\"" \ 34 + --replace '__TIME__' "\"$(date -ud "@$SOURCE_DATE_EPOCH" +'%T')\"" 35 + 36 + substituteInPlace build/makeinit \ 37 + --replace '%__CYEAR__' '%OWCYEAR' 38 + '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 39 + substituteInPlace build/mif/local.mif \ 40 + --replace '-static' "" 41 + ''; 42 + 43 + nativeBuildInputs = [ ] 44 + ++ lib.optional (withDocs || withGUI) dosbox 45 + ++ lib.optional withDocs ghostscript; 46 + 47 + configurePhase = '' 48 + runHook preConfigure 49 + 50 + export OWROOT=$(realpath $PWD) 51 + export OWTOOLS=${if stdenv.cc.isClang then "CLANG" else "GCC"} 52 + export OWDOCBUILD=${if withDocs then "1" else "0"} 53 + export OWGHOSTSCRIPTPATH=${lib.optionalString withDocs "${ghostscript}/bin"} 54 + export OWGUINOBUILD=${if withGUI then "0" else "1"} 55 + export OWNOBUILD= 56 + export OWDISTRBUILD=0 57 + export OWDOSBOX=${lib.optionalString (withDocs || withGUI) "${dosbox}/bin/dosbox"} 58 + export OWVERBOSE=0 59 + export OWRELROOT=$out 60 + 61 + source cmnvars.sh 62 + 63 + runHook postConfigure 64 + ''; 65 + 66 + buildPhase = '' 67 + runHook preBuild 68 + 69 + ./build.sh build 70 + 71 + runHook postBuild 72 + ''; 73 + 74 + installPhase = '' 75 + runHook preInstall 76 + 77 + ./build.sh cprel 78 + 79 + runHook postInstall 80 + ''; 81 + 82 + # Stripping breaks many tools 83 + dontStrip = true; 84 + 85 + meta = with lib; { 86 + description = "The v2 fork of the Open Watcom suite of compilers and tools"; 87 + longDescription = '' 88 + A fork of Open Watcom: A C/C++/Fortran compiler and assembler suite 89 + targeting a multitude of architectures (x86, IA-32, Alpha AXP, MIPS, 90 + PowerPC) and operating systems (DOS, OS/2, Windows, Linux). 91 + 92 + Main differences from Open Watcom 1.9: 93 + 94 + - New two-phase build system - Open Watcom can be built by the host's 95 + native C/C++ compiler or by itself 96 + - Code generator properly initializes pointers by DLL symbol addresses 97 + - DOS tools now support long file names (LFN) if appropriate LFN driver 98 + is loaded by DOS 99 + - Open Watcom is ported to 64-bit hosts (Win64, Linux x64) 100 + - Librarian supports x64 CPU object modules and libraries 101 + - RDOS 32-bit C run-time compact memory model libraries are fixed 102 + - Resource compiler and Resource editors support Win64 executables 103 + - Open Watcom text editor is now self-contained, it can be used as 104 + standalone tool without any requirements for any additional files or 105 + configuration 106 + - Broken C++ compiler pre-compiled header template support is fixed 107 + - Many C++ compiler crashes are fixed 108 + - Debugger has no length limit for any used environment variable 109 + '' + lib.optionalString (!withDocs) '' 110 + 111 + The documentation has been excluded from this build for build time reasons. It can be found here: 112 + https://github.com/open-watcom/open-watcom-v2/wiki/Open-Watcom-Documentation 113 + ''; 114 + homepage = "https://open-watcom.github.io"; 115 + license = licenses.watcom; 116 + platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "x86_64-windows" "i686-windows" ]; 117 + maintainers = with maintainers; [ OPNA2608 ]; 118 + }; 119 + }
+128
pkgs/development/compilers/open-watcom/wrapper.nix
··· 1 + # Arguments that this derivation gets when it is created with `callPackage` 2 + { stdenv 3 + , lib 4 + , symlinkJoin 5 + , makeWrapper 6 + , runCommand 7 + , file 8 + }: 9 + 10 + open-watcom: 11 + 12 + let 13 + wrapper = 14 + {}: 15 + let 16 + binDirs = with stdenv.hostPlatform; if isWindows then [ 17 + (lib.optionalString is64bit "binnt64") 18 + "binnt" 19 + (lib.optionalString is32bit "binw") 20 + ] else if (isDarwin && is64bit) then [ 21 + "osx64" 22 + ] else [ 23 + (lib.optionalString is64bit "binl64") 24 + "binl" 25 + ]; 26 + includeDirs = with stdenv.hostPlatform; [ 27 + "h" 28 + ] 29 + ++ lib.optional isWindows "h/nt" 30 + ++ lib.optional isLinux "lh"; 31 + listToDirs = list: lib.strings.concatMapStringsSep ":" (dir: "${placeholder "out"}/${dir}") list; 32 + name = "${open-watcom.pname}-${open-watcom.version}"; 33 + in 34 + symlinkJoin { 35 + inherit name; 36 + 37 + paths = [ open-watcom ]; 38 + 39 + buildInputs = [ makeWrapper ]; 40 + 41 + postBuild = '' 42 + mkdir $out/bin 43 + 44 + for binDir in ${lib.strings.concatStringsSep " " binDirs}; do 45 + for exe in $(find ${open-watcom}/$binDir \ 46 + -type f -executable \ 47 + ${lib.optionalString stdenv.hostPlatform.isLinux "-not -iname '*.so' -not -iname '*.exe'"} \ 48 + ); do 49 + if [ ! -f $out/bin/$(basename $exe) ]; then 50 + makeWrapper $exe $out/bin/$(basename $exe) \ 51 + --set WATCOM ${open-watcom} \ 52 + --prefix PATH : ${listToDirs binDirs} \ 53 + --set EDPATH ${open-watcom}/eddat \ 54 + --set INCLUDE ${listToDirs includeDirs} 55 + fi 56 + done 57 + done 58 + ''; 59 + 60 + passthru = { 61 + unwrapped = open-watcom; 62 + tests = let 63 + wrapped = wrapper { }; 64 + in { 65 + simple = runCommand "${name}-test-simple" { nativeBuildInputs = [ wrapped ]; } '' 66 + cat <<EOF >test.c 67 + #include <stdio.h> 68 + int main() { 69 + printf ("Testing OpenWatcom C89 compiler.\n"); 70 + return 0; 71 + } 72 + EOF 73 + cat test.c 74 + # Darwin target not supported, only host 75 + wcl386 -fe=test_c test.c 76 + ${lib.optionalString (!stdenv.hostPlatform.isDarwin) "./test_c"} 77 + 78 + cat <<EOF >test.cpp 79 + #include <string> 80 + #include <iostream> 81 + int main() { 82 + std::cout << "Testing OpenWatcom C++ library implementation." << std::endl; 83 + watcom::istring HELLO ("HELLO"); 84 + if (HELLO != "hello") { 85 + return 1; 86 + } 87 + if (HELLO.find ("ello") != 1) { 88 + return 2; 89 + } 90 + return 0; 91 + } 92 + EOF 93 + cat test.cpp 94 + # Darwin target not supported, only host 95 + wcl386 -fe=test_cpp test.cpp 96 + ${lib.optionalString (!stdenv.hostPlatform.isDarwin) "./test_cpp"} 97 + touch $out 98 + ''; 99 + cross = runCommand "${name}-test-cross" { nativeBuildInputs = [ wrapped file ]; } '' 100 + cat <<EOF >test.c 101 + #include <stdio.h> 102 + int main() { 103 + printf ("Testing OpenWatcom cross-compilation.\n"); 104 + return 0; 105 + } 106 + EOF 107 + cat test.c 108 + 109 + echo "Test compiling" 110 + wcl386 -bcl=linux -fe=linux test.c 111 + wcl386 -bcl=nt -fe=nt test.c 112 + wcl386 -bcl=dos4g -fe=dos4g test.c 113 + wcl -bcl=windows -fe=windows test.c 114 + wcl -bcl=dos -fe=dos test.c 115 + 116 + echo "Test file format" 117 + file ./linux | grep "32-bit" | grep "Linux" 118 + file ./nt.exe | grep "PE32" | grep "Windows" 119 + file ./dos4g.exe | grep "MS-DOS" | grep "LE executable" 120 + file ./windows.exe | grep "MS-DOS" | grep "Windows 3.x" 121 + file ./dos.exe | grep "MS-DOS" | grep -v "LE" | grep -v "Windows 3.x" 122 + touch $out 123 + ''; 124 + }; 125 + }; 126 + }; 127 + in 128 + lib.makeOverridable wrapper
+5 -1
pkgs/top-level/all-packages.nix
··· 12705 12705 12706 12706 opam-installer = callPackage ../development/tools/ocaml/opam/installer.nix { }; 12707 12707 12708 - open-watcom-bin = callPackage ../development/compilers/open-watcom-bin { }; 12708 + wrapWatcom = callPackage ../development/compilers/open-watcom/wrapper.nix { }; 12709 + open-watcom-v2-unwrapped = callPackage ../development/compilers/open-watcom/v2.nix { }; 12710 + open-watcom-v2 = wrapWatcom open-watcom-v2-unwrapped { }; 12711 + open-watcom-bin-unwrapped = callPackage ../development/compilers/open-watcom/bin.nix { }; 12712 + open-watcom-bin = wrapWatcom open-watcom-bin-unwrapped { }; 12709 12713 12710 12714 passerine = callPackage ../development/compilers/passerine { }; 12711 12715