Skip to content

Commit

Permalink
add environment includes and better environment queries
Browse files Browse the repository at this point in the history
  • Loading branch information
mulle-nat committed Jun 14, 2017
1 parent dc48b1e commit f958902
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ FIND_PACKAGE( ZLIB REQUIRED)
message( STATUS "FOUNDATION_LIBRARY is ${FOUNDATION_LIBRARY}")
message( STATUS "ZLIB_LIBRARIES is ${ZLIB_LIBRARIES}")

add_definitions( -DPROJECT_VERSION=1857)
add_definitions( -DPROJECT_VERSION=1858)


add_library( MulleScion STATIC
Expand Down
2 changes: 1 addition & 1 deletion MulleScion.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MulleScion"
s.version = '1857'
s.version = '1858'
s.summary = "MulleScion a modern Template library for ObjC."
s.description = <<-DESC
MulleScion is indeed a modern Template library for ObjC.
Expand Down
6 changes: 3 additions & 3 deletions MulleScion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@
baseConfigurationReference = 413C51611CC284CA00F62468 /* Debug.xcconfig */;
buildSettings = {
CLANG_WARN_INT_CONVERSION = YES;
CURRENT_PROJECT_VERSION = 1857;
CURRENT_PROJECT_VERSION = 1858;
DYLIB_COMPATIBILITY_VERSION = 1848.0;
DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)";
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -1995,7 +1995,7 @@
baseConfigurationReference = 413C516B1CC284CA00F62468 /* Release.xcconfig */;
buildSettings = {
CLANG_WARN_INT_CONVERSION = YES;
CURRENT_PROJECT_VERSION = 1857;
CURRENT_PROJECT_VERSION = 1858;
DYLIB_COMPATIBILITY_VERSION = 1848.0;
DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)";
GCC_PREPROCESSOR_DEFINITIONS = (
Expand Down Expand Up @@ -2064,7 +2064,7 @@
baseConfigurationReference = 413C516B1CC284CA00F62468 /* Release.xcconfig */;
buildSettings = {
CLANG_WARN_INT_CONVERSION = YES;
CURRENT_PROJECT_VERSION = 1857;
CURRENT_PROJECT_VERSION = 1858;
DYLIB_COMPATIBILITY_VERSION = 1848.0;
DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)";
GCC_PREPROCESSOR_DEFINITIONS = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "YES"
customWorkingDirectory = "/Volumes/Source/srcM/MulleScion/tests"
customWorkingDirectory = "/Volumes/Source/srcO/MulleObjC-master/MulleObjCFoundation"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
Expand All @@ -64,7 +64,7 @@
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "commands/define/define-1.scion none"
argument = "&apos;/Volumes/Source/srcO/MulleObjC-master/MulleObjCFoundation/templates/__wrapper.scion&apos; args &apos;dox/HOWTO_DEPENDENCIES.md&apos; PUBLISHER=&apos;mulle-nat&apos; PUBLISHER_TAP=&apos;mulle-kybernetik/software&apos; PUBLISHER_FULLNAME=&apos;Mulle kybernetiK&apos; COMMENT=&apos;DO NOT EDIT THIS. EDIT THE TEMPLATE &quot;templates/dox/HOWTO_DEPENDENCIES.md.scion&quot;&apos; TEMPLATE_FILE=&apos;templates/dox/HOWTO_DEPENDENCIES.md.scion&apos;"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
Expand Down
9 changes: 9 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 1858

There is an option that allows specifying includes via the environment like
so:
`MULLESCION_ALLOW_GETENV_INCLUDES="YES" MY_INCLUDE="foo.scion" mulle-scion bar.scion none`
and then in `bar.scion` use `{% includes MY_INCLUDE %}`. This looks obscure,
but I needed it to wrap code around existing templates.
* MULLESCION_.. environment variables now are of the YES/NO variety.

## 1857

* fix missing menu due to change of root dox
Expand Down
65 changes: 53 additions & 12 deletions src/MulleScionParser+Parsing.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ - (void) parserError:(parser_error_info *) info

enum
{
MULLESCION_VERBATIM_INCLUDE_HASHBANG = 0x01,
MULLESCION_ALLOW_GETENV_INCLUDES = 0x01,
MULLESCION_NO_HASHBANG = 0x02,
MULLESCION_DUMP_MACROS = 0x04,
MULLESCION_VERBATIM_INCLUDE_HASHBANG = 0x04,
MULLESCION_DUMP_COMMANDS = 0x08,
MULLESCION_DUMP_EXPRESSIONS = 0x10,
MULLESCION_DUMP_FILE_INCLUDES = 0x20
MULLESCION_DUMP_FILE_INCLUDES = 0x20,
MULLESCION_DUMP_MACROS = 0x40
};

static void parser_skip_after_newline( parser *p);
Expand All @@ -158,6 +159,33 @@ static void parser_skip_initial_hashbang_line_if_present( parser *p)
}


static int getenv_yes_no_default( char *name, int default_value)
{
char *s;

s = getenv( name);
if( ! s)
return( default_value);

switch( *s)
{
case 'f' :
case 'F' :
case 'n' :
case 'N' :
case '0' : return( 0);
}

return( 1);
}


static inline int getenv_yes_no( char *name)
{
return( getenv_yes_no_default( name, 0));
}


static void parser_init( parser *p, unsigned char *buf, size_t len)
{
memset( p, 0, sizeof( parser));
Expand All @@ -168,12 +196,13 @@ static void parser_init( parser *p, unsigned char *buf, size_t len)
p->lineNumber = 1;
}

p->environment |= getenv( "MULLESCION_DUMP_MACROS") ? MULLESCION_DUMP_MACROS : 0;
p->environment |= getenv( "MULLESCION_VERBATIM_INCLUDE_HASHBANG") ? MULLESCION_VERBATIM_INCLUDE_HASHBANG : 0;
p->environment |= getenv( "MULLESCION_NO_HASHBANG") ? MULLESCION_NO_HASHBANG : 0;
p->environment |= getenv( "MULLESCION_DUMP_COMMANDS") ? MULLESCION_DUMP_COMMANDS : 0;
p->environment |= getenv( "MULLESCION_DUMP_EXPRESSIONS") ? MULLESCION_DUMP_EXPRESSIONS : 0;
p->environment |= getenv( "MULLESCION_DUMP_FILE_INCLUDES") ? MULLESCION_DUMP_FILE_INCLUDES : 0;
p->environment |= getenv_yes_no( "MULLESCION_ALLOW_GETENV_INCLUDES") ? MULLESCION_ALLOW_GETENV_INCLUDES : 0;
p->environment |= getenv_yes_no( "MULLESCION_NO_HASHBANG") ? MULLESCION_NO_HASHBANG : 0;
p->environment |= getenv_yes_no( "MULLESCION_VERBATIM_INCLUDE_HASHBANG") ? MULLESCION_VERBATIM_INCLUDE_HASHBANG : 0;
p->environment |= getenv_yes_no( "MULLESCION_DUMP_COMMANDS") ? MULLESCION_DUMP_COMMANDS : 0;
p->environment |= getenv_yes_no( "MULLESCION_DUMP_EXPRESSIONS") ? MULLESCION_DUMP_EXPRESSIONS : 0;
p->environment |= getenv_yes_no( "MULLESCION_DUMP_FILE_INCLUDES") ? MULLESCION_DUMP_FILE_INCLUDES : 0;
p->environment |= getenv_yes_no( "MULLESCION_DUMP_MACROS") ? MULLESCION_DUMP_MACROS : 0;
}


Expand Down Expand Up @@ -2224,7 +2253,8 @@ static void parser_add_dependency( parser *p, NSString *fileName, NSString *inc
NSString *converter;
SEL sel;
NSString *s;
char *env;
if( p->inMacro)
parser_error( p, "no including or extending in macro");
Expand All @@ -2245,19 +2275,30 @@ static void parser_add_dependency( parser *p, NSString *fileName, NSString *inc
converter = nil;
goto retry;
}
if( p->environment & MULLESCION_ALLOW_GETENV_INCLUDES)
{
env = getenv( [converter cString]);
if( env)
{
fileName = [NSString stringWithCString:env];
goto env_string;
}
}
//
// markdown -> markdownedData or some other variety
// (rarely useful)
sel = NSSelectorFromString( converter);
if( ! [NSData instancesRespondToSelector:sel])
parser_error( p, "converter method \"%s\" not found on NSData", [converter cString]);
parser_error( p, "unknown converter method \"%s\" (hint: use quoted strings for filenames)", [converter cString]);
}
fileName = parser_do_string( p);
if( ! [fileName length])
parser_error( p, "a filename was expected as a quoted string");
env_string:
if( p->environment & MULLESCION_DUMP_FILE_INCLUDES)
fprintf( stderr, "-> opening \"%s\"\n", [fileName UTF8String]);
Expand Down
11 changes: 8 additions & 3 deletions src/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
#import "NSFileHandle+MulleOutputFileHandle.h"


// all C strings
#ifndef DEBUG
# define DOCUMENT_ROOT "/usr/local/share/mulle-scion/dox" // C string!
# define DOCUMENT_ROOT "/usr/local/share/mulle-scion/dox"
#else
# define DOCUMENT_ROOT "/Volumes/Source/srcM/MulleScion/dox"
#endif

#define SERVER_HOST "127.0.0.1"
#define SERVER_PORT "18048"

static NSString *processName( void);

Expand Down Expand Up @@ -460,7 +462,7 @@ static int _archive_main( int argc, char *argv[], BOOL keyed)
static char *default_options[] =
{
"document_root", DOCUMENT_ROOT,
"listening_ports", "127.0.0.1:18048",
"listening_ports", SERVER_HOST ":" SERVER_PORT,
"num_threads", "1",
"index_files", "index.scion,index.html,index.htm,index.cgi,index.shtml,index.php,index.lp",
NULL
Expand Down Expand Up @@ -503,6 +505,9 @@ static int main_www( int argc, char *argv[])
if( ! plist)
plist = [NSDictionary dictionary];

#if __APPLE__
system( "(sleep 1 ; open http://" SERVER_HOST ":" SERVER_PORT ") &");
#endif
mulle_mongoose_main( plist, default_options);
return( 0);
}
Expand Down

0 comments on commit f958902

Please sign in to comment.