Skip to content

Commit

Permalink
Allow disabling with_ruby. We don't need it for C#, and it fails to b…
Browse files Browse the repository at this point in the history
…uild on win32
  • Loading branch information
jmarrec committed May 22, 2024
1 parent 2a0d5dd commit 91142f1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/buildCSharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/CMakeLists.txt
rm conan.lock
aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/conan.lock
rm conanfile.py
aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/conanfile.py
cd src/measure/
rm Measure.i
aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/src/measure/Measure.i
Expand Down Expand Up @@ -130,9 +132,9 @@ jobs:
begin_group "Conan install"
if [ "$RUNNER_OS" == "macOS" ]; then
# Avoid "builtin __has_nothrow_assign is deprecated; use __is_nothrow_assignable instead" in boost/1.79 with recent clang
conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=${{ env.BUILD_TYPE }} -o 'openstudio/:*with_testing=False' -o 'openstudio/:*with_benchmark=False' -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']"
conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=${{ env.BUILD_TYPE }} -o 'openstudio/*:with_testing=False' -o 'openstudio/*:with_benchmark=False' -o 'openstudio/*:with_ruby=False' -o 'openstudio/*:with_python=False' -o 'openstudio/*:with_csharp=True' -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']"
else
conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=${{ env.BUILD_TYPE }} -o 'openstudio/:*with_testing=False' -o 'openstudio/:*with_benchmark=False'
conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=${{ env.BUILD_TYPE }} -o 'openstudio/*:with_testing=False' -o 'openstudio/*:with_benchmark=False' -o 'openstudio/*:with_ruby=False' -o 'openstudio/*:with_python=False' -o 'openstudio/*:with_csharp=True'
fi
echo -e "::endgroup::"
Expand All @@ -151,7 +153,7 @@ jobs:
shell: cmd
run: |
echo "::group::Conan Install"
conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator="Visual Studio 17 2022" -s compiler.cppstd=20 -s build_type=${{ env.BUILD_TYPE }} -o 'openstudio/:*with_testing=False' -o 'openstudio/:*with_benchmark=False'
conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator="Visual Studio 17 2022" -s compiler.cppstd=20 -s build_type=${{ env.BUILD_TYPE }} -o 'openstudio/*:with_testing=False' -o 'openstudio/*:with_benchmark=False' -o 'openstudio/*:with_ruby=False' -o 'openstudio/*:with_python=False' -o 'openstudio/*:with_csharp=True'
echo "::engroup::"
cmake --list-presets
Expand All @@ -178,7 +180,7 @@ jobs:
shell: cmd
run: |
echo "::group::Conan Install"
conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator="Visual Studio 17 2022" -s compiler.cppstd=20 -s build_type=${{ env.BUILD_TYPE }} -o 'openstudio/:*with_testing=False' -o 'openstudio/:*with_benchmark=False' -s:b arch=x86_64 -s:h arch=x86
conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator="Visual Studio 17 2022" -s compiler.cppstd=20 -s build_type=${{ env.BUILD_TYPE }} -o 'openstudio/*:with_testing=False' -o 'openstudio/*:with_benchmark=False' -o 'openstudio/*:with_ruby=False' -o 'openstudio/*:with_python=False' -o 'openstudio/*:with_csharp=True' -s:b arch=x86_64 -s:h arch=x86
echo "::engroup::"
echo "::group::CMake Configure"
Expand Down
46 changes: 28 additions & 18 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@ class OpenStudioBuildRecipe(ConanFile):
generators = "CMakeDeps" # CMakeToolchain explicitly instantiated

options = {
"with_ruby": [True, False],
"with_python": [True, False],
"with_csharp": [True, False],
"with_testing": [True, False],
"with_benchmark": [True, False],
}
default_options = {
"with_ruby": True,
"with_python": True,
"with_csharp": False,
"with_testing": True,
"with_benchmark": True,
}

def requirements(self):
self.requires("ruby/3.2.2")
if self.options.with_ruby:
self.requires("ruby/3.2.2")

if is_apple_os(self):
self.requires(
Expand Down Expand Up @@ -68,9 +75,11 @@ def generate(self):
tc = CMakeToolchain(self)

tc.cache_variables["BUILD_CLI"] = True
tc.cache_variables["BUILD_RUBY_BINDINGS"] = True
tc.cache_variables["BUILD_PYTHON_BINDINGS"] = True
tc.cache_variables["BUILD_PYTHON_PIP_PACKAGE"] = False
tc.cache_variables["BUILD_RUBY_BINDINGS"] = bool(self.options.with_ruby)
tc.cache_variables["BUILD_PYTHON_BINDINGS"] = bool(self.options.with_python)
tc.cache_variables["BUILD_CSHARP_BINDINGS"] = bool(self.options.with_csharp)
# tc.cache_variables["BUILD_NUGET_PACKAGE"] = False
# tc.cache_variables["BUILD_PYTHON_PIP_PACKAGE"] = False

tc.cache_variables["BUILD_TESTING"] = bool(self.options.with_testing)
tc.cache_variables["BUILD_BENCHMARK"] = bool(self.options.with_benchmark)
Expand All @@ -90,18 +99,19 @@ def generate(self):
tc.cache_variables["CPACK_BINARY_TXZ"] = False
tc.cache_variables["CPACK_BINARY_TZ"] = False

v = sys.version_info
if (v.major, v.minor) == (3, 8):
python_version = f"{v.major}.{v.minor}.{v.micro}"
self.output.info(
f"Setting PYTHON_VERSION and Python_ROOT_DIR from your current python: {python_version}, '{sys.base_prefix}'"
)
tc.cache_variables["PYTHON_VERSION"] = python_version
tc.cache_variables["Python_ROOT_DIR"] = str(Path(sys.base_prefix))
else:
self.output.warning(
"Your current python is not in the 3.8.x range, which is what we target.\n"
"You'll need to pass it properly when configuring CMake\n"
"via -DPYTHON_VERSION:STRING='3.8.xx' and -DPython_ROOT_DIR:PATH='/path/to/python3.8/'"
)
if self.options.with_python:
v = sys.version_info
if (v.major, v.minor) == (3, 8):
python_version = f"{v.major}.{v.minor}.{v.micro}"
self.output.info(
f"Setting PYTHON_VERSION and Python_ROOT_DIR from your current python: {python_version}, '{sys.base_prefix}'"
)
tc.cache_variables["PYTHON_VERSION"] = python_version
tc.cache_variables["Python_ROOT_DIR"] = str(Path(sys.base_prefix))
else:
self.output.warning(
"Your current python is not in the 3.8.x range, which is what we target.\n"
"You'll need to pass it properly when configuring CMake\n"
"via -DPYTHON_VERSION:STRING='3.8.xx' and -DPython_ROOT_DIR:PATH='/path/to/python3.8/'"
)
tc.generate()

0 comments on commit 91142f1

Please sign in to comment.