diff --git a/.github/workflows/archicad_addon.yml b/.github/workflows/archicad_addon.yml index f30d20a..9ba3edd 100644 --- a/.github/workflows/archicad_addon.yml +++ b/.github/workflows/archicad_addon.yml @@ -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 }} diff --git a/archicad-addon/CMakeLists.txt b/archicad-addon/CMakeLists.txt index b5b915f..7e9d28d 100644 --- a/archicad-addon/CMakeLists.txt +++ b/archicad-addon/CMakeLists.txt @@ -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 () @@ -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) @@ -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}/$/${OutputName}.bundle/Contents/Resources" - COMMAND ${CMAKE_COMMAND} -E copy "${AC_API_DEVKIT_DIR}/Support/Inc/PkgInfo" "${CMAKE_BINARY_DIR}/$/${OutputName}.bundle/Contents/PkgInfo" + COMMAND ${CMAKE_COMMAND} -E copy "${AC_API_DEVKIT_DIR}/Inc/PkgInfo" "${CMAKE_BINARY_DIR}/$/${OutputName}.bundle/Contents/PkgInfo" COMMAND ${CMAKE_COMMAND} -E touch ${ResourceStampFile} ) endif () @@ -144,19 +135,19 @@ endif () target_include_directories (AddOn PUBLIC ${AddOnSourcesFolder} - ${AC_API_DEVKIT_DIR}/Support/Inc + ${AC_API_DEVKIT_DIR}/Inc ) if (WIN32) target_link_libraries (AddOn - "$<$:${AC_API_DEVKIT_DIR}/Support/Lib/Win/ACAP_STATD.lib>" - "$<$:${AC_API_DEVKIT_DIR}/Support/Lib/Win/ACAP_STAT.lib>" - "$<$:${AC_API_DEVKIT_DIR}/Support/Lib/Win/ACAP_STAT.lib>" + "$<$:${AC_API_DEVKIT_DIR}/Lib/Win/ACAP_STATD.lib>" + "$<$:${AC_API_DEVKIT_DIR}/Lib/Win/ACAP_STAT.lib>" + "$<$:${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 () @@ -164,12 +155,12 @@ 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 () diff --git a/archicad-addon/Sources/Tools/CompileResources.py b/archicad-addon/Sources/Tools/CompileResources.py index ee6ec06..362586c 100644 --- a/archicad-addon/Sources/Tools/CompileResources.py +++ b/archicad-addon/Sources/Tools/CompileResources.py @@ -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) @@ -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', @@ -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, @@ -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) @@ -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, diff --git a/archicad-addon/Tools/build_ac25_vs2022.bat b/archicad-addon/Tools/build_ac25_vs2022.bat deleted file mode 100644 index 48888e7..0000000 --- a/archicad-addon/Tools/build_ac25_vs2022.bat +++ /dev/null @@ -1,11 +0,0 @@ -pushd %~dp0 -cmake -B ../Build/AC25 -G "Visual Studio 17 2022" -A "x64" -T "v142" -DAC_API_DEVKIT_DIR="C:\Program Files\GRAPHISOFT\API Development Kit 25.3002" .. || goto :error -cmake --build ../Build/AC25 --config Debug || goto :error -cmake --build ../Build/AC25 --config RelWithDebInfo || goto :error -popd -exit /b 0 - -:error -echo Build Failed with Error %errorlevel%. -popd -exit /b 1 diff --git a/archicad-addon/Tools/build_ac26_vs2022.bat b/archicad-addon/Tools/build_ac26_vs2022.bat deleted file mode 100644 index 4928017..0000000 --- a/archicad-addon/Tools/build_ac26_vs2022.bat +++ /dev/null @@ -1,11 +0,0 @@ -pushd %~dp0 -cmake -B ../Build/AC26 -G "Visual Studio 17 2022" -A "x64" -T "v142" -DAC_API_DEVKIT_DIR="C:\Program Files\GRAPHISOFT\API Development Kit 26.3000" .. || goto :error -cmake --build ../Build/AC26 --config Debug || goto :error -cmake --build ../Build/AC26 --config RelWithDebInfo || goto :error -popd -exit /b 0 - -:error -echo Build Failed with Error %errorlevel%. -popd -exit /b 1 diff --git a/archicad-addon/Tools/download_and_unzip.py b/archicad-addon/Tools/download_and_unzip.py deleted file mode 100644 index 677ba3e..0000000 --- a/archicad-addon/Tools/download_and_unzip.py +++ /dev/null @@ -1,29 +0,0 @@ -import os -import sys -import subprocess -import platform -import zipfile -import urllib.request -import urllib.parse - -url = sys.argv[1] -dest = sys.argv[2] - -if not os.path.exists (dest): - os.makedirs (dest) - -fileName = urllib.parse.unquote (os.path.split (url)[1]) -filePath = os.path.join (dest, fileName) - -urllib.request.urlretrieve (url, filePath) - -if platform.system () == 'Windows': - with zipfile.ZipFile (filePath, 'r') as zip: - zip.extractall (dest) -elif platform.system () == 'Darwin': - subprocess.call ([ - 'unzip', '-qq', filePath, - '-d', dest - ]) - -sys.exit (0) diff --git a/archicad-addon/build.py b/archicad-addon/build.py new file mode 100644 index 0000000..d1926b9 --- /dev/null +++ b/archicad-addon/build.py @@ -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 ())