dotgnu-pnet-commits
[Top][All Lists]
Advanced

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

[Dotgnu-pnet-commits] pnet/csant csant.c, 1.10, 1.11 csant_build.c, 1.7,


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] pnet/csant csant.c, 1.10, 1.11 csant_build.c, 1.7, 1.8 csant_cscc.c, 1.21, 1.22 csant_defs.h, 1.9, 1.10 csant_task.c, 1.9, 1.10
Date: Tue, 11 Nov 2003 04:46:05 +0000

Update of /cvsroot/dotgnu-pnet/pnet/csant
In directory subversions:/tmp/cvs-serv30416/csant

Modified Files:
        csant.c csant_build.c csant_cscc.c csant_defs.h csant_task.c 
Log Message:


Add the <resgen> and <reslink> tags to csant; add --install and
--uninstall options to csant.


Index: csant.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csant/csant.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** csant.c     27 Feb 2003 21:41:51 -0000      1.10
--- csant.c     11 Nov 2003 04:46:03 -0000      1.11
***************
*** 2,6 ****
   * csant.c - Build tool for C# program compilation.
   *
!  * Copyright (C) 2001, 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 2,6 ----
   * csant.c - Build tool for C# program compilation.
   *
!  * Copyright (C) 2001, 2002, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 95,98 ****
--- 95,106 ----
                "--mono-corlib          or -m",
                "Use Mono's corlib instead of mscorlib during C# compiles."},
+       {"-i", 'i', 0, 0, 0},
+       {"--install", 'i', 0,
+               "--install              or -i",
+               "Install assemblies with `ilgac' instead of compiling."},
+       {"-u", 'u', 0, 0, 0},
+       {"--uninstall", 'u', 0,
+               "--uninstall            or -u",
+               "Uninstall assemblies with `ilgac' instead of compiling."},
        {"--quiet", 's', 0, 0, 0},
        {"-C", 'C', 1, 0, 0},
***************
*** 211,214 ****
--- 219,234 ----
                        break;
  
+                       case 'i':
+                       {
+                               CSAntInstallMode = 1;
+                       }
+                       break;
+ 
+                       case 'u':
+                       {
+                               CSAntUninstallMode = 1;
+                       }
+                       break;
+ 
                        case 'C':
                        {
***************
*** 336,340 ****
  {
        fprintf(stdout, "CSANT " VERSION " - C# compilation build tool\n");
!       fprintf(stdout, "Copyright (c) 2001 Southern Storm Software, Pty 
Ltd.\n");
        fprintf(stdout, "\n");
        fprintf(stdout, "Usage: %s [options] [target ...]\n", progname);
--- 356,360 ----
  {
        fprintf(stdout, "CSANT " VERSION " - C# compilation build tool\n");
!       fprintf(stdout, "Copyright (c) 2001, 2002, 2003 Southern Storm 
Software, Pty Ltd.\n");
        fprintf(stdout, "\n");
        fprintf(stdout, "Usage: %s [options] [target ...]\n", progname);
***************
*** 347,351 ****
  
        printf("CSANT " VERSION " - C# compilation build tool\n");
!       printf("Copyright (c) 2001 Southern Storm Software, Pty Ltd.\n");
        printf("\n");
        printf("CSANT comes with ABSOLUTELY NO WARRANTY.  This is free 
software,\n");
--- 367,371 ----
  
        printf("CSANT " VERSION " - C# compilation build tool\n");
!       printf("Copyright (c) 2001, 2002, 2003 Southern Storm Software, Pty 
Ltd.\n");
        printf("\n");
        printf("CSANT comes with ABSOLUTELY NO WARRANTY.  This is free 
software,\n");

Index: csant_task.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csant/csant_task.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** csant_task.c        27 Feb 2003 07:27:27 -0000      1.9
--- csant_task.c        11 Nov 2003 04:46:03 -0000      1.10
***************
*** 2,6 ****
   * csant_task.c - Dispatch functions for csant task elements.
   *
!  * Copyright (C) 2001, 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 2,6 ----
   * csant_task.c - Dispatch functions for csant task elements.
   *
!  * Copyright (C) 2001, 2002, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 291,294 ****
--- 291,302 ----
                argv[argc++] = "-m";
        }
+       if(CSAntInstallMode)
+       {
+               argv[argc++] = "-i";
+       }
+       if(CSAntUninstallMode)
+       {
+               argv[argc++] = "-u";
+       }
        argv[argc++] = "-C";
        argv[argc++] = (char *)compiler;
***************
*** 323,339 ****
  
  CSAntTaskInfo const CSAntTasks[] = {
!       {"compile",                     CSAntTask_Compile},
!       {"cscc",                        CSAntTask_Cscc},
!       {"csc",                         CSAntTask_Csc},
!       {"mcs",                         CSAntTask_Mcs},
!       {"csdoc",                       CSAntTask_Csdoc},
!       {"property",            Task_Property},
!       {"echo",                        Task_Echo},
!       {"fail",                        Task_Fail},
!       {"delete",                      Task_Delete},
!       {"mkdir",                       Task_Mkdir},
!       {"copy",                        Task_Copy},
!       {"csant",                       Task_CSAnt},
!       {"nant",                        Task_CSAnt},
  };
  int const CSAntNumTasks = (sizeof(CSAntTasks) / sizeof(CSAntTaskInfo));
--- 331,349 ----
  
  CSAntTaskInfo const CSAntTasks[] = {
!       {"compile",                     1, CSAntTask_Compile},
!       {"cscc",                        1, CSAntTask_Cscc},
!       {"csc",                         1, CSAntTask_Csc},
!       {"mcs",                         1, CSAntTask_Mcs},
!       {"csdoc",                       0, CSAntTask_Csdoc},
!       {"resgen",                      0, CSAntTask_ResGen},
!       {"reslink",                     1, CSAntTask_ResLink},
!       {"property",            1, Task_Property},
!       {"echo",                        0, Task_Echo},
!       {"fail",                        0, Task_Fail},
!       {"delete",                      0, Task_Delete},
!       {"mkdir",                       0, Task_Mkdir},
!       {"copy",                        0, Task_Copy},
!       {"csant",                       1, Task_CSAnt},
!       {"nant",                        1, Task_CSAnt},
  };
  int const CSAntNumTasks = (sizeof(CSAntTasks) / sizeof(CSAntTaskInfo));

Index: csant_build.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csant/csant_build.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** csant_build.c       27 Feb 2003 07:27:27 -0000      1.7
--- csant_build.c       11 Nov 2003 04:46:03 -0000      1.8
***************
*** 2,6 ****
   * csant_build.c - Build all targets.
   *
!  * Copyright (C) 2001, 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 2,6 ----
   * csant_build.c - Build all targets.
   *
!  * Copyright (C) 2001, 2002, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 25,35 ****
  #endif
  
! int   CSAntJustPrint   = 0;
! int   CSAntKeepGoing   = 0;
! int   CSAntSilent      = 0;
! int   CSAntRedirectCsc = 0;
! int   CSAntDummyDoc    = 0;
! int   CSAntForceCorLib = 0;
! char *CSAntCompiler    = 0;
  
  /*
--- 25,38 ----
  #endif
  
! int   CSAntJustPrint     = 0;
! int   CSAntKeepGoing     = 0;
! int   CSAntSilent        = 0;
! int   CSAntRedirectCsc   = 0;
! int   CSAntDummyDoc      = 0;
! int   CSAntForceCorLib   = 0;
! int   CSAntInstallMode   = 0;
! int   CSAntUninstallMode = 0;
! char *CSAntCompiler      = 0;
! char *CSAntCacheDir      = 0;
  
  /*
***************
*** 135,139 ****
                if(!strcmp(CSAntTasks[posn].name, task->name))
                {
!                       return (*(CSAntTasks[posn].func))(task);
                }
        }
--- 138,153 ----
                if(!strcmp(CSAntTasks[posn].name, task->name))
                {
!                       /* Validate that the task can be executed in the
!                          install/uninstall modes of csant */
!                       if((!CSAntInstallMode && !CSAntInstallMode) ||
!                          CSAntTasks[posn].installMode)
!                       {
!                               return (*(CSAntTasks[posn].func))(task);
!                       }
!                       else
!                       {
!                               /* Ignore non-installable tasks in 
install/uninstall mode */
!                               return 1;
!                       }
                }
        }

Index: csant_defs.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csant/csant_defs.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** csant_defs.h        9 Nov 2003 21:29:01 -0000       1.9
--- csant_defs.h        11 Nov 2003 04:46:03 -0000      1.10
***************
*** 2,6 ****
   * csant_defs.h - Internal definitions for "csant".
   *
!  * Copyright (C) 2001, 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 2,6 ----
   * csant_defs.h - Internal definitions for "csant".
   *
!  * Copyright (C) 2001, 2002, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 42,45 ****
--- 42,47 ----
  extern int   CSAntDummyDoc;
  extern int   CSAntForceCorLib;
+ extern int   CSAntInstallMode;
+ extern int   CSAntUninstallMode;
  extern char *CSAntCompiler;
  extern char *CSAntBaseSrcDir;
***************
*** 47,50 ****
--- 49,53 ----
  extern char *CSAntProjectName;
  extern char *CSAntDefaultTarget;
+ extern char *CSAntCacheDir;
  
  /*
***************
*** 101,104 ****
--- 104,108 ----
  {
        const char     *name;
+       int                             installMode;
        CSAntTaskFunc   func;
  
***************
*** 186,189 ****
--- 190,203 ----
   */
  int CSAntTask_Csdoc(CSAntTask *task);
+ 
+ /*
+  * Handle a "resgen" task, which invokes the resource converter.
+  */
+ int CSAntTask_ResGen(CSAntTask *task);
+ 
+ /*
+  * Handle a "reslink" task, which links resources into a standalone assembly.
+  */
+ int CSAntTask_ResLink(CSAntTask *task);
  
  #ifdef        __cplusplus

Index: csant_cscc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csant/csant_cscc.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** csant_cscc.c        9 Nov 2003 21:29:01 -0000       1.21
--- csant_cscc.c        11 Nov 2003 04:46:03 -0000      1.22
***************
*** 2,6 ****
   * csant_cscc.c - Task dispatch for launching C# compilers.
   *
!  * Copyright (C) 2001, 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 2,6 ----
   * csant_cscc.c - Task dispatch for launching C# compilers.
   *
!  * Copyright (C) 2001, 2002, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 27,88 ****
  
  /*
!  * Find the pathname for "cscc".
!  */
! static char *FindPNetPath(void)
! {
!       const char *value;
! 
!       /* Check for the "cscc" property */
!       value = CSAntGetProperty("cscc", -1);
!       if(value)
!       {
!               return (char *)value;
!       }
! 
!       /* Check for the "CSCC" environment variable */
!       value = CSAntGetProperty("csant.env.CSCC", -1);
!       if(value)
!       {
!               return (char *)value;
!       }
! 
!       /* Assume that it is "cscc" somewhere on the path */
!       return "cscc";
! }
! 
! /*
!  * Find the pathname for "csc".
!  */
! static char *FindMSPath(void)
! {
!       const char *value;
! 
!       /* Check for the "csc" property */
!       value = CSAntGetProperty("csc", -1);
!       if(value)
!       {
!               return (char *)value;
!       }
! 
!       /* Check for the "CSC" environment variable */
!       value = CSAntGetProperty("csant.env.CSC", -1);
!       if(value)
!       {
!               return (char *)value;
!       }
! 
!       /* Assume that it is "csc" somewhere on the path */
!       return "csc";
! }
! 
! /*
!  * Find the pathname for "mcs".
   */
! static char *FindMonoPath(void)
  {
        const char *value;
  
!       /* Check for the "mcs" property */
!       value = CSAntGetProperty("mcs", -1);
        if(value)
        {
--- 27,38 ----
  
  /*
!  * Find the pathname for a particular program.
   */
! static char *FindProgramPath(const char *name, const char *env)
  {
        const char *value;
  
!       /* Check for the "name" property */
!       value = CSAntGetProperty(name, -1);
        if(value)
        {
***************
*** 90,95 ****
        }
  
!       /* Check for the "MCS" environment variable */
!       value = CSAntGetProperty("csant.env.MCS", -1);
        if(value)
        {
--- 40,45 ----
        }
  
!       /* Check for the "env" environment variable */
!       value = CSAntGetProperty(env, -1);
        if(value)
        {
***************
*** 97,127 ****
        }
  
!       /* Assume that it is "mcs" somewhere on the path */
!       return "mcs";
  }
  
  /*
!  * Find the pathname for "csdoc".
   */
! static char *FindCsdocPath(void)
  {
!       const char *value;
! 
!       /* Check for the "csdoc" property */
!       value = CSAntGetProperty("csdoc", -1);
!       if(value)
!       {
!               return (char *)value;
!       }
! 
!       /* Check for the "CSDOC" environment variable */
!       value = CSAntGetProperty("csant.env.CSDOC", -1);
!       if(value)
!       {
!               return (char *)value;
!       }
! 
!       /* Assume that it is "csdoc" somewhere on the path */
!       return "csdoc";
  }
  
--- 47,60 ----
        }
  
!       /* Assume that it is "name" somewhere on the path */
!       return (char *)name;
  }
  
  /*
!  * Find the pathname for "cscc".
   */
! static char *FindCsccPath(void)
  {
!       return FindProgramPath("cscc", "csant.env.CSCC");
  }
  
***************
*** 276,279 ****
--- 209,213 ----
        char               *output;
        const char         *target;
+       const char         *version;
        int                             debug;
        int                             checked;
***************
*** 284,287 ****
--- 218,223 ----
        int                             warnAsError;
        int                             saneWarnings;
+       int                             install;
+       int                             installAsDefault;
        CSAntFileSet   *sources;
        CSAntFileSet   *references;
***************
*** 327,330 ****
--- 263,267 ----
        args->output = (char *)CSAntTaskParam(task, "output");
        args->target = CSAntTaskParam(task, "target");
+       args->version = CSAntTaskParam(task, "version");
        args->debug = COMP_FLAG_NOT_SET;
        args->checked = COMP_FLAG_NOT_SET;
***************
*** 335,338 ****
--- 272,277 ----
        args->warnAsError = COMP_FLAG_NOT_SET;
        args->saneWarnings = COMP_FLAG_NOT_SET;
+       args->install = COMP_FLAG_NOT_SET;
+       args->installAsDefault = COMP_FLAG_TRUE;
        args->sources = CSAntFileSetLoad(task, "sources", CSAntBaseSrcDir);
        args->references = CSAntFileSetLoad(task, "references", 
CSAntBaseBuildDir);
***************
*** 414,417 ****
--- 353,366 ----
                args->saneWarnings = !ILStrICmp(value, "true");
        }
+       value = CSAntTaskParam(task, "install");
+       if(value)
+       {
+               args->install = !ILStrICmp(value, "true");
+       }
+       value = CSAntTaskParam(task, "installasdefault");
+       if(value)
+       {
+               args->installAsDefault = !ILStrICmp(value, "true");
+       }
  
        /* Get the list of symbol definitions */
***************
*** 553,557 ****
  
        /* Add the program name */
!       AddArg(&argv, &argc, FindPNetPath());
  
        /* Add the explicitly-specified locations of "cscc-cs" and "cscc-c" */
--- 502,506 ----
  
        /* Add the program name */
!       AddArg(&argv, &argc, FindCsccPath());
  
        /* Add the explicitly-specified locations of "cscc-cs" and "cscc-c" */
***************
*** 639,642 ****
--- 588,598 ----
        }
  
+       /* Add the assembly version information */
+       if(args->version)
+       {
+               AddValueArg(&argv, &argc, "-fassembly-version",
+                                       (char *)(args->version));
+       }
+ 
        /* Add any extra arguments that were supplied */
        for(posn = 0; posn < args->numArgs; ++posn)
***************
*** 728,732 ****
  
        /* Add the program name and fixed options */
!       AddArg(&argv, &argc, FindMSPath());
        AddArg(&argv, &argc, "/nologo");
  
--- 684,688 ----
  
        /* Add the program name and fixed options */
!       AddArg(&argv, &argc, FindProgramPath("csc", "csant.env.CSC"));
        AddArg(&argv, &argc, "/nologo");
  
***************
*** 896,900 ****
  
        /* Add the program name */
!       AddArg(&argv, &argc, FindMonoPath());
  
        /* Set the target and output file */
--- 852,856 ----
  
        /* Add the program name */
!       AddArg(&argv, &argc, FindProgramPath("mcs", "csant.env.MCS"));
  
        /* Set the target and output file */
***************
*** 992,995 ****
--- 948,1062 ----
  
  /*
+  * Print and execute a command line.
+  */
+ static int PrintAndExecute(char **argv)
+ {
+       /* Print the command to be executed */
+       if(!CSAntSilent)
+       {
+               int argc = 0;
+               while(argv[argc] != 0)
+               {
+                       fputs(argv[argc], stdout);
+                       ++argc;
+                       if(argv[argc] != 0)
+                       {
+                               putc(' ', stdout);
+                       }
+               }
+               putc('\n', stdout);
+       }
+ 
+       /* Execute the command */
+       if(!CSAntJustPrint)
+       {
+               return (ILSpawnProcess(argv) == 0);
+       }
+       else
+       {
+               return 1;
+       }
+ }
+ 
+ /*
+  * Build a command-line to install an assembly.
+  */
+ static char **BuildInstallLine(const char *output, const char *subdir,
+                                                          int installAsDefault)
+ {
+       char **argv = 0;
+       int argc = 0;
+ 
+       /* Add the name of the "ilgac" program */
+       AddArg(&argv, &argc, FindProgramPath("ilgac", "csant.env.ILGAC"));
+ 
+       /* Add the command-line options */
+       AddArg(&argv, &argc, "--silent");
+       AddArg(&argv, &argc, "--install");
+       AddArg(&argv, &argc, "--force");
+       if(installAsDefault)
+       {
+               AddArg(&argv, &argc, "--default");
+       }
+       if(subdir)
+       {
+               AddArg(&argv, &argc, "--subdir");
+               AddArg(&argv, &argc, (char *)subdir);
+       }
+       if(CSAntCacheDir)
+       {
+               AddArg(&argv, &argc, "--cache");
+               AddArg(&argv, &argc, (char *)CSAntCacheDir);
+       }
+ 
+       /* Add the name of the assembly to install */
+       AddArg(&argv, &argc, (char *)output);
+ 
+       /* Terminate the command-line */
+       AddArg(&argv, &argc, 0);
+       return argv;
+ }
+ 
+ /*
+  * Build a command-line to uninstall an assembly.
+  */
+ static char **BuildUninstallLine(const char *output, const char *version,
+                                                                const char 
*subdir)
+ {
+       char **argv = 0;
+       int argc = 0;
+ 
+       /* Add the name of the "ilgac" program */
+       AddArg(&argv, &argc, FindProgramPath("ilgac", "csant.env.ILGAC"));
+ 
+       /* Add the command-line options */
+       AddArg(&argv, &argc, "--silent");
+       AddArg(&argv, &argc, "--uninstall");
+       if(subdir)
+       {
+               AddArg(&argv, &argc, "--subdir");
+               AddArg(&argv, &argc, (char *)subdir);
+       }
+       if(CSAntCacheDir)
+       {
+               AddArg(&argv, &argc, "--cache");
+               AddArg(&argv, &argc, (char *)CSAntCacheDir);
+       }
+ 
+       /* Add the name of the assembly to uninstall */
+       AddArg(&argv, &argc, (char *)output);
+ 
+       /* Add the version number for the assembly */
+       if(version)
+       {
+               AddArg(&argv, &argc, (char *)version);
+       }
+ 
+       /* Terminate the command-line */
+       AddArg(&argv, &argc, 0);
+       return argv;
+ }
+ 
+ /*
   * Build a command-line and execute it.
   */
***************
*** 998,1002 ****
  {
        char **argv;
-       int argc;
        int result;
  
--- 1065,1068 ----
***************
*** 1011,1042 ****
  
        /* Build the command-line using the supplied function */
!       argv = (*func)(args);
! 
!       /* Print the command to be executed */
!       if(!CSAntSilent)
        {
!               argc = 0;
!               while(argv[argc] != 0)
                {
!                       fputs(argv[argc], stdout);
!                       ++argc;
!                       if(argv[argc] != 0)
!                       {
!                               putc(' ', stdout);
!                       }
                }
!               putc('\n', stdout);
        }
! 
!       /* Execute the command */
!       if(!CSAntJustPrint)
        {
!               result = (ILSpawnProcess(argv) == 0);
        }
        else
        {
!               result = 1;
        }
  
        /* Clean up and exit */
        ILFree(argv);
--- 1077,1106 ----
  
        /* Build the command-line using the supplied function */
!       if(CSAntInstallMode)
        {
!               if(args->install != COMP_FLAG_TRUE)
                {
!                       /* Ignore targets that are not marked for installation 
*/
!                       return 1;
                }
!               argv = BuildInstallLine(args->output, 0, 
(args->installAsDefault > 0));
        }
!       else if(CSAntUninstallMode)
        {
!               if(args->install != COMP_FLAG_TRUE)
!               {
!                       /* Ignore targets that are not marked for installation 
*/
!                       return 1;
!               }
!               argv = BuildUninstallLine(args->output, args->version, 0);
        }
        else
        {
!               argv = (*func)(args);
        }
  
+       /* Print and execute the command */
+       result = PrintAndExecute(argv);
+ 
        /* Clean up and exit */
        ILFree(argv);
***************
*** 1228,1232 ****
  
        /* Add the program name */
!       AddArg(&argv, &argc, FindCsdocPath());
  
        /* Set the output file */
--- 1292,1296 ----
  
        /* Add the program name */
!       AddArg(&argv, &argc, FindProgramPath("csdoc", "csant.env.CSDOC"));
  
        /* Set the output file */
***************
*** 1288,1322 ****
        AddArg(&argv, &argc, (char *)0);
  
!       /* Print the command to be executed */
!       if(!CSAntSilent)
        {
!               argc = 0;
!               while(argv[argc] != 0)
                {
!                       fputs(argv[argc], stdout);
!                       ++argc;
!                       if(argv[argc] != 0)
!                       {
!                               putc(' ', stdout);
!                       }
                }
!               putc('\n', stdout);
        }
  
!       /* Execute the command */
!       if(!CSAntJustPrint)
        {
!               result = (ILSpawnProcess(argv) == 0);
        }
!       else
        {
!               result = 1;
        }
  
        /* Clean up and exit */
        ILFree(argv);
!       CSAntFileSetDestroy(sources);
!       CSAntFileSetDestroy(references);
        return result;
  }
  
--- 1352,1575 ----
        AddArg(&argv, &argc, (char *)0);
  
!       /* Print and execute the command */
!       result = PrintAndExecute(argv);
! 
!       /* Clean up and exit */
!       ILFree(argv);
!       CSAntFileSetDestroy(sources);
!       CSAntFileSetDestroy(references);
!       return result;
! }
! 
! /*
!  * Handle a "resgen" task, which invokes the resource converter.
!  */
! int CSAntTask_ResGen(CSAntTask *task)
! {
!       char *output;
!       char *input;
!       char *temp;
!       CSAntFileSet *inputs;
!       int isLatin1;
!       const char *compiler;
!       char **argv = 0;
!       int argc = 0;
!       unsigned long numFiles;
!       unsigned long file;
!       int result;
! 
!       /* Get the output name */
!       output = (char *)CSAntTaskParam(task, "output");
!       if(!output)
        {
!               fprintf(stderr, "%s: no output specified\n", task->name);
!               return 0;
!       }
!       output = CSAntDirCombine(CSAntBaseBuildDir, output);
! 
!       /* Get the list of input files */
!       inputs = CSAntFileSetLoad(task, "resources", CSAntBaseSrcDir);
!       input = (char *)CSAntTaskParam(task, "input");
!       if(input)
!       {
!               input = CSAntDirCombine(CSAntBaseSrcDir, input);
!               inputs = CSAntFileSetAdd(inputs, input);
!       }
!       if(!CSAntFileSetSize(inputs))
!       {
!               CSAntFileSetDestroy(inputs);
!               fprintf(stderr, "%s: no inputs specified\n", task->name);
!               return 0;
!       }
! 
!       /* Determine if we should use Latin1 conversion */
!       compiler = CSAntGetProperty("csant.compiler", -1);
!       if(compiler && !ILStrICmp(compiler, "cscc"))
!       {
!               /* We are probably using our resgen */
!               temp = (char *)CSAntTaskParam(task, "latin1");
!               if(temp && !ILStrICmp(temp, "true"))
                {
!                       isLatin1 = 1;
                }
!               else
!               {
!                       isLatin1 = 0;
!               }
!       }
!       else
!       {
!               /* Cannot rely upon other resgen's having Latin1 support */
!               isLatin1 = 0;
        }
  
!       /* Build the command-line to be executed */
!       AddArg(&argv, &argc, FindProgramPath("resgen", "csant.env.RESGEN"));
!       AddArg(&argv, &argc, "/compile");
!       if(isLatin1)
        {
!               AddArg(&argv, &argc, "--latin1");
        }
!       numFiles = CSAntFileSetSize(inputs);
!       for(file = 0; file < numFiles; ++file)
        {
!               temp = CSAntFileSetFile(inputs, file);
!               AddArg(&argv, &argc, temp);
        }
+       AddArg(&argv, &argc, output);
+       AddArg(&argv, &argc, (char *)0);
+ 
+       /* Print and execute the command */
+       result = PrintAndExecute(argv);
  
        /* Clean up and exit */
        ILFree(argv);
!       CSAntFileSetDestroy(inputs);
        return result;
+ }
+ 
+ /*
+  * Handle a "reslink" task, which links resources into a standalone assembly.
+  */
+ int CSAntTask_ResLink(CSAntTask *task)
+ {
+       char *output;
+       char *language;
+       char *version;
+       char *temp;
+       CSAntFileSet *resources;
+       const char *compiler;
+       char **argv = 0;
+       int argc = 0;
+       unsigned long numFiles;
+       unsigned long file;
+       int result;
+       int install;
+       int installAsDefault;
+ 
+       /* Get the option values */
+       output = (char *)CSAntTaskParam(task, "output");
+       if(!output)
+       {
+               fprintf(stderr, "%s: no output specified\n", task->name);
+               return 0;
+       }
+       output = CSAntDirCombine(CSAntBaseBuildDir, output);
+       language = (char *)CSAntTaskParam(task, "language");
+       if(!language)
+       {
+               language = "en";
+       }
+       version = (char *)CSAntTaskParam(task, "version");
+       resources = CSAntFileSetLoad(task, "resources", CSAntBaseBuildDir);
+       temp = (char *)CSAntTaskParam(task, "install");
+       install = (temp && !ILStrICmp(temp, "true"));
+       temp = (char *)CSAntTaskParam(task, "install");
+       if(temp)
+       {
+               installAsDefault = !ILStrICmp(temp, "true");
+       }
+       else
+       {
+               installAsDefault = 1;
+       }
+ 
+       /* Check that we have at least one input file */
+       if(!CSAntFileSetSize(resources))
+       {
+               CSAntFileSetDestroy(resources);
+               fprintf(stderr, "%s: no resource files specified\n", 
task->name);
+               return 0;
+       }
+ 
+       /* Build the required command-line */
+       if(CSAntInstallMode)
+       {
+               if(!install)
+               {
+                       CSAntFileSetDestroy(resources);
+                       return 1;
+               }
+               argv = BuildInstallLine(output, language, installAsDefault);
+       }
+       else if(CSAntUninstallMode)
+       {
+               if(!install)
+               {
+                       CSAntFileSetDestroy(resources);
+                       return 1;
+               }
+               argv = BuildUninstallLine(output, version, language);
+       }
+       else
+       {
+               /* Link the resources as specified */
+               compiler = CSAntGetProperty("csant.compiler", -1);
+               if(compiler && !ILStrICmp(compiler, "cscc"))
+               {
+                       /* Use the cscc C# compiler to do the work */
+                       AddArg(&argv, &argc, FindCsccPath());
+                       AddArg(&argv, &argc, "-nostdlib");
+                       if(version && version[0] != '\0')
+                       {
+                               AddValueArg(&argv, &argc, 
"-fassembly-version=", version);
+                       }
+                       AddArg(&argv, &argc, "-o");
+                       AddArg(&argv, &argc, output);
+                       numFiles = CSAntFileSetSize(resources);
+                       for(file = 0; file < numFiles; ++file)
+                       {
+                               AddValueArg(&argv, &argc, "-fresources=",
+                                                       
CSAntFileSetFile(resources, file));
+                       }
+               }
+               else
+               {
+                       /* Use the Microsoft "al" linker to do the work */
+                       AddArg(&argv, &argc, FindProgramPath("al", 
"csant.env.AL"));
+                       AddArg(&argv, &argc, "/nologo");
+                       AddArg(&argv, &argc, "/target:library");
+                       if(version && version[0] != '\0')
+                       {
+                               AddValueArg(&argv, &argc, "/version:", version);
+                       }
+                       AddValueArg(&argv, &argc, "/out:", output);
+                       AddValueArg(&argv, &argc, "/culture:", language);
+                       numFiles = CSAntFileSetSize(resources);
+                       for(file = 0; file < numFiles; ++file)
+                       {
+                               AddValueArg(&argv, &argc, "/embed:",
+                                                       
CSAntFileSetFile(resources, file));
+                       }
+               }
+       }
+ 
+       /* Print and execute the command */
+       result = PrintAndExecute(argv);
+ 
+       /* Clean up and exit */
+       ILFree(argv);
+       CSAntFileSetDestroy(resources);
+       return 1;
  }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]