1 # Arguments that this derivation gets when it is created with `callPackage`
16 archToBindir = with stdenv.hostPlatform; if isx86 then
20 # we don't support running on AXP
21 # don't know what MIPS, PPC bindirs are called
22 else throw "Don't know where ${system} binaries are located!";
24 binDirs = with stdenv.hostPlatform; if isWindows then [
25 (lib.optionalString is64bit "${archToBindir}nt64")
27 (lib.optionalString is32bit "${archToBindir}w")
28 ] else if (isDarwin) then [
29 (lib.optionalString is64bit "${archToBindir}o64")
30 # modern Darwin cannot execute 32-bit code anymore
31 (lib.optionalString is32bit "${archToBindir}o")
33 (lib.optionalString is64bit "${archToBindir}l64")
37 # This works good enough as-is, but should really only be targetPlatform-specific
38 # but we don't support targeting DOS, OS/2, 16-bit Windows etc Nixpkgs-wide so this needs extra logic
39 includeDirs = with stdenv.hostPlatform; [
42 ++ lib.optional isWindows "h/nt"
43 ++ lib.optional isLinux "lh";
44 listToDirs = list: lib.strings.concatMapStringsSep ":" (dir: "${placeholder "out"}/${dir}") list;
45 name = "${open-watcom.passthru.prettyName}-${open-watcom.version}";
50 paths = [ open-watcom ];
52 nativeBuildInputs = [ makeWrapper ];
57 for binDir in ${lib.strings.concatStringsSep " " binDirs}; do
58 for exe in $(find ${open-watcom}/$binDir \
60 ${lib.optionalString stdenv.hostPlatform.isLinux "-not -iname '*.so' -not -iname '*.exe'"} \
62 if [ ! -f $out/bin/$(basename $exe) ]; then
63 makeWrapper $exe $out/bin/$(basename $exe) \
64 --set WATCOM ${open-watcom} \
65 --prefix PATH : ${listToDirs binDirs} \
66 --set EDPATH ${open-watcom}/eddat \
67 --set INCLUDE ${listToDirs includeDirs}
74 unwrapped = open-watcom;
76 wrapped = wrapper { };
78 simple = runCommand "${name}-test-simple" { nativeBuildInputs = [ wrapped ]; } ''
82 printf ("Testing OpenWatcom C89 compiler.\n");
87 wcl386 -fe=test_c test.c
88 # Only test execution if hostPlatform is targetable
89 ${lib.optionalString (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isAarch) "./test_c"}
95 std::cout << "Testing OpenWatcom C++ library implementation." << std::endl;
96 watcom::istring HELLO ("HELLO");
97 if (HELLO != "hello") {
100 if (HELLO.find ("ello") != 1) {
107 wcl386 -fe=test_cpp test.cpp
108 # Only test execution if hostPlatform is targetable
109 ${lib.optionalString (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isAarch) "./test_cpp"}
112 cross = runCommand "${name}-test-cross" { nativeBuildInputs = [ wrapped file ]; } ''
116 printf ("Testing OpenWatcom cross-compilation.\n");
122 echo "Test compiling"
123 wcl386 -bcl=linux -fe=linux test.c
124 wcl386 -bcl=nt -fe=nt test.c
125 wcl386 -bcl=dos4g -fe=dos4g test.c
126 wcl -bcl=windows -fe=windows test.c
127 wcl -bcl=dos -fe=dos test.c
129 echo "Test file format"
130 file ./linux | grep "32-bit" | grep "Linux"
131 file ./nt.exe | grep "PE32" | grep "Windows"
132 file ./dos4g.exe | grep "MS-DOS" | grep "LE executable"
133 file ./windows.exe | grep "MS-DOS" | grep "Windows 3.x"
134 file ./dos.exe | grep "MS-DOS" | grep -v "LE" | grep -v "Windows 3.x"
140 inherit (open-watcom) meta;
143 lib.makeOverridable wrapper