diff --git a/debian/changelog b/debian/changelog index ddf4244..273ba85 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -rabs (2.21.0) UNRELEASED; urgency=medium +rabs (2.22.0) UNRELEASED; urgency=medium * Updates. * Updates. @@ -29,5 +29,6 @@ rabs (2.21.0) UNRELEASED; urgency=medium * Updates. * Updates. * Updates. + * Updates. - -- Raja Mukherji Wed, 27 Oct 2021 09:28:17 +0100 + -- Raja Mukherji Sat, 06 Nov 2021 10:04:58 +0000 diff --git a/docs/index.rst b/docs/index.rst index a0e7e9e..aab890f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,15 +1,10 @@ -.. Rabs documentation master file, created by - sphinx-quickstart on Thu May 9 07:06:34 2019. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to Rabs's documentation! -================================ +Rabs +==== Overview -------- -Rabs is a general purpose build system, designed for fast and consistent incremental rebuilds. See here to get started: :doc:`/quickstart`. +Rabs (Raja's Attempt at a Build System) is a general purpose build system, designed for fast and consistent incremental rebuilds. See here to get started: :doc:`/quickstart`. Features -------- diff --git a/docs/library/expr.rst b/docs/library/expr.rst index e737c92..fd704e8 100644 --- a/docs/library/expr.rst +++ b/docs/library/expr.rst @@ -7,10 +7,6 @@ expr The value of an expression target is the return value of its build function. -:mini:`meth string(Target: exprtarget): string` - Converts the value of an expression target to a string, calling its build function first if necessary. - - :mini:`fun expr(Name: string): exprtarget` Returns a new expression target with :mini:`Name`. diff --git a/docs/library/file.rst b/docs/library/file.rst index 9b1320a..bcb62f8 100644 --- a/docs/library/file.rst +++ b/docs/library/file.rst @@ -11,10 +11,6 @@ file Returns a new file target. If :mini:`Path` does not begin with `/`, it is considered relative to the current context path. If :mini:`Path` is specified as an absolute path but lies inside the project directory, it is converted into a relative path. -:mini:`meth string(Target: filetarget): string` - Returns the absolute resolved path of :mini:`Target` as a string. - - :mini:`meth (Target: filetarget):dir: filetarget` Returns the directory containing :mini:`Target`. diff --git a/minilang b/minilang index 7890ae9..37de40f 160000 --- a/minilang +++ b/minilang @@ -1 +1 @@ -Subproject commit 7890ae9c782b52503be509912b11d570f7dd4c2a +Subproject commit 37de40ffc0b35703cb8cd74eb65e1465cd8ceaa2 diff --git a/src/rabs.c b/src/rabs.c index 3f625cc..c71d0fc 100644 --- a/src/rabs.c +++ b/src/rabs.c @@ -273,7 +273,7 @@ ML_FUNCTION(Include) { } size_t Length = Buffer->Length; char *FileName0 = GC_MALLOC_ATOMIC(Length + MAX_EXTENSION); - memcpy(FileName0, ml_stringbuffer_get(Buffer), Length); + memcpy(FileName0, ml_stringbuffer_get_string(Buffer), Length); char *FileName = FileName0; struct stat Stat[1]; @@ -382,6 +382,13 @@ ML_METHOD("append", MLStringBufferT, MLMapT) { static int ErrorLogFile = STDERR_FILENO; +typedef struct command_output_t command_output_t; + +struct command_output_t { + command_output_t *Next; + char Chars[ML_STRINGBUFFER_NODE_SIZE]; +}; + static ml_value_t *command(int Capture, int Count, ml_value_t **Args) { ML_CHECK_ARG_COUNT(1); ml_stringbuffer_t Buffer[1] = {ML_STRINGBUFFER_INIT}; @@ -392,7 +399,7 @@ static ml_value_t *command(int Capture, int Count, ml_value_t **Args) { ml_value_t *Result = ml_stringbuffer_append(Buffer, Args[I]); if (Result->Type == MLErrorT) return Result; } - const char *Command = ml_stringbuffer_get(Buffer); + const char *Command = ml_stringbuffer_get_string(Buffer); if (EchoCommands) printf("\e[34m%s: %s\e[0m\n", CurrentDirectory, Command); if (DebugThreads && CurrentThread) { strncpy(CurrentThread->Command, Command, sizeof(CurrentThread->Command) - 1); @@ -417,21 +424,39 @@ static ml_value_t *command(int Capture, int Count, ml_value_t **Args) { if (CurrentThread) CurrentThread->Child = Child; pthread_mutex_unlock(InterpreterLock); if (Capture) { - ml_stringbuffer_t Output[1] = {ML_STRINGBUFFER_INIT}; - char Chars[ML_STRINGBUFFER_NODE_SIZE]; + size_t Total = 0; + command_output_t *Head = new(command_output_t), *Current = Head; + size_t Space = ML_STRINGBUFFER_NODE_SIZE; + char *Chars = Current->Chars; for (;;) { - ssize_t Size = read(Pipe[0], Chars, ML_STRINGBUFFER_NODE_SIZE); - if (Size <= 0) break; - //pthread_mutex_lock(GlobalLock); - if (Size > 0) ml_stringbuffer_add(Output, Chars, Size); - //pthread_mutex_unlock(GlobalLock); + ssize_t Count = read(Pipe[0], Chars, Space); + if (Count <= 0) break; + if (Count > 0) { + Total += Count; + Space -= Count; + if (!Space) { + Current = Current->Next = new(command_output_t); + Space = ML_STRINGBUFFER_NODE_SIZE; + Chars = Current->Chars; + } else { + Chars += Count; + } + } + } + Chars = snew(Total + 1); + char *End = Chars; + for (command_output_t *Output = Head; Output != Current; Output = Output->Next) { + memcpy(End, Output->Chars, ML_STRINGBUFFER_NODE_SIZE); + End += ML_STRINGBUFFER_NODE_SIZE; } - Result = ml_stringbuffer_value(Output); + memcpy(End, Current->Chars, ML_STRINGBUFFER_NODE_SIZE - Space); + Chars[Total] = 0; + Result = ml_string(Chars, Total); } else { char Chars[ML_STRINGBUFFER_NODE_SIZE]; for (;;) { - ssize_t Size = read(Pipe[0], Chars, ML_STRINGBUFFER_NODE_SIZE); - if (Size <= 0) break; + ssize_t Count = read(Pipe[0], Chars, ML_STRINGBUFFER_NODE_SIZE); + if (Count <= 0) break; } } close(Pipe[0]); @@ -523,7 +548,7 @@ ML_METHOD(ArgifyMethod, MLListT, MLMapT) { Result = ml_stringbuffer_append(Buffer, Iter->Value); if (ml_is_error(Result)) return Result; } - ml_list_append(Args[0], ml_stringbuffer_value(Buffer)); + ml_list_append(Args[0], ml_stringbuffer_get_value(Buffer)); } return Args[0]; } @@ -644,7 +669,7 @@ ML_FUNCTION(Shellv) { return ml_error("ExecuteError", "process returned non-zero exit code"); } else { size_t Length = Buffer->Length; - ml_value_t *Result = ml_string(ml_stringbuffer_get(Buffer), Length); + ml_value_t *Result = ml_string(ml_stringbuffer_get_string(Buffer), Length); return Result; } } else { @@ -663,7 +688,7 @@ ML_FUNCTION(Mkdir) { ml_value_t *Result = ml_stringbuffer_append(Buffer, Args[I]); if (Result->Type == MLErrorT) return Result; } - char *Path = ml_stringbuffer_get(Buffer); + char *Path = ml_stringbuffer_get_string(Buffer); if (mkdir_p(Path) < 0) { return ml_error("FileError", "error creating directory %s", Path); } @@ -694,7 +719,7 @@ ML_FUNCTION(Open) { ml_stringbuffer_t Buffer[1] = {ML_STRINGBUFFER_INIT}; ml_value_t *Result = ml_stringbuffer_append(Buffer, Args[0]); if (Result->Type == MLErrorT) return Result; - char *FileName = ml_stringbuffer_get(Buffer); + char *FileName = ml_stringbuffer_get_string(Buffer); return ml_simple_inline((ml_value_t *)MLFileOpen, 2, ml_string(FileName, -1), Args[1]); } diff --git a/src/rabs.h b/src/rabs.h index 03d7a26..f90f55d 100644 --- a/src/rabs.h +++ b/src/rabs.h @@ -29,7 +29,7 @@ extern __thread target_t *CurrentTarget; ml_value_t *rabs_global(const char *Name); -#define CURRENT_VERSION 2, 21, 0 +#define CURRENT_VERSION 2, 22, 0 #define MINIMAL_VERSION 2, 10, 0 #endif diff --git a/src/target_expr.c b/src/target_expr.c index 4acc8e8..6ddde94 100644 --- a/src/target_expr.c +++ b/src/target_expr.c @@ -33,17 +33,6 @@ ML_METHOD("append", MLStringBufferT, ExprTargetT) { return ml_stringbuffer_append(Buffer, Target->Value); } -ML_METHOD(MLStringT, ExprTargetT) { -//string -// Converts the value of an expression target to a string, calling its build function first if necessary. - target_expr_t *Target = (target_expr_t *)Args[0]; - target_depends_auto((target_t *)Target); - target_queue((target_t *)Target, CurrentTarget); - target_wait((target_t *)Target, CurrentTarget); - return ml_simple_inline((ml_value_t *)MLStringT, 1, Target->Value); -} - time_t target_expr_hash(target_expr_t *Target, time_t PreviousTime, unsigned char PreviousHash[SHA256_BLOCK_SIZE]) { target_value_hash(Target->Value, Target->Base.Hash); return 0; diff --git a/src/target_file.c b/src/target_file.c index becd952..915b4ed 100644 --- a/src/target_file.c +++ b/src/target_file.c @@ -142,23 +142,6 @@ ML_FUNCTION(File) { return (ml_value_t *)Target; } -ML_METHOD(MLStringT, FileTargetT) { -//string -// Returns the absolute resolved path of :mini:`Target` as a string. - target_file_t *Target = (target_file_t *)Args[0]; - const char *Path; - if (Target->Absolute) { - Path = Target->Path; - } else if (Target->Path[0]) { - Path = vfs_resolve(concat(RootPath, "/", Target->Path, NULL)); - } else { - Path = RootPath; - } - //Path = relative_path(Path, CurrentDirectory); - return ml_string(Path, strlen(Path)); -} - ML_METHOD(ArgifyMethod, MLListT, FileTargetT) { //!internal target_file_t *Target = (target_file_t *)Args[1];