minimal-bootstrap.ln-boot: init at unstable-2023-05-01

This commit is contained in:
Emily Trau 2023-05-01 12:05:30 +10:00
parent 0cbdbdc20d
commit e055a75edd
4 changed files with 64 additions and 14 deletions

View file

@ -15,5 +15,7 @@ lib.makeScope newScope (self: with self; {
nyacc = callPackage ./mes/nyacc.nix { };
mes = callPackage ./mes { };
ln-boot = callPackage ./ln-boot { };
tinycc-with-mes-libc = callPackage ./tinycc/default.nix { };
})

View file

@ -0,0 +1,27 @@
{ lib
, runCommand
, mes
}:
let
pname = "ln-boot";
version = "unstable-2023-05-01";
src = ./ln.c;
in
runCommand "${pname}-${version}" {
inherit pname version;
meta = with lib; {
description = "Basic tool for creating symbolic links";
license = licenses.mit;
maintainers = with maintainers; [ emilytrau ];
mainProgram = "ln";
platforms = platforms.unix;
};
} ''
mkdir -p ''${out}/bin
${mes}/bin/mes --no-auto-compile -e main ${mes}/bin/mescc.scm -- \
-lc+tcc \
-o ''${out}/bin/ln \
${src}
''

View file

@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char** argv)
{
if (argc != 4 || strcmp(argv[1], "-s")) {
fputs("Usage: ", stdout);
fputs(argv[0], stdout);
fputs("ln -s TARGET LINK_NAME\n", stdout);
exit(EXIT_FAILURE);
}
symlink(argv[2], argv[3]);
exit(EXIT_SUCCESS);
}

View file

@ -66,20 +66,24 @@ let
+ "lib/linux/waitpid.c lib/linux/x86-mes-${cc}/syscall.c lib/linux/getpid.c "
+ "lib/linux/kill.c");
libc_tcc_SOURCES = cc: lib.splitString " " (
"lib/ctype/islower.c lib/ctype/isupper.c lib/ctype/tolower.c lib/ctype/toupper.c "
+ "lib/mes/abtod.c lib/mes/dtoab.c lib/mes/search-path.c lib/posix/execvp.c "
+ "lib/stdio/fclose.c lib/stdio/fdopen.c lib/stdio/ferror.c lib/stdio/fflush.c "
+ "lib/stdio/fopen.c lib/stdio/fprintf.c lib/stdio/fread.c lib/stdio/fseek.c "
+ "lib/stdio/ftell.c lib/stdio/fwrite.c lib/stdio/printf.c lib/stdio/remove.c "
+ "lib/stdio/snprintf.c lib/stdio/sprintf.c lib/stdio/sscanf.c lib/stdio/vfprintf.c "
+ "lib/stdio/vprintf.c lib/stdio/vsnprintf.c lib/stdio/vsprintf.c lib/stdio/vsscanf.c "
+ "lib/stdlib/calloc.c lib/stdlib/qsort.c lib/stdlib/strtod.c lib/stdlib/strtof.c "
+ "lib/stdlib/strtol.c lib/stdlib/strtold.c lib/stdlib/strtoll.c lib/stdlib/strtoul.c "
+ "lib/stdlib/strtoull.c lib/string/memmem.c lib/string/strcat.c lib/string/strchr.c "
+ "lib/string/strlwr.c lib/string/strncpy.c lib/string/strrchr.c lib/string/strstr.c "
+ "lib/string/strupr.c lib/stub/sigaction.c lib/stub/ldexp.c lib/stub/mprotect.c "
+ "lib/stub/localtime.c lib/stub/sigemptyset.c lib/x86-mes-${cc}/setjmp.c "
+ "lib/linux/close.c lib/linux/rmdir.c lib/linux/stat.c");
"lib/ctype/islower.c lib/ctype/isupper.c lib/ctype/tolower.c lib/ctype/toupper.c "
+ "lib/mes/abtod.c lib/mes/dtoab.c lib/mes/search-path.c lib/posix/execvp.c "
+ "lib/stdio/fclose.c lib/stdio/fdopen.c lib/stdio/ferror.c lib/stdio/fflush.c "
+ "lib/stdio/fopen.c lib/stdio/fprintf.c lib/stdio/fread.c lib/stdio/fseek.c "
+ "lib/stdio/ftell.c lib/stdio/fwrite.c lib/stdio/printf.c lib/stdio/remove.c "
+ "lib/stdio/snprintf.c lib/stdio/sprintf.c lib/stdio/sscanf.c lib/stdio/vfprintf.c "
+ "lib/stdio/vprintf.c lib/stdio/vsnprintf.c lib/stdio/vsprintf.c lib/stdio/vsscanf.c "
+ "lib/stdlib/calloc.c lib/stdlib/qsort.c lib/stdlib/strtod.c lib/stdlib/strtof.c "
+ "lib/stdlib/strtol.c lib/stdlib/strtold.c lib/stdlib/strtoll.c lib/stdlib/strtoul.c "
+ "lib/stdlib/strtoull.c lib/string/memmem.c lib/string/strcat.c lib/string/strchr.c "
+ "lib/string/strlwr.c lib/string/strncpy.c lib/string/strrchr.c lib/string/strstr.c "
+ "lib/string/strupr.c lib/stub/sigaction.c lib/stub/ldexp.c lib/stub/mprotect.c "
+ "lib/stub/localtime.c lib/stub/sigemptyset.c lib/x86-mes-${cc}/setjmp.c "
+ "lib/linux/close.c lib/linux/rmdir.c lib/linux/stat.c"
) ++ [
# add symlink() to libc+tcc so we can use it in ln-boot
"lib/linux/symlink.c"
];
libc_gnu_SOURCES = cc: libc_tcc_SOURCES cc ++ lib.splitString " " (
"lib/ctype/isalnum.c lib/ctype/isalpha.c lib/ctype/isascii.c lib/ctype/iscntrl.c "
+ "lib/ctype/isgraph.c lib/ctype/isprint.c lib/ctype/ispunct.c lib/dirent/__getdirentries.c "