Skip to content

Commit

Permalink
Merge pull request #61 from wrapl/dev
Browse files Browse the repository at this point in the history
Updates.
  • Loading branch information
rajamukherji authored May 2, 2019
2 parents 7d7faeb + 5cb6208 commit af66b85
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion minilang
2 changes: 1 addition & 1 deletion rabs.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <sys/wait.h>
#endif

#define VERSION_STRING "1.9.1"
#define VERSION_STRING "1.9.2"

const char *SystemName = "build.rabs";
const char *RootPath = 0;
Expand Down
35 changes: 16 additions & 19 deletions target.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ static time_t target_file_hash(target_file_t *Target, time_t PreviousTime, unsig
if (stat(FileName, Stat)) {
printf("\e[31mWarning: rule failed to build: %s\e[0m\n", FileName);
pthread_mutex_lock(InterpreterLock);
return 0;
memcpy(Target->Hash, PreviousHash, SHA256_BLOCK_SIZE);
return PreviousTime;
}
if (Stat->st_mtime == PreviousTime) {
memcpy(Target->Hash, PreviousHash, SHA256_BLOCK_SIZE);
Expand Down Expand Up @@ -1029,20 +1030,6 @@ target_t *target_find(const char *Id) {
target_expr_t *Target = target_new(target_expr_t, ExprTargetT, Id, Slot);
return (target_t *)Target;
}
if (!memcmp(Id, "scan*:", 6)) {
target_scan_t *Target = target_new(target_scan_t, ScanTargetT, Id, Slot);
const char *Name;
for (Name = Id + strlen(Id) - 1; --Name > Id + 6;) {
if (Name[0] == ':' && Name[1] == ':') break;
}
size_t ParentIdLength = Name - Id - 6;
char *ParentId = snew(ParentIdLength + 1);
memcpy(ParentId, Id + 6, ParentIdLength);
ParentId[ParentIdLength] = 0;
Target->Source = target_find(ParentId);
Target->Name = Name + 2;
return (target_t *)Target;
}
if (!memcmp(Id, "scan:", 5)) {
target_scan_t *Target = target_new(target_scan_t, ScanTargetT, Id, Slot);
const char *Name;
Expand Down Expand Up @@ -1124,6 +1111,9 @@ int target_affect(target_t *Target, target_t *Depend) {
static int target_depends_fn(target_t *Depend, int *DependsLastUpdated) {
//printf("\e[34m%s version = %d\e[0m\n", Depend->Id, Depend->LastUpdated);
if (Depend->LastUpdated > *DependsLastUpdated) *DependsLastUpdated = Depend->LastUpdated;
if (Depend->LastUpdated == CurrentVersion) {
if (StatusUpdates) printf("\tUpdating due to \e[32m%s\e[0m\n", Depend->Id);
}
return 0;
}

Expand Down Expand Up @@ -1162,6 +1152,11 @@ int target_find_leaves(target_t *Target, targetset_t *Leaves) {
return 0;
}

int target_insert(target_t *Target, targetset_t *Set) {
targetset_insert(Set, Target);
return 0;
}

int target_set_parent(target_t *Target, target_t *Parent) {
if (!Target->Parent) Target->Parent = Parent;
return 0;
Expand Down Expand Up @@ -1270,16 +1265,18 @@ void target_update(target_t *Target) {
((target_expr_t *)Target)->Value = Result;
cache_expr_set(Target, Result);
} else if (Target->Type == ScanTargetT) {
targetset_t Roots[1] = {TARGETSET_INIT};
targetset_init(Roots, ml_list_length(Result));
ml_list_foreach(Result, Roots, (void *)build_scan_target_list);
targetset_t Scans[1] = {TARGETSET_INIT};
targetset_init(Scans, ml_list_length(Result));
ml_list_foreach(Result, Scans, (void *)build_scan_target_list);
targetset_foreach(Roots, Scans, (void *)target_insert);
targetset_foreach(Roots, Scans, (void *)target_find_leaves);
cache_scan_set(Target, Scans);
if (DependencyGraph) {
targetset_foreach(Scans, Target, (void *)target_graph_dependencies);
}
targetset_foreach(Scans, 0, (void *)target_queue);
targetset_foreach(Scans, Target, (void *)target_wait);
targetset_foreach(Scans, Target->BuildDepends, (void *)target_find_leaves);

//printf("scans(%s) = \n", Target->Id);
//targetset_foreach(Scans, 0, targetset_print);
Expand All @@ -1300,8 +1297,8 @@ void target_update(target_t *Target) {
if (DependencyGraph) {
targetset_foreach(Scans, Target, (void *)target_graph_dependencies);
}
targetset_foreach(Scans, Target, (void *)target_queue);
targetset_foreach(Scans, Target, (void *)target_set_parent);
targetset_foreach(Scans, Target, (void *)target_queue);
targetset_foreach(Scans, Target, (void *)target_wait);

//printf("scans(%s) = \n", Target->Id);
Expand Down
3 changes: 2 additions & 1 deletion test/common.rabs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ DEBUG := defined("DEBUG")

CFLAGS := []
LDFLAGS := []
PREBUILDS := []

c_compile := fun(Source, Object) do
execute('gcc -c {CFLAGS} -o{Object} {Source}')
Expand Down Expand Up @@ -33,7 +34,7 @@ c_program := fun(Executable, Objects, Libraries) do
var Source := Object % Extension
if Source:exists then
Sources:put(Source)
var Scan := Source:scan("INCLUDES") => Functions[1]
var Scan := Source:scan("INCLUDES")[PREBUILDS] => Functions[1]
Object[Source, Scan] => (Functions[2] !! [Source])
exit
end
Expand Down
4 changes: 4 additions & 0 deletions test/src/build.rabs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
EXTERNALS := old or subdir("externals")

var pkgconfig := fun(Args) expr(Args) => fun() Args

TEST := defined("TEST")
Expand Down Expand Up @@ -26,6 +28,8 @@ end
var TestCflags := expr("TestCflags")[Config, "TEST"] => fun() shell(Config):trim

CFLAGS := old + [TestCflags, pkgconfig("-march=native")]
LDFLAGS := old + ["-lminilang"]
PREBUILDS := old + [EXTERNALS."MINILANG"]

c_program(file("test"), [file("test.o"), file("test2.o")])

Expand Down
12 changes: 12 additions & 0 deletions test/src/externals/build.rabs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
context():parent."CFLAGS" := old + ['-I{PATH/"include"}']
context():parent."LDFLAGS" := old + ['-L{PATH/"lib"}']

MINILANG_VERSION := old or "1.2.0"

MINILANG := meta("minilang"):scan("install") => fun() do
file("minilang"):rmdir:mkdir:chdir
execute('wget https://github.com/wrapl/minilang/archive/v{MINILANG_VERSION}.tar.gz -O- | tar xzP --strip-components=1')
execute('make -j4')
execute('make install PREFIX={PATH}')
ret [PATH / "lib/libminilang.a"]
end

0 comments on commit af66b85

Please sign in to comment.