From 7b4e2a52bd716a2a1e1e846b926a4eb3ba790eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Kiss?= Date: Tue, 17 Jan 2023 14:05:13 +0200 Subject: [PATCH] (#12844) Archicad General API Development Kit * Added archicad-apidevkit * Packages for MAC * Packages for WIN * Fix linter warnings * Too many whitespaces * Too many whitespaces * Added test package * CI updates * CI updates * Get was missing * Trying to fix linter * Perhaps is good now * Self was missing * Remove warnings * Only Intel arch is supported yet * Test package modifications * Topics as list * Testing is done without building az executable Just test some file existences * Review by prince-chrismc * Too many blank lines * Update recipes/archicad-apidevkit/all/conanfile.py Co-authored-by: Chris Mc * No need for this * Package doesn't check anymore for toolkit upper limit * Fix the test package of the ArchiCAD Devkit The test package uses the deprecated cmake generator, so it was renamed to test_v1_package to make sure CCI only runs this for Conan v1. The code in the test package was also improved to actually build. * Tidy up the conanfile.py The methods are defined in the order the create command calls them and unused setting were removed. * Use definitions instead of -D compile options * Run pre-built binary * Remove files * Removed file * No info in self * Try to skip VS != 16 * Visual Studio instead of msvc * Compiler was missing * Don't test on Debug build_type * Final? Don't test on Debug build_type Use tools.Version() to check VS version Specify cpp_info.system_libs for 3rd party libs Use spaces instead of tabs to intend everywhere * Setup dependencies in cpp_info according to CI * Update recipes/archicad-apidevkit/all/test_v1_package/conanfile.py Co-authored-by: Uilian Ries * Update recipes/archicad-apidevkit/all/test_v1_package/CMakeLists.txt Co-authored-by: Uilian Ries * Remove unneccesary compiler flags Co-authored-by: Chris Mc Co-authored-by: vhorvath-gs Co-authored-by: Uilian Ries --- recipes/archicad-apidevkit/all/conandata.yml | 28 ++++++++ recipes/archicad-apidevkit/all/conanfile.py | 65 +++++++++++++++++++ .../all/test_package/CMakeLists.txt | 44 +++++++++++++ .../all/test_package/conanfile.py | 26 ++++++++ .../all/test_package/test_gsroot.cpp | 10 +++ .../all/test_v1_package/CMakeLists.txt | 10 +++ .../all/test_v1_package/conanfile.py | 20 ++++++ recipes/archicad-apidevkit/config.yml | 5 ++ 8 files changed, 208 insertions(+) create mode 100644 recipes/archicad-apidevkit/all/conandata.yml create mode 100644 recipes/archicad-apidevkit/all/conanfile.py create mode 100644 recipes/archicad-apidevkit/all/test_package/CMakeLists.txt create mode 100644 recipes/archicad-apidevkit/all/test_package/conanfile.py create mode 100644 recipes/archicad-apidevkit/all/test_package/test_gsroot.cpp create mode 100644 recipes/archicad-apidevkit/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/archicad-apidevkit/all/test_v1_package/conanfile.py create mode 100644 recipes/archicad-apidevkit/config.yml diff --git a/recipes/archicad-apidevkit/all/conandata.yml b/recipes/archicad-apidevkit/all/conandata.yml new file mode 100644 index 0000000000000..d3788a4383b77 --- /dev/null +++ b/recipes/archicad-apidevkit/all/conandata.yml @@ -0,0 +1,28 @@ +sources: + "26": + Macos: + "x86_64": + - url: "https://stgsswsconan001.blob.core.windows.net/apidevkit/220529.v2022Release.3000.FULL.FIN.MAC64.DevKitAPI.tar.gz" + sha256: "326643eb79619166b6cb8f2858be3b24c1c3e3dd6749d20d2960baa0690f8e9c" + - url: "https://stgsswsconan001.blob.core.windows.net/apidevkit/licenses.zip" + sha256: "ad798e4760d784a84d2708be77b3c8d7562a88ac8cddbc3177f21a6d6e91772a" + Windows: + "x86_64": + - url: "https://stgsswsconan001.blob.core.windows.net/apidevkit/220529.v2022Release.3000.FULL.FIN.WIN64.DevKitAPI.zip" + sha256: "588c411b8bb8263bd417c271bb5a8d01136a802cb60116732ab5c1e2fbbf0558" + - url: "https://stgsswsconan001.blob.core.windows.net/apidevkit/licenses.zip" + sha256: "ad798e4760d784a84d2708be77b3c8d7562a88ac8cddbc3177f21a6d6e91772a" + + "25": + Macos: + "x86_64": + - url: "https://stgsswsconan001.blob.core.windows.net/apidevkit/210709.v2021Release.3006.FULL.FIN.MAC64.DevKitAPI.tar.gz" + sha256: "d692a59bdec7847ef4632e2c6741be064822a91eda2735dcff768985eaf4ec1e" + - url: "https://stgsswsconan001.blob.core.windows.net/apidevkit/licenses.zip" + sha256: "ad798e4760d784a84d2708be77b3c8d7562a88ac8cddbc3177f21a6d6e91772a" + Windows: + "x86_64": + - url: "https://stgsswsconan001.blob.core.windows.net/apidevkit/210519.v2021Release.3002.FULL.FIN.WIN64.DevKitAPI.zip" + sha256: "e7da392408f6150c58f3cba5d4f05118f1eaed4519fdb76895e13aed9ceede97" + - url: "https://stgsswsconan001.blob.core.windows.net/apidevkit/licenses.zip" + sha256: "ad798e4760d784a84d2708be77b3c8d7562a88ac8cddbc3177f21a6d6e91772a" diff --git a/recipes/archicad-apidevkit/all/conanfile.py b/recipes/archicad-apidevkit/all/conanfile.py new file mode 100644 index 0000000000000..55e0ec99e9a6b --- /dev/null +++ b/recipes/archicad-apidevkit/all/conanfile.py @@ -0,0 +1,65 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.52.0" + + +class ArchicadApidevkitConan(ConanFile): + name = "archicad-apidevkit" + description = "The General API Development Kit enables software developers to extend the functionality of Archicad" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://archicadapi.graphisoft.com/" + license = "LicenseRef-LICENSE" + settings = "os", "compiler", "arch", "build_type" + no_copy_source = True + topics = "api", "archicad", "development" + short_paths = True + + def validate(self): + if self.settings.build_type == "Debug": + raise ConanInvalidConfiguration("Debug configuration is not supported") + if is_msvc(self): + # Approximate requirement for toolset >= v142 + check_min_vs(self, "192") + if not self.info.settings.os in ("Macos", "Windows"): + raise ConanInvalidConfiguration( + f"{self.ref} is not supported by the OS {self.info.settings.os}") + if not str(self.settings.arch) in ("x86_64"): + raise ConanInvalidConfiguration( + f"{self.ref} is not supported yet.") + if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) < "16": + raise ConanInvalidConfiguration( + "This recipe does not support this compiler version") + + def build(self): + devkit, licenses = self.conan_data["sources"][self.version][str(self.settings.os)][str(self.settings.arch)] + get(self, **devkit, destination=os.path.join(self.package_folder, "bin"), strip_root=True) + get(self, **licenses, destination=os.path.join(self.package_folder, "licenses"), strip_root=True) + + def package(self): + copy(self, "bin", src=self.build_folder, dst=self.package_folder) + copy(self, "licenses", src=self.build_folder, dst=self.package_folder) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] + + # These are dependencies of third party vendored libraries + self.cpp_info.system_libs = [ + "WinMM", "MSImg32", "WS2_32", "USP10", "DNSApi"] + if self.settings.os == "Macos": + self.cpp_info.frameworks = ["CoreText", "CoreFoundation", "CoreServices", + "ApplicationServices", "Carbon", "CoreGraphics", "AppKit", "Foundation"] + else: + self.cpp_info.system_libs.extend(["gdiplus", "iphlpapi"]) + + devkit_dir = os.path.join(self.package_folder, "bin") + self.output.info(f"Setting AC_API_DEVKIT_DIR environment variable: {devkit_dir}") + self.env_info.AC_API_DEVKIT_DIR = devkit_dir + self.buildenv_info.define("AC_API_DEVKIT_DIR", devkit_dir) diff --git a/recipes/archicad-apidevkit/all/test_package/CMakeLists.txt b/recipes/archicad-apidevkit/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7e25d3d3b7690 --- /dev/null +++ b/recipes/archicad-apidevkit/all/test_package/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.15) + +project(test_package CXX) + +function(SetCompilerOptions target ac_version) + if(ac_version GREATER "26") + target_compile_features("${target}" PUBLIC cxx_std_17) + else() + target_compile_features("${target}" PUBLIC cxx_std_14) + endif() +endfunction() + +set(AC_API_DEVKIT_DIR "$ENV{AC_API_DEVKIT_DIR}" CACHE PATH "API DevKit directory.") + +find_package(archicad-apidevkit REQUIRED CONFIG) + +add_executable(test_package test_gsroot.cpp) +SetCompilerOptions(test_package "${archicad-apidevkit_VERSION}") + +if(WIN32) + target_compile_definitions(test_package PRIVATE UNICODE _UNICODE) +else() + target_compile_definitions(test_package PRIVATE macintosh=1) +endif() + +target_include_directories(test_package SYSTEM PRIVATE "${AC_API_DEVKIT_DIR}/Modules/GSRoot") + +if(WIN32) + target_link_libraries( + test_package PRIVATE + "${AC_API_DEVKIT_DIR}/Modules/GSRoot/Win/GSRootImp.lib" + ) +else() + find_library( + GSROOT_FRAMEWORK GSRoot + PATHS "${AC_API_DEVKIT_DIR}/Frameworks" + ) + + if(NOT GSROOT_FRAMEWORK) + message(FATAL_ERROR "GSRoot not found: ${GSROOT_FRAMEWORK}") + endif() + + target_link_libraries(test_package PRIVATE "${GSROOT_FRAMEWORK}") +endif() diff --git a/recipes/archicad-apidevkit/all/test_package/conanfile.py b/recipes/archicad-apidevkit/all/test_package/conanfile.py new file mode 100644 index 0000000000000..f6d3c68ca3efb --- /dev/null +++ b/recipes/archicad-apidevkit/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualBuildEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/archicad-apidevkit/all/test_package/test_gsroot.cpp b/recipes/archicad-apidevkit/all/test_package/test_gsroot.cpp new file mode 100644 index 0000000000000..8712d2cd553d3 --- /dev/null +++ b/recipes/archicad-apidevkit/all/test_package/test_gsroot.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main () +{ + Gfx::Color someColor; + someColor.SetRed (176); + + return someColor.GetRed () == 176 ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/recipes/archicad-apidevkit/all/test_v1_package/CMakeLists.txt b/recipes/archicad-apidevkit/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..50f1488b009a2 --- /dev/null +++ b/recipes/archicad-apidevkit/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS KEEP_RPATHS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/archicad-apidevkit/all/test_v1_package/conanfile.py b/recipes/archicad-apidevkit/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..af4b5cc85f42f --- /dev/null +++ b/recipes/archicad-apidevkit/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conans import CMake +from conan.errors import ConanInvalidConfiguration +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/archicad-apidevkit/config.yml b/recipes/archicad-apidevkit/config.yml new file mode 100644 index 0000000000000..ca23918e2d0f4 --- /dev/null +++ b/recipes/archicad-apidevkit/config.yml @@ -0,0 +1,5 @@ +versions: + "25": + folder: all + "26": + folder: all