summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2017-07-21 12:39:39 -0400
committerAdrian Thurston <thurston@colm.net>2017-07-21 12:39:39 -0400
commit333f69421540b5031fe38dbc2f3d18ee8e9ca0db (patch)
tree1021c32a7a41a227dc028e65f2b158fe22a1ae92 /src/main.cc
parent520d6a7cf9e95d5f9e631b20e3560e3672cd6d10 (diff)
downloadcolm-333f69421540b5031fe38dbc2f3d18ee8e9ca0db.tar.gz
be consistent with the in-source boolean semantics
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/main.cc b/src/main.cc
index f672d6e8..de6232de 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -415,13 +415,19 @@ void compileOutputCommand( const char *command )
error() << "there was a problem compiling the output" << endl;
}
-void compileOutput( const char *argv0, const bool installed, char *srcLocation )
+void compileOutput( const char *argv0, const bool inSource, char *srcLocation )
{
/* Find the location of the colm program that is executing. */
char *location = strdup( argv0 );
char *last;
int length = 1024 + strlen( intermedFn ) + strlen( binaryFn );
- if ( installed ) {
+ if ( inSource ) {
+ last = strrchr( location, '/' );
+ assert( last != 0 );
+ last[0] = 0;
+ length += 3 * strlen( location );
+ }
+ else {
last = location + strlen( location ) - 1;
while ( true ) {
if ( last == location ) {
@@ -435,11 +441,6 @@ void compileOutput( const char *argv0, const bool installed, char *srcLocation )
}
last -= 1;
}
- } else {
- last = strrchr( location, '/' );
- assert( last != 0 );
- last[0] = 0;
- length += 3 * strlen( location );
}
for ( ArgsVector::Iter af = additionalCodeFiles; af.lte(); af++ )
length += strlen( *af ) + 2;
@@ -452,14 +453,7 @@ void compileOutput( const char *argv0, const bool installed, char *srcLocation )
" -o %s" \
" %s"
char *command = new char[length];
- if ( installed ) {
- sprintf( command,
- COMPILE_COMMAND_STRING
- " -I" PREFIX "/include"
- " -L" PREFIX "/lib",
- binaryFn, intermedFn );
- }
- else {
+ if ( inSource ) {
sprintf( command,
COMPILE_COMMAND_STRING
" -I%s/../aapl"
@@ -469,6 +463,13 @@ void compileOutput( const char *argv0, const bool installed, char *srcLocation )
binaryFn, intermedFn, srcLocation,
srcLocation, location, location );
}
+ else {
+ sprintf( command,
+ COMPILE_COMMAND_STRING
+ " -I" PREFIX "/include"
+ " -L" PREFIX "/lib",
+ binaryFn, intermedFn );
+ }
#undef COMPILE_COMMAND_STRING
for ( ArgsVector::Iter af = additionalCodeFiles; af.lte(); af++ ) {
strcat( command, " " );
@@ -764,10 +765,8 @@ int main(int argc, const char **argv)
if ( !gblLibrary ) {
char *location = 0;
- if ( inSourceTree( argv[0], location ) )
- compileOutput( argv[0], false, location );
- else
- compileOutput( argv[0], true, location );
+ bool inSource = inSourceTree( argv[0], location );
+ compileOutput( argv[0], inSource, location );
}
if ( exportHeaderFn != 0 ) {