Skip to content

Commit 74c76ad

Browse files
committed
* set-force
1 parent abe2739 commit 74c76ad

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

dist/autark.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define CONFIG_H
33

44
#define META_VERSION "0.9.0"
5-
#define META_REVISION "e899b5a"
5+
#define META_REVISION "abe2739"
66

77
#endif
88
#define _AMALGAMATE_
@@ -3839,7 +3839,12 @@ static struct unit* _unit_for_set(struct node *n, struct node *nn, const char **
38393839
return unit_peek();
38403840
}
38413841

3842+
static void _set_init(struct node *n);
3843+
38423844
static void _set_setup(struct node *n) {
3845+
if (!n->init) {
3846+
_set_init(n);
3847+
}
38433848
if (n->child && strcmp(n->value, "env") == 0) {
38443849
const char *v = _set_value_get(n);
38453850
if (v) {
@@ -3869,14 +3874,18 @@ static void _set_init(struct node *n) {
38693874
unit_env_set_node(unit, key, n);
38703875
}
38713876

3877+
static bool _set_is_force(struct node *n) {
3878+
return strcmp(n->value, "set-force") == 0;
3879+
}
3880+
38723881
static const char* _set_value_get(struct node *n) {
38733882
if (n->recur_next.active && n->recur_next.n) {
38743883
return _set_value_get(n->recur_next.n);
38753884
}
38763885
n->recur_next.active = true;
38773886

38783887
struct node_foreach *fe = node_find_parent_foreach(n);
3879-
if (fe) {
3888+
if (fe || _set_is_force(n)) {
38803889
if ((uintptr_t) n->impl != (uintptr_t) -1) {
38813890
free(n->impl);
38823891
}
@@ -3935,12 +3944,19 @@ static void _set_dispose(struct node *n) {
39353944
n->impl = 0;
39363945
}
39373946

3947+
static void _set_build(struct node *n) {
3948+
_set_init(n);
3949+
}
3950+
39383951
int node_set_setup(struct node *n) {
39393952
n->flags |= NODE_FLG_NO_CWD;
39403953
n->init = _set_init;
39413954
n->setup = _set_setup;
39423955
n->value_get = _set_value_get;
39433956
n->dispose = _set_dispose;
3957+
if (_set_is_force(n)) {
3958+
n->build = _set_build;
3959+
}
39443960
return 0;
39453961
}
39463962
#ifndef _AMALGAMATE_
@@ -8304,7 +8320,7 @@ static unsigned _rule_type(const char *key, unsigned *flags) {
83048320
return NODE_TYPE_SUBST;
83058321
} else if (strcmp(key, "^") == 0) {
83068322
return NODE_TYPE_JOIN;
8307-
} else if (strcmp(key, "set") == 0 || strcmp(key, "env") == 0) {
8323+
} else if (strcmp(key, "set") == 0 || strcmp(key, "env") == 0 || strcmp(key, "set-force") == 0) {
83088324
return NODE_TYPE_SET;
83098325
} else if (strcmp(key, "check") == 0) {
83108326
return NODE_TYPE_CHECK;

dist/build.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# https://github.com/Softmotions/autark
77

88
META_VERSION=0.9.0
9-
META_REVISION=e899b5a
9+
META_REVISION=abe2739
1010
cd "$(cd "$(dirname "$0")"; pwd -P)"
1111

1212
prev_arg=""
@@ -62,7 +62,7 @@ cat <<'a292effa503b' > ${AUTARK_HOME}/autark.c
6262
#ifndef CONFIG_H
6363
#define CONFIG_H
6464
#define META_VERSION "0.9.0"
65-
#define META_REVISION "e899b5a"
65+
#define META_REVISION "abe2739"
6666
#endif
6767
#define _AMALGAMATE_
6868
#define _XOPEN_SOURCE 700
@@ -3298,7 +3298,11 @@ static struct unit* _unit_for_set(struct node *n, struct node *nn, const char **
32983298
}
32993299
return unit_peek();
33003300
}
3301+
static void _set_init(struct node *n);
33013302
static void _set_setup(struct node *n) {
3303+
if (!n->init) {
3304+
_set_init(n);
3305+
}
33023306
if (n->child && strcmp(n->value, "env") == 0) {
33033307
const char *v = _set_value_get(n);
33043308
if (v) {
@@ -3326,13 +3330,16 @@ static void _set_init(struct node *n) {
33263330
}
33273331
unit_env_set_node(unit, key, n);
33283332
}
3333+
static bool _set_is_force(struct node *n) {
3334+
return strcmp(n->value, "set-force") == 0;
3335+
}
33293336
static const char* _set_value_get(struct node *n) {
33303337
if (n->recur_next.active && n->recur_next.n) {
33313338
return _set_value_get(n->recur_next.n);
33323339
}
33333340
n->recur_next.active = true;
33343341
struct node_foreach *fe = node_find_parent_foreach(n);
3335-
if (fe) {
3342+
if (fe || _set_is_force(n)) {
33363343
if ((uintptr_t) n->impl != (uintptr_t) -1) {
33373344
free(n->impl);
33383345
}
@@ -3383,12 +3390,18 @@ static void _set_dispose(struct node *n) {
33833390
}
33843391
n->impl = 0;
33853392
}
3393+
static void _set_build(struct node *n) {
3394+
_set_init(n);
3395+
}
33863396
int node_set_setup(struct node *n) {
33873397
n->flags |= NODE_FLG_NO_CWD;
33883398
n->init = _set_init;
33893399
n->setup = _set_setup;
33903400
n->value_get = _set_value_get;
33913401
n->dispose = _set_dispose;
3402+
if (_set_is_force(n)) {
3403+
n->build = _set_build;
3404+
}
33923405
return 0;
33933406
}
33943407
#ifndef _AMALGAMATE_
@@ -7320,7 +7333,7 @@ static unsigned _rule_type(const char *key, unsigned *flags) {
73207333
return NODE_TYPE_SUBST;
73217334
} else if (strcmp(key, "^") == 0) {
73227335
return NODE_TYPE_JOIN;
7323-
} else if (strcmp(key, "set") == 0 || strcmp(key, "env") == 0) {
7336+
} else if (strcmp(key, "set") == 0 || strcmp(key, "env") == 0 || strcmp(key, "set-force") == 0) {
73247337
return NODE_TYPE_SET;
73257338
} else if (strcmp(key, "check") == 0) {
73267339
return NODE_TYPE_CHECK;

0 commit comments

Comments
 (0)