Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
- os: ubuntu-20.04
arch: "x86_64"
- os: ubuntu-22.04
arch: "i686"
Expand Down Expand Up @@ -78,12 +78,23 @@ jobs:
name: cibw-wheels-${{ matrix.os }}-${{ matrix.arch }}
path: ./wheelhouse/*.whl

- name: Install Ubuntu Python 2.7
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends python2 python3-virtualenv
virtualenv -p python2 ${HOME}/cp27
${HOME}/cp27/bin/python -m pip install -U pip
${HOME}/cp27/bin/python -m pip install -U setuptools wheel
echo "${HOME}/cp27/bin" >> $GITHUB_PATH

- name: Test wheel on host Linux
if: runner.os == 'Linux' && matrix.arch == 'x86_64'
run: |
pip install wheelhouse/*manylinux*x86_64*.whl
ninja --version
python -m ninja --version
python --version

build_sdist:
name: Build source distribution
Expand All @@ -105,43 +116,26 @@ jobs:
test_sdist:
name: Test SDist with python ${{ matrix.python }}
needs: [build_sdist]
# 22.04 doesn't have 2.7 or 3.6
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["2.7", "3.6", "3.12"]
python: ["3.7", "3.12"]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python ${{ matrix.python }}
if: matrix.python != '2.7'
with:
python-version: ${{ matrix.python }}

- name: Install Ubuntu Python 2.7
if: matrix.python == '2.7'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends python2 python3-virtualenv
virtualenv -p python2 ${HOME}/cp27
${HOME}/cp27/bin/python -m pip install -U pip
${HOME}/cp27/bin/python -m pip install -U setuptools wheel
echo "${HOME}/cp27/bin" >> $GITHUB_PATH

- uses: actions/download-artifact@v4
with:
name: cibw-sdist
path: sdist

- name: Install SDist
env:
SKBUILD_CONFIGURE_OPTIONS: "-DBUILD_CMAKE_FROM_SOURCE:BOOL=OFF"
run: pip install sdist/*.tar.gz

- name: Install test dependencies
run: pip install -r requirements-test.txt
run: pip install $(ls sdist/*.tar.gz)[test] -Ccmake.define.BUILD_CMAKE_FROM_SOURCE=OFF

- name: Test installed SDist
run: pytest ./tests
Expand Down
113 changes: 12 additions & 101 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ set(ARCHIVE_DOWNLOAD_DIR "${CMAKE_BINARY_DIR}" CACHE PATH "Directory where to do

include(NinjaUrls)

#-----------------------------------------------------------------------------
# Which archives ?
#-----------------------------------------------------------------------------
function(check_archive_var archive_var)
if(NOT DEFINED "${archive_var}_url")
message(FATAL_ERROR "Failed to determine which archive to download: '${archive_var}_url' variable is not defined")
Expand All @@ -29,9 +26,6 @@ if(WIN32)
endif()
check_archive_var("${src_archive}")

#-----------------------------------------------------------------------------
# Summary
#-----------------------------------------------------------------------------
message(STATUS "*********************************************")
message(STATUS "Ninja Python Distribution")
message(STATUS "")
Expand All @@ -45,105 +39,22 @@ message(STATUS " <src_archive>_url : ${${src_archive}_url}")
message(STATUS " <src_archive>_sha256 : ${${src_archive}_sha256}")
message(STATUS "*********************************************")

#-----------------------------------------------------------------------------
include(ExternalProject)

set(ep_download_no_progress_args)
if(NOT BUILD_VERBOSE)
set(ep_download_no_progress_args
DOWNLOAD_NO_PROGRESS 1
)
endif()

#-----------------------------------------------------------------------------
# Download source
#-----------------------------------------------------------------------------
if(NOT DEFINED Ninja_SOURCE_DIR)
set(Ninja_SOURCE_DIR "${CMAKE_SOURCE_DIR}/Ninja-src")

# Download selected source archive
ExternalProject_add(download_ninja_source
SOURCE_DIR ${Ninja_SOURCE_DIR}
URL ${${src_archive}_url}
URL_HASH SHA256=${${src_archive}_sha256}
DOWNLOAD_DIR ${ARCHIVE_DOWNLOAD_DIR}
USES_TERMINAL_DOWNLOAD 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
BUILD_IN_SOURCE 1
INSTALL_COMMAND ""
${ep_download_no_progress_args}
)
message(STATUS "download_ninja_source - URL: ${${src_archive}_url}")
elseif(NOT EXISTS ${Ninja_SOURCE_DIR})
message(FATAL_ERROR "Ninja_SOURCE_DIR is set to a nonexistent directory")
endif()

#-----------------------------------------------------------------------------
# Build from source
#-----------------------------------------------------------------------------
set(Ninja_BINARY_DIR ${CMAKE_BINARY_DIR}/Ninja-build)
# cache arguments
set(_cache_args )
foreach(var_name IN ITEMS
CMAKE_BUILD_TYPE
CMAKE_TOOLCHAIN_FILE
CMAKE_BUILD_PARALLEL_LEVEL
CMAKE_JOB_POOLS
CMAKE_JOB_POOL_COMPILE
CMAKE_JOB_POOL_LINK
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_SYSROOT
)
if(DEFINED ${var_name})
list(APPEND _cache_args -D${var_name}:STRING=${${var_name}})
message(STATUS "SuperBuild - ${var_name}: ${${var_name}}")
endif()
endforeach()

# _cache_args should not be empty
list(APPEND _cache_args -DNINJA_SUPERBUILD:BOOL=true)
ExternalProject_add(build_ninja
SOURCE_DIR ${Ninja_SOURCE_DIR}
BINARY_DIR ${Ninja_BINARY_DIR}
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
BUILD_ALWAYS 1
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
INSTALL_COMMAND ""
CMAKE_CACHE_ARGS ${_cache_args}
DEPENDS
download_ninja_source
)
set(ninja_executable ${Ninja_BINARY_DIR}/ninja${CMAKE_EXECUTABLE_SUFFIX})
set(NINJA_BUILD_LAST_STEP "build")

# This should not be stripped or tested if cross-compiling on Windows
if(CMAKE_CROSS_COMPILE OR NOT DEFINED ENV{DIST_EXTRA_CONFIG})
find_program(STRIP_EXECUTABLE strip)
if(STRIP_EXECUTABLE)
ExternalProject_Add_Step(build_ninja strip_executables
DEPENDEES ${NINJA_BUILD_LAST_STEP}
COMMENT "Stripping CMake executables"
COMMAND ${STRIP_EXECUTABLE} ${ninja_executable}
USES_TERMINAL 1
)
set(NINJA_BUILD_LAST_STEP "strip_executables")
endif()

if(RUN_NINJA_TEST)
ExternalProject_Add_Step(build_ninja run_ninja_test_suite
DEPENDEES ${NINJA_BUILD_LAST_STEP}
COMMENT "Running Ninja test suite"
COMMAND ${Ninja_BINARY_DIR}/ninja_test${CMAKE_EXECUTABLE_SUFFIX}
WORKING_DIRECTORY ${Ninja_BINARY_DIR}
USES_TERMINAL 1
)
set(NINJA_BUILD_LAST_STEP "run_ninja_test_suite")
endif()
endif()

install(FILES ${Ninja_SOURCE_DIR}/misc/ninja_syntax.py DESTINATION src/ninja)
install(PROGRAMS ${ninja_executable} DESTINATION src/ninja/data/bin)
include(FetchContent)
FetchContent_Declare(
ninja
URL ${${src_archive}_url}
URL_HASH SHA256=${${src_archive}_sha256}
DOWNLOAD_DIR ${ARCHIVE_DOWNLOAD_DIR}
${ep_download_no_progress_args}
)
FetchContent_MakeAvailable(ninja)

install(TARGETS ninja COMPONENT python DESTINATION "${SKBUILD_SCRIPTS_DIR}")
install(FILES "${ninja_SOURCE_DIR}/misc/ninja_syntax.py" COMPONENT python DESTINATION ninja)
14 changes: 0 additions & 14 deletions MANIFEST.in

This file was deleted.

2 changes: 0 additions & 2 deletions constraints-ci.txt

This file was deleted.

Loading