Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
darwin: fix builds
Browse files Browse the repository at this point in the history
  • Loading branch information
vlinkz committed May 14, 2024
1 parent f31f6ac commit b3f031a
Show file tree
Hide file tree
Showing 45 changed files with 1,821 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pkgs/by-name/bi/binutils/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ with pkgs;
inherit (stdenv.targetPlatform) linker;
in
if linker == "lld" then llvmPackages.bintools-unwrapped
# else if linker == "cctools" then darwin.binutils-unwrapped
else if linker == "cctools" then darwin.binutils-unwrapped
else if linker == "bfd" then binutils-unwrapped
else if linker == "gold" then binutils-unwrapped.override { enableGoldDefault = true; }
else null;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/by-name/cm/cmake/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,6 @@ stdenv.mkDerivation (finalAttrs: {
maintainers = with lib.maintainers; [ ttuegel lnl7 AndersonTorres ];
platforms = lib.platforms.all;
mainProgram = "cmake";
broken = (/*qt5UI &&*/ stdenv.isDarwin);
# broken = (qt5UI && stdenv.isDarwin);
};
})
56 changes: 56 additions & 0 deletions pkgs/by-name/cm/cmocka/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{ fetchurl, fetchpatch, lib, stdenv, cmake }:

stdenv.mkDerivation rec {
pname = "cmocka";
majorVersion = "1.1";
version = "${majorVersion}.7";

src = fetchurl {
url = "https://cmocka.org/files/${majorVersion}/cmocka-${version}.tar.xz";
sha256 = "sha256-gQVw6wuNZIBDMfgrKf9Hx5DOnNaxY+mNR6SAcEfsrYI=";
};

patches = [
./uintptr_t.patch
];

nativeBuildInputs = [ cmake ];

cmakeFlags = lib.optional doCheck "-DUNIT_TESTING=ON"
++ lib.optional stdenv.hostPlatform.isStatic "-DBUILD_SHARED_LIBS=OFF";

doCheck = true;

meta = with lib; {
description = "Lightweight library to simplify and generalize unit tests for C";
longDescription = ''
There are a variety of C unit testing frameworks available however
many of them are fairly complex and require the latest compiler
technology. Some development requires the use of old compilers which
makes it difficult to use some unit testing frameworks. In addition
many unit testing frameworks assume the code being tested is an
application or module that is targeted to the same platform that will
ultimately execute the test. Because of this assumption many
frameworks require the inclusion of standard C library headers in the
code module being tested which may collide with the custom or
incomplete implementation of the C library utilized by the code under
test.
Cmocka only requires a test application is linked with the standard C
library which minimizes conflicts with standard C library headers.
Also, CMocka tries to avoid the use of some of the newer features of
C compilers.
This results in CMocka being a relatively small library that can be
used to test a variety of exotic code. If a developer wishes to
simply test an application with the latest compiler then other unit
testing frameworks may be preferable.
This is the successor of Google's Cmockery.
'';
homepage = "https://cmocka.org/";
license = licenses.asl20;
platforms = platforms.all;
maintainers = with maintainers; [ kragniz rasendubi ];
};
}
16 changes: 16 additions & 0 deletions pkgs/by-name/cm/cmocka/uintptr_t.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Resolve messy situation with uintptr_t and stdint.h

Platforms common in nixpkgs will have stdint.h - thereby we avoid problems
that seem complicated to avoid. References:
https://gitlab.com/cmocka/cmocka/-/issues/38#note_1286565655
https://git.alpinelinux.org/aports/plain/main/cmocka/musl_uintptr.patch?id=6a15dd0d0ba9cc354a621fb359ca5e315ff2eabd

It isn't easy, as 1.1.6 codebase is missing stdint.h includes on many places,
and HAVE_UINTPTR_T from cmake also wouldn't get on all places it needs to.
--- a/include/cmocka.h
+++ b/include/cmocka.h
@@ -18,2 +18,4 @@
#define CMOCKA_H_
+#include <stdint.h>
+#define HAVE_UINTPTR_T 1

44 changes: 44 additions & 0 deletions pkgs/by-name/ct/ctags/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{ lib, stdenv, fetchsvn, autoreconfHook }:

stdenv.mkDerivation rec {
pname = "ctags";
version = "816";

src = fetchsvn {
url = "https://svn.code.sf.net/p/ctags/code/trunk";
rev = version;
sha256 = "0jmbkrmscbl64j71qffcc39x005jrmphx8kirs1g2ws44wil39hf";
};

nativeBuildInputs = [ autoreconfHook ];

# don't use $T(E)MP which is set to the build directory
configureFlags= [ "--enable-tmpdir=/tmp" ];

patches = [
# Library defines an `__unused__` which is a reserved name, and may
# conflict with the standard library definition. One such conflict is with
# macOS headers.
./unused-collision.patch
];

meta = with lib; {
description = "A tool for fast source code browsing (exuberant ctags)";
mainProgram = "ctags";
longDescription = ''
Ctags generates an index (or tag) file of language objects found
in source files that allows these items to be quickly and easily
located by a text editor or other utility. A tag signifies a
language object for which an index entry is available (or,
alternatively, the index entry created for that object). Many
programming languages are supported.
'';
homepage = "https://ctags.sourceforge.net/";
license = licenses.gpl2Plus;
platforms = platforms.unix;

# So that Exuberant ctags is preferred over emacs's ctags
priority = 1;
};

}
246 changes: 246 additions & 0 deletions pkgs/by-name/ct/ctags/unused-collision.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
--- a/c.c (revision 816)
+++ b/c.c (working copy)
@@ -619,7 +619,7 @@
return name;
}

-static void __unused__ pt (tokenInfo *const token)
+static void UNUSED pt (tokenInfo *const token)
{
if (isType (token, TOKEN_NAME))
printf ("type: %-12s: %-13s line: %lu\n",
@@ -634,7 +634,7 @@
tokenString (token->type), token->lineNumber);
}

-static void __unused__ ps (statementInfo *const st)
+static void UNUSED ps (statementInfo *const st)
{
unsigned int i;
printf ("scope: %s decl: %s gotName: %s gotParenName: %s\n",
--- a/eiffel.c (revision 816)
+++ b/eiffel.c (working copy)
@@ -807,7 +807,7 @@

static boolean parseType (tokenInfo *const token);

-static void parseGeneric (tokenInfo *const token, boolean declaration __unused__)
+static void parseGeneric (tokenInfo *const token, boolean declaration UNUSED)
{
unsigned int depth = 0;
#ifdef TYPE_REFERENCE_TOOL
--- a/general.h (revision 816)
+++ b/general.h (working copy)
@@ -57,10 +57,10 @@
* to prevent warnings about unused variables.
*/
#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !defined (__GNUG__)
-# define __unused__ __attribute__((unused))
+# define UNUSED __attribute__((unused))
# define __printf__(s,f) __attribute__((format (printf, s, f)))
#else
-# define __unused__
+# define UNUSED
# define __printf__(s,f)
#endif

--- a/lregex.c (revision 816)
+++ b/lregex.c (working copy)
@@ -538,11 +538,11 @@
#endif /* HAVE_REGEX */

extern void addTagRegex (
- const langType language __unused__,
- const char* const regex __unused__,
- const char* const name __unused__,
- const char* const kinds __unused__,
- const char* const flags __unused__)
+ const langType language UNUSED,
+ const char* const regex UNUSED,
+ const char* const name UNUSED,
+ const char* const kinds UNUSED,
+ const char* const flags UNUSED)
{
#ifdef HAVE_REGEX
Assert (regex != NULL);
@@ -564,10 +564,10 @@
}

extern void addCallbackRegex (
- const langType language __unused__,
- const char* const regex __unused__,
- const char* const flags __unused__,
- const regexCallback callback __unused__)
+ const langType language UNUSED,
+ const char* const regex UNUSED,
+ const char* const flags UNUSED,
+ const regexCallback callback UNUSED)
{
#ifdef HAVE_REGEX
Assert (regex != NULL);
@@ -581,7 +581,7 @@
}

extern void addLanguageRegex (
- const langType language __unused__, const char* const regex __unused__)
+ const langType language UNUSED, const char* const regex UNUSED)
{
#ifdef HAVE_REGEX
if (! regexBroken)
@@ -602,7 +602,7 @@
*/

extern boolean processRegexOption (const char *const option,
- const char *const parameter __unused__)
+ const char *const parameter UNUSED)
{
boolean handled = FALSE;
const char* const dash = strchr (option, '-');
@@ -624,7 +624,7 @@
return handled;
}

-extern void disableRegexKinds (const langType language __unused__)
+extern void disableRegexKinds (const langType language UNUSED)
{
#ifdef HAVE_REGEX
if (language <= SetUpper && Sets [language].count > 0)
@@ -639,8 +639,8 @@
}

extern boolean enableRegexKind (
- const langType language __unused__,
- const int kind __unused__, const boolean mode __unused__)
+ const langType language UNUSED,
+ const int kind UNUSED, const boolean mode UNUSED)
{
boolean result = FALSE;
#ifdef HAVE_REGEX
@@ -660,7 +660,7 @@
return result;
}

-extern void printRegexKinds (const langType language __unused__, boolean indent __unused__)
+extern void printRegexKinds (const langType language UNUSED, boolean indent UNUSED)
{
#ifdef HAVE_REGEX
if (language <= SetUpper && Sets [language].count > 0)
--- a/lua.c (revision 816)
+++ b/lua.c (working copy)
@@ -37,7 +37,7 @@
*/

/* for debugging purposes */
-static void __unused__ print_string (char *p, char *q)
+static void UNUSED print_string (char *p, char *q)
{
for ( ; p != q; p++)
fprintf (errout, "%c", *p);
--- a/main.c (revision 816)
+++ b/main.c (working copy)
@@ -522,7 +522,7 @@
* Start up code
*/

-extern int main (int __unused__ argc, char **argv)
+extern int main (int UNUSED argc, char **argv)
{
cookedArgs *args;
#ifdef VMS
--- a/options.c (revision 816)
+++ b/options.c (working copy)
@@ -730,7 +730,7 @@
}

static void processExcludeOption (
- const char *const option __unused__, const char *const parameter)
+ const char *const option UNUSED, const char *const parameter)
{
const char *const fileName = parameter + 1;
if (parameter [0] == '\0')
@@ -867,7 +867,7 @@
}

static void processFilterTerminatorOption (
- const char *const option __unused__, const char *const parameter)
+ const char *const option UNUSED, const char *const parameter)
{
freeString (&Option.filterTerminator);
Option.filterTerminator = stringCopy (parameter);
@@ -930,8 +930,8 @@
}

static void processHelpOption (
- const char *const option __unused__,
- const char *const parameter __unused__)
+ const char *const option UNUSED,
+ const char *const parameter UNUSED)
{
printProgramIdentification ();
putchar ('\n');
@@ -1139,8 +1139,8 @@
}

static void processLicenseOption (
- const char *const option __unused__,
- const char *const parameter __unused__)
+ const char *const option UNUSED,
+ const char *const parameter UNUSED)
{
printProgramIdentification ();
puts ("");
@@ -1166,8 +1166,8 @@
}

static void processListMapsOption (
- const char *const __unused__ option,
- const char *const __unused__ parameter)
+ const char *const UNUSED option,
+ const char *const UNUSED parameter)
{
if (parameter [0] == '\0' || strcasecmp (parameter, "all") == 0)
printLanguageMaps (LANG_AUTO);
@@ -1183,8 +1183,8 @@
}

static void processListLanguagesOption (
- const char *const option __unused__,
- const char *const parameter __unused__)
+ const char *const option UNUSED,
+ const char *const parameter UNUSED)
{
printLanguageList ();
exit (0);
@@ -1358,8 +1358,8 @@
}

static void processVersionOption (
- const char *const option __unused__,
- const char *const parameter __unused__)
+ const char *const option UNUSED,
+ const char *const parameter UNUSED)
{
printProgramIdentification ();
exit (0);
--- a/parse.c (revision 816)
+++ b/parse.c (working copy)
@@ -376,7 +376,7 @@
*/

extern void processLanguageDefineOption (
- const char *const option, const char *const parameter __unused__)
+ const char *const option, const char *const parameter UNUSED)
{
#ifdef HAVE_REGEX
if (parameter [0] == '\0')
--- a/routines.c (revision 816)
+++ b/routines.c (working copy)
@@ -526,7 +526,7 @@

#if ! defined (HAVE_STAT_ST_INO)

-static void canonicalizePath (char *const path __unused__)
+static void canonicalizePath (char *const path UNUSED)
{
#if defined (MSDOS_STYLE_PATH)
char *p;
Loading

0 comments on commit b3f031a

Please sign in to comment.