[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Allow myrbuild to set the object file
- Subject: Re: [PATCH] Allow myrbuild to set the object file
- From: Ryan Gonzalez <rymg19@xxxxxxxxx>
- Date: Mon, 9 Mar 2015 16:15:35 -0500
- To: myrddin-dev@xxxxxxxxxxxxxx
...and I forgot to attach the patch file...
On Mon, Mar 9, 2015 at 4:12 PM, Ryan Gonzalez <rymg19@xxxxxxxxx> wrote:
> This allows you to do stuff like:
>
> $ myrbuild -b build/hello -o build/hello.o hello.myr
>
> If you can't already tell, I'm one of those people who's paranoid about
> object files in source directories. ;)
>
> Also, could you not put this message as the commit message?
>
> --
> Ryan
> If I were in a 10-story building glass-sided building and forced to write
> either Go or autotools scripts, I’d jump out a window.
> http://kirbyfan64.github.io/
>
>
--
Ryan
If I were in a 10-story building glass-sided building and forced to write
either Go or autotools scripts, I’d jump out a window.
http://kirbyfan64.github.io/
diff --git a/myrbuild/myrbuild.c b/myrbuild/myrbuild.c
index e892b7e..b1e4866 100644
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -40,6 +40,8 @@ size_t nincpaths;
Htab *libgraph; /* string -> null terminated string list */
/* the linker script to use */
char *ldscript;
+/* the object file */
+char* objfile = NULL;
char *sysname;
@@ -64,6 +66,7 @@ static void usage(char *prog)
printf("\t-s script\tUse the linker script 'script' when linking\n");
printf("\t-I path\tAdd 'path' to use search path\n");
printf("\t-S\tGenerate assembly files for all compiled code\n");
+ printf("\t-o path\tThe object file to write\n");
}
int hassuffix(char *path, char *suffix)
@@ -120,7 +123,7 @@ void gencmd(char ***cmd, size_t *ncmd, char *bin, char *file, char **extra, size
for (i = 0; i < nextra; i++)
lappend(cmd, ncmd, extra[i]);
lappend(cmd, ncmd, file);
- lappend(cmd, ncmd, NULL);
+ lappend(cmd, ncmd, NULL);
}
void run(char **cmd)
@@ -276,8 +279,15 @@ void compile(char *file, char ***stack, size_t *nstack)
}
htput(loopdetect, file, file);
if (hassuffix(file, ".myr")) {
- swapsuffix(use, sizeof use, file, ".myr", ".use");
- swapsuffix(obj, sizeof obj, file, ".myr", Objsuffix);
+ if (objfile != NULL) {
+ swapsuffix(use, sizeof use, objfile, Objsuffix, ".use");
+ snprintf(obj, sizeof obj, "%s", objfile);
+ extra[nextra++] = "-o";
+ extra[nextra++] = objfile;
+ } else {
+ swapsuffix(use, sizeof use, file, ".myr", ".use");
+ swapsuffix(obj, sizeof obj, file, ".myr", Objsuffix);
+ }
getdeps(file, deps, 512, &ndeps);
for (i = 0; i < ndeps; i++) {
if (isquoted(deps[i])) {
@@ -497,8 +507,8 @@ int main(int argc, char **argv)
if (uname(&name) == 0)
sysname = strdup(name.sysname);
-
- optinit(&ctx, "hb:l:s:r:SI:C:A:M:L:R:", argv, argc);
+
+ optinit(&ctx, "hb:l:s:r:SI:C:A:M:L:R:o:", argv, argc);
while (!optdone(&ctx)) {
switch (optnext(&ctx)) {
case 'b': binname = ctx.optarg; break;
@@ -510,6 +520,7 @@ int main(int argc, char **argv)
case 'A': as[0] = ctx.optarg; break;
case 'L': ld[0] = ctx.optarg; break;
case 'R': ar[0] = ctx.optarg; break;
+ case 'o': objfile = ctx.optarg; break;
case 'r':
if (!strcmp(ctx.optarg, "none"))
runtime = NULL;