Skip to content

Commit

Permalink
(#12844) Archicad General API Development Kit
Browse files Browse the repository at this point in the history
* 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 <prince.chrismc@gmail.com>

* 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 <uilianries@gmail.com>

* Update recipes/archicad-apidevkit/all/test_v1_package/CMakeLists.txt

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Remove unneccesary compiler flags

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
Co-authored-by: vhorvath-gs <vhorvath@graphisoft.com>
Co-authored-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
4 people authored Jan 17, 2023
1 parent 828dabb commit 7b4e2a5
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 0 deletions.
28 changes: 28 additions & 0 deletions recipes/archicad-apidevkit/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
65 changes: 65 additions & 0 deletions recipes/archicad-apidevkit/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
44 changes: 44 additions & 0 deletions recipes/archicad-apidevkit/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
26 changes: 26 additions & 0 deletions recipes/archicad-apidevkit/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
10 changes: 10 additions & 0 deletions recipes/archicad-apidevkit/all/test_package/test_gsroot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <cstdlib>
#include <Color.hpp>

int main ()
{
Gfx::Color someColor;
someColor.SetRed (176);

return someColor.GetRed () == 176 ? EXIT_SUCCESS : EXIT_FAILURE;
}
10 changes: 10 additions & 0 deletions recipes/archicad-apidevkit/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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/)
20 changes: 20 additions & 0 deletions recipes/archicad-apidevkit/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions recipes/archicad-apidevkit/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
versions:
"25":
folder: all
"26":
folder: all

1 comment on commit 7b4e2a5

@manuelpagliuca
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When AC27 DevKit ?

Please sign in to comment.