Skip to content

Commit

Permalink
Merge pull request #168 from wrapl/dev
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
rajamukherji authored Nov 6, 2021
2 parents 49513e8 + 98a44a2 commit ab080c9
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 64 deletions.
5 changes: 3 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rabs (2.21.0) UNRELEASED; urgency=medium
rabs (2.22.0) UNRELEASED; urgency=medium

* Updates.
* Updates.
Expand Down Expand Up @@ -29,5 +29,6 @@ rabs (2.21.0) UNRELEASED; urgency=medium
* Updates.
* Updates.
* Updates.
* Updates.

-- Raja Mukherji <raja@localhost.localdomain> Wed, 27 Oct 2021 09:28:17 +0100
-- Raja Mukherji <raja@localhost.localdomain> Sat, 06 Nov 2021 10:04:58 +0000
11 changes: 3 additions & 8 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -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
--------
Expand Down
4 changes: 0 additions & 4 deletions docs/library/expr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
4 changes: 0 additions & 4 deletions docs/library/file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion minilang
Submodule minilang updated 59 files
+6 −1 docs/_static/css/custom.css
+2 −14 docs/conf.py
+3 −1 docs/docutils.conf
+1 −1 docs/library/address.rst
+3 −3 docs/library/boolean.rst
+1 −1 docs/library/bytecode.rst
+2 −2 docs/library/compiler.rst
+3 −0 docs/library/file.rst
+7 −6 docs/library/general.rst
+3 −3 docs/library/gir.rst
+0 −8 docs/library/list.rst
+4 −8 docs/library/map.rst
+0 −3 docs/library/method.rst
+1 −1 docs/library/module.rst
+7 −7 docs/library/number.rst
+2 −5 docs/library/object.rst
+11 −10 docs/library/string.rst
+2 −2 docs/library/table.rst
+4 −4 docs/library/time.rst
+0 −4 docs/library/tuple.rst
+2 −7 docs/library/type.rst
+0 −3 docs/library/uuid.rst
+42 −6 docs/library/xe.rst
+1 −1 docs/library/xml.rst
+2 −2 docs/readthedocs.yaml
+1 −0 docs/requirements.txt
+1 −2 editor.mini
+7 −0 src/build.rabs
+1 −1 src/document.mini
+1 −1 src/gtk_console.c
+16 −16 src/lib/ml_kiwi.cpp
+7 −5 src/lib/ml_onion.c
+4 −4 src/lib/ml_ravs.c
+1 −1 src/lib/ml_zlog.c
+18 −0 src/minilang.c
+65 −92 src/minixe.c
+17 −28 src/ml_array.c
+61 −59 src/ml_bytecode.c
+16 −15 src/ml_compiler.c
+20 −5 src/ml_file.c
+19 −13 src/ml_gir.c
+2 −2 src/ml_json.c
+4 −46 src/ml_list.c
+43 −61 src/ml_map.c
+6 −9 src/ml_method.c
+17 −22 src/ml_object.c
+4 −4 src/ml_runtime.c
+3 −3 src/ml_sequence.c
+174 −115 src/ml_string.c
+15 −15 src/ml_table.c
+33 −25 src/ml_time.c
+23 −50 src/ml_types.c
+19 −7 src/ml_types.h
+1 −8 src/ml_uuid.c
+448 −0 src/ml_xe.c
+8 −0 src/ml_xe.h
+21 −21 src/ml_xml.c
+2 −2 src/test/test1.pp
+2 −2 src/test/test10.mini
57 changes: 41 additions & 16 deletions src/rabs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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};
Expand All @@ -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);
Expand All @@ -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]);
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/rabs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 0 additions & 11 deletions src/target_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ ML_METHOD("append", MLStringBufferT, ExprTargetT) {
return ml_stringbuffer_append(Buffer, Target->Value);
}

ML_METHOD(MLStringT, ExprTargetT) {
//<Target
//>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;
Expand Down
17 changes: 0 additions & 17 deletions src/target_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,6 @@ ML_FUNCTION(File) {
return (ml_value_t *)Target;
}

ML_METHOD(MLStringT, FileTargetT) {
//<Target
//>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];
Expand Down

0 comments on commit ab080c9

Please sign in to comment.