Skip to content

Commit

Permalink
Add conan build.
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Jul 9, 2023
1 parent d7b68f6 commit 7b40f32
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 171 deletions.
112 changes: 20 additions & 92 deletions .github/workflows/archicad_addon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,114 +8,42 @@ on:
- '*'

jobs:
build_win_ac25:
runs-on: [ windows-2019 ]
build:
runs-on: ${{matrix.os-type}}

strategy:
matrix:
os-type: [windows-2019, macos-latest]
configuration: [Debug, Release, RelWithDebInfo]

steps:

- name: Checkout Repo
uses: actions/checkout@v3
- name: Download Development Kit
run: python archicad-addon/Tools/download_and_unzip.py ${{ secrets.WIN_DEVKIT_AC25 }} archicad-addon/Build
- name: Generate Project
run: cmake -B archicad-addon/Build/AC25 -G "Visual Studio 16 2019" -A "x64" -T "v142" -DAC_API_DEVKIT_DIR="archicad-addon/Build/API Development Kit 25.3002" archicad-addon
- name: Build Debug
run: cmake --build archicad-addon/Build/AC25 --config Debug
- name: Build RelWithDebInfo
run: cmake --build archicad-addon/Build/AC25 --config RelWithDebInfo
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: Tapir Add-On AC25 Win
path: archicad-addon/Build/AC25/RelWithDebInfo/TapirAddOn_AC25_Win.apx
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
artifacts: archicad-addon/Build/AC25/RelWithDebInfo/TapirAddOn_AC25_Win.apx
draft: true
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}

build_win_ac26:
runs-on: [ windows-2019 ]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Download Development Kit
run: python archicad-addon/Tools/download_and_unzip.py ${{ secrets.WIN_DEVKIT_AC26 }} archicad-addon/Build
- name: Generate Project
run: cmake -B archicad-addon/Build/AC26 -G "Visual Studio 16 2019" -A "x64" -T "v142" -DAC_API_DEVKIT_DIR="archicad-addon/Build/API Development Kit 26.3000" archicad-addon
- name: Build Debug
run: cmake --build archicad-addon/Build/AC26 --config Debug
- name: Build RelWithDebInfo
run: cmake --build archicad-addon/Build/AC26 --config RelWithDebInfo
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: Tapir Add-On AC26 Win
path: archicad-addon/Build/AC26/RelWithDebInfo/TapirAddOn_AC26_Win.apx
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
- name: Get Conan
uses: turtlebrowser/get-conan@v1.2
with:
artifacts: archicad-addon/Build/AC26/RelWithDebInfo/TapirAddOn_AC26_Win.apx
draft: true
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
version: 1.59.0

build_mac_ac25:
runs-on: [ macos-12 ]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Download Development Kit
run: python3 archicad-addon/Tools/download_and_unzip.py ${{ secrets.MAC_DEVKIT_AC25 }} archicad-addon/Build
- name: Generate Project
run: cmake -B archicad-addon/Build/AC25 -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DAC_API_DEVKIT_DIR="archicad-addon/Build/GRAPHISOFT ARCHICAD API DevKit 25.3006" archicad-addon
- name: Build Debug
run: cmake --build archicad-addon/Build/AC25 --config Debug
- name: Build RelWithDebInfo
run: cmake --build archicad-addon/Build/AC25 --config RelWithDebInfo
- name: Create DMG file
run: hdiutil create -format UDZO -srcfolder archicad-addon/Build/AC25/RelWithDebInfo/TapirAddOn_AC25_Mac.bundle archicad-addon/Build/AC25/RelWithDebInfo/TapirAddOn_AC25_Mac.dmg
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: Tapir Add-On AC25 Mac
path: archicad-addon/Build/AC25/RelWithDebInfo/TapirAddOn_AC25_Mac.dmg
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
artifacts: archicad-addon/Build/AC25/RelWithDebInfo/TapirAddOn_AC25_Mac.dmg
draft: true
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup python
if: runner.os == 'Windows'
run: doskey python3=python

build_mac_ac26:
runs-on: [ macos-12 ]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Download Development Kit
run: python3 archicad-addon/Tools/download_and_unzip.py ${{ secrets.MAC_DEVKIT_AC26 }} archicad-addon/Build
- name: Generate Project
run: cmake -B archicad-addon/Build/AC26 -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DAC_API_DEVKIT_DIR="archicad-addon/Build/Graphisoft Archicad API DevKit 26.3000" archicad-addon
run: python3 archicad-addon/build.py --acVersion 26

- name: Build Debug
run: cmake --build archicad-addon/Build/AC26 --config Debug

- name: Build RelWithDebInfo
run: cmake --build archicad-addon/Build/AC26 --config RelWithDebInfo
- name: Create DMG file
run: hdiutil create -format UDZO -srcfolder archicad-addon/Build/AC26/RelWithDebInfo/TapirAddOn_AC26_Mac.bundle archicad-addon/Build/AC26/RelWithDebInfo/TapirAddOn_AC26_Mac.dmg
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: Tapir Add-On AC26 Mac
path: archicad-addon/Build/AC26/RelWithDebInfo/TapirAddOn_AC26_Mac.dmg

- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
artifacts: archicad-addon/Build/AC26/RelWithDebInfo/TapirAddOn_AC26_Mac.dmg
artifacts: archicad-addon/Build/AC25/RelWithDebInfo/TapirAddOn_AC25_Win.apx
draft: true
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
31 changes: 11 additions & 20 deletions archicad-addon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,10 @@ set_property (GLOBAL PROPERTY USE_FOLDERS ON)
set (CMAKE_SUPPRESS_REGENERATION 1)
set (CMAKE_CONFIGURATION_TYPES Debug;Release;RelWithDebInfo)
set (AC_API_DEVKIT_DIR $ENV{AC_API_DEVKIT_DIR} CACHE PATH "API DevKit directory.")
set (AC_VERSION "" CACHE STRING "Archicad version.")
set (AC_ADDON_NAME "TapirAddOn" CACHE STRING "Add-On name.")
set (AC_ADDON_LANGUAGE "INT" CACHE STRING "Add-On language code.")

set (ACAPINC_FILE_LOCATION ${AC_API_DEVKIT_DIR}/Support/Inc/ACAPinc.h)
if (EXISTS ${ACAPINC_FILE_LOCATION})
file (READ ${ACAPINC_FILE_LOCATION} ACAPIncContent)
string (REGEX MATCHALL "#define[ \t]+ServerMainVers_([0-9][0-9])" VersionList ${ACAPIncContent})
set (ARCHICAD_VERSION ${CMAKE_MATCH_1})
message (STATUS "Archicad Version: ${ARCHICAD_VERSION}")
else ()
message (FATAL_ERROR "Failed to detect Archicad version, please check the value of the AC_API_DEVKIT_DIR variable.")
endif ()

if (WIN32)
add_definitions (-DUNICODE -D_UNICODE)
else ()
Expand All @@ -57,7 +48,7 @@ else ()
set (OutputPostfix Mac)
endif ()

set (OutputName ${AC_ADDON_NAME}_AC${ARCHICAD_VERSION}_${OutputPostfix})
set (OutputName ${AC_ADDON_NAME}_AC${AC_VERSION}_${OutputPostfix})
project (${OutputName})

set (AddOnSourcesFolder Sources)
Expand Down Expand Up @@ -123,7 +114,7 @@ else ()
COMMENT "Compiling resources..."
COMMAND ${CMAKE_COMMAND} -E make_directory "${ResourceObjectsDir}"
COMMAND python3 "${AddOnSourcesFolderAbsolute}/Tools/CompileResources.py" "${AC_ADDON_LANGUAGE}" "${AC_API_DEVKIT_DIR}" "${AddOnSourcesFolderAbsolute}" "${AddOnSourcesFolderAbsolute}" "${ResourceObjectsDir}" "${CMAKE_BINARY_DIR}/$<CONFIG>/${OutputName}.bundle/Contents/Resources"
COMMAND ${CMAKE_COMMAND} -E copy "${AC_API_DEVKIT_DIR}/Support/Inc/PkgInfo" "${CMAKE_BINARY_DIR}/$<CONFIG>/${OutputName}.bundle/Contents/PkgInfo"
COMMAND ${CMAKE_COMMAND} -E copy "${AC_API_DEVKIT_DIR}/Inc/PkgInfo" "${CMAKE_BINARY_DIR}/$<CONFIG>/${OutputName}.bundle/Contents/PkgInfo"
COMMAND ${CMAKE_COMMAND} -E touch ${ResourceStampFile}
)
endif ()
Expand All @@ -144,32 +135,32 @@ endif ()

target_include_directories (AddOn PUBLIC
${AddOnSourcesFolder}
${AC_API_DEVKIT_DIR}/Support/Inc
${AC_API_DEVKIT_DIR}/Inc
)

if (WIN32)
target_link_libraries (AddOn
"$<$<CONFIG:Debug>:${AC_API_DEVKIT_DIR}/Support/Lib/Win/ACAP_STATD.lib>"
"$<$<CONFIG:Release>:${AC_API_DEVKIT_DIR}/Support/Lib/Win/ACAP_STAT.lib>"
"$<$<CONFIG:RelWithDebInfo>:${AC_API_DEVKIT_DIR}/Support/Lib/Win/ACAP_STAT.lib>"
"$<$<CONFIG:Debug>:${AC_API_DEVKIT_DIR}/Lib/Win/ACAP_STATD.lib>"
"$<$<CONFIG:Release>:${AC_API_DEVKIT_DIR}/Lib/Win/ACAP_STAT.lib>"
"$<$<CONFIG:RelWithDebInfo>:${AC_API_DEVKIT_DIR}/Lib/Win/ACAP_STAT.lib>"
)
else ()
find_library (CocoaFramework Cocoa)
target_link_libraries (AddOn
"${AC_API_DEVKIT_DIR}/Support/Lib/Mactel/libACAP_STAT.a"
"${AC_API_DEVKIT_DIR}/Lib/Mactel/libACAP_STAT.a"
${CocoaFramework}
)
endif ()

SetCompilerOptions (AddOn)
set_source_files_properties (${AddOnSourceFiles} PROPERTIES LANGUAGE CXX)

file (GLOB ModuleFolders ${AC_API_DEVKIT_DIR}/Support/Modules/*)
file (GLOB ModuleFolders ${AC_API_DEVKIT_DIR}/Modules/*)
target_include_directories (AddOn PUBLIC ${ModuleFolders})
if (WIN32)
file (GLOB LibFilesInFolder ${AC_API_DEVKIT_DIR}/Support/Modules/*/*/*.lib)
file (GLOB LibFilesInFolder ${AC_API_DEVKIT_DIR}/Modules/*/*/*.lib)
target_link_libraries (AddOn ${LibFilesInFolder})
else ()
file (GLOB FrameworkFilesInFolder ${AC_API_DEVKIT_DIR}/Support/Frameworks/*.framework)
file (GLOB FrameworkFilesInFolder ${AC_API_DEVKIT_DIR}/Frameworks/*.framework)
target_link_libraries (AddOn ${FrameworkFilesInFolder})
endif ()
16 changes: 8 additions & 8 deletions archicad-addon/Sources/Tools/CompileResources.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def CollectFilesFromFolderWithExtension (self, folderPath, extension):
class WinResourceCompiler (ResourceCompiler):
def __init__ (self, devKitPath, languageCode, sourcesPath, resourcesPath, resourceObjectsPath):
super (WinResourceCompiler, self).__init__ (devKitPath, languageCode, sourcesPath, resourcesPath, resourceObjectsPath)
self.resConvPath = os.path.join (devKitPath, 'Support', 'Tools', 'Win', 'ResConv.exe')
self.resConvPath = os.path.join (devKitPath, 'Tools', 'Win', 'ResConv.exe')

def PrecompileResourceFile (self, grcFilePath):
precompiledGrcFilePath = self.GetPrecompiledResourceFilePath (grcFilePath)
Expand All @@ -78,8 +78,8 @@ def PrecompileResourceFile (self, grcFilePath):
'/X',
'/EP',
'/P',
'/I', os.path.join (self.devKitPath, 'Support', 'Inc'),
'/I', os.path.join (self.devKitPath, 'Support', 'Modules', 'DGLib'),
'/I', os.path.join (self.devKitPath, 'Inc'),
'/I', os.path.join (self.devKitPath, 'Modules', 'DGLib'),
'/I', self.sourcesPath,
'/I', self.resourceObjectsPath,
'/DWINDOWS',
Expand Down Expand Up @@ -108,8 +108,8 @@ def CompileNativeResource (self, resultResourcePath):
nativeResourceFile = self.GetNativeResourceFile ()
result = subprocess.call ([
'rc',
'/i', os.path.join (self.devKitPath, 'Support', 'Inc'),
'/i', os.path.join (self.devKitPath, 'Support', 'Modules', 'DGLib'),
'/i', os.path.join (self.devKitPath, 'Inc'),
'/i', os.path.join (self.devKitPath, 'Modules', 'DGLib'),
'/i', self.sourcesPath,
'/i', self.resourceObjectsPath,
'/fo', resultResourcePath,
Expand All @@ -120,7 +120,7 @@ def CompileNativeResource (self, resultResourcePath):
class MacResourceCompiler (ResourceCompiler):
def __init__ (self, devKitPath, languageCode, sourcesPath, resourcesPath, resourceObjectsPath):
super (MacResourceCompiler, self).__init__ (devKitPath, languageCode, sourcesPath, resourcesPath, resourceObjectsPath)
self.resConvPath = os.path.join (devKitPath, 'Support', 'Tools', 'OSX', 'ResConv')
self.resConvPath = os.path.join (devKitPath, 'Tools', 'OSX', 'ResConv')

def PrecompileResourceFile (self, grcFilePath):
precompiledGrcFilePath = self.GetPrecompiledResourceFilePath (grcFilePath)
Expand All @@ -130,8 +130,8 @@ def PrecompileResourceFile (self, grcFilePath):
'-E',
'-P',
'-Dmacintosh',
'-I', os.path.join (self.devKitPath, 'Support', 'Inc'),
'-I', os.path.join (self.devKitPath, 'Support', 'Modules', 'DGLib'),
'-I', os.path.join (self.devKitPath, 'Inc'),
'-I', os.path.join (self.devKitPath, 'Modules', 'DGLib'),
'-I', self.sourcesPath,
'-I', self.resourceObjectsPath,
'-o', precompiledGrcFilePath,
Expand Down
11 changes: 0 additions & 11 deletions archicad-addon/Tools/build_ac25_vs2022.bat

This file was deleted.

11 changes: 0 additions & 11 deletions archicad-addon/Tools/build_ac26_vs2022.bat

This file was deleted.

29 changes: 0 additions & 29 deletions archicad-addon/Tools/download_and_unzip.py

This file was deleted.

55 changes: 55 additions & 0 deletions archicad-addon/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import os
import sys
import json
import argparse
import subprocess
import platform

def Main ():
parser = argparse.ArgumentParser ()
parser.add_argument ('--acVersion', dest = 'acVersion', type = str, required = True, help = 'Version of the target Archicad.')
args = parser.parse_args ()

currentPath = os.path.dirname (os.path.abspath (__file__))
rootFolder = os.path.dirname (currentPath)
os.chdir (rootFolder)

isWindows = (platform.system () == 'Windows')

subprocess.call (['conan', 'profile', 'new', 'default', '--detect'])
if isWindows:
subprocess.call (['conan', 'profile', 'update', 'settings.compiler.version=16', 'default'])
else:
subprocess.call (['conan', 'profile', 'update', 'settings.compiler.version=13', 'default'])
subprocess.call (['conan', 'install', 'archicad-apidevkit/{0}@'.format (args.acVersion)])

infoJsonPath = os.path.join ('Build', 'conan_info.json')
subprocess.call (['conan', 'info', '--paths', '-j', infoJsonPath, 'archicad-apidevkit/{0}@'.format (args.acVersion)])

infoJson = None
with open (infoJsonPath, 'r') as infoJsonFile:
infoJson = json.load (infoJsonFile)
devKitPath = os.path.join (infoJson[0]['package_folder'], 'bin')

projGenResult = subprocess.call ([
'cmake',
'-B', 'Build/AC{0}'.format (args.acVersion),
'-G', 'Visual Studio 17 2022',
'-A', 'x64',
'-T', 'v142',
'-DAC_VERSION={0}'.format (args.acVersion),
'-DAC_API_DEVKIT_DIR={0}'.format (devKitPath)
])

if projGenResult != 0:
return projGenResult

buildResult = subprocess.call ([
'cmake',
'--build', 'Build/AC{0}'.format (args.acVersion)
])

if buildResult != 0:
return buildResult

sys.exit (Main ())

0 comments on commit 7b40f32

Please sign in to comment.