From 20255c536acebd516a73947e5238ab6e2420f32b Mon Sep 17 00:00:00 2001 From: dixyes Date: Tue, 8 Feb 2022 15:41:59 +0800 Subject: [PATCH 01/22] Adopt removal of ZEND_TYPE_HAS_CLASS from php/php-src@069a9fa5e4478c7044cb6432258cfe207d10a202 --- src/check.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/check.c b/src/check.c index df656509..5a878797 100644 --- a/src/check.c +++ b/src/check.c @@ -27,6 +27,10 @@ TSRM_TLS struct { HashTable classes; } php_parallel_check_globals; +#ifdef ZEND_TYPE_IS_COMPLEX +#define ZEND_TYPE_HAS_CLASS ZEND_TYPE_IS_COMPLEX +#endif + #define PCG(e) php_parallel_check_globals.e typedef struct _php_parallel_check_task_t { @@ -159,7 +163,6 @@ static zend_always_inline zend_bool php_parallel_check_arginfo(const zend_functi if (function->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { it = function->op_array.arg_info - 1; - if (ZEND_TYPE_IS_SET(it->type) && ZEND_TYPE_HAS_CLASS(it->type)) { if (!php_parallel_check_type(it->type)) { php_parallel_exception_ex( From 192dd10e45f95537d23d4828c7ea6d88b7aaf983 Mon Sep 17 00:00:00 2001 From: dixyes Date: Tue, 8 Feb 2022 15:49:32 +0800 Subject: [PATCH 02/22] Adopt removal of ZEND_TYPE_HAS_CE/ZEND_TYPE_CE from php/php-src@315f40942b1db9ae3451bdb82e34b48ad5f565fe --- src/check.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/check.c b/src/check.c index 5a878797..7ae5fec4 100644 --- a/src/check.c +++ b/src/check.c @@ -560,10 +560,12 @@ static zend_always_inline php_parallel_check_class_result_t php_parallel_check_c zend_type *single; ZEND_TYPE_FOREACH(info->type, single) { - +#ifdef ZEND_TYPE_HAS_CE if (ZEND_TYPE_HAS_CE(*single)) { next = ZEND_TYPE_CE(*single); - } else if (ZEND_TYPE_HAS_NAME(*single)) { + } else +#endif + if (ZEND_TYPE_HAS_NAME(*single)) { next = zend_lookup_class(ZEND_TYPE_NAME(*single)); } else { continue; @@ -611,9 +613,12 @@ static zend_always_inline php_parallel_check_class_result_t php_parallel_check_c } ZEND_TYPE_FOREACH_END(); } else { +#ifdef ZEND_TYPE_HAS_CE if (ZEND_TYPE_HAS_CE(info->type)) { next = ZEND_TYPE_CE(info->type); - } else { + } else +#endif + { next = zend_lookup_class( ZEND_TYPE_NAME(info->type)); } From dfa6ca54a0a50abef2934856dd2a27b65f9275ff Mon Sep 17 00:00:00 2001 From: dixyes Date: Tue, 8 Feb 2022 15:58:20 +0800 Subject: [PATCH 03/22] Adopt PHP8.1 arginfo for Events::count --- src/events.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/events.c b/src/events.c index ceb25523..0ccc6894 100644 --- a/src/events.c +++ b/src/events.c @@ -230,6 +230,8 @@ PHP_METHOD(Events, poll) php_parallel_events_poll(events, return_value); } +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(php_parallel_events_count_arginfo, IS_LONG, 0) +ZEND_END_ARG_INFO() PHP_METHOD(Events, count) { php_parallel_events_t *events = php_parallel_events_from(getThis()); @@ -247,7 +249,7 @@ zend_function_entry php_parallel_events_methods[] = { PHP_ME(Events, setBlocking, php_parallel_events_set_blocking_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Events, setTimeout, php_parallel_events_set_timeout_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Events, poll, php_parallel_events_poll_arginfo, ZEND_ACC_PUBLIC) - PHP_ME(Events, count, php_parallel_no_args_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(Events, count, php_parallel_events_count_arginfo, ZEND_ACC_PUBLIC) PHP_FE_END }; From b5e70c2d0c60a2d43ae18c02b6aa12e86bf763ac Mon Sep 17 00:00:00 2001 From: dixyes Date: Mon, 21 Mar 2022 11:46:53 +0800 Subject: [PATCH 04/22] Use ZEND_TYPE_IS_COMPLEX instead --- src/check.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/check.c b/src/check.c index 7ae5fec4..80df59aa 100644 --- a/src/check.c +++ b/src/check.c @@ -27,8 +27,8 @@ TSRM_TLS struct { HashTable classes; } php_parallel_check_globals; -#ifdef ZEND_TYPE_IS_COMPLEX -#define ZEND_TYPE_HAS_CLASS ZEND_TYPE_IS_COMPLEX +#ifndef ZEND_TYPE_IS_COMPLEX +#define ZEND_TYPE_IS_COMPLEX ZEND_TYPE_HAS_CLASS #endif #define PCG(e) php_parallel_check_globals.e @@ -163,7 +163,7 @@ static zend_always_inline zend_bool php_parallel_check_arginfo(const zend_functi if (function->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { it = function->op_array.arg_info - 1; - if (ZEND_TYPE_IS_SET(it->type) && ZEND_TYPE_HAS_CLASS(it->type)) { + if (ZEND_TYPE_IS_SET(it->type) && ZEND_TYPE_IS_COMPLEX(it->type)) { if (!php_parallel_check_type(it->type)) { php_parallel_exception_ex( php_parallel_runtime_error_illegal_return_ce, @@ -189,7 +189,7 @@ static zend_always_inline zend_bool php_parallel_check_arginfo(const zend_functi } while (it < end) { - if (ZEND_TYPE_IS_SET(it->type) && ZEND_TYPE_HAS_CLASS(it->type)) { + if (ZEND_TYPE_IS_SET(it->type) && ZEND_TYPE_IS_COMPLEX(it->type)) { if (!php_parallel_check_type(it->type)) { php_parallel_exception_ex( php_parallel_runtime_error_illegal_parameter_ce, @@ -552,7 +552,7 @@ static zend_always_inline php_parallel_check_class_result_t php_parallel_check_c goto _php_parallel_checked_class; } - if (!ZEND_TYPE_IS_SET(info->type) || !ZEND_TYPE_HAS_CLASS(info->type)) { + if (!ZEND_TYPE_IS_SET(info->type) || !ZEND_TYPE_IS_COMPLEX(info->type)) { continue; } From b7592989c0c6b052c0d2fd765ec08df01490169a Mon Sep 17 00:00:00 2001 From: dixyes Date: Mon, 21 Mar 2022 11:49:33 +0800 Subject: [PATCH 05/22] Use tentative return info for backward compatibility --- src/events.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/events.c b/src/events.c index 0ccc6894..e9f9fb06 100644 --- a/src/events.c +++ b/src/events.c @@ -230,8 +230,13 @@ PHP_METHOD(Events, poll) php_parallel_events_poll(events, return_value); } +#ifdef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(php_parallel_events_count_arginfo, 0, 0, IS_LONG, 0) +#else ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(php_parallel_events_count_arginfo, IS_LONG, 0) +#endif ZEND_END_ARG_INFO() + PHP_METHOD(Events, count) { php_parallel_events_t *events = php_parallel_events_from(getThis()); From 18158de3f469ffb431cb5fa90fe22663d3106135 Mon Sep 17 00:00:00 2001 From: dixyes Date: Fri, 11 Mar 2022 11:55:41 +0800 Subject: [PATCH 06/22] Adopt zend_op_array.static_variables change from php/php-src@ddaf64b56c88f0ae223b1aca25293dd7fec77fc0 --- src/cache.c | 10 ++++++++++ src/copy.c | 4 ++++ src/scheduler.c | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/cache.c b/src/cache.c index de0e3b45..ace9e00e 100644 --- a/src/cache.c +++ b/src/cache.c @@ -149,7 +149,11 @@ static zend_op_array* php_parallel_cache_create(const zend_function *source, zen php_parallel_cache_statics(cached->static_variables); } +#if PHP_VERSION_ID >= 80200 + ZEND_MAP_PTR_INIT(cached->static_variables_ptr, cached->static_variables); +#else ZEND_MAP_PTR_INIT(cached->static_variables_ptr, &cached->static_variables); +#endif ZEND_MAP_PTR_SET(cached->run_time_cache, NULL); #if PHP_VERSION_ID >= 80100 @@ -386,9 +390,15 @@ zend_function* php_parallel_cache_closure(const zend_function *source, zend_func closure->op_array.static_variables = php_parallel_copy_hash_ctor(statics, 1); +#if PHP_VERSION_ID >= 80200 + ZEND_MAP_PTR_INIT( + closure->op_array.static_variables_ptr, + closure->op_array.static_variables); +#else ZEND_MAP_PTR_INIT( closure->op_array.static_variables_ptr, &closure->op_array.static_variables); +#endif } ZEND_MAP_PTR_NEW(closure->op_array.run_time_cache); diff --git a/src/copy.c b/src/copy.c index ed9983b7..60a0a4c0 100644 --- a/src/copy.c +++ b/src/copy.c @@ -423,7 +423,11 @@ static zend_always_inline zend_object* php_parallel_copy_closure_thread(zend_obj php_parallel_copy_hash_ctor(function->static_variables, 0); } +#if PHP_VERSION_ID >= 80200 + ZEND_MAP_PTR_INIT(function->static_variables_ptr, function->static_variables); +#else ZEND_MAP_PTR_INIT(function->static_variables_ptr, &function->static_variables); +#endif php_parallel_copy_closure_init_run_time_cache(function); diff --git a/src/scheduler.c b/src/scheduler.c index 1a9a0ca8..e0053f76 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -220,10 +220,15 @@ static zend_always_inline zend_bool php_parallel_scheduler_pop(php_parallel_runt el->frame->func->op_array.static_variables = php_parallel_copy_hash_ctor(statics, 0); - +#if PHP_VERSION_ID >= 80200 + ZEND_MAP_PTR_INIT( + el->frame->func->op_array.static_variables_ptr, + el->frame->func->op_array.static_variables); +#else ZEND_MAP_PTR_INIT( el->frame->func->op_array.static_variables_ptr, &el->frame->func->op_array.static_variables); +#endif php_parallel_copy_hash_dtor(statics, 1); } From e1362a36561dba29e69231dd65f0956428f2a61c Mon Sep 17 00:00:00 2001 From: dixyes Date: Fri, 11 Mar 2022 17:25:32 +0800 Subject: [PATCH 07/22] Adopt HT_PACKED changes on hashtable from php/php-src@90b7bde61507cee1c6b37f153909d72f5b203b8c --- src/copy.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/src/copy.c b/src/copy.c index 60a0a4c0..bba7d522 100644 --- a/src/copy.c +++ b/src/copy.c @@ -184,7 +184,7 @@ static zend_always_inline HashTable* php_parallel_copy_hash_persistent_inline( ht->u.flags |= HASH_FLAG_STATIC_KEYS; if (ht->nNumUsed == 0) { - ht->u.flags = HASH_FLAG_UNINITIALIZED; + ht->u.flags = HASH_FLAG_UNINITIALIZED; ht->nNextFreeElement = 0; ht->nTableMask = HT_MIN_MASK; HT_SET_DATA_ADDR(ht, &php_parallel_copy_uninitialized_bucket); @@ -195,6 +195,28 @@ static zend_always_inline HashTable* php_parallel_copy_hash_persistent_inline( ht->nInternalPointer = 0; HT_SET_DATA_ADDR(ht, php_parallel_copy_memory_func(HT_GET_DATA_ADDR(ht), HT_USED_SIZE(ht))); + +#ifdef HT_PACKED_SIZE + // if array is packed, copy it as packed + if (HT_IS_PACKED(ht)) { + for (idx = 0; idx < ht->nNumUsed; idx++) { + zval *zv = ht->arPacked + idx; + + if (Z_TYPE_P(zv) == IS_UNDEF) + continue; + + if (Z_OPT_REFCOUNTED_P(zv)) { + php_parallel_copy_zval_persistent( + zv, + zv, + php_parallel_copy_string_func, + php_parallel_copy_memory_func); + } + } + ht->nNextFreeElement = ht->nNumUsed; + return ht; + } +#endif for (idx = 0; idx < ht->nNumUsed; idx++) { Bucket *p = ht->arData + idx; @@ -240,7 +262,19 @@ static zend_always_inline HashTable* php_parallel_copy_hash_thread(HashTable *so HT_GET_DATA_ADDR(ht), HT_GET_DATA_ADDR(source), HT_HASH_SIZE(ht->nTableMask)); - +#ifdef HT_PACKED_SIZE + if (HT_IS_PACKED(ht)) { + zval *p = ht->arPacked, + *q = source->arPacked, + *p_end = p + ht->nNumUsed; + for (; p < p_end; p++, q++) { + *p = *q; + if (Z_OPT_REFCOUNTED_P(p)) { + PARALLEL_ZVAL_COPY(p, q, 0); + } + } + } else +#endif if (ht->u.flags & HASH_FLAG_STATIC_KEYS) { Bucket *p = ht->arData, *q = source->arData, @@ -306,9 +340,6 @@ HashTable *php_parallel_copy_hash_persistent(HashTable *source, void php_parallel_copy_hash_dtor(HashTable *table, zend_bool persistent) { if (GC_DELREF(table) == (persistent ? 1 : 0)) { - Bucket *p = table->arData, - *end = p + table->nNumUsed; - if (!persistent) { GC_REMOVE_FROM_BUFFER(table); GC_TYPE_INFO(table) = @@ -319,7 +350,21 @@ void php_parallel_copy_hash_dtor(HashTable *table, zend_bool persistent) { #endif } +#ifdef HT_PACKED_SIZE + if (HT_IS_PACKED(table)){ + zval *p = table->arPacked, + *end = p + table->nNumUsed; + while (p < end) { + if (Z_OPT_REFCOUNTED_P(p)) { + PARALLEL_ZVAL_DTOR(p); + } + p++; + } + } else +#endif if (HT_HAS_STATIC_KEYS_ONLY(table)) { + Bucket *p = table->arData, + *end = p + table->nNumUsed; while (p < end) { if (Z_OPT_REFCOUNTED(p->val)) { PARALLEL_ZVAL_DTOR(&p->val); @@ -327,6 +372,8 @@ void php_parallel_copy_hash_dtor(HashTable *table, zend_bool persistent) { p++; } } else { + Bucket *p = table->arData, + *end = p + table->nNumUsed; while (p < end) { if (Z_ISUNDEF(p->val)) { p++; From cb0d82613400233cb1c912662d2a403be702f200 Mon Sep 17 00:00:00 2001 From: dixyes Date: Fri, 11 Mar 2022 11:54:37 +0800 Subject: [PATCH 08/22] Add arginfo for Channel::__toString --- src/channel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/channel.c b/src/channel.c index fc89a763..6dc68e75 100644 --- a/src/channel.c +++ b/src/channel.c @@ -271,6 +271,9 @@ PHP_METHOD(Channel, close) php_parallel_monitor_unlock(php_parallel_channels.monitor); } +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_channel___toString_arginfo, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + PHP_METHOD(Channel, __toString) { php_parallel_channel_t *channel = @@ -286,7 +289,7 @@ zend_function_entry php_parallel_channel_methods[] = { PHP_ME(Channel, send, php_parallel_channel_send_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Channel, recv, php_parallel_channel_recv_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Channel, close, php_parallel_channel_close_arginfo, ZEND_ACC_PUBLIC) - PHP_ME(Channel, __toString, php_parallel_no_args_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(Channel, __toString, php_parallel_channel___toString_arginfo, ZEND_ACC_PUBLIC) PHP_FE_END }; From 5c6a0b20961e078d00c07c3abca520c177630917 Mon Sep 17 00:00:00 2001 From: dixyes Date: Mon, 21 Mar 2022 12:01:44 +0800 Subject: [PATCH 09/22] Use tentative return info for backward compatibility --- src/channel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/channel.c b/src/channel.c index 6dc68e75..2d9a81d2 100644 --- a/src/channel.c +++ b/src/channel.c @@ -271,7 +271,11 @@ PHP_METHOD(Channel, close) php_parallel_monitor_unlock(php_parallel_channels.monitor); } +#ifdef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(php_parallel_channel___toString_arginfo, 0, 0, IS_STRING, 0) +#else ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_parallel_channel___toString_arginfo, 0, 0, IS_STRING, 0) +#endif ZEND_END_ARG_INFO() PHP_METHOD(Channel, __toString) From 23a3b5bdb7b2a7223dbf408198a53a8053175932 Mon Sep 17 00:00:00 2001 From: dixyes Date: Tue, 22 Mar 2022 10:48:38 +0800 Subject: [PATCH 10/22] Adopt zend map ptr indirection from php/php-src@ddaf64b56c88f0ae223b1aca25293dd7fec77fc0 --- src/copy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/copy.c b/src/copy.c index bba7d522..36be1c39 100644 --- a/src/copy.c +++ b/src/copy.c @@ -428,7 +428,11 @@ static zend_always_inline void php_parallel_copy_closure_init_run_time_cache(zen void *rtc; function->fn_flags |= ZEND_ACC_HEAP_RT_CACHE; +#if PHP_VERSION_ID >= 80200 + rtc = emalloc(function->cache_size); + ZEND_MAP_PTR_INIT(function->run_time_cache, rtc); +#else rtc = emalloc(sizeof(void*) + function->cache_size); ZEND_MAP_PTR_INIT(function->run_time_cache, rtc); @@ -436,6 +440,7 @@ static zend_always_inline void php_parallel_copy_closure_init_run_time_cache(zen rtc = (char*)rtc + sizeof(void*); ZEND_MAP_PTR_SET(function->run_time_cache, rtc); +#endif memset(rtc, 0, function->cache_size); } From 06a786bb5ca5ea0fea1e440e05abfa31b82d5687 Mon Sep 17 00:00:00 2001 From: dixyes Date: Wed, 15 Jun 2022 10:42:11 +0800 Subject: [PATCH 11/22] Fix PHP 8.1 cgi segfault in request shutdown --- src/scheduler.c | 9 ++---- tests/base/disabled_functions.phpt | 50 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 tests/base/disabled_functions.phpt diff --git a/src/scheduler.c b/src/scheduler.c index e0053f76..728ab026 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -23,10 +23,6 @@ TSRM_TLS php_parallel_runtime_t* php_parallel_scheduler_context = NULL; TSRM_TLS php_parallel_future_t* php_parallel_scheduler_future = NULL; -static void zend_disable_function(const char *name, size_t length) { - zend_hash_str_del(CG(function_table), name, length); -} - void (*zend_interrupt_handler)(zend_execute_data*) = NULL; static zend_always_inline int php_parallel_scheduler_list_delete(void *lhs, void *rhs) { @@ -76,10 +72,9 @@ static zend_always_inline php_parallel_runtime_t* php_parallel_scheduler_setup(p PG(expose_php) = 0; PG(auto_globals_jit) = 1; - php_request_startup(); + zend_disable_functions("setlocale,dl"); - zend_disable_function(ZEND_STRL("setlocale")); - zend_disable_function(ZEND_STRL("dl")); + php_request_startup(); PG(during_request_startup) = 0; SG(sapi_started) = 0; diff --git a/tests/base/disabled_functions.phpt b/tests/base/disabled_functions.phpt new file mode 100644 index 00000000..7afd4525 --- /dev/null +++ b/tests/base/disabled_functions.phpt @@ -0,0 +1,50 @@ +--TEST-- +parallel disabled functions +--SKIPIF-- + +--FILE-- +run(function() { + try { + setlocale(LC_ALL, "0"); + } catch (Error $e) { + if ($e->getMessage() !== 'Call to undefined function setlocale()') { + echo "failed check function setlocale disabling" . PHP_EOL; + } + } + }); + + $future->value(); + + setlocale(LC_ALL, "0"); +} + +if (function_exists("dl")) { + $future = $parallel->run(function() { + try { + dl(":/invalid"); + } catch (Error $e) { + if ($e->getMessage() !== 'Call to undefined function dl()') { + echo "failed check function dl disabling" . PHP_EOL; + } + } + }); + $future->value(); +} + +echo "Done" . PHP_EOL; + +?> +--EXPECT-- +Done + From 7d490d8f508ab6e868253226418b59ea33579de1 Mon Sep 17 00:00:00 2001 From: dixyes Date: Wed, 15 Jun 2022 10:44:39 +0800 Subject: [PATCH 12/22] Fix assertion fail in PHP 8.1 https://github.com/krakjoe/parallel/pull/226#issuecomment-1065035133 Co-authored-by: Christoph M. Becker --- src/scheduler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scheduler.c b/src/scheduler.c index 728ab026..ab329f18 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -191,7 +191,7 @@ static zend_always_inline zend_bool php_parallel_scheduler_pop(php_parallel_runt ZEND_CALL_TOP_FUNCTION, php_parallel_copy_function(function, 0), ZEND_CALL_NUM_ARGS(head->frame), - NULL); + scope); if (scope != function->op_array.scope) { el->frame->func->op_array.scope = scope; From 1b8566efe35e2f431fa81ebc5e1a4c3b932b8fdd Mon Sep 17 00:00:00 2001 From: dixyes Date: Tue, 20 Sep 2022 14:08:28 +0800 Subject: [PATCH 13/22] Adopt zend_atomic things --- src/runtime.h | 7 ++++++- src/scheduler.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/runtime.h b/src/runtime.h index 5ced3790..9e208836 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -18,12 +18,17 @@ #ifndef HAVE_PARALLEL_RUNTIME_H #define HAVE_PARALLEL_RUNTIME_H +#if PHP_VERSION_ID < 80200 +# define zend_atomic_bool zend_bool +# define zend_atomic_bool_store(dest, value) (*(dest) = value) +#endif + typedef struct _php_parallel_runtime_t { pthread_t thread; php_parallel_monitor_t *monitor; zend_string *bootstrap; struct { - zend_bool *interrupt; + zend_atomic_bool *interrupt; } child; struct { void *server; diff --git a/src/scheduler.c b/src/scheduler.c index ab329f18..8eafe1a9 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -530,7 +530,7 @@ void php_parallel_scheduler_join(php_parallel_runtime_t *runtime, zend_bool kill if (kill){ php_parallel_monitor_set(runtime->monitor, PHP_PARALLEL_KILLED); - *(runtime->child.interrupt) = 1; + zend_atomic_bool_store(runtime->child.interrupt, true); } else { php_parallel_monitor_set(runtime->monitor, PHP_PARALLEL_CLOSE); } @@ -566,7 +566,7 @@ zend_bool php_parallel_scheduler_cancel(php_parallel_future_t *future) { php_parallel_monitor_lock(future->monitor); if (!php_parallel_monitor_check(future->monitor, PHP_PARALLEL_READY)) { - *(future->runtime->child.interrupt) = 1; + zend_atomic_bool_store(future->runtime->child.interrupt, true); php_parallel_monitor_set(future->monitor, PHP_PARALLEL_CANCELLED); php_parallel_monitor_wait_locked(future->monitor, PHP_PARALLEL_READY); From 47b01d39c9ddf15253147ca5617e76ae2f9ed15d Mon Sep 17 00:00:00 2001 From: dixyes Date: Tue, 20 Sep 2022 17:51:10 +0800 Subject: [PATCH 14/22] Fix disabled function assert fail for 8.2 --- src/scheduler.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/scheduler.c b/src/scheduler.c index 8eafe1a9..5d7a07a4 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -58,6 +58,25 @@ void php_parallel_scheduler_destroy(php_parallel_runtime_t *runtime) { zend_llist_destroy(&runtime->schedule); } +static PHP_FUNCTION(parallel_display_disabled_function) +{ + zend_throw_error(NULL, "Call to undefined function %s()", get_active_function_name()); +} + +// port from php 7.4 code +static int php_parallel_disable_function(const char* function_name, size_t function_name_length) { + zend_internal_function *func; + if ((func = zend_hash_str_find_ptr(CG(function_table), function_name, function_name_length))) { + //zend_free_internal_arg_info(func); + func->fn_flags &= ~(ZEND_ACC_VARIADIC | ZEND_ACC_HAS_TYPE_HINTS | ZEND_ACC_HAS_RETURN_TYPE); + func->num_args = 0; + func->arg_info = NULL; + func->handler = ZEND_FN(parallel_display_disabled_function); + return SUCCESS; + } + return FAILURE; +} + static zend_always_inline php_parallel_runtime_t* php_parallel_scheduler_setup(php_parallel_runtime_t *runtime) { php_parallel_scheduler_context = runtime; @@ -72,7 +91,9 @@ static zend_always_inline php_parallel_runtime_t* php_parallel_scheduler_setup(p PG(expose_php) = 0; PG(auto_globals_jit) = 1; - zend_disable_functions("setlocale,dl"); + // we cannot use zend_disable_functions to disable functions at runtime since PHP 8.2 + php_parallel_disable_function(ZEND_STRL("setlocale")); + php_parallel_disable_function(ZEND_STRL("dl")); php_request_startup(); From e6cc27ed6e15b3ab89fa632aee11cd103dbaeb79 Mon Sep 17 00:00:00 2001 From: dixyes Date: Thu, 22 Sep 2022 17:06:38 +0800 Subject: [PATCH 15/22] Workaround closure static_variables double free --- src/scheduler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scheduler.c b/src/scheduler.c index 5d7a07a4..1eabe281 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -310,7 +310,8 @@ static void php_parallel_scheduler_run(php_parallel_runtime_t *runtime, zend_exe frame->func->op_array.static_variables_ptr); if (!(GC_FLAGS(statics) & IS_ARRAY_IMMUTABLE)) { - zend_array_destroy(statics); + //zend_array_destroy(statics); + php_parallel_copy_hash_dtor(statics, 1); } } From 75c1139b6b871e3ed35639630d78fbff84b1241c Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Thu, 29 Sep 2022 21:32:43 -0300 Subject: [PATCH 16/22] Fix broken tests due to format changes --- tests/base/023.phpt | 5 +++-- tests/base/030.phpt | 3 ++- tests/base/037.phpt | 5 +++-- tests/events/012.phpt | 10 +++++++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/base/023.phpt b/tests/base/023.phpt index 89a2ee54..9582130d 100644 --- a/tests/base/023.phpt +++ b/tests/base/023.phpt @@ -14,7 +14,7 @@ try { $parallel->run(function(){ thrower(); }); -} catch (Error $er) { +} catch (Error $er) { /* can't catch here what is thrown in runtime */ } ?> @@ -22,6 +22,7 @@ try { Fatal error: Uncaught %s in %s:7 Stack trace: #0 %s(6): thrower() -#1 {main} +#1 [internal function]: {closure}() +#2 {main} thrown in %s on line 7 diff --git a/tests/base/030.phpt b/tests/base/030.phpt index 8dac92cb..56fb1716 100644 --- a/tests/base/030.phpt +++ b/tests/base/030.phpt @@ -20,7 +20,8 @@ $future->value(); --EXPECTF-- Fatal error: Uncaught Exception in %s:4 Stack trace: -#0 {main} +#0 [internal function]: {closure}() +#1 {main} thrown in %s on line 4 diff --git a/tests/base/037.phpt b/tests/base/037.phpt index 29ac029d..65c63d64 100644 --- a/tests/base/037.phpt +++ b/tests/base/037.phpt @@ -12,7 +12,7 @@ $parallel = new \parallel\Runtime(sprintf("%s/bootstrap.inc", __DIR__)); $future = $parallel->run(function(){ $foo = new Foo(); - + return $foo->bar([42],new stdClass); }); @@ -23,6 +23,7 @@ Fatal error: Uncaught RuntimeException: message in %s:12 Stack trace: #0 %s(19): Qux->method(Array, Object(stdClass)) #1 %s(7): Foo->bar(Array, Object(stdClass)) -#2 {main} +#2 [internal function]: {closure}() +#3 {main} thrown in %s on line 12 diff --git a/tests/events/012.phpt b/tests/events/012.phpt index d9de89be..31311be6 100644 --- a/tests/events/012.phpt +++ b/tests/events/012.phpt @@ -46,7 +46,15 @@ object(parallel\Events\Event)#%d (%d) { ["line":protected]=> int(7) ["trace":"Exception":private]=> - array(0) { + array(1) { + [0]=> + array(2) { + ["function"]=> + string(9) "{closure}" + ["args"]=> + array(0) { + } + } } ["previous":"Exception":private]=> NULL From 90889f548c481dd9a3e7004dcc3da679a2201960 Mon Sep 17 00:00:00 2001 From: "L. Stubbs" Date: Sat, 12 Nov 2022 11:35:05 -0500 Subject: [PATCH 17/22] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 49e24a96..80218581 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,4 @@ tests/**/*.log tests/**/*.out tests/**/*.php tests/**/*.sh +php-src-php-*/ From 821fb341062863fe33e97a0da5e8e43bd36814b6 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Sun, 23 Apr 2023 00:55:22 -0400 Subject: [PATCH 18/22] added bat scripts for single Windows build command - will download _php-sdk_, original _pthreadsW4_ source code, and _any PHP version_ source code, compile all with: `.\cmd\compile_x64.bat --php 8.2.5 --shared` `.\cmd\compile_x64.bat --php 8.2.5 --shared --snap` create zip packages - files in directory **php-sdk\phpdev\vs16\x64\php-8.2.5\x64\Release_TS** `.\cmd\windows_run_test.bat --php 8.2.5 --arch x64` run .phpt tests --- .gitignore | 1 + cmd/compile_x32.bat | 6 + cmd/compile_x64.bat | 6 + cmd/deps_build/CMakeLists.txt | 248 ++++++++++++++ cmd/deps_build/cmake/config_h_in.cmake | 123 +++++++ cmd/deps_build/cmake/get_version.cmake | 21 ++ cmd/deps_build/cmake/target_arch.cmake | 41 +++ cmd/deps_build/cmake/version.rc.in | 429 +++++++++++++++++++++++++ cmd/deps_build/pthread.cxx | 6 + cmd/getopt.bat | 21 ++ cmd/make_module.bat | 40 +++ cmd/phpsdk_setshell.bat | 175 ++++++++++ cmd/pthread_build.bat | 20 ++ cmd/windows_run_test.bat | 21 ++ 14 files changed, 1158 insertions(+) create mode 100644 cmd/compile_x32.bat create mode 100644 cmd/compile_x64.bat create mode 100644 cmd/deps_build/CMakeLists.txt create mode 100644 cmd/deps_build/cmake/config_h_in.cmake create mode 100644 cmd/deps_build/cmake/get_version.cmake create mode 100644 cmd/deps_build/cmake/target_arch.cmake create mode 100644 cmd/deps_build/cmake/version.rc.in create mode 100644 cmd/deps_build/pthread.cxx create mode 100644 cmd/getopt.bat create mode 100644 cmd/make_module.bat create mode 100644 cmd/phpsdk_setshell.bat create mode 100644 cmd/pthread_build.bat create mode 100644 cmd/windows_run_test.bat diff --git a/.gitignore b/.gitignore index 80218581..5aea9223 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,4 @@ tests/**/*.out tests/**/*.php tests/**/*.sh php-src-php-*/ +php-sdk/ diff --git a/cmd/compile_x32.bat b/cmd/compile_x32.bat new file mode 100644 index 00000000..007eb3c9 --- /dev/null +++ b/cmd/compile_x32.bat @@ -0,0 +1,6 @@ +@echo off +if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" ( + "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat" && cmd\getopt.bat %* && set ARCH=x86&& cmd\make_module.bat +) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" ( + "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat" && .\cmd\getopt.bat %* && set ARCH=x86&& .\cmd\make_module.bat +) diff --git a/cmd/compile_x64.bat b/cmd/compile_x64.bat new file mode 100644 index 00000000..ccc61b92 --- /dev/null +++ b/cmd/compile_x64.bat @@ -0,0 +1,6 @@ +@echo off +if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" ( + "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" && cmd\getopt.bat %* && set ARCH=x64&& cmd\make_module.bat +) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" ( + "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && .\cmd\getopt.bat %* && set ARCH=x64&& .\cmd\make_module.bat +) diff --git a/cmd/deps_build/CMakeLists.txt b/cmd/deps_build/CMakeLists.txt new file mode 100644 index 00000000..654122f8 --- /dev/null +++ b/cmd/deps_build/CMakeLists.txt @@ -0,0 +1,248 @@ +cmake_minimum_required(VERSION 3.14) + +set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake") + +include (CheckIncludeFile) +include (CheckFunctionExists) +include (CheckSymbolExists) +include (CheckTypeSize) +include (config_h_in) +include (get_version) + +project(pthreads4w VERSION ${PTHREADS4W_VERSION} LANGUAGES C CXX) + +set(PTW32_VER ${PROJECT_VERSION_MAJOR}${EXTRAVERSION}) + +if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE) + message(STATUS "No build type specified, defaulting to MinSizeRel.") +endif() + +message(STATUS "") +message(STATUS "") +message(STATUS "Generator ......... ${CMAKE_GENERATOR}") +if(NOT CMAKE_CONFIGURATION_TYPES) + set(the_build_type ${CMAKE_BUILD_TYPE}) +else () + set(the_build_type "Generator-defined, one of ${CMAKE_CONFIGURATION_TYPES}") +endif () +message(STATUS "Build Type ........ ${the_build_type}") +message(STATUS "Version ........... ${PTHREADS4W_VERSION}") + +## Deprecated +## set(CMAKE_DEBUG_POSTFIX d) + +# Uncomment this if config.h defines RETAIN_WSALASTERROR +#set(XLIBS wsock32.lib) + + +# Initial include path set. Look in the build directory first, where the +# generated config.h resides, before looking in the source directory. +include_directories("${CMAKE_BINARY_DIR}/" "${CMAKE_SOURCE_DIR}/") + +################################# +# Target Arch # +################################# +include (target_arch) + +get_target_arch(TARGET_ARCH) +set(build_defines "") +if(${TARGET_ARCH} STREQUAL "ARM") + set(build_defines __PTW32_ARCHARM _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1) +elseif(${TARGET_ARCH} STREQUAL "ARM64") + set(build_defines __PTW32_ARCHARM64 _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1) +elseif(${TARGET_ARCH} STREQUAL "x86_64") + set(build_defines __PTW32_ARCHAMD64) +elseif(${TARGET_ARCH} STREQUAL "x86") + set(build_defines __PTW32_ARCHX86) +elseif(${TARGET_ARCH} STREQUAL "x64") + set(build_defines __PTW32_ARCHX64) +else() + MESSAGE(ERROR "\"${TARGET_ARCH}\" not supported in version.rc") +endif() + +message(STATUS "Target ............ ${TARGET_ARCH}") +set(CMAKE_C_LIBRARY_ARCHITECTURE ${TARGET_ARCH}) +set(CMAKE_CXX_LIBRARY_ARCHITECTURE ${TARGET_ARCH}) +set(CMAKE_LIBRARY_ARCHITECTURE ${TARGET_ARCH}) + +if(MSVC) + message(STATUS "MSVC Version ...... ${MSVC_VERSION}") +else() + message(STATUS "C Compiler ID ..... ${CMAKE_C_COMPILER_ID}") +endif() + +################################# +# Install Path # +################################# +if (DIST_ROOT) + set(CMAKE_INSTALL_PREFIX "${DIST_ROOT}") +elseif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/PTHREADS-BUILT" CACHE PATH "Install path prefix (default)" FORCE) +endif() + +message(STATUS "Installing to ${CMAKE_INSTALL_PREFIX}") + +message(STATUS "") +message(STATUS "") + +################################# +# configuration features # +################################# +check_include_file(errno.h HAVE_ERRNO_H) +check_include_file(inttypes.h HAVE_INTTYPES_H) +check_include_file(memory.h HAVE_MEMORY_H) +check_include_file(signal.h HAVE_SIGNAL_H) +check_include_file(stdint.h HAVE_STDINT_H) +check_include_file(stdlib.h HAVE_STDLIB_H) +check_include_file(strings.h HAVE_STRINGS_H) +check_include_file(string.h HAVE_STRING_H) +check_include_file(sys/stat.h HAVE_SYS_STAT_H) +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(time.h HAVE_TIME_H) +check_include_file(unistd.h HAVE_UNISTD_H) +check_function_exists(calloc HAVE_CALLOC) +check_type_size(sigset_t HAVE_SIGSET_T) +check_type_size("struct timespec" HAVE_STRUCT_TIMESPEC) +check_symbol_exists(_beginthreadex process.h HAVE__BEGINTHREADEX) +check_symbol_exists(DuplicateHandle windows.h HAVE_DUPLICATEHANDLE) + +create_config_h_in() +configure_file("${CMAKE_BINARY_DIR}/config.h.in" "${CMAKE_BINARY_DIR}/config.h") + +################################# +# Defs # +################################# + +if(MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /errorReport:none /nologo ") + + # C++ Exceptions + # (Note: If you are using Microsoft VC++6.0, the library needs to be built + # with /EHa instead of /EHs or else cancellation won't work properly.) + if(MSVC_VERSION EQUAL 1200) + set(VCEFLAGS "/EHa" "/TP") + else() + set(VCEFLAGS "/EHs" "/TP") + endif() + + set(build_defines ${build_defines} HAVE_CONFIG_H __PTW32_RC_MSC) +elseif (${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + set(build_defines ${build_defines} HAVE_CONFIG_H) +endif() + + +# Update filename with proper version info +configure_file(${CMAKE_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_BINARY_DIR}/version.rc @ONLY) + +################################# +# Libraries # +################################# + +function(shared_lib type def) + set(targ pthread${type}${PTW32_VER}) + + if (${type} STREQUAL "VCE") + add_library(${targ} SHARED pthread.cxx ${CMAKE_BINARY_DIR}/version.rc) + set_target_properties(${targ} PROPERTIES LINKER_LANGUAGE CXX) + target_compile_options(${targ} PUBLIC "${VCEFLAGS}") + elseif (${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + add_library(${targ} SHARED pthread.cxx ${CMAKE_BINARY_DIR}/version.rc) + target_compile_options(${targ} PRIVATE "-mthreads") + if (${type} STREQUAL "GCE") + set_target_properties(${targ} PROPERTIES LINKER_LANGUAGE CXX) + target_compile_options(${targ} PRIVATE "-xc++") + target_link_libraries(${targ} stdc++) + target_link_options(${targ} PRIVATE "-shared-libgcc") + endif (${type} STREQUAL "GCE") + else () + add_library(${targ} SHARED pthread.c ${CMAKE_BINARY_DIR}/version.rc) + endif (${type} STREQUAL "VCE") + + target_compile_definitions(${targ} PRIVATE ${def} ${build_defines} __PTW32_BUILD_INLINED) + if (MSVC) + # Set resource compiler definition... + target_compile_definitions(${targ} PRIVATE __PTW32_RC_MSC) + endif () + set_target_properties(${targ} PROPERTIES DEBUG_POSTFIX "d") + + message(STATUS "Shared library ${targ}") + + install( + TARGETS ${targ} + ARCHIVE # DESTINATION ${TARGET_ARCH}/${CONFIG}/lib + LIBRARY # DESTINATION ${TARGET_ARCH}/${CONFIG}/lib + RUNTIME # DESTINATION ${TARGET_ARCH}/${CONFIG}/bin + ) + + install( + FILES $ + CONFIGURATION Debug + DESTINATION lib + OPTIONAL + ) +endfunction() + +function(static_lib type def) + set(targ libpthread${type}${PTW32_VER}) + + if(${type} STREQUAL "VCE") + add_library(${targ} STATIC pthread.cxx) + target_compile_options(${targ} PRIVATE "/EHs") + elseif (${CMAKE_C_COMPILER_ID} STREQUAL "GNU") + if (${type} STREQUAL "GCE") + add_library(${targ} STATIC pthread.cxx) + target_compile_options(${targ} PRIVATE "-xc++") + target_link_libraries(${targ} stdc++) + target_link_options(${targ} PRIVATE "-shared-libgcc") + endif (${type} STREQUAL "GCE") + else () + add_library(${targ} STATIC pthread.c) + endif() + + target_compile_definitions(${targ} PRIVATE "${def}" ${build_defines} __PTW32_STATIC_LIB __PTW32_BUILD_INLINED) + set_target_properties(${targ} PROPERTIES DEBUG_POSTFIX "d") + + message(STATUS "Static library ${targ}") + + install( + TARGETS ${targ} + ARCHIVE # DESTINATION ${TARGET_ARCH}/${CONFIG}/lib + LIBRARY # DESTINATION ${TARGET_ARCH}/${CONFIG}/lib + RUNTIME # DESTINATION ${TARGET_ARCH}/${CONFIG}/bin + ) +endfunction() + +if (MSVC) + shared_lib ( VCE __PTW32_CLEANUP_CXX ) + shared_lib ( VSE __PTW32_CLEANUP_SEH ) + shared_lib ( VC __PTW32_CLEANUP_C ) + + static_lib ( VCE __PTW32_CLEANUP_CXX ) + static_lib ( VSE __PTW32_CLEANUP_SEH ) + static_lib ( VC __PTW32_CLEANUP_C ) +elseif (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") + ## NOTE: MinGW64 does support SEH exception handling, BUT it does not yet + ## have the MSVC keywords "__try", "__except" and "__finally". + shared_lib ( GCE __PTW32_CLEANUP_CXX ) + shared_lib ( GC __PTW32_CLEANUP_C ) + + static_lib ( GCE __PTW32_CLEANUP_CXX ) + static_lib ( GC __PTW32_CLEANUP_C ) +endif (MSVC) + +################################# +# Install # +################################# +install(FILES _ptw32.h pthread.h sched.h semaphore.h TYPE INCLUDE) + +################################# +# Test # +################################# +option(ENABLE_TESTS "Enable Test code build" FALSE) + +#TODO determine if cross compile... +if(ENABLE_TESTS AND (NOT CMAKE_CROSSCOMPILING AND BUILD_TESTING)) + include (CTest) + add_subdirectory(tests) +endif() diff --git a/cmd/deps_build/cmake/config_h_in.cmake b/cmd/deps_build/cmake/config_h_in.cmake new file mode 100644 index 00000000..320a3521 --- /dev/null +++ b/cmd/deps_build/cmake/config_h_in.cmake @@ -0,0 +1,123 @@ +set(PTHREAD_CONFIG_H " +/* config.h, automagically generated by cmake. */ + +#ifndef __PTW32_CONFIG_H +#define __PTW32_CONFIG_H + +/* Define to 1 if you have the `calloc' function. */ +#cmakedefine HAVE_CALLOC 1 + +/* Define if CPU_AFFINITY is supported */ +#define HAVE_CPU_AFFINITY 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H 1 + +/* Define if your compiler knows about mode_t */ +#define HAVE_MODE_T 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SIGNAL_H 1 + +/* Define if your compiler knows about sigset_t */ +#cmakedefine HAVE_SIGSET_T 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 + +/* Define if your compiler knows about struct timespec */ +#cmakedefine HAVE_STRUCT_TIMESPEC 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `_beginthreadex' function. */ +#cmakedefine HAVE__BEGINTHREADEX 1 + +/* Define to 1 if you have the DuplicateHandle function. */ +#cmakedefine HAVE_DUPLICATEHANDLE 1 + +/* Make sure that __PTW32_BUILD is defined. */ +#if !defined(__PTW32_BUILD) +#define __PTW32_BUILD +#endif + +/* Define if you do not have calloc */ +#if !defined(HAVE_CALLOC) || !HAVE_CALLOC +#define NEED_CALLOC +#endif + +#if !defined(HAVE__BEGINTHREADEX) || !HAVE__BEGINTHREADEX +#define NEED_CREATETHREAD +#endif + +/* Define if DuplicateHandle is unsupported */ +#if !defined(HAVE_DUPLICATEHANDLE) || !HAVE_DUPLICATEHANDLE +#define NEED_DUPLICATEHANDLE +#endif + +/* Define if you do not have errno */ +/* #undef NEED_ERRNO */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT \"\" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME \"pthreads4w\" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING \"pthreads4w git\" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME \"pthreads4w\" + +/* Define to the home page for this package. */ +#define PACKAGE_URL \"\" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION \"git\" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +#define HAVE_C_INLINE 1 + +#endif +") + + +function (create_config_h_in) + file(WRITE + "${CMAKE_BINARY_DIR}/config.h.in" + "${PTHREAD_CONFIG_H}") +endfunction (create_config_h_in) diff --git a/cmd/deps_build/cmake/get_version.cmake b/cmd/deps_build/cmake/get_version.cmake new file mode 100644 index 00000000..82e92c7e --- /dev/null +++ b/cmd/deps_build/cmake/get_version.cmake @@ -0,0 +1,21 @@ + +file(READ ${CMAKE_SOURCE_DIR}/_ptw32.h _PTW32_H_CONTENTS) + +string(REGEX MATCH "#define __PTW32_VERSION_MAJOR ([a-zA-Z0-9_]+)" PTW32_VERSION_MAJOR "${_PTW32_H_CONTENTS}") +string(REPLACE "#define __PTW32_VERSION_MAJOR " "" PTW32_VERSION_MAJOR "${PTW32_VERSION_MAJOR}") + +string(REGEX MATCH "#define __PTW32_VERSION_MINOR ([a-zA-Z0-9_]+)" PTW32_VERSION_MINOR "${_PTW32_H_CONTENTS}") +string(REPLACE "#define __PTW32_VERSION_MINOR " "" PTW32_VERSION_MINOR "${PTW32_VERSION_MINOR}") + +string(REGEX MATCH "#define __PTW32_VERSION_MICRO ([a-zA-Z0-9_]+)" PTW32_VERSION_MICRO "${_PTW32_H_CONTENTS}") +string(REPLACE "#define __PTW32_VERSION_MICRO " "" PTW32_VERSION_MICRO "${PTW32_VERSION_MICRO}") + +string(REGEX MATCH "#define __PTW32_VERION_BUILD ([a-zA-Z0-9_]+)" PTW32_VERSION_BUILD "${_PTW32_H_CONTENTS}") +string(REPLACE "#define __PTW32_VERION_BUILD " "" PTW32_VERSION_BUILD "${PTW32_VERSION_BUILD}") + +if(BUILD_NUMBER) + set(PTW32_VERSION_BUILD ${BUILD_NUMBER}) +endif() + +set(PTHREADS4W_VERSION ${PTW32_VERSION_MAJOR}.${PTW32_VERSION_MINOR}.${PTW32_VERSION_MICRO}.${PTW32_VERSION_BUILD}) + diff --git a/cmd/deps_build/cmake/target_arch.cmake b/cmd/deps_build/cmake/target_arch.cmake new file mode 100644 index 00000000..0c96f316 --- /dev/null +++ b/cmd/deps_build/cmake/target_arch.cmake @@ -0,0 +1,41 @@ + +set(TARGET_ARCH_DETECT_CODE " +#if defined(_M_ARM) +# error cmake_arch ARM +#elif defined(_M_ARM64) +# error cmake_arch ARM64 +#elif defined(_M_AMD64) +# error cmake_arch x86_64 +#elif defined(_M_X64) +# error cmake_arch x64 +#elif defined(_M_IX86) +# error cmake_arch x86 +#elif defined(__MINGW64__) || defined(__x86_64__) +/* NOTE: MinGW64 gcc defined BOTH __MINGW32__ and __MINGW64__, so order + is important. */ +# error cmake_arch x64 +#elif defined(__MINGW32__) +# error cmake_arch x86 +#else +#error cmake_arch unknown +#endif +") + +function(get_target_arch out) + + file(WRITE + "${CMAKE_BINARY_DIR}/target_arch_detect.c" + "${TARGET_ARCH_DETECT_CODE}") + + try_run( + run_result_unused compile_result_unused + "${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}/target_arch_detect.c" + COMPILE_OUTPUT_VARIABLE TARGET_ARCH) + + # parse compiler output + string(REGEX MATCH "cmake_arch ([a-zA-Z0-9_]+)" TARGET_ARCH "${TARGET_ARCH}") + string(REPLACE "cmake_arch " "" TARGET_ARCH "${TARGET_ARCH}") + + set(${out} "${TARGET_ARCH}" PARENT_SCOPE) + +endfunction() diff --git a/cmd/deps_build/cmake/version.rc.in b/cmd/deps_build/cmake/version.rc.in new file mode 100644 index 00000000..0e41fcb2 --- /dev/null +++ b/cmd/deps_build/cmake/version.rc.in @@ -0,0 +1,429 @@ +/* This is an implementation of the threads API of POSIX 1003.1-2001. + * + * -------------------------------------------------------------------------- + * + * Pthreads4w - POSIX Threads for Windows + * Copyright 1998 John E. Bossom + * Copyright 1999-2018, Pthreads4w contributors + * + * Homepage: https://sourceforge.net/projects/pthreads4w/ + * + * The current list of contributors is contained + * in the file CONTRIBUTORS included with the source + * code distribution. The list can also be seen at the + * following World Wide Web location: + * + * https://sourceforge.net/p/pthreads4w/wiki/Contributors/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "pthread.h" + +/* + * Note: the correct __PTW32_CLEANUP_* macro must be defined corresponding to + * the definition used for the object file builds. This is done in the + * relevent makefiles for the command line builds, but users should ensure + * that their resource compiler knows what it is too. + * If using the default (no __PTW32_CLEANUP_* defined), pthread.h will define it + * as __PTW32_CLEANUP_C. + */ + +#if defined (__PTW32_RC_MSC) +# if defined (__PTW32_ARCHx64) || defined (__PTW32_ARCHX64) || defined (__PTW32_ARCHAMD64) +# if defined(__PTW32_CLEANUP_C) +# define __PTW32_VERSIONINFO_NAME "pthreadVC@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C x64\0" +# elif defined(__PTW32_CLEANUP_CXX) +# define __PTW32_VERSIONINFO_NAME "pthreadVCE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C++ x64\0" +# elif defined(__PTW32_CLEANUP_SEH) +# define __PTW32_VERSIONINFO_NAME "pthreadVSE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C SEH x64\0" +# endif +# elif defined (__PTW32_ARCHx86) || defined (__PTW32_ARCHX86) +# if defined(__PTW32_CLEANUP_C) +# define __PTW32_VERSIONINFO_NAME "pthreadVC@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C x86\0" +# elif defined(__PTW32_CLEANUP_CXX) +# define __PTW32_VERSIONINFO_NAME "pthreadVCE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C++ x86\0" +# elif defined(__PTW32_CLEANUP_SEH) +# define __PTW32_VERSIONINFO_NAME "pthreadVSE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C SEH x86\0" +# endif +# elif defined (__PTW32_ARCHARM) || defined (__PTW32_ARCHARM) +# if defined(__PTW32_CLEANUP_C) +# define __PTW32_VERSIONINFO_NAME "pthreadVC@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C ARM\0" +# elif defined(__PTW32_CLEANUP_CXX) +# define __PTW32_VERSIONINFO_NAME "pthreadVCE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C++ ARM\0" +# elif defined(__PTW32_CLEANUP_SEH) +# define __PTW32_VERSIONINFO_NAME "pthreadVSE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C SEH ARM\0" +# endif +# elif defined (__PTW32_ARCHARM64) || defined (__PTW32_ARCHARM64) +# if defined(__PTW32_CLEANUP_C) +# define __PTW32_VERSIONINFO_NAME "pthreadVC@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C ARM64\0" +# elif defined(__PTW32_CLEANUP_CXX) +# define __PTW32_VERSIONINFO_NAME "pthreadVCE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C++ ARM64\0" +# elif defined(__PTW32_CLEANUP_SEH) +# define __PTW32_VERSIONINFO_NAME "pthreadVSE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "MS C SEH ARM64\0" +# endif +# endif +#elif defined(__GNUC__) +# if defined(_M_X64) +# define __PTW32_ARCH "x64 (mingw64)" +# else +# define __PTW32_ARCH "x86 (mingw32)" +# endif +# if defined(__PTW32_CLEANUP_C) +# define __PTW32_VERSIONINFO_NAME "pthreadGC@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "GNU C " __PTW32_ARCH "\0" +# elif defined(__PTW32_CLEANUP_CXX) +# define __PTW32_VERSIONINFO_NAME "pthreadGCE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "GNU C++ " __PTW32_ARCH "\0" +# else +# error Resource compiler doesn't know which cleanup style you're using - see version.rc +# endif +#elif defined(__BORLANDC__) +# if defined(_M_X64) +# define __PTW32_ARCH "x64 (Borland)" +# else +# define __PTW32_ARCH "x86 (Borland)" +# endif +# if defined(__PTW32_CLEANUP_C) +# define __PTW32_VERSIONINFO_NAME "pthreadBC@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "BORLAND C " __PTW32_ARCH "\0" +# elif defined(__PTW32_CLEANUP_CXX) +# define __PTW32_VERSIONINFO_NAME "pthreadBCE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "BORLAND C++ " __PTW32_ARCH "\0" +# else +# error Resource compiler doesn't know which cleanup style you're using - see version.rc +# endif +#elif defined(__WATCOMC__) +# if defined(_M_X64) +# define __PTW32_ARCH "x64 (Watcom)" +# else +# define __PTW32_ARCH "x86 (Watcom)" +# endif +# if defined(__PTW32_CLEANUP_C) +# define __PTW32_VERSIONINFO_NAME "pthreadWC@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "WATCOM C " __PTW32_ARCH "\0" +# elif defined(__PTW32_CLEANUP_CXX) +# define __PTW32_VERSIONINFO_NAME "pthreadWCE@PTW32_VER@.DLL\0" +# define __PTW32_VERSIONINFO_DESCRIPTION "WATCOM C++ " __PTW32_ARCH "\0" +# else +# error Resource compiler doesn't know which cleanup style you're using - see version.rc +# endif +#else +# error Resource compiler doesn't know which compiler you're using - see version.rc +#endif + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __PTW32_VERSION + PRODUCTVERSION __PTW32_VERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "ProductName", "POSIX Threads for Windows\0" + VALUE "ProductVersion", __PTW32_VERSION_STRING + VALUE "FileVersion", __PTW32_VERSION_STRING + VALUE "FileDescription", __PTW32_VERSIONINFO_DESCRIPTION + VALUE "InternalName", __PTW32_VERSIONINFO_NAME + VALUE "OriginalFilename", __PTW32_VERSIONINFO_NAME + VALUE "CompanyName", "Open Source Software community\0" + VALUE "LegalCopyright", "Copyright - Project contributors 1999-2018\0" + VALUE "Comments", "https://sourceforge.net/p/pthreads4w/wiki/Contributors/\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +/* +VERSIONINFO Resource + +The VERSIONINFO resource-definition statement creates a version-information +resource. The resource contains such information about the file as its +version number, its intended operating system, and its original filename. +The resource is intended to be used with the Version Information functions. + +versionID VERSIONINFO fixed-info { block-statement...} + +versionID + Version-information resource identifier. This value must be 1. + +fixed-info + Version information, such as the file version and the intended operating + system. This parameter consists of the following statements. + + + Statement Description + -------------------------------------------------------------------------- + FILEVERSION + version Binary version number for the file. The version + consists of two 32-bit integers, defined by four + 16-bit integers. For example, "FILEVERSION 3,10,0,61" + is translated into two doublewords: 0x0003000a and + 0x0000003d, in that order. Therefore, if version is + defined by the DWORD values dw1 and dw2, they need + to appear in the FILEVERSION statement as follows: + HIWORD(dw1), LOWORD(dw1), HIWORD(dw2), LOWORD(dw2). + PRODUCTVERSION + version Binary version number for the product with which the + file is distributed. The version parameter is two + 32-bit integers, defined by four 16-bit integers. + For more information about version, see the + FILEVERSION description. + FILEFLAGSMASK + fileflagsmask Bits in the FILEFLAGS statement are valid. If a bit + is set, the corresponding bit in FILEFLAGS is valid. + FILEFLAGSfileflags Attributes of the file. The fileflags parameter must + be the combination of all the file flags that are + valid at compile time. For 16-bit Windows, this + value is 0x3f. + FILEOSfileos Operating system for which this file was designed. + The fileos parameter can be one of the operating + system values given in the Remarks section. + FILETYPEfiletype General type of file. The filetype parameter can be + one of the file type values listed in the Remarks + section. + FILESUBTYPE + subtype Function of the file. The subtype parameter is zero + unless the type parameter in the FILETYPE statement + is VFT_DRV, VFT_FONT, or VFT_VXD. For a list of file + subtype values, see the Remarks section. + +block-statement + Specifies one or more version-information blocks. A block can contain + string information or variable information. For more information, see + StringFileInfo Block or VarFileInfo Block. + +Remarks + +To use the constants specified with the VERSIONINFO statement, you must +include the Winver.h or Windows.h header file in the resource-definition file. + +The following list describes the parameters used in the VERSIONINFO statement: + +fileflags + A combination of the following values. + + Value Description + + VS_FF_DEBUG File contains debugging information or is compiled + with debugging features enabled. + VS_FF_PATCHED File has been modified and is not identical to the + original shipping file of the same version number. + VS_FF_PRERELEASE File is a development version, not a commercially + released product. + VS_FF_PRIVATEBUILD File was not built using standard release procedures. + If this value is given, the StringFileInfo block must + contain a PrivateBuild string. + VS_FF_SPECIALBUILD File was built by the original company using standard + release procedures but is a variation of the standard + file of the same version number. If this value is + given, the StringFileInfo block must contain a + SpecialBuild string. + +fileos + One of the following values. + + Value Description + + VOS_UNKNOWN The operating system for which the file was designed + is unknown. + VOS_DOS File was designed for MS-DOS. + VOS_NT File was designed for Windows Server 2003 family, + Windows XP, Windows 2000, or Windows NT. + VOS__WINDOWS16 File was designed for 16-bit Windows. + VOS__WINDOWS32 File was designed for 32-bit Windows. + VOS_DOS_WINDOWS16 File was designed for 16-bit Windows running with + MS-DOS. + VOS_DOS_WINDOWS32 File was designed for 32-bit Windows running with + MS-DOS. + VOS_NT_WINDOWS32 File was designed for Windows Server 2003 family, + Windows XP, Windows 2000, or Windows NT. + + The values 0x00002L, 0x00003L, 0x20000L and 0x30000L are reserved. + +filetype + One of the following values. + + Value Description + + VFT_UNKNOWN File type is unknown. + VFT_APP File contains an application. + VFT_DLL File contains a dynamic-link library (DLL). + VFT_DRV File contains a device driver. If filetype is + VFT_DRV, subtype contains a more specific + description of the driver. + VFT_FONT File contains a font. If filetype is VFT_FONT, + subtype contains a more specific description of the + font. + VFT_VXD File contains a virtual device. + VFT_STATIC_LIB File contains a static-link library. + + All other values are reserved for use by Microsoft. + +subtype + Additional information about the file type. + + If filetype specifies VFT_DRV, this parameter can be one of the + following values. + + Value Description + + VFT2_UNKNOWN Driver type is unknown. + VFT2_DRV_COMM File contains a communications driver. + VFT2_DRV_PRINTER File contains a printer driver. + VFT2_DRV_KEYBOARD File contains a keyboard driver. + VFT2_DRV_LANGUAGE File contains a language driver. + VFT2_DRV_DISPLAY File contains a display driver. + VFT2_DRV_MOUSE File contains a mouse driver. + VFT2_DRV_NETWORK File contains a network driver. + VFT2_DRV_SYSTEM File contains a system driver. + VFT2_DRV_INSTALLABLE File contains an installable driver. + VFT2_DRV_SOUND File contains a sound driver. + VFT2_DRV_VERSIONED_PRINTER File contains a versioned printer driver. + + If filetype specifies VFT_FONT, this parameter can be one of the + following values. + + Value Description + + VFT2_UNKNOWN Font type is unknown. + VFT2_FONT_RASTER File contains a raster font. + VFT2_FONT_VECTOR File contains a vector font. + VFT2_FONT_TRUETYPE File contains a TrueType font. + + If filetype specifies VFT_VXD, this parameter must be the virtual-device + identifier included in the virtual-device control block. + + All subtype values not listed here are reserved for use by Microsoft. + +langID + One of the following language codes. + + Code Language Code Language + + 0x0401 Arabic 0x0415 Polish + 0x0402 Bulgarian 0x0416 Portuguese (Brazil) + 0x0403 Catalan 0x0417 Rhaeto-Romanic + 0x0404 Traditional Chinese 0x0418 Romanian + 0x0405 Czech 0x0419 Russian + 0x0406 Danish 0x041A Croato-Serbian (Latin) + 0x0407 German 0x041B Slovak + 0x0408 Greek 0x041C Albanian + 0x0409 U.S. English 0x041D Swedish + 0x040A Castilian Spanish 0x041E Thai + 0x040B Finnish 0x041F Turkish + 0x040C French 0x0420 Urdu + 0x040D Hebrew 0x0421 Bahasa + 0x040E Hungarian 0x0804 Simplified Chinese + 0x040F Icelandic 0x0807 Swiss German + 0x0410 Italian 0x0809 U.K. English + 0x0411 Japanese 0x080A Mexican Spanish + 0x0412 Korean 0x080C Belgian French + 0x0413 Dutch 0x0C0C Canadian French + 0x0414 Norwegian – Bokmal 0x100C Swiss French + 0x0810 Swiss Italian 0x0816 Portuguese (Portugal) + 0x0813 Belgian Dutch 0x081A Serbo-Croatian (Cyrillic) + 0x0814 Norwegian – Nynorsk + +charsetID + One of the following character-set identifiers. + + Identifier Character Set + + 0 7-bit ASCII + 932 Japan (Shift %G–%@ JIS X-0208) + 949 Korea (Shift %G–%@ KSC 5601) + 950 Taiwan (Big5) + 1200 Unicode + 1250 Latin-2 (Eastern European) + 1251 Cyrillic + 1252 Multilingual + 1253 Greek + 1254 Turkish + 1255 Hebrew + 1256 Arabic + +string-name + One of the following predefined names. + + Name Description + + Comments Additional information that should be displayed for + diagnostic purposes. + CompanyName Company that produced the file%G—%@for example, + "Microsoft Corporation" or "Standard Microsystems + Corporation, Inc." This string is required. + FileDescription File description to be presented to users. This + string may be displayed in a list box when the user + is choosing files to install%G—%@for example, + "Keyboard Driver for AT-Style Keyboards". This + string is required. + FileVersion Version number of the file%G—%@for example, + "3.10" or "5.00.RC2". This string is required. + InternalName Internal name of the file, if one exists — for + example, a module name if the file is a dynamic-link + library. If the file has no internal name, this + string should be the original filename, without + extension. This string is required. + LegalCopyright Copyright notices that apply to the file. This + should include the full text of all notices, legal + symbols, copyright dates, and so on — for example, + "Copyright (C) Microsoft Corporation 1990–1999". + This string is optional. + LegalTrademarks Trademarks and registered trademarks that apply to + the file. This should include the full text of all + notices, legal symbols, trademark numbers, and so on. + This string is optional. + OriginalFilename Original name of the file, not including a path. + This information enables an application to determine + whether a file has been renamed by a user. The + format of the name depends on the file system for + which the file was created. This string is required. + PrivateBuild Information about a private version of the file — for + example, "Built by TESTER1 on \TESTBED". This string + should be present only if VS_FF_PRIVATEBUILD is + specified in the fileflags parameter of the root + block. + ProductName Name of the product with which the file is + distributed. This string is required. + ProductVersion Version of the product with which the file is + distributed — for example, "3.10" or "5.00.RC2". + This string is required. + SpecialBuild Text that indicates how this version of the file + differs from the standard version — for example, + "Private build for TESTER1 solving mouse problems + on M250 and M250E computers". This string should be + present only if VS_FF_SPECIALBUILD is specified in + the fileflags parameter of the root block. + */ diff --git a/cmd/deps_build/pthread.cxx b/cmd/deps_build/pthread.cxx new file mode 100644 index 00000000..318041a4 --- /dev/null +++ b/cmd/deps_build/pthread.cxx @@ -0,0 +1,6 @@ +/* Stub source so that CMake 3.18 and higher actually compile using the C++ + * compiler. CMake 3.18 started enforcing source type (e.g., "/TC" for C source + * and "/TP" for C++ source) on the command line, forcing this as the + * workaround. */ + +#include "pthread.c" diff --git a/cmd/getopt.bat b/cmd/getopt.bat new file mode 100644 index 00000000..5eb4db51 --- /dev/null +++ b/cmd/getopt.bat @@ -0,0 +1,21 @@ +@echo off +set SNAP= +set OPTIONS= +set EXT=--with-parallel +set PHP_TS=_TS +set DEPS=pthread +set EXTNAME=parallel +:parse +if "%~1" == "" goto endparse +if "%~1" == "--php" set PHP_VER=%2 +if "%~1" == "--option" set OPTIONS=%2 %OPTIONS% +if "%~1" == "--snap" set SNAP=snap +if "%~1" == "--shared" set EXT=--with-parallel=shared +if "%~1" == "--arch" set ARCH=x64 + +shift +goto parse +:endparse +if not defined PHP_VER ( + set PHP_VER=8.2.5 +) diff --git a/cmd/make_module.bat b/cmd/make_module.bat new file mode 100644 index 00000000..649ff333 --- /dev/null +++ b/cmd/make_module.bat @@ -0,0 +1,40 @@ +@echo off +if "%PHP_VER%" == "7.4.33" ( + set CRT=vc15 +) else ( + set CRT=vs16 +) + +if NOT EXIST php-sdk ( + curl -L https://github.com/php/php-sdk-binary-tools/archive/refs/tags/php-sdk-2.2.0.tar.gz | tar xzf - && ren php-sdk-binary-tools-php-sdk-2.2.0 php-sdk +) + +if NOT DEFINED ARCH set ARCH=x64 +if NOT EXIST php-sdk\phpdev\%CRT%\%ARCH% ( mkdir php-sdk\phpdev\%CRT%\%ARCH% ) +if NOT EXIST php-sdk\phpdev\%CRT%\%ARCH%\pecl ( mkdir php-sdk\phpdev\%CRT%\%ARCH%\pecl ) +if NOT EXIST php-sdk\phpdev\%CRT%\%ARCH%\pecl\%EXTNAME% ( mklink /j "php-sdk\phpdev\%CRT%\%ARCH%\pecl\%EXTNAME%" . ) + +cd php-sdk\phpdev\%CRT%\%ARCH% +IF EXIST php-src-php-%PHP_VER% ren php-src-php-%PHP_VER% php-%PHP_VER% +IF NOT EXIST php-%PHP_VER% ( + curl -L https://github.com/php/php-src/archive/refs/tags/php-%PHP_VER%.tar.gz | tar xzf - + IF EXIST php-src-php-%PHP_VER% ren php-src-php-%PHP_VER% php-%PHP_VER% +) + +cd ..\..\.. + +set "VSCMD_START_DIR=%CD%" +set "__VSCMD_ARG_NO_LOGO=yes" +set PHP_SDK_ROOT_PATH=%~dp0 +set PHP_SDK_ROOT_PATH=%PHP_SDK_ROOT_PATH:~0,-1% +set PHP_SDK_RUN_FROM_ROOT=.\php-sdk + +copy /Y ..\cmd\phpsdk_setshell.bat bin\phpsdk_setshell.bat + +bin\phpsdk_setshell.bat %CRT% %ARCH% && bin\phpsdk_setvars.bat && bin\phpsdk_dumpenv.bat && bin\phpsdk_buildtree.bat phpdev && cd php-%PHP_VER% && ..\..\..\..\bin\phpsdk_deps -u --no-backup && if NOT EXIST "..\deps\include\%DEPS%.h" ( + cd .. && ..\..\..\..\cmd\%DEPS%_build.bat && cd php-%PHP_VER% && buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi --with-iconv --enable-phar --enable-filter --with-openssl --enable-sockets --enable-mbstring --with-libxml --enable-fileinfo --enable-xmlwriter --enable-tokenizer --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. +) else if EXIST config.nice.bat ( + config.nice.bat && nmake %SNAP% && cd ..\..\..\..\.. +) else ( + buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi --with-iconv --enable-phar --enable-filter --with-openssl --enable-sockets --enable-mbstring --with-libxml --enable-fileinfo --enable-xmlwriter --enable-tokenizer --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. +) diff --git a/cmd/phpsdk_setshell.bat b/cmd/phpsdk_setshell.bat new file mode 100644 index 00000000..78dadb0a --- /dev/null +++ b/cmd/phpsdk_setshell.bat @@ -0,0 +1,175 @@ +@echo off + +if not defined PHP_SDK_RUN_FROM_ROOT ( + echo This script should not be run directly. + echo Use starter scripts looking like phpsdk-^-^.bat in the PHP SDK root instead. + goto out_error +) + + +if "%1"=="" goto :help +if "%1"=="/?" goto :help +if "%1"=="-h" goto :help +if "%1"=="--help" goto :help +if "%2"=="" goto :help + +cmd /c "exit /b 0" + +set PHP_SDK_VS=%1 +if /i not "%PHP_SDK_VS:~0,2%"=="vc" ( + if /i not "%PHP_SDK_VS:~0,2%"=="vs" ( +:malformed_vc_string + echo Malformed CRT string "%1" + set PHP_SDK_VS= + goto out_error + ) +) +if ""=="%PHP_SDK_VS:~2%" ( + goto malformed_vc_string +) +set /a TMP_CHK=%PHP_SDK_VS:~2% +if 14 gtr %TMP_CHK% ( + if "0"=="%TMP_CHK%" ( + if not "0"=="%PHP_SDK_VS:~2%" ( + set TMP_CHK= + goto malformed_vc_string + ) + ) + + echo At least vc14 is required + set PHP_SDK_VS= + set TMP_CHK= + goto out_error +) +set PHP_SDK_VS_NUM=%TMP_CHK% +set TMP_CHK= + +if /i not "%2"=="x64" ( + if /i not "%2"=="x86" ( + echo Unsupported arch "%2" + goto out_error + ) +) + +set PHP_SDK_ARCH=%2 + +rem check OS arch +set TMPKEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion +reg query "%TMPKEY%" /v "ProgramFilesDir (x86)" >nul 2>nul +if not errorlevel 1 ( + set PHP_SDK_OS_ARCH=x64 +) else ( + if /i "%PHP_SDK_ARCH%"=="x64" ( + echo 32-bit OS detected, native 64-bit toolchain is unavailable. + goto out_error + ) + set PHP_SDK_OS_ARCH=x86 +) +set TMPKEY= + +rem get vc base dir +if 15 gtr %PHP_SDK_VS_NUM% ( + if /i "%PHP_SDK_OS_ARCH%"=="x64" ( + set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC + ) else ( + set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC + ) + reg query !TMPKEY! /v ProductDir >nul 2>&1 + if errorlevel 1 ( + echo Couldn't determine VC%PHP_SDK_VS:~2% directory + goto out_error; + ) + for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VC_DIR=%%b +) else ( + rem build the version range, e.g. "[15,16]" + set /a PHP_SDK_VS_RANGE=PHP_SDK_VS_NUM + 1 + set PHP_SDK_VS_RANGE="[%PHP_SDK_VS_NUM%,!%PHP_SDK_VS_RANGE%!]" + for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text -prerelease') do ( + set PHP_SDK_VC_DIR=%%b\VC + ) + if not exist "!PHP_SDK_VC_DIR!" ( + for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do ( + set PHP_SDK_VC_DIR=%%b\VC + ) + if not exist "!PHP_SDK_VC_DIR!" ( + rem check for a preview release + for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do ( + set PHP_SDK_VC_DIR=%%b\VC + ) + if not exist "!PHP_SDK_VC_DIR!" ( + echo Could not determine '%PHP_SDK_VS%' directory + ) + ) + ) + set VSCMD_ARG_no_logo=nologo +) +set TMPKEY= +set PHP_SDK_VS_RANGE= + +if 15 gtr %PHP_SDK_VS_NUM% ( + rem get sdk dir + rem if 10.0 is available, it's ok + if /i "%PHP_SDK_OS_ARCH%"=="x64" ( + set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0 + ) else ( + set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0 + ) + for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do ( + for /f "tokens=2*" %%c in ('reg query "!TMPKEY!" /v ProductVersion') do ( + if exist "%%bInclude\%%d.0\um\Windows.h" ( + goto got_sdk + ) + ) + ) + + rem Otherwise 8.1 should be available anyway + if /i "%PHP_SDK_OS_ARCH%"=="x64" ( + set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1 + ) else ( + set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1 + ) + for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do ( + if exist "%%b\Include\um\Windows.h" ( + goto got_sdk + ) + ) + + echo Windows SDK not found. + goto out_error; +:got_sdk + set TMPKEY= +) + +if /i "%PHP_SDK_ARCH%"=="x64" ( + if 15 gtr %PHP_SDK_VS_NUM% ( + set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64 -vcvars_ver=%vcvars_ver% + ) else ( + set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=%vcvars_ver% + ) +) else ( + if 15 gtr %PHP_SDK_VS_NUM% ( + set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86 -vcvars_ver=%vcvars_ver% + ) else ( + set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86 -vcvars_ver=%vcvars_ver% + ) +) + +rem echo Visual Studio VC path %PHP_SDK_VC_DIR% +rem echo Windows SDK path %PHP_SDK_WIN_SDK_DIR% + + +goto out + +:help + echo "Start Visual Studio command line for PHP SDK" + echo "Usage: %0 vc arch" + echo nul + +:out_error + exit /b 3 + +:out +rem echo Shell configuration complete + exit /b 0 + +goto :eof diff --git a/cmd/pthread_build.bat b/cmd/pthread_build.bat new file mode 100644 index 00000000..ead2423e --- /dev/null +++ b/cmd/pthread_build.bat @@ -0,0 +1,20 @@ +@echo off +curl -LO https://cytranet.dl.sourceforge.net/project/pthreads4w/pthreads4w-code-v3.0.0.zip +unzip -xoq pthreads4w-code-v3.0.0.zip +ren pthreads4w-code-07053a521b0a9deb6db2a649cde1f828f2eb1f4f pthreads4w +mkdir pthreads4w\cmake +copy /Y ..\..\..\..\cmd\deps_build\cmake\*.* pthreads4w\cmake +copy /Y ..\..\..\..\cmd\deps_build\CMakeLists.txt pthreads4w +copy /Y ..\..\..\..\cmd\deps_build\pthread.cxx pthreads4w +cd pthreads4w +mkdir build +cd build +cmake .. -D BUILD_TESTING=OFF -G "Visual Studio 16 2019" -A %ARCH% -D CMAKE_BUILD_TYPE=Release +cmake --build . --config Release --target install +copy /Y ..\PTHREADS-BUILT\lib\*.* ..\..\deps\lib\ +copy /Y ..\PTHREADS-BUILT\include\*.* ..\..\deps\include\ +copy /Y ..\PTHREADS-BUILT\bin\*.* ..\..\deps\bin\ +cd ..\.. + +del pthreads4w-code-v3.0.0.zip +rmdir /S /Q pthreads4w diff --git a/cmd/windows_run_test.bat b/cmd/windows_run_test.bat new file mode 100644 index 00000000..164a80dc --- /dev/null +++ b/cmd/windows_run_test.bat @@ -0,0 +1,21 @@ +@echo off +call cmd\getopt.bat %* + +if "%PHP_VER%" == "7.4.33" ( + set CRT=vc15 +) else ( + set CRT=vs16 +) + +if NOT DEFINED ARCH set ARCH=x64 + +dir php-sdk\phpdev\%CRT%\%ARCH%\php-%PHP_VER%\%ARCH%\Release%PHP_TS% +dir php-sdk\phpdev\%CRT%\%ARCH%\php-%PHP_VER%\%ARCH%\Release%PHP_TS%\php-%PHP_VER% +dir php-sdk\phpdev\%CRT%\%ARCH%\php-%PHP_VER%\%ARCH%\Release%PHP_TS%\pecl-%PHP_VER% +cd php-sdk\phpdev\%CRT%\%ARCH%\php-%PHP_VER%\%ARCH%\Release%PHP_TS%\php-%PHP_VER% +IF EXIST php.exe ( +dir ext +php -m +php -v +php ..\..\..\run-tests.php --offline --show-diff --set-timeout 240 ..\..\..\tests +) From c67be3d28521b0ce71047e5c8b4e0fcf6ab87f4a Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Sun, 23 Apr 2023 16:44:29 -0400 Subject: [PATCH 19/22] insure pthreads.dll is added, allow shared builds --- cmd/{compile_x32.bat => compile_x86.bat} | 0 cmd/getopt.bat | 2 +- cmd/make_module.bat | 4 ++-- cmd/pthread_build.bat | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) rename cmd/{compile_x32.bat => compile_x86.bat} (100%) diff --git a/cmd/compile_x32.bat b/cmd/compile_x86.bat similarity index 100% rename from cmd/compile_x32.bat rename to cmd/compile_x86.bat diff --git a/cmd/getopt.bat b/cmd/getopt.bat index 5eb4db51..af572f70 100644 --- a/cmd/getopt.bat +++ b/cmd/getopt.bat @@ -10,7 +10,7 @@ if "%~1" == "" goto endparse if "%~1" == "--php" set PHP_VER=%2 if "%~1" == "--option" set OPTIONS=%2 %OPTIONS% if "%~1" == "--snap" set SNAP=snap -if "%~1" == "--shared" set EXT=--with-parallel=shared +if "%~1" == "--shared" ( set EXT=--with-parallel=shared && set SHARE==shared ) if "%~1" == "--arch" set ARCH=x64 shift diff --git a/cmd/make_module.bat b/cmd/make_module.bat index 649ff333..a81ae1d4 100644 --- a/cmd/make_module.bat +++ b/cmd/make_module.bat @@ -32,9 +32,9 @@ set PHP_SDK_RUN_FROM_ROOT=.\php-sdk copy /Y ..\cmd\phpsdk_setshell.bat bin\phpsdk_setshell.bat bin\phpsdk_setshell.bat %CRT% %ARCH% && bin\phpsdk_setvars.bat && bin\phpsdk_dumpenv.bat && bin\phpsdk_buildtree.bat phpdev && cd php-%PHP_VER% && ..\..\..\..\bin\phpsdk_deps -u --no-backup && if NOT EXIST "..\deps\include\%DEPS%.h" ( - cd .. && ..\..\..\..\cmd\%DEPS%_build.bat && cd php-%PHP_VER% && buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi --with-iconv --enable-phar --enable-filter --with-openssl --enable-sockets --enable-mbstring --with-libxml --enable-fileinfo --enable-xmlwriter --enable-tokenizer --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. + cd .. && ..\..\..\..\cmd\%DEPS%_build.bat && cd php-%PHP_VER% && buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi%SHARE% --with-iconv%SHARE% --enable-phar%SHARE% --enable-filter%SHARE% --with-openssl%SHARE% --enable-sockets%SHARE% --enable-mbstring%SHARE% --with-libxml%SHARE% --enable-fileinfo%SHARE% --enable-xmlwriter%SHARE% --enable-tokenizer%SHARE% --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. && copy /Y php-sdk\phpdev\%CRT%\%ARCH%\deps\bin\%DEPS%*.dll php-sdk\phpdev\%CRT%\%ARCH%\php-%PHP_VER%\%ARCH%\Release%PHP_TS%\php-%PHP_VER% ) else if EXIST config.nice.bat ( config.nice.bat && nmake %SNAP% && cd ..\..\..\..\.. ) else ( - buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi --with-iconv --enable-phar --enable-filter --with-openssl --enable-sockets --enable-mbstring --with-libxml --enable-fileinfo --enable-xmlwriter --enable-tokenizer --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. + buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi%SHARE% --with-iconv%SHARE% --enable-phar%SHARE% --enable-filter%SHARE% --with-openssl%SHARE% --enable-sockets%SHARE% --enable-mbstring%SHARE% --with-libxml%SHARE% --enable-fileinfo%SHARE% --enable-xmlwriter%SHARE% --enable-tokenizer%SHARE% --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. ) diff --git a/cmd/pthread_build.bat b/cmd/pthread_build.bat index ead2423e..4db7dd3f 100644 --- a/cmd/pthread_build.bat +++ b/cmd/pthread_build.bat @@ -14,6 +14,7 @@ cmake --build . --config Release --target install copy /Y ..\PTHREADS-BUILT\lib\*.* ..\..\deps\lib\ copy /Y ..\PTHREADS-BUILT\include\*.* ..\..\deps\include\ copy /Y ..\PTHREADS-BUILT\bin\*.* ..\..\deps\bin\ +copy /Y ..\PTHREADS-BUILT\bin\*.* ..\..\php-%PHP_VER%\%ARCH%\Release_TS\php-%PHP_VER% cd ..\.. del pthreads4w-code-v3.0.0.zip From 20b861deca1e3d1b8b87e2d7343a38fbccccbf29 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Sun, 23 Apr 2023 16:45:38 -0400 Subject: [PATCH 20/22] ci: create windows-release.yml --- .github/workflows/windows-release.yml | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/windows-release.yml diff --git a/.github/workflows/windows-release.yml b/.github/workflows/windows-release.yml new file mode 100644 index 00000000..92485ae5 --- /dev/null +++ b/.github/workflows/windows-release.yml @@ -0,0 +1,37 @@ +# GitHub Action for PHP with extensions +name: Windows Release + +on: + release: + types: [published, edited] + +jobs: + windows: + name: Windows + defaults: + run: + shell: cmd + runs-on: windows-2019 + strategy: + fail-fast: false + matrix: + php: ['8.0.28', '8.1.18', '8.2.5'] + thread: [ts] + arch: [x86, x64] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build static PHP ${{ matrix.php }}-${{ matrix.thread }} with pthreads and parallel + run: .\cmd\compile_${{ matrix.arch }}.bat --php ${{ matrix.php }} --${{ matrix.thread }} + - name: Create static PHP ${{ matrix.php }}-${{ matrix.thread }} Zip archive of pthreads and parallel + run: .\cmd\compile_${{ matrix.arch }}.bat --php ${{ matrix.php }} --${{ matrix.thread }} --snap + - name: Upload the windows binary artifacts + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: php-sdk\phpdev\vs16\${{ matrix.arch }}\php-${{matrix.php}}\${{ matrix.arch }}\Release_TS\*.zip + asset_name: php-${{matrix.php}}-${{ matrix.thread }}-Win32-vs16-${{ matrix.arch }}_static_ext_parallel-${{ github.event.release.tag_name }}.zip + tag: ${{ github.ref }} + overwrite: true + file_glob: true + body: "Static PHP-${{matrix.php}}-${{ matrix.thread }} Windows build, includes pthreads4w, parallel with all other extensions and Zip archives" From 36fd1ff2bc31080c5645e7604f6aa2397b0e6ebc Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Fri, 5 Jul 2024 19:53:09 -0400 Subject: [PATCH 21/22] ci: update windows-release.yml --- .github/workflows/windows-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-release.yml b/.github/workflows/windows-release.yml index 92485ae5..442a9c46 100644 --- a/.github/workflows/windows-release.yml +++ b/.github/workflows/windows-release.yml @@ -20,7 +20,7 @@ jobs: arch: [x86, x64] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build static PHP ${{ matrix.php }}-${{ matrix.thread }} with pthreads and parallel run: .\cmd\compile_${{ matrix.arch }}.bat --php ${{ matrix.php }} --${{ matrix.thread }} - name: Create static PHP ${{ matrix.php }}-${{ matrix.thread }} Zip archive of pthreads and parallel From 8e015c6ddc611098367ffb26c6628382f2196508 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Sat, 6 Jul 2024 14:20:30 -0400 Subject: [PATCH 22/22] shared build bug fix, remove it on `--with-iconv` --- cmd/make_module.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/make_module.bat b/cmd/make_module.bat index a81ae1d4..07674b04 100644 --- a/cmd/make_module.bat +++ b/cmd/make_module.bat @@ -32,9 +32,9 @@ set PHP_SDK_RUN_FROM_ROOT=.\php-sdk copy /Y ..\cmd\phpsdk_setshell.bat bin\phpsdk_setshell.bat bin\phpsdk_setshell.bat %CRT% %ARCH% && bin\phpsdk_setvars.bat && bin\phpsdk_dumpenv.bat && bin\phpsdk_buildtree.bat phpdev && cd php-%PHP_VER% && ..\..\..\..\bin\phpsdk_deps -u --no-backup && if NOT EXIST "..\deps\include\%DEPS%.h" ( - cd .. && ..\..\..\..\cmd\%DEPS%_build.bat && cd php-%PHP_VER% && buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi%SHARE% --with-iconv%SHARE% --enable-phar%SHARE% --enable-filter%SHARE% --with-openssl%SHARE% --enable-sockets%SHARE% --enable-mbstring%SHARE% --with-libxml%SHARE% --enable-fileinfo%SHARE% --enable-xmlwriter%SHARE% --enable-tokenizer%SHARE% --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. && copy /Y php-sdk\phpdev\%CRT%\%ARCH%\deps\bin\%DEPS%*.dll php-sdk\phpdev\%CRT%\%ARCH%\php-%PHP_VER%\%ARCH%\Release%PHP_TS%\php-%PHP_VER% + cd .. && ..\..\..\..\cmd\%DEPS%_build.bat && cd php-%PHP_VER% && buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi%SHARE% --with-iconv --enable-phar%SHARE% --enable-filter%SHARE% --with-openssl%SHARE% --enable-sockets%SHARE% --enable-mbstring%SHARE% --with-libxml%SHARE% --enable-fileinfo%SHARE% --enable-xmlwriter%SHARE% --enable-tokenizer%SHARE% --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. && copy /Y php-sdk\phpdev\%CRT%\%ARCH%\deps\bin\%DEPS%*.dll php-sdk\phpdev\%CRT%\%ARCH%\php-%PHP_VER%\%ARCH%\Release%PHP_TS%\php-%PHP_VER% ) else if EXIST config.nice.bat ( config.nice.bat && nmake %SNAP% && cd ..\..\..\..\.. ) else ( - buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi%SHARE% --with-iconv%SHARE% --enable-phar%SHARE% --enable-filter%SHARE% --with-openssl%SHARE% --enable-sockets%SHARE% --enable-mbstring%SHARE% --with-libxml%SHARE% --enable-fileinfo%SHARE% --enable-xmlwriter%SHARE% --enable-tokenizer%SHARE% --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. + buildconf --force --add-modules-dir=..\pecl\ && configure --enable-cli --with-ffi%SHARE% --with-iconv --enable-phar%SHARE% --enable-filter%SHARE% --with-openssl%SHARE% --enable-sockets%SHARE% --enable-mbstring%SHARE% --with-libxml%SHARE% --enable-fileinfo%SHARE% --enable-xmlwriter%SHARE% --enable-tokenizer%SHARE% --enable-embed %EXT% %ZTS% %OPTIONS% && nmake %SNAP% && cd ..\..\..\..\.. )