mirror of
https://github.com/boostorg/build.git
synced 2026-02-11 23:52:20 +00:00
Added the 'PWD' builtin.
[SVN r13117]
This commit is contained in:
@@ -117,7 +117,7 @@ Library libjam.a :
|
||||
hash.c headers.c hdrmacro.c lists.c make.c make1.c newstr.c
|
||||
option.c parse.c regexp.c rules.c scan.c search.c subst.c
|
||||
timestamp.c variable.c modules.c strings.c filesys.c
|
||||
builtins.c ;
|
||||
builtins.c pwd.c ;
|
||||
|
||||
|
||||
if $(BINDIR) { InstallBin $(BINDIR) : jam ; }
|
||||
@@ -138,7 +138,7 @@ ALLSOURCE =
|
||||
parse.h patchlevel.h pathmac.c pathunix.c pathvms.c regexp.c regexp.h
|
||||
rules.c rules.h scan.c scan.h search.c search.h subst.c timestamp.c
|
||||
timestamp.h variable.c variable.h yyacc strings.c modules.h
|
||||
frames.h filesys.c strings.h
|
||||
frames.h filesys.c strings.h pwd.c pwd.h
|
||||
INSTALL
|
||||
common.mk
|
||||
builds/win32-visualc.mk
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# include "frames.h"
|
||||
# include "hash.h"
|
||||
# include "strings.h"
|
||||
# include "pwd.h"
|
||||
|
||||
/*
|
||||
* builtins.c - builtin jam rules
|
||||
@@ -170,6 +171,12 @@ load_builtins()
|
||||
bind_builtin( "BACKTRACE" ,
|
||||
builtin_backtrace, 0, args );
|
||||
}
|
||||
|
||||
{
|
||||
char * args[] = { 0 };
|
||||
bind_builtin( "PWD" ,
|
||||
builtin_pwd, 0, args );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -569,6 +576,17 @@ LIST *builtin_caller_module( PARSE *parse, FRAME *frame )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the current working directory.
|
||||
*
|
||||
* Usage: pwd = [ PWD ] ;
|
||||
*/
|
||||
LIST*
|
||||
builtin_pwd( PARSE *parse, FRAME *frame )
|
||||
{
|
||||
return pwd();
|
||||
}
|
||||
|
||||
static void lol_build( LOL* lol, char** elements )
|
||||
{
|
||||
LIST* l = L0;
|
||||
|
||||
@@ -27,5 +27,6 @@ LIST *builtin_import( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_export( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_caller_module( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_backtrace( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_pwd( PARSE *parse, FRAME *args );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@ SOURCES = \
|
||||
hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c \
|
||||
newstr.c option.c parse.c pathunix.c pathvms.c regexp.c \
|
||||
rules.c scan.c search.c subst.c timestamp.c variable.c modules.c \
|
||||
strings.c filesys.c builtins.c
|
||||
strings.c filesys.c builtins.c pwd.c
|
||||
|
||||
# the bootstrap "jam0" build tool
|
||||
#
|
||||
|
||||
28
src/engine/pwd.c
Normal file
28
src/engine/pwd.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "jam.h"
|
||||
#include "lists.h"
|
||||
#include "newstr.h"
|
||||
|
||||
#ifdef NT
|
||||
#include <dir.h>
|
||||
#define PATH_MAX _MAX_PATH
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
LIST*
|
||||
pwd(void)
|
||||
{
|
||||
char buffer[PATH_MAX];
|
||||
if (getcwd(buffer, sizeof(buffer)) == NULL)
|
||||
{
|
||||
perror("can not get current directory");
|
||||
return L0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return list_new(L0, newstr(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
6
src/engine/pwd.h
Normal file
6
src/engine/pwd.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef PWD_H
|
||||
#define PWD_H
|
||||
|
||||
LIST* pwd(void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user