Skip to content

Commit

Permalink
Merge pull request #335 from Distributive-Network/caleb/fix/publish
Browse files Browse the repository at this point in the history
fix(CI): fix building docs in CI by adding a 'None' BUILD_TYPE
  • Loading branch information
philippedistributive authored May 1, 2024
2 parents ccf210b + aadda43 commit 7b661a4
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 120 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/test-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ on:
- 'Profile'
- 'DRelease'
- 'Release'
- 'None'
pull_request:

env:
Expand Down Expand Up @@ -154,15 +155,9 @@ jobs:
if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
sudo apt-get update -y
sudo apt-get install -y cmake graphviz llvm
# Install Doxygen
# the newest version in Ubuntu 20.04 repository is 1.8.17, but we need Doxygen 1.9 series
wget -c -q https://www.doxygen.nl/files/doxygen-1.9.7.linux.bin.tar.gz
tar xf doxygen-1.9.7.linux.bin.tar.gz
cd doxygen-1.9.7 && sudo make install && cd -
rm -rf doxygen-1.9.7 doxygen-1.9.7.linux.bin.tar.gz
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
brew update || true # allow failure
brew install cmake doxygen pkg-config wget coreutils # `coreutils` installs the `realpath` command
brew install cmake pkg-config wget coreutils # `coreutils` installs the `realpath` command
fi
echo "Installing python deps"
poetry self add "poetry-dynamic-versioning[plugin]"
Expand Down Expand Up @@ -250,8 +245,15 @@ jobs:
version: 1.5.1
- name: Build source distribution (sdist) file
run: |
# Install Doxygen
# the newest version in Ubuntu 20.04 repository is 1.8.17, but we need Doxygen 1.9 series
wget -c -q https://www.doxygen.nl/files/doxygen-1.9.7.linux.bin.tar.gz
tar xf doxygen-1.9.7.linux.bin.tar.gz
cd doxygen-1.9.7 && sudo make install && cd -
rm -rf doxygen-1.9.7 doxygen-1.9.7.linux.bin.tar.gz
poetry self add "poetry-dynamic-versioning[plugin]"
BUILD_DOCS=1 BUILD_TYPE=Release poetry build --format=sdist
BUILD_DOCS=1 BUILD_TYPE=None poetry install
poetry build --format=sdist
ls -lah ./dist/
- name: Upload sdist as CI artifacts
uses: actions/upload-artifact@v3
Expand Down
67 changes: 35 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,19 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
SET(RELEASE_FLAGS "${OPTIMIZED} ${STRIP_SYMBOLS}")

if(GENERATOR_IS_MULTI_CONFIG)
set(CMAKE_CONFIGURATION_TYPES "Profile;Debug;DRelease;Release" CACHE STRING "" FORCE)
set(CMAKE_CONFIGURATION_TYPES "Profile;Debug;DRelease;Release;None" CACHE STRING "" FORCE)
string(APPEND COMPILE_FLAGS "$<$<CONFIG:Profile>:${PROFILE_FLAGS}> $<$<CONFIG:Debug>:${DEBUG_FLAGS}> $<$<CONFIG:DRelease>:${DRELEASE_FLAGS}> $<$<CONFIG:Release>:${RELEASE_FLAGS}>")
else()
set_property(CACHE PM_BUILD_TYPE PROPERTY HELPSTRING "Choose the type of build")
set_property(CACHE PM_BUILD_TYPE PROPERTY STRINGS "Profile;Debug;DRelease;Release")
set_property(CACHE PM_BUILD_TYPE PROPERTY STRINGS "Profile;Debug;DRelease;Release;None")
if(PM_BUILD_TYPE STREQUAL "Profile")
list(APPEND COMPILE_FLAGS "${PROFILE_FLAGS}")
elseif(PM_BUILD_TYPE STREQUAL "Debug")
list(APPEND COMPILE_FLAGS "${DEBUG_FLAGS}")
elseif(PM_BUILD_TYPE STREQUAL "DRelease")
list(APPEND COMPILE_FLAGS "${DRELEASE_FLAGS}")
elseif(PM_BUILD_TYPE STREQUAL "None")
message("PM_BUILD_TYPE is None. Not compiling.")
else() #Release build
message("PM_BUILD_TYPE not detected or invalid value, defaulting to Release build.")
set(PM_BUILD_TYPE Release CACHE STRING "" FORCE)
Expand All @@ -72,33 +74,37 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
list(JOIN COMPILE_FLAGS " " COMPILE_FLAGS)
endif()

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS}")

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
if(APPLE)
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
find_package(SpiderMonkey REQUIRED)
set(PYTHON_MAJOR $ENV{Python_VERSION_MAJOR})
set(PYTHON_MINOR $ENV{Python_VERSION_MINOR})
set(PYTHONLIBS_VERSION_STRING ${Python_VERSION})
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS})
set(PYTHON_LIBRARIES ${Python_LIBRARIES})
elseif(UNIX)
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
set(Python_FIND_VIRTUALENV FIRST) # (require cmake >= v3.15 and this is the default) use the Python version configured by pyenv if available
set(PYTHON_LIBRARIES ${Python_LIBRARIES})
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS})
find_package(SpiderMonkey REQUIRED)
elseif(WIN32)
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
set(Python_FIND_VIRTUALENV FIRST) # (require cmake >= v3.15 and this is the default) use the Python version configured by pyenv if available
set(PYTHON_LIBRARIES ${Python_LIBRARIES})
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS})
find_package(SpiderMonkey REQUIRED)
endif()
message("${CMAKE_SYSTEM_NAME} - Using Python:${Python_VERSION} - Libraries:${Python_LIBRARIES} - IncludeDirs: ${Python_INCLUDE_DIRS}")
include_directories(${Python_INCLUDE_DIRS})
include_directories(${SPIDERMONKEY_INCLUDE_DIR})
if(NOT PM_BUILD_TYPE STREQUAL "None")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS}")

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
if(APPLE)
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
find_package(SpiderMonkey REQUIRED)
set(PYTHON_MAJOR $ENV{Python_VERSION_MAJOR})
set(PYTHON_MINOR $ENV{Python_VERSION_MINOR})
set(PYTHONLIBS_VERSION_STRING ${Python_VERSION})
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS})
set(PYTHON_LIBRARIES ${Python_LIBRARIES})
elseif(UNIX)
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
set(Python_FIND_VIRTUALENV FIRST) # (require cmake >= v3.15 and this is the default) use the Python version configured by pyenv if available
set(PYTHON_LIBRARIES ${Python_LIBRARIES})
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS})
find_package(SpiderMonkey REQUIRED)
elseif(WIN32)
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
set(Python_FIND_VIRTUALENV FIRST) # (require cmake >= v3.15 and this is the default) use the Python version configured by pyenv if available
set(PYTHON_LIBRARIES ${Python_LIBRARIES})
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS})
find_package(SpiderMonkey REQUIRED)
endif()
message("${CMAKE_SYSTEM_NAME} - Using Python:${Python_VERSION} - Libraries:${Python_LIBRARIES} - IncludeDirs: ${Python_INCLUDE_DIRS}")
include_directories(${Python_INCLUDE_DIRS})
include_directories(${SPIDERMONKEY_INCLUDE_DIR})
# Add compiled folder directories
add_subdirectory(src)
endif(NOT PM_BUILD_TYPE STREQUAL "None")

# Add doxygen if this is the main app
option(BUILD_DOCS "Build documentation" OFF)
Expand All @@ -112,6 +118,3 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
endif()

endif()

# Add compiled folder directories
add_subdirectory(src)
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# @date March 2024
#

BUILD = Debug # (case-insensitive) Release, DRelease, Debug, or Profile
BUILD = Debug # (case-insensitive) Release, DRelease, Debug, Profile, or None
DOCS = false
VERBOSE = true
PYTHON = python3
Expand All @@ -25,6 +25,8 @@ else ifeq ($(BUILD),Debug)
PYTHON_BUILD_ENV += BUILD_TYPE=Debug
else ifeq ($(BUILD),DRelease)
PYTHON_BUILD_ENV += BUILD_TYPE=DRelease
else ifeq($(BUILD), None)
PYTHON_BUILD_ENV += BUILD_TYPE=None
else # Release build
PYTHON_BUILD_ENV += BUILD_TYPE=Release
endif
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ PythonMonkey supports multiple build types, which you can build by setting the `
- `DRelease`: same as `Release`, except symbols are not stripped
- `Debug`: minimal optimizations
- `Profile`: same as `Debug`, except profiling is enabled
- `None`: don't compile (useful if you only want to build the docs)

If you are using VSCode, you can just press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>B</kbd> to [run build task](https://code.visualstudio.com/docs/editor/tasks#_custom-tasks) - We have [the `tasks.json` file configured for you](.vscode/tasks.json).

Expand Down
3 changes: 3 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def run_cmake_build():


def copy_artifacts():
if "BUILD_TYPE" in os.environ and os.environ["BUILD_TYPE"].title() == "None":
return # do not copy artifacts if we did not build them

if platform.system() == "Windows":
execute("cp ./build/src/*/pythonmonkey.pyd ./python/pythonmonkey/", cwd=TOP_DIR) # Release or Debug build
execute("cp ./_spidermonkey_install/lib/mozjs-*.dll ./python/pythonmonkey/", cwd=TOP_DIR)
Expand Down
Loading

0 comments on commit 7b661a4

Please sign in to comment.