From 2df8d6501eb4bb6f977929585dc6da2f898f9099 Mon Sep 17 00:00:00 2001 From: Chad Elliott Date: Wed, 26 Apr 2023 08:24:11 -0500 Subject: Support projects without explicit sharedname or staticname settings. --- create_base.pl | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/create_base.pl b/create_base.pl index a87c0199..8e18703b 100755 --- a/create_base.pl +++ b/create_base.pl @@ -32,7 +32,7 @@ require Creator; # Data Section # ****************************************************************** -my $version = '0.1'; +my $version = '0.2'; # ****************************************************************** # Subroutine Section @@ -45,6 +45,8 @@ sub gather_info { if (open($fh, $name)) { my @lines = (); my $pname = undef; + my $pline = undef; + while(<$fh>) { ## Get the line a remove leading and trailing white space my $line = $_; @@ -81,6 +83,7 @@ sub gather_info { ## us. $pname = Creator::fill_type_name(undef, $pname, $def); push(@lines, "project$parents {"); + $pline = $def; } elsif ($line =~ /^(shared|static)name\s*=\s*(.+)$/) { ## Add in the libs and after settings. @@ -95,10 +98,15 @@ sub gather_info { } close($fh); - ## Only return the lines if there is more than one line. It is - ## possible (and likely) that we've read in the project declaration, - ## but the project did not contain a sharedname or staticname - ## setting. + ## If we have the unmodified project name, but the user did not provide + ## a sharedname or staticname, we will use that as the library name. + if (defined $pline && $#lines == 0) { + push(@lines, " libs += $pline", + " after += $pname", + "}"); + } + + ## Only return the lines if there is more than one line. return @lines if ($#lines > 0); } @@ -148,9 +156,7 @@ sub usageAndExit { print STDERR "Create Base Project v$version\n", "Usage: ", basename($0), " \n\nThis script will create a base project ", - "based on the contents of the\nsupplied MPC file. ", - "This is only useful if the project ", - "explicitly sets\nsharedname or staticname.\n"; + "based on the contents of the\nsupplied MPC file.\n"; exit(0); } -- cgit v1.2.1