Skip to content

Commit

Permalink
Patch TBB makefile, add testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Jan 8, 2024
1 parent 0061d8f commit 3cd6894
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 22 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/rtools-make.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Windows Rtools40

on:
pull_request:
branches: [ develop, master ]
push:
branches: [ tbb-rtools-make ]
paths-ignore:
- 'doygen/**'
- 'hooks/**'
- 'licenses/**'
- 'LICENSE.md'
- 'README.md'
- 'RELEASE-NOTES.txt'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
rtools-build-check:
runs-on: windows-latest
name: R ${{ matrix.config.r }} with Rtools ${{ matrix.config.rtools }}

strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: '4.3.2', rtools: '43', path: 'C:/rtools43/x86_64-w64-mingw32.static.posix/bin;C:/rtools43/usr/bin'}
- {os: windows-latest, r: '4.2.3', rtools: '42', path: 'C:/rtools42/x86_64-w64-mingw32.static.posix/bin;C:/rtools42/usr/bin'}
- {os: windows-latest, r: '4.1.3', rtools: '40', path: 'C:/rtools40/mingw64/bin;C:/rtools40/usr/bin'}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
rtools-version: ${{ matrix.config.rtools }}

- name: Set path for Rtools${{ matrix.config.rtools }}
run: echo "${{ matrix.config.path }}" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8

- name: Build Math libs
shell: powershell
run: |
Add-Content make\local "O=1`n"
make -f make/standalone math-libs -j2
- name: Add TBB to PATH
shell: powershell
run: echo "D:/a/math/math/lib/tbb" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Run prim and rev unit tests
shell: powershell
run: |
python.exe runTests.py -j2 test/unit/*_test.cpp
python.exe runTests.py -j2 test/unit/math/*_test.cpp
python.exe runTests.py -j2 test/unit/math/prim
python.exe runTests.py -j2 test/unit/math/rev
python.exe runTests.py -j2 test/unit/math/memory
- name: Upload gtest_output xml
uses: actions/upload-artifact@v4
if: failure()
with:
name: gtest_outputs_xml
path: '**/*_test.xml'
12 changes: 8 additions & 4 deletions lib/tbb_2020.3/build/windows.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

export SHELL = cmd
ifeq (true,$(USING_RTOOLS))
export SHELL = sh.exe
else
export SHELL = cmd
endif

ifdef tbb_build_dir
test_dir:=$(tbb_build_dir)
Expand All @@ -22,7 +26,7 @@ endif

# A convenience wrapper for calls to detect.js.
# $(1) is the full command line for the script, e.g. /minversion icl 12
detect_js = $(shell cmd /C "cscript /nologo /E:jscript $(tbb_root)/build/detect.js $(1)")
detect_js = $(shell cmd //C "cscript //nologo //E:jscript $(tbb_root)/build/detect.js $(1)")

# TODO give an error if archs doesn't match
ifndef arch
Expand Down Expand Up @@ -110,8 +114,8 @@ ifneq ($(filter vc8 vc9,$(runtime)),)
RML.MANIFEST = tbbmanifest.exe.manifest
endif

MAKE_VERSIONS = cmd /C cscript /nologo /E:jscript $(subst \,/,$(tbb_root))/build/version_info_windows.js $(compiler) $(arch) $(subst \,/,"$(VERSION_FLAGS)") > version_string.ver
MAKE_TBBVARS = cmd /C "$(subst /,\,$(tbb_root))\build\generate_tbbvars.bat"
MAKE_VERSIONS = cmd //C cscript //nologo //E:jscript $(subst \,/,$(tbb_root))/build/version_info_windows.js $(compiler) $(arch) $(subst \,/,"$(VERSION_FLAGS)") > version_string.ver
MAKE_TBBVARS = cmd //C "$(subst /,\,$(tbb_root))\build\generate_tbbvars.bat"

TEST_LAUNCHER = $(subst /,\,$(tbb_root))\build\test_launcher.bat $(largs)

Expand Down
11 changes: 3 additions & 8 deletions make/libraries
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ ifeq (Windows_NT, $(OS))
ifeq ($(IS_UCRT),true)
TBB_CXXFLAGS += -D_UCRT
endif
USING_RTOOLS := true
endif

# If brackets or spaces are found in MAKE on Windows
Expand All @@ -157,12 +158,6 @@ $(TBB_BIN)/tbb-make-check:
ifeq ($(OS),Windows_NT)
ifneq ($(MAKE),$(MAKE_ESCAPED))
$(error '$nError:$n$nThe RTools toolchain is installed in a path with spaces or brackets.$nPlease reinstall the toolchain.$n$n')
else
if ! [[ $(MAKE) =~ mingw32 ]]; then \
echo "ERROR: Please use mingw32-make on Windows to build the Intel TBB library."; \
echo "This is packaged with RTools, for example."; \
exit 1; \
fi
endif
endif
@mkdir -p $(TBB_BIN)
Expand All @@ -172,11 +167,11 @@ endif
$(TBB_BIN)/tbb.def: $(TBB_BIN)/tbb-make-check
@mkdir -p $(TBB_BIN)
touch $(TBB_BIN)/version_$(notdir $(TBB))
tbb_root="$(TBB_RELATIVE_PATH)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbb" compiler=$(TBB_CXX_TYPE) cfg=release stdver=c++1y CXXFLAGS="$(TBB_CXXFLAGS)"
USING_RTOOLS=$(USING_RTOOLS) tbb_root="$(TBB_RELATIVE_PATH)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbb" compiler=$(TBB_CXX_TYPE) cfg=release stdver=c++1y CXXFLAGS="$(TBB_CXXFLAGS)"

$(TBB_BIN)/tbbmalloc.def: $(TBB_BIN)/tbb-make-check
@mkdir -p $(TBB_BIN)
tbb_root="$(TBB_RELATIVE_PATH)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbbmalloc" compiler=$(TBB_CXX_TYPE) cfg=release stdver=c++1y malloc CXXFLAGS="$(TBB_CXXFLAGS)"
USING_RTOOLS=$(USING_RTOOLS) tbb_root="$(TBB_RELATIVE_PATH)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbbmalloc" compiler=$(TBB_CXX_TYPE) cfg=release stdver=c++1y malloc CXXFLAGS="$(TBB_CXXFLAGS)"

$(TBB_BIN)/libtbb.dylib: $(TBB_BIN)/tbb.def
$(TBB_BIN)/libtbbmalloc.dylib: $(TBB_BIN)/tbbmalloc.def
Expand Down
12 changes: 3 additions & 9 deletions runTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ def doCommand(command, exit_on_failure=True):

def generateTests(j):
"""Generate all tests and pass along the j parameter to make."""
if isWin():
doCommand("mingw32-make -j%d generate-tests -s" % (j or 1))
else:
doCommand("make -j%d generate-tests -s" % (j or 1))
doCommand("make -j%d generate-tests -s" % (j or 1))


def divide_chunks(l, n):
Expand Down Expand Up @@ -238,10 +235,7 @@ def cleanupJumboTests(paths):

def makeTest(name, j):
"""Run the make command for a given single test."""
if isWin():
doCommand("mingw32-make -j%d %s" % (j or 1, name))
else:
doCommand("make -j%d %s" % (j or 1, name))
doCommand("make -j%d %s" % (j or 1, name))


def commandExists(command):
Expand Down Expand Up @@ -374,7 +368,7 @@ def handleExpressionTests(tests, only_functions, n_test_files):
def checkToolchainPathWindows():
if isWin():
p1 = subprocess.Popen(
"where.exe mingw32-make",
"where.exe make",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
Expand Down
2 changes: 1 addition & 1 deletion test/sig_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys

if os.name == "nt": # Windows
make = "mingw32-make"
make = "make"
exe_extension = ".exe"
else:
make = "make"
Expand Down

0 comments on commit 3cd6894

Please sign in to comment.