Skip to content

Commit

Permalink
writers: drop writeC
Browse files Browse the repository at this point in the history
This function is fundamentally broken.
Not even the ncurses example will compile.
The interface needs to be rethought for it to work (i.e. don't
unconditionally include all pc files, set include path and ld path and
rpath).
Since it is unlikely that in the current this has any user, just drop it for now.
  • Loading branch information
Mic92 committed Aug 25, 2021
1 parent ce38fec commit 982f469
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 71 deletions.
45 changes: 0 additions & 45 deletions pkgs/build-support/writers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,51 +99,6 @@ rec {
writeBashBin = name:
writeBash "/bin/${name}";

# writeC writes an executable c package called `name` to `destination` using `libraries`.
#
# Examples:
# writeC "hello-world-ncurses" { libraries = [ pkgs.ncurses ]; } ''
# #include <ncurses.h>
# int main() {
# initscr();
# printw("Hello World !!!");
# refresh(); endwin();
# return 0;
# }
# ''
writeC = name: {
libraries ? [],
strip ? true
}:
makeBinWriter {
compileScript = ''
PATH=${makeBinPath [
pkgs.binutils-unwrapped
pkgs.coreutils
pkgs.findutils
pkgs.gcc
pkgs.pkg-config
]}
export PKG_CONFIG_PATH=${concatMapStringsSep ":" (pkg: "${pkg}/lib/pkgconfig") libraries}
gcc \
${optionalString (libraries != [])
"$(pkg-config --cflags --libs ${
concatMapStringsSep " " (pkg: "$(find ${escapeShellArg pkg}/lib/pkgconfig -name \\*.pc)") libraries
})"
} \
-O \
-o "$out" \
-Wall \
-x c \
"$contentPath"
'';
inherit strip;
} name;

# writeCBin takes the same arguments as writeC but outputs a directory (like writeScriptBin)
writeCBin = name:
writeC "/bin/${name}";

# Like writeScript but the first line is a shebang to dash
#
# Example:
Expand Down
26 changes: 0 additions & 26 deletions pkgs/build-support/writers/test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ let
if [[ "test" == "test" ]]; then echo "success"; fi
'';

c = writeCBin "test-writers-c" { libraries = [ ]; } ''
#include <stdio.h>
int main() {
printf("success\n");
return 0;
}
'';

dash = writeDashBin "test-writers-dash-bin" ''
test '~' = '~' && echo 'success'
'';
Expand Down Expand Up @@ -88,24 +80,6 @@ let
if [[ "test" == "test" ]]; then echo "success"; fi
'';

c = writeC "test-writers-c" { libraries = [ glib.dev ]; } ''
#include <gio/gio.h>
#include <stdio.h>
int main() {
GApplication *application = g_application_new ("hello.world", G_APPLICATION_FLAGS_NONE);
g_application_register (application, NULL, NULL);
GNotification *notification = g_notification_new ("Hello world!");
g_notification_set_body (notification, "This is an example notification.");
GIcon *icon = g_themed_icon_new ("dialog-information");
g_notification_set_icon (notification, icon);
g_object_unref (icon);
g_object_unref (notification);
g_object_unref (application);
printf("success\n");
return 0;
}
'';

dash = writeDash "test-writers-dash" ''
test '~' = '~' && echo 'success'
'';
Expand Down

2 comments on commit 982f469

@sternenseemann
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is unlikely that in the current this has any user, just drop it for now.

That would be me…

@Mic92
Copy link
Member Author

@Mic92 Mic92 commented on 982f469 Aug 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the other writeCBin that is in nixpkgs.

Please sign in to comment.