[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master fab05b7 2/2: BuildProgram deletes the compiled
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master fab05b7 2/2: BuildProgram deletes the compiled program if requested |
Date: |
Fri, 27 Oct 2017 12:30:37 -0400 (EDT) |
branch: master
commit fab05b77a1d3a94735d90c98666a730e2adb5635
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
BuildProgram deletes the compiled program if requested
BuildProgram can also run a program that it builds. This is the default
behavior. Therefore, in some situations, you don't want the actual
binary/compiled program, you just want to see the result of some operation
and you will later delete the compiled file.
With this commit, BuildProgram has a new `--deletecompiled' option. With
this option, when the built program is run (when `--onlybuild' isn't
called), BuildProgram will delete the compiled binary.
Two other minor corrections:
- The number of threads are irrelevant to BuildProgram, so it is now a
hidden option for it.
- The "Single row calculations" option group title in CosmicCalculator was
changed to "Specific calculation" to fit the terminology of the book and
code.
---
NEWS | 3 +++
bin/buildprog/args.h | 16 ++++++++++++++++
bin/buildprog/buildprog.c | 12 ++++++++++--
bin/buildprog/main.h | 1 +
bin/buildprog/ui.c | 1 +
bin/buildprog/ui.h | 17 +++++++++--------
bin/cosmiccal/args.h | 2 +-
doc/gnuastro.texi | 7 +++++++
8 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/NEWS b/NEWS
index eb0a522..aafd6ea 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,9 @@ GNU Astronomy Utilities NEWS -*-
outline -*-
BuildProgram: The new `--la' option allows the identification of a
different Libtool `.la' file for Libtool linking information.
+ BuildProgram: The new `--deletecompiled' option will delete the compiled
+ program after running it.
+
CosmicCalculator: all the various cosmological calculations can now be
requested individually in one line with a specific option added for each
calculation (for example `--age' or `--luminositydist' for the age of the
diff --git a/bin/buildprog/args.h b/bin/buildprog/args.h
index 01a96fc..a64911d 100644
--- a/bin/buildprog/args.h
+++ b/bin/buildprog/args.h
@@ -88,6 +88,9 @@ struct argp_option program_options[] =
},
+
+
+
{
"debug",
UI_KEY_DEBUG,
@@ -140,6 +143,19 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
+ {
+ "deletecompiled",
+ UI_KEY_DETELECOMPILED,
+ 0,
+ 0,
+ "Delete compiled program after running.",
+ GAL_OPTIONS_GROUP_OUTPUT,
+ &p->deletecompiled,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
{0}
};
diff --git a/bin/buildprog/buildprog.c b/bin/buildprog/buildprog.c
index 24fbce1..f35236d 100644
--- a/bin/buildprog/buildprog.c
+++ b/bin/buildprog/buildprog.c
@@ -119,7 +119,7 @@ buildprog(struct buildprogparams *p)
/* Free the initial command. */
free(command);
- /* Right the command to run the program. Note that if the output
+ /* Wright the command to run the program. Note that if the output
value doesn't start with a directory, we'll have to put one for
it. */
switch(p->cp.output[0])
@@ -136,11 +136,19 @@ buildprog(struct buildprogparams *p)
/* Print the executed command if necessary, then run it. */
if(!p->cp.quiet)
{
- printf("Run the compiled program\n");
+ printf("\nRun the compiled program\n");
printf("------------------------\n");
printf("%s\n", command);
}
retval=system(command);
+
+ /* Delete the compiled program after running it. */
+ if(p->deletecompiled)
+ {
+ errno=0;
+ if( remove(p->cp.output) == -1 )
+ error(EXIT_FAILURE, 0, "unable to delete %s", p->cp.output);
+ }
}
/* Clean up and return. */
diff --git a/bin/buildprog/main.h b/bin/buildprog/main.h
index 2e3902c..b519f30 100644
--- a/bin/buildprog/main.h
+++ b/bin/buildprog/main.h
@@ -54,6 +54,7 @@ struct buildprogparams
char *debug; /* Keep debugging information. */
char *warning; /* Compiler warnings. */
uint8_t onlybuild; /* Don't run the compiled program. */
+ uint8_t deletecompiled; /* Delete compiled program after running. */
/* Output: */
time_t rawtime; /* Starting time of the program. */
diff --git a/bin/buildprog/ui.c b/bin/buildprog/ui.c
index 28c172b..6a4cc8c 100644
--- a/bin/buildprog/ui.c
+++ b/bin/buildprog/ui.c
@@ -122,6 +122,7 @@ ui_initialize_options(struct buildprogparams *p,
case GAL_OPTIONS_KEY_HDU:
case GAL_OPTIONS_KEY_TYPE:
case GAL_OPTIONS_KEY_SEARCHIN:
+ case GAL_OPTIONS_KEY_NUMTHREADS:
case GAL_OPTIONS_KEY_MINMAPSIZE:
case GAL_OPTIONS_KEY_TABLEFORMAT:
cp->coptions[i].flags=OPTION_HIDDEN;
diff --git a/bin/buildprog/ui.h b/bin/buildprog/ui.h
index 712147b..f937df5 100644
--- a/bin/buildprog/ui.h
+++ b/bin/buildprog/ui.h
@@ -38,17 +38,18 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
enum option_keys_enum
{
/* With short-option version. */
- UI_KEY_INCLUDE = 'I',
- UI_KEY_LINKDIR = 'L',
- UI_KEY_LINKLIB = 'l',
- UI_KEY_LA = 'a',
- UI_KEY_ONLYBUILD = 'b',
- UI_KEY_DEBUG = 'g',
- UI_KEY_OPTIMIZE = 'O',
- UI_KEY_WARNING = 'W',
+ UI_KEY_INCLUDE = 'I',
+ UI_KEY_LINKDIR = 'L',
+ UI_KEY_LINKLIB = 'l',
+ UI_KEY_LA = 'a',
+ UI_KEY_ONLYBUILD = 'b',
+ UI_KEY_DEBUG = 'g',
+ UI_KEY_OPTIMIZE = 'O',
+ UI_KEY_WARNING = 'W',
/* Only with long version (start with a value 1000, the rest will be set
automatically). */
+ UI_KEY_DETELECOMPILED = 1000,
};
diff --git a/bin/cosmiccal/args.h b/bin/cosmiccal/args.h
index 46d4bfd..8def9bc 100644
--- a/bin/cosmiccal/args.h
+++ b/bin/cosmiccal/args.h
@@ -102,7 +102,7 @@ struct argp_option program_options[] =
{
0, 0, 0, 0,
- "Single row calculations",
+ "Specific calculations",
UI_GROUP_SPECIFIC
},
{
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index a4357b0..b2a0f3e 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -17386,6 +17386,13 @@ confronts).
Only build the program, don't run it. By default, the built program is
immediately run afterwards.
address@hidden --deletecompiled
+Delete the compiled binary file after running it. This option is only
+relevant when the compiled program is run after being built. In other
+words, it is only relevant when @option{--onlybuild} is not called. It can
+be useful when you are busy testing a program or just want a fast result
+and the actual binary/compiled file is not of later use.
+
@item -a STR
@itemx --la=STR
Use the given @file{.la} file (Libtool control file) instead of the one