|
6 | 6 | # https://github.com/Softmotions/autark |
7 | 7 |
|
8 | 8 | META_VERSION=0.9.0 |
9 | | -META_REVISION=4a8a474 |
| 9 | +META_REVISION=42084e3 |
10 | 10 | cd "$(cd "$(dirname "$0")"; pwd -P)" |
11 | 11 |
|
12 | 12 | prev_arg="" |
@@ -62,7 +62,7 @@ cat <<'a292effa503b' > ${AUTARK_HOME}/autark.c |
62 | 62 | #ifndef CONFIG_H |
63 | 63 | #define CONFIG_H |
64 | 64 | #define META_VERSION "0.9.0" |
65 | | -#define META_REVISION "4a8a474" |
| 65 | +#define META_REVISION "42084e3" |
66 | 66 | #define MACRO_MAX_RECURSIVE_CALLS 128 |
67 | 67 | #endif |
68 | 68 | #define _AMALGAMATE_ |
@@ -481,6 +481,7 @@ int utils_copy_file(const char *src, const char *dst); |
481 | 481 | int utils_rename_file(const char *src, const char *dst); |
482 | 482 | void utils_split_values_add(const char *v, struct xstr *xstr); |
483 | 483 | int utils_fd_make_non_blocking(int fd); |
| 484 | +int64_t utils_current_time_ms(void); |
484 | 485 | //----------------------- Vlist |
485 | 486 | struct vlist_iter { |
486 | 487 | const char *item; |
@@ -704,13 +705,14 @@ const char* env_libdir(void); |
704 | 705 | #include <limits.h> |
705 | 706 | #include <stdint.h> |
706 | 707 | #endif |
707 | | -#define DEPS_TYPE_FILE 102 // f |
708 | | -#define DEPS_TYPE_FILE_OUTDATED 111 // x |
709 | | -#define DEPS_TYPE_NODE_VALUE 118 // v |
710 | | -#define DEPS_TYPE_ENV 101 // e |
711 | | -#define DEPS_TYPE_SYS_ENV 115 // s |
712 | | -#define DEPS_TYPE_ALIAS 97 // a |
713 | | -#define DEPS_TYPE_OUTDATED 120 // o |
| 708 | +#define DEPS_TYPE_FILE 102 // f |
| 709 | +#define DEPS_TYPE_FILE_OUTDATED 111 // x |
| 710 | +#define DEPS_TYPE_NODE_VALUE 118 // v |
| 711 | +#define DEPS_TYPE_ENV 101 // e |
| 712 | +#define DEPS_TYPE_SYS_ENV 115 // s |
| 713 | +#define DEPS_TYPE_ALIAS 97 // a |
| 714 | +#define DEPS_TYPE_OUTDATED 120 // o |
| 715 | +#define DEPS_TYPE_FILE_NOT_EXISTS 110 // n |
714 | 716 | #define DEPS_OPEN_TRUNCATE 0x01U |
715 | 717 | #define DEPS_OPEN_READONLY 0x02U |
716 | 718 | #define DEPS_BUF_SZ 262144 |
@@ -879,6 +881,7 @@ void node_env_set(struct node*, const char *key, const char *val); |
879 | 881 | void node_env_set_node(struct node*, const char *key, unsigned tag); |
880 | 882 | struct node* node_by_product(struct node*, const char *prod, char pathbuf[PATH_MAX]); |
881 | 883 | struct node* node_by_product_raw(struct node*, const char *prod); |
| 884 | +void node_products_add_as_deps(struct node *n, struct deps *deps); |
882 | 885 | void node_product_add(struct node*, const char *prod, char pathbuf[PATH_MAX]); |
883 | 886 | void node_product_add_raw(struct node*, const char *prod); |
884 | 887 | void node_reset(struct node *n); |
@@ -2011,6 +2014,7 @@ int map_iter_next(struct map_iter *iter) { |
2011 | 2014 | #include <errno.h> |
2012 | 2015 | #include <fcntl.h> |
2013 | 2016 | #include <stdio.h> |
| 2017 | +#include <time.h> |
2014 | 2018 | #endif |
2015 | 2019 | struct value utils_file_as_buf(const char *path, ssize_t buflen_max) { |
2016 | 2020 | struct value ret = { 0 }; |
@@ -2190,6 +2194,19 @@ int utils_fd_make_non_blocking(int fd) { |
2190 | 2194 | } |
2191 | 2195 | return 0; |
2192 | 2196 | } |
| 2197 | +int64_t utils_current_time_ms(void) { |
| 2198 | + struct timespec ts; |
| 2199 | +#if defined(CLOCK_REALTIME) |
| 2200 | + if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { |
| 2201 | + akfatal(errno, "", 0); |
| 2202 | + } |
| 2203 | +#else |
| 2204 | + struct timeval tv; |
| 2205 | + gettimeofday(&tv, NULL); |
| 2206 | + return (int64_t) tv.tv_sec * 1000 + tv.tv_usec / 1000; |
| 2207 | +#endif |
| 2208 | + return (int64_t) ts.tv_sec * 1000 + ts.tv_nsec / 1000000; |
| 2209 | +} |
2193 | 2210 | #ifndef _AMALGAMATE_ |
2194 | 2211 | #include "paths.h" |
2195 | 2212 | #include "xstr.h" |
@@ -3095,6 +3112,13 @@ bool deps_cur_is_outdated(struct node *n, struct deps *d) { |
3095 | 3112 | } |
3096 | 3113 | return strcmp(val, d->resource) != 0; |
3097 | 3114 | } |
| 3115 | + case DEPS_TYPE_FILE_NOT_EXISTS: { |
| 3116 | + struct akpath_stat st; |
| 3117 | + if (path_stat(d->resource, &st) || st.ftype == AKPATH_NOT_EXISTS) { |
| 3118 | + return true; |
| 3119 | + } |
| 3120 | + break; |
| 3121 | + } |
3098 | 3122 | case DEPS_TYPE_OUTDATED: |
3099 | 3123 | return true; |
3100 | 3124 | } |
@@ -3134,6 +3158,10 @@ static int _deps_add(struct deps *d, char type, char flags, const char *resource |
3134 | 3158 | path_normalize(resource, buf[0]); |
3135 | 3159 | resource = buf[0]; |
3136 | 3160 | serial = 0; |
| 3161 | + } else if (type == DEPS_TYPE_FILE_NOT_EXISTS) { |
| 3162 | + path_normalize(resource, buf[0]); |
| 3163 | + resource = buf[0]; |
| 3164 | + serial = 0; |
3137 | 3165 | } |
3138 | 3166 | long int off = ftell(d->file); |
3139 | 3167 | if (off < 0) { |
@@ -4124,6 +4152,7 @@ static void _run_on_resolve(struct node_resolve *r) { |
4124 | 4152 | const char *path = *(const char**) ulist_get(&ctx->consumes_foreach, i); |
4125 | 4153 | deps_add(&deps, DEPS_TYPE_FILE, 'f', path, 0); |
4126 | 4154 | } |
| 4155 | + node_products_add_as_deps(n, &deps); |
4127 | 4156 | deps_close(&deps); |
4128 | 4157 | } |
4129 | 4158 | static bool _run_setup_foreach(struct node *n) { |
@@ -4459,6 +4488,7 @@ static void _configure_on_resolve(struct node_resolve *r) { |
4459 | 4488 | char *src = *(char**) ulist_get(&ctx->sources, i); |
4460 | 4489 | deps_add(&deps, DEPS_TYPE_FILE, 's', src, 0); |
4461 | 4490 | } |
| 4491 | + node_products_add_as_deps(n, &deps); |
4462 | 4492 | deps_close(&deps); |
4463 | 4493 | ulist_destroy_keep(&rlist); |
4464 | 4494 | } |
@@ -8226,6 +8256,17 @@ struct node* node_by_product_raw(struct node *n, const char *prod) { |
8226 | 8256 | struct sctx *s = n->ctx; |
8227 | 8257 | return map_get(s->products, prod); |
8228 | 8258 | } |
| 8259 | +void node_products_add_as_deps(struct node *n, struct deps *deps) { |
| 8260 | + struct map_iter it; |
| 8261 | + struct sctx *s = n->ctx; |
| 8262 | + map_iter_init(s->products, &it); |
| 8263 | + int64_t ts = utils_current_time_ms(); |
| 8264 | + while (map_iter_next(&it)) { |
| 8265 | + if (it.val == n) { |
| 8266 | + deps_add(deps, DEPS_TYPE_FILE, 0, it.key, ts); |
| 8267 | + } |
| 8268 | + } |
| 8269 | +} |
8229 | 8270 | struct node* node_find_direct_child(struct node *n, int type, const char *val) { |
8230 | 8271 | if (n) { |
8231 | 8272 | for (struct node *nn = n->child; nn; nn = nn->next) { |
|
0 commit comments