diff --git a/v2/build/configure.jam b/v2/build/configure.jam index 6a87157a2..14c1328af 100644 --- a/v2/build/configure.jam +++ b/v2/build/configure.jam @@ -17,6 +17,8 @@ import sequence ; import property ; import property-set ; import "class" : new ; +import common ; +import path ; rule log-summary ( ) { @@ -185,12 +187,9 @@ rule builds ( metatarget-reference : properties * : what ? : retry ? ) # should never be called by users. rule set-log-file ( log-file ) { - # FIXME: remove this check as soon as Boost regression tests - # start using trunk bjam - if FILE_OPEN in [ RULENAMES ] - { - .log-fd = [ FILE_OPEN $(log-file) : "w" ] ; - } + path.makedirs [ path.parent $(log-file) ] ; + + .log-fd = [ FILE_OPEN $(log-file) : "w" ] ; } # Frontend rules diff --git a/v2/engine/builtins.c b/v2/engine/builtins.c index 28c1b3aec..b28a484ec 100644 --- a/v2/engine/builtins.c +++ b/v2/engine/builtins.c @@ -399,6 +399,11 @@ void load_builtins() bind_builtin( "SELF_PATH", builtin_self_path, 0, args ); } + { + char * args [] = { "path", 0 }; + bind_builtin( "MAKEDIR", builtin_makedir, 0, args ); + } + /* Initialize builtin modules. */ init_set(); init_path(); @@ -1757,6 +1762,20 @@ LIST *builtin_self_path( PARSE *parse, FRAME *frame ) } } +LIST *builtin_makedir( PARSE *parse, FRAME *frame ) +{ + LIST *path = lol_get(frame->args, 0); + + if (file_mkdir(path->string) == 0) + { + LIST *result = list_new (0, newstr(path->string)); + return result; + } + else + { + return L0; + } +} #ifdef HAVE_PYTHON diff --git a/v2/engine/builtins.h b/v2/engine/builtins.h index 9ed3e6dc9..5fed07c96 100644 --- a/v2/engine/builtins.h +++ b/v2/engine/builtins.h @@ -61,6 +61,7 @@ LIST *builtin_file_open( PARSE *parse, FRAME *frame ); LIST *builtin_pad( PARSE *parse, FRAME *frame ); LIST *builtin_precious( PARSE *parse, FRAME *frame ); LIST *builtin_self_path( PARSE *parse, FRAME *frame ); +LIST *builtin_makedir( PARSE *parse, FRAME *frame ); void backtrace( FRAME *frame ); extern int last_update_now_status; diff --git a/v2/engine/filemac.c b/v2/engine/filemac.c index 06074417d..e69aa648f 100644 --- a/v2/engine/filemac.c +++ b/v2/engine/filemac.c @@ -157,6 +157,11 @@ int file_is_file( char * filename ) return S_ISREG( statbuf.st_mode ) ? 1 : 0; } +int file_mkdir(char *pathname) +{ + return mkdir(pathname, 0766); +} + /* * file_archscan() - scan an archive for files. diff --git a/v2/engine/filent.c b/v2/engine/filent.c index 0bef792b9..3d45273f9 100644 --- a/v2/engine/filent.c +++ b/v2/engine/filent.c @@ -32,6 +32,7 @@ # include # include # include +# include /* * filent.c - scan directories and archives on NT @@ -243,6 +244,10 @@ int file_is_file(char* filename) return ff->is_file; } +int file_mkdir(char *pathname) +{ + return _mkdir(pathname); +} /* * file_archscan() - scan an archive for files diff --git a/v2/engine/filesys.h b/v2/engine/filesys.h index 9281c8674..efc081d12 100644 --- a/v2/engine/filesys.h +++ b/v2/engine/filesys.h @@ -30,6 +30,7 @@ int file_time( char *filename, time_t *time ); void file_build1(PATHNAME *f, string* file) ; int file_is_file(char* filename); +int file_mkdir(char *pathname); typedef struct file_info_t file_info_t ; struct file_info_t diff --git a/v2/engine/fileunix.c b/v2/engine/fileunix.c index 51267a0ca..680c3f539 100644 --- a/v2/engine/fileunix.c +++ b/v2/engine/fileunix.c @@ -17,6 +17,7 @@ # include "pathsys.h" # include "newstr.h" # include +# include #if defined(sun) || defined(__sun) || defined(linux) # include /* needed for read and close prototype */ @@ -253,6 +254,10 @@ int file_is_file(char* filename) return ff->is_file; } +int file_mkdir(char* pathname) +{ + return mkdir(pathname, 0766); +} /* * file_archscan() - scan an archive for files diff --git a/v2/util/path.jam b/v2/util/path.jam index 34b0f630c..cf48d11a2 100644 --- a/v2/util/path.jam +++ b/v2/util/path.jam @@ -465,6 +465,22 @@ rule programs-path ( ) return $(result) ; } +rule makedirs ( path ) +{ + local result = true ; + if ! [ exists $(path) ] + { + if [ makedirs [ parent $(path) ] ] + { + if ! [ MAKEDIR $(path) ] + { + errors.error "Could not create directory '$(path)'" ; + result = ; + } + } + } + return $(result) ; +} # Converts native Windows paths into our internal canonic path representation. # Supports 'invalid' paths containing multiple successive path separator