1 # Arguments that this derivation gets when it is created with `callPackage`
18 with stdenv.hostPlatform;
23 # we don't support running on AXP
24 # don't know what MIPS, PPC bindirs are called
26 throw "Don't know where ${system} binaries are located!";
29 with stdenv.hostPlatform;
32 (lib.optionalString is64bit "${archToBindir}nt64")
34 (lib.optionalString is32bit "${archToBindir}w")
36 else if (isDarwin) then
38 (lib.optionalString is64bit "${archToBindir}o64")
39 # modern Darwin cannot execute 32-bit code anymore
40 (lib.optionalString is32bit "${archToBindir}o")
44 (lib.optionalString is64bit "${archToBindir}l64")
48 # This works good enough as-is, but should really only be targetPlatform-specific
49 # but we don't support targeting DOS, OS/2, 16-bit Windows etc Nixpkgs-wide so this needs extra logic
51 with stdenv.hostPlatform;
55 ++ lib.optional isWindows "h/nt"
56 ++ lib.optional isLinux "lh";
57 listToDirs = list: lib.strings.concatMapStringsSep ":" (dir: "${placeholder "out"}/${dir}") list;
58 name = "${open-watcom.passthru.prettyName}-${open-watcom.version}";
63 paths = [ open-watcom ];
65 nativeBuildInputs = [ makeWrapper ];
70 for binDir in ${lib.strings.concatStringsSep " " binDirs}; do
71 for exe in $(find ${open-watcom}/$binDir \
73 ${lib.optionalString stdenv.hostPlatform.isLinux "-not -iname '*.so' -not -iname '*.exe'"} \
75 if [ ! -f $out/bin/$(basename $exe) ]; then
76 makeWrapper $exe $out/bin/$(basename $exe) \
77 --set WATCOM ${open-watcom} \
78 --prefix PATH : ${listToDirs binDirs} \
79 --set EDPATH ${open-watcom}/eddat \
80 --set INCLUDE ${listToDirs includeDirs}
87 unwrapped = open-watcom;
90 wrapped = wrapper { };
93 simple = runCommand "${name}-test-simple" { nativeBuildInputs = [ wrapped ]; } ''
97 printf ("Testing OpenWatcom C89 compiler.\n");
102 wcl386 -fe=test_c test.c
103 # Only test execution if hostPlatform is targetable
104 ${lib.optionalString (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isAarch) "./test_c"}
110 std::cout << "Testing OpenWatcom C++ library implementation." << std::endl;
111 watcom::istring HELLO ("HELLO");
112 if (HELLO != "hello") {
115 if (HELLO.find ("ello") != 1) {
122 wcl386 -fe=test_cpp test.cpp
123 # Only test execution if hostPlatform is targetable
124 ${lib.optionalString (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isAarch) "./test_cpp"}
128 runCommand "${name}-test-cross"
130 nativeBuildInputs = [
139 printf ("Testing OpenWatcom cross-compilation.\n");
145 echo "Test compiling"
146 wcl386 -bcl=linux -fe=linux test.c
147 wcl386 -bcl=nt -fe=nt test.c
148 wcl386 -bcl=dos4g -fe=dos4g test.c
149 wcl -bcl=windows -fe=windows test.c
150 wcl -bcl=dos -fe=dos test.c
152 echo "Test file format"
153 file ./linux | grep "32-bit" | grep "Linux"
154 file ./nt.exe | grep "PE32" | grep "Windows"
155 file ./dos4g.exe | grep "MS-DOS" | grep "LE executable"
156 file ./windows.exe | grep "MS-DOS" | grep "Windows 3.x"
157 file ./dos.exe | grep "MS-DOS" | grep -v "LE" | grep -v "Windows 3.x"
163 inherit (open-watcom) meta;
166 lib.makeOverridable wrapper