[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tyndur-devel] [PATCH 1/4] build: Kernel ohne libc bauen



On Fri, Aug 07 22:33, Kevin Wolf wrote:
> + build: Mit -k kann man -nostdinc und -nostdlib aktivieren
> 
> Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
> ---
>  src/modules/c/build/build.c         |   16 ++++++++++++++--
>  src/modules/c/build/include/build.h |    2 ++
>  src/modules/c/build/main.c          |    7 ++++++-
>  3 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/src/modules/c/build/build.c b/src/modules/c/build/build.c
> index ace3260..3319508 100644
> --- a/src/modules/c/build/build.c
> +++ b/src/modules/c/build/build.c
> @@ -54,6 +54,9 @@ static const char* fpcflags = "-n -Cn -CX -Tlost";
>  static const char* nasmflags = "-felf -O99";
>  static const char* gasflags = "-m32 -c";
>  
> +static const char* c_compiler = "gcc";
> +static const char* linker = "gcc";
> +
>  static char* root_path;
>  
>  /**
> @@ -227,7 +230,7 @@ static void do_build(struct build_dir* dir, const char* parent_include,
>      // TODO Pruefen, ob sich Abhaengigkeiten veraendert haben
>      printf("%s: Kompilieren (C)...", dir->path);
>      fflush(stdout);
> -    compile(dir->path, dir->src_files[LANG_C], "gcc", cflags, include);
> +    compile(dir->path, dir->src_files[LANG_C], c_compiler, cflags, include);
>  
>      printf("\r%s: Kompilieren (Pascal)...\033[K", dir->path);
>      fflush(stdout);
> @@ -247,7 +250,11 @@ static void do_build(struct build_dir* dir, const char* parent_include,
>          fflush(stdout);
>  
>          objs = get_obj_files(dir->path);
> -        do_command(".", "gcc", "-o %s/run %s %s", dir->path, lib, objs);
> +        if (!standalone) {
> +            do_command(".", linker, "-o %s/run %s %s", dir->path, lib, objs);
> +        } else {
> +            do_command(".", linker, "-o %s/run --start-group %s %s --end-group", dir->path, lib, objs);
> +        }
>          free(objs);
>      }
>  
> @@ -262,9 +269,14 @@ static void do_build(struct build_dir* dir, const char* parent_include,
>   * Bauen!
>   *
>   * @param root Wurzelverzeichnis des Projekts
> + * @param standalone Wenn != 0, wird die Standardbibliothek nicht benutzt
>   */
>  void build(struct build_dir* root)
>  {
> +    if (standalone) {
> +        c_compiler = "gcc -nostdinc";
> +        linker = "ld";
> +    }
>      root_path = getcwd(NULL, 0);
>      do_build(root, "", "", 0);
>      printf("Fertig gebaut.\n");
> diff --git a/src/modules/c/build/include/build.h b/src/modules/c/build/include/build.h
> index c7ee608..b1d7659 100644
> --- a/src/modules/c/build/include/build.h
> +++ b/src/modules/c/build/include/build.h
> @@ -76,5 +76,7 @@ void build(struct build_dir* root);
>  
>  extern int dry_run;
>  extern int verbose;
> +extern int dont_compile;
Weg damit.

> +extern int standalone;
>  
>  #endif
> diff --git a/src/modules/c/build/main.c b/src/modules/c/build/main.c
> index d531db7..46f196f 100644
> --- a/src/modules/c/build/main.c
> +++ b/src/modules/c/build/main.c
> @@ -72,9 +72,12 @@ int verbose = 0;
>  int dry_run= 0;
>  
>  
> +/// Keine Standardbibliotheken einbinden
> +int standalone = 0;
> +
>  static void usage(char* binary)
>  {
> -    fprintf(stderr, "Aufruf: %s [-v] [--dry-run] [<Wurzelverzeichnis>]\n",
> +    fprintf(stderr, "Aufruf: %s [-k] [-v] [--dry-run] [<Wurzelverzeichnis>]\n",
>          binary);
>      exit(1);
>  }
> @@ -96,6 +99,8 @@ int main(int argc, char** argv)
>              verbose = 1;
>          } else if (!strcmp(argv[i], "--dry-run")) {
>              dry_run = 1;
> +        } else if (!strcmp(argv[i], "-k")) {
> +            standalone = 1;
>          } else if (argv[i][0] == '-') {
>              usage(argv[0]);
>          } else if (rootdir_path) {

Wenn du das noch fixt, dann:
Acked-by: Antoine Kaufmann <toni@xxxxxxxxxx>

-- 
Antoine Kaufmann
<toni@xxxxxxxxxxxxxxxx>

Attachment: pgpp7zJ2wi4qC.pgp
Description: PGP signature