From 748c341f25bf7b4090103f5d2e988f9ff4c40d70 Mon Sep 17 00:00:00 2001 From: Kien Nguyen Date: Sun, 4 Aug 2024 13:31:43 -0700 Subject: [PATCH] support inner loop build --- .github/workflows/build.yml | 10 +-- emacs-build.sh | 51 +++++++----- ...se-SetHandleInformation-to-set-NOINH.patch | 80 +++++++++++++++++++ ...o-need-to-reset-to-uninherited-std-h.patch | 32 -------- scripts/tools.sh | 1 + 5 files changed, 115 insertions(+), 59 deletions(-) create mode 100644 patches/0001-init_winntproc-Use-SetHandleInformation-to-set-NOINH.patch delete mode 100644 patches/0001-init_winntproc-no-need-to-reset-to-uninherited-std-h.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index abd6f0b..40d05c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,13 +71,9 @@ jobs: - name: Build Emacs if: runner.os == 'Windows' - uses: Wandalen/wretry.action@master - with: - # Require --nativecomp and --with-* flags, else the deps will not be included properly - command: | - .\emacs-build.cmd --nativecomp --slim --with-rsvg --build - attempt_limit: 5 - attempt_delay: 2000 + # Require --nativecomp and --with-* flags, else the deps will not be included properly + run: | + .\emacs-build.cmd --nativecomp --slim --with-rsvg --build - name: Package Emacs if: runner.os == 'Windows' diff --git a/emacs-build.sh b/emacs-build.sh index 189b9a8..7954392 100644 --- a/emacs-build.sh +++ b/emacs-build.sh @@ -204,33 +204,42 @@ function action1_ensure_packages () ensure_packages `emacs_root_packages` } -function action2_build () +function action2.0_prep_build () { - echo start building + echo Preparing build directory + prepare_source_dir $emacs_source_dir \ + && prepare_build_dir $emacs_build_dir \ + && emacs_configure_build_dir && return 0 + + echo Configuration failed + return -1 +} + +function action2.1_build () +{ + echo Start building rm -f "$emacs_install_dir/bin/emacs.exe" # See https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-emacs/PKGBUILD # _sanity_check=$([[ "${MSYSTEM}" != MINGW* ]] || echo yes) _sanity_check=$(echo yes) - if prepare_source_dir $emacs_source_dir \ - && prepare_build_dir $emacs_build_dir && emacs_configure_build_dir; then - echo Building Emacs in directory $emacs_build_dir - if [[ "$_sanity_check" == "yes" ]]; then - make -j $emacs_build_threads -C $emacs_build_dir && return 0 - else - make -j $emacs_build_threads -C $emacs_build_dir actual-all && return 0 - fi + echo Building Emacs in directory $emacs_build_dir + if [[ "$_sanity_check" == "yes" ]]; then + make -j $emacs_build_threads -C $emacs_build_dir && return 0 + else + make -j $emacs_build_threads -C $emacs_build_dir actual-all && return 0 fi - echo Configuration and build process failed + + echo Build process failed return -1 } -function action2_install () +function action2.2_install () { if test -f "$emacs_install_dir/bin/emacs.exe"; then echo $emacs_install_dir/bin/emacs.exe exists - echo refusing to reinstall + echo Refusing to reinstall else rm -rf "$emacs_install_dir" mkdir -p "$emacs_install_dir/bin" @@ -499,14 +508,16 @@ while test -n "$*"; do --clean-all) add_actions action0_clean action0_clean_rest;; --clone) add_actions action0_clone;; --ensure) add_actions action1_ensure_packages;; - --build) add_actions action1_ensure_packages action2_build;; + --configure) add_actions action2.0_prep_build;; + --build-dev) add_actions action2.1_build;; + --build) add_actions action1_ensure_packages action2.0_prep_build action2.1_build;; --deps) add_actions action1_ensure_packages action3_package_deps;; - --pack-emacs) add_actions action2_install action4_package_emacs;; - --pack-all) add_actions action1_ensure_packages action3_package_deps action2_install action5_package_all;; - # --pack-all) add_actions action1_ensure_packages action2_install;; + --pack-emacs) add_actions action2.2_install action4_package_emacs;; + --pack-all) add_actions action1_ensure_packages action3_package_deps action2.2_install action5_package_all;; + # --pack-all) add_actions action1_ensure_packages action2.2_install;; - --pdf-tools) add_actions action2_install action3_pdf_tools;; - --mu) add_actions action2_install action3_mu;; + --pdf-tools) add_actions action2.2_install action3_pdf_tools;; + --mu) add_actions action2.2_install action3_mu;; --isync) add_actions action3_isync;; --aspell) add_actions action3_aspell;; --hunspell) add_actions action3_hunspell;; @@ -536,7 +547,7 @@ if test -z "$emacs_branch"; then fi actions=`unique_list $actions` if test -z "$actions"; then - actions="action0_clone action1_ensure_packages action2_build action3_package_deps action5_package_all" + actions="action0_clone action1_ensure_packages action2.1_build action3_package_deps action5_package_all" fi features=`unique_list $features` ensure_mingw_build_software diff --git a/patches/0001-init_winntproc-Use-SetHandleInformation-to-set-NOINH.patch b/patches/0001-init_winntproc-Use-SetHandleInformation-to-set-NOINH.patch new file mode 100644 index 0000000..ceb4ef6 --- /dev/null +++ b/patches/0001-init_winntproc-Use-SetHandleInformation-to-set-NOINH.patch @@ -0,0 +1,80 @@ +From 65fb0e39e3e2b355735f0f94ea2c46f9665c3e2b Mon Sep 17 00:00:00 2001 +From: Kien Nguyen +Date: Sun, 4 Aug 2024 04:29:35 -0700 +Subject: [PATCH] init_winntproc: Use SetHandleInformation to set NOINHERIT + +--- + src/w32.c | 57 +++------------------------------------------------- + 1 file changed, 3 insertions(+), 54 deletions(-) + +diff --git a/src/w32.c b/src/w32.c +index 31ffa301c2f..10d01ebb502 100644 +--- a/src/w32.c ++++ b/src/w32.c +@@ -10480,60 +10480,9 @@ init_ntproc (int dumping) + /* Initial preparation for subprocess support: replace our standard + handles with non-inheritable versions. */ + { +- HANDLE parent; +- HANDLE stdin_save = INVALID_HANDLE_VALUE; +- HANDLE stdout_save = INVALID_HANDLE_VALUE; +- HANDLE stderr_save = INVALID_HANDLE_VALUE; +- +- parent = GetCurrentProcess (); +- +- /* ignore errors when duplicating and closing; typically the +- handles will be invalid when running as a gui program. */ +- DuplicateHandle (parent, +- GetStdHandle (STD_INPUT_HANDLE), +- parent, +- &stdin_save, +- 0, +- FALSE, +- DUPLICATE_SAME_ACCESS); +- +- DuplicateHandle (parent, +- GetStdHandle (STD_OUTPUT_HANDLE), +- parent, +- &stdout_save, +- 0, +- FALSE, +- DUPLICATE_SAME_ACCESS); +- +- DuplicateHandle (parent, +- GetStdHandle (STD_ERROR_HANDLE), +- parent, +- &stderr_save, +- 0, +- FALSE, +- DUPLICATE_SAME_ACCESS); +- +- fclose (stdin); +- fclose (stdout); +- fclose (stderr); +- +- if (stdin_save != INVALID_HANDLE_VALUE) +- _open_osfhandle ((intptr_t) stdin_save, O_TEXT); +- else +- _open ("nul", O_TEXT | O_NOINHERIT | O_RDONLY); +- _fdopen (0, "r"); +- +- if (stdout_save != INVALID_HANDLE_VALUE) +- _open_osfhandle ((intptr_t) stdout_save, O_TEXT); +- else +- _open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY); +- _fdopen (1, "w"); +- +- if (stderr_save != INVALID_HANDLE_VALUE) +- _open_osfhandle ((intptr_t) stderr_save, O_TEXT); +- else +- _open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY); +- _fdopen (2, "w"); ++ SetHandleInformation(GetStdHandle(STD_INPUT_HANDLE), HANDLE_FLAG_INHERIT, 0); ++ SetHandleInformation(GetStdHandle(STD_OUTPUT_HANDLE), HANDLE_FLAG_INHERIT, 0); ++ SetHandleInformation(GetStdHandle(STD_ERROR_HANDLE), HANDLE_FLAG_INHERIT, 0); + } + + /* unfortunately, atexit depends on implementation of malloc */ +-- +2.46.0.windows.1 + diff --git a/patches/0001-init_winntproc-no-need-to-reset-to-uninherited-std-h.patch b/patches/0001-init_winntproc-no-need-to-reset-to-uninherited-std-h.patch deleted file mode 100644 index bf8ca3f..0000000 --- a/patches/0001-init_winntproc-no-need-to-reset-to-uninherited-std-h.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 2e73677cbfe5236c9604b32ea7bfaf320f68c055 Mon Sep 17 00:00:00 2001 -From: Kien Nguyen -Date: Sun, 4 Aug 2024 04:29:35 -0700 -Subject: [PATCH] init_winntproc: no need to reset to uninherited std handles - ---- - src/w32.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/w32.c b/src/w32.c -index 31ffa301c2f..d854046af0d 100644 ---- a/src/w32.c -+++ b/src/w32.c -@@ -10477,6 +10477,7 @@ init_ntproc (int dumping) - if (getenv ("PRELOAD_WINSOCK") != NULL) - init_winsock (TRUE); - -+#ifndef _UCRT /* The handles should be non-inheritable already */ - /* Initial preparation for subprocess support: replace our standard - handles with non-inheritable versions. */ - { -@@ -10535,6 +10536,7 @@ init_ntproc (int dumping) - _open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY); - _fdopen (2, "w"); - } -+#endif - - /* unfortunately, atexit depends on implementation of malloc */ - /* atexit (term_ntproc); */ --- -2.46.0.windows.1 - diff --git a/scripts/tools.sh b/scripts/tools.sh index 834895b..7ea2dfe 100644 --- a/scripts/tools.sh +++ b/scripts/tools.sh @@ -5,6 +5,7 @@ function errcho () function unique_list () { + # To preserve order, we use awk to remove duplicates `awk '!seen[$0]++'` echo $* | sed -e 's,[[:space:]][[:space:]]*,\n,g' | sort | uniq | sed -e '/^$/d' }