Skip to content

Commit

Permalink
experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
aregtech committed Nov 21, 2024
1 parent cabd3d8 commit ad4df51
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 103 deletions.
92 changes: 0 additions & 92 deletions .github/workflows/cmake-areg-opt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,6 @@ env:
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix

jobs:
job_windows:
name: Windows Platform, x86_64 and x86 builds
runs-on: windows-latest
steps:
- name: Windows - checkout AREG SDK Demo project sources and dependencies
uses: actions/checkout@v4

- name: Windows - Setup Java JDK on Windows to run code generator
uses: actions/[email protected]
with:
java-version: 17
java-package: jre
distribution: temurin

- name: Windows - Configure Demo, include AREG SDK after project(), MSVC on x64, shared
working-directory: ${{github.workspace}}
run: cmake -B ./product/cache/msvc-cl-x64-so -DAREG_COMPILER_FAMILY=msvc

- name: Windows - Build Demo, include AREG SDK after project(), MSVC on x64, shared
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/msvc-cl-x64-so -j20

- name: Windows - Configure Demo, include AREG SDK after project(), ClangCL on x64, shared
working-directory: ${{github.workspace}}
run: cmake -B ./product/cache/llvm-x64-so -DAREG_COMPILER_FAMILY=llvm

- name: Build Demo, include AREG SDK after project(), ClangCL on x64, shared
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/llvm-x64-so -j20

- name: Windows - Configure Demo, include AREG SDK after project(), MSVC on x86, shared
working-directory: ${{github.workspace}}
run: cmake -B ./product/cache/msvc-cl-x86-so -DAREG_COMPILER_FAMILY=msvc -DAREG_PROCESSOR=x86

- name: Windows - Build Demo, include AREG SDK after project(), MSVC on x86, shared
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/msvc-cl-x86-so -j20

- name: Windows - Configure Demo, include AREG SDK after project(), ClangCL on x86, shared
working-directory: ${{github.workspace}}
run: cmake -B ./product/cache/llvm-x86-so -DAREG_COMPILER_FAMILY=llvm -DAREG_PROCESSOR=x86

- name: Windows - Build Demo, include AREG SDK after project(), ClangCL on x86, shared
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/llvm-x86-so -j20


job_linux:
name: Linux Platform, x86_64, x86, arm, aarch64 builds
Expand Down Expand Up @@ -88,14 +42,6 @@ jobs:
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/gnu-x64-so -j20

- name: Linux - Configure Demo, include AREG SDK after project(), LLVM on x64, shared
working-directory: ${{github.workspace}}
run: cmake -B ./product/cache/llvm-x64-so -DAREG_COMPILER_FAMILY=llvm

- name: Linux - Build Demo, include AREG SDK after project(), LLVM on x64, shared
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/llvm-x64-so -j20

- name: Linux - Install multilib
run: sudo apt-get install -y gcc-multilib g++-multilib

Expand All @@ -107,14 +53,6 @@ jobs:
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/gnu-x86-so -j20

- name: Linux - Configure Demo, include AREG SDK after project(), LLVM on x86, shared
working-directory: ${{github.workspace}}
run: cmake -B ./product/cache/llvm-x86-so -DAREG_COMPILER_FAMILY=llvm -DAREG_PROCESSOR=x86

- name: Linux - Build Demo, include AREG SDK after project(), LLVM on x86, shared
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/llvm-x86-so -j20

- name: Linux - Install GNU 32-bit ARM compilers
run: sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf

Expand All @@ -137,33 +75,3 @@ jobs:
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/gnu-aarch64-x86-so -j20

job_macos:
name: macOS Platform, x64 builds
runs-on: macos-latest
steps:
- name: macOS - Checkout AREG SDK Demo project sources and dependencies
uses: actions/checkout@v4

- name: Linux - Setup Java JDK on Windows to run code generator
uses: actions/[email protected]
with:
java-version: 17
java-package: jre
distribution: temurin

- name: macOS - Configure Demo, include AREG SDK after project(), GNU on x64, shared
working-directory: ${{github.workspace}}
run: cmake -B ./product/cache/gnu-x64-so -DAREG_COMPILER_FAMILY=gnu

- name: macOS - Build Demo, include AREG SDK after project(), GNU on x64, shared
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/gnu-x64-so -j20

- name: macOS - Configure Demo, include AREG SDK after project(), LLVM on x64, shared
working-directory: ${{github.workspace}}
run: cmake -B ./product/cache/llvm-x64-so -DAREG_COMPILER_FAMILY=llvm

- name: macOS - Build Demo, include AREG SDK after project(), LLVM on x64, shared
working-directory: ${{github.workspace}}
run: cmake --build ./product/cache/llvm-x64-so -j20

87 changes: 82 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
# set project options before integrating AREG SDK.
# ##################################################################

cmake_minimum_required(VERSION 3.20.0)

set(PROJECT_DEMO_NAME "areg-sdk-demo")
set(PROJECT_DEMO_VERSION "2.0.0")

# Macro to load and configure the AREG SDK package or source repository
macro(macro_load_areg_sdk)

Expand Down Expand Up @@ -66,6 +61,86 @@ macro(macro_load_areg_sdk)
endif()
endmacro(macro_load_areg_sdk)

macro(macro_normalize_architecture arc_processor var_processor var_found)
set(${var_found} FALSE)
string(TOLOWER "${arc_processor}" arc_processor)
foreach(_entry "x64;x64" "x86_64;x64" "x86-64;x64" "amd64;x64" "x86;x86" "i386;x86" "arm64;arm64" "aarch64;arm64" "arm32;arm32" "armv7;arm32" "arm;arm32")
list(GET _entry 0 _arch)
list(GET _entry 1 _norm)
string(FIND "${arc_processor}" ${_arch} _arch_pos)
if (_arch_pos GREATER -1)
set(${var_found} TRUE)
set(${var_processor} _norm)
break()
endif()
endforeach()
unset(_arch)
unset(_norm)
unset(_entry)
endmacro()

macro(macro_test_find_package package_name package_architecture package_found)
set(${package_found} FALSE)
macro_normalize_architecture("${package_architecture}" _arch _found)
if ("${_arch}" STREQUAL "x64")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF)
elseif("${_arch}" STREQUAL "x86")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS ON)
endif()

if (${package_name} STREQUAL "SQLite3")
include(FindSQLite3)
elseif(${package_name} STREQUAL "GTest")
include(FindGTest)
else()
find_package(${package_name} CONFIG)
endif()

message(STATUS "Demo: >>> ${package_name}_FOUND = ${${package_name}_FOUND}")
if (NOT ${package_name}_FOUND)

find_library(_lib_path NAMES "sqlite3")
message(STATUS "Demo: <<<<< _lib_path = ${_lib_path}")
set(_str_arch)
set(_found_pos -1)

if ("${_arch}" STREQUAL "arm64")
execute_process(COMMAND "aarch64-linux-gnu-objdump -f ${_lib_path} | grep ^architecture | cut -d' ' -f-2 | sort -u" OUTPUT_VARIABLE _arch_data)
string(FIND "${_arch_data}" "aarch64" _found_pos)
elseif("${_arch}" STREQUAL "arm32")
if (EXISTS "arm-linux-gnueabi-objdump")
execute_process(COMMAND "arm-linux-gnueabi-objdump -f ${_lib_path} | grep ^architecture | cut -d' ' -f-2 | sort -u" OUTPUT_VARIABLE _arch_data)
string(FIND "${_arch_data}" "aarch64" _found_pos)
elseif(EXISTS "arm-linux-gnueabihf-objdump")
execute_process(COMMAND "arm-linux-gnueabihf-objdump -f ${_lib_path} | grep ^architecture | cut -d' ' -f-2 | sort -u" OUTPUT_VARIABLE _arch_data)
string(FIND "${_arch_data}" "aarch64" _found_pos)
endif()
elseif ("${_arch}" STREQUAL "x64")
execute_process(COMMAND "x86_64-linux-gnu-objdump -f ${_lib_path} | grep ^architecture | cut -d' ' -f-2 | sort -u" OUTPUT_VARIABLE _arch_data)
string(FIND "${_arch_data}" "64" _found_pos)
elseif ("${_arch}" STREQUAL "x86")
execute_process(COMMAND "x86_64-linux-gnu-objdump -f ${_lib_path} | grep ^architecture | cut -d' ' -f-2 | sort -u" OUTPUT_VARIABLE _arch_data)
string(FIND "${_arch_data}" "i386" _found_pos)
else()
execute_process(COMMAND "objdump -f ${_lib_path} | grep ^architecture | cut -d' ' -f-2 | sort -u" OUTPUT_VARIABLE _arch_data)
string(FIND "${_arch_data}" "${_arch}" _found_pos)
endif()

if (_found_pos GREATER -1)
set(${package_found} TRUE)
endif()

endif()

endmacro()


cmake_minimum_required(VERSION 3.20.0)

set(PROJECT_DEMO_NAME "areg-sdk-demo")
set(PROJECT_DEMO_VERSION "2.0.0")

# Set the root of the demo project and its sources
set(AREG_SDK_DEMO_ROOT "${CMAKE_SOURCE_DIR}")
set(AREG_DEMO_SOURCES "${AREG_SDK_DEMO_ROOT}/demo")
Expand All @@ -74,6 +149,8 @@ set(AREG_DEMO_SOURCES "${AREG_SDK_DEMO_ROOT}/demo")
if (NOT DEFINED INTEGRATE_AREG_BEFORE_PROJECT)
set(INTEGRATE_AREG_BEFORE_PROJECT TRUE) # Default is TRUE (integrate before `project()`)
endif()
set(CMAKE_LIBRARY_ARCHITECTURE "x86_64")
macro_test_find_package("SQLite3" "${CMAKE_SYSTEM_PROCESSOR}" AREG_USE_PACKAGES)

# Integration logic based on INTEGRATE_AREG_BEFORE_PROJECT flag
if (INTEGRATE_AREG_BEFORE_PROJECT)
Expand Down
3 changes: 2 additions & 1 deletion toolchains/clang-linux-x64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x64)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_FIND_ROOT_PATH /usr/bin)
set(CMAKE_FIND_ROOT_PATH /usr)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
3 changes: 2 additions & 1 deletion toolchains/clang-linux-x86.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_FIND_ROOT_PATH /usr/bin)
set(CMAKE_FIND_ROOT_PATH /usr)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
2 changes: 2 additions & 0 deletions toolchains/clang-win-x64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ set(CMAKE_FIND_ROOT_PATH /)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_GENERATOR_TOOLSET ClangCL CACHE INTERNAL "Force ClangCL tool-set")
set(CMAKE_GENERATOR_PLATFORM x64 CACHE INTERNAL "Force 64-bit compilation")
2 changes: 2 additions & 0 deletions toolchains/clang-win-x86.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ set(CMAKE_FIND_ROOT_PATH /)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_GENERATOR_TOOLSET ClangCL CACHE INTERNAL "Force ClangCL tool-set")
set(CMAKE_GENERATOR_PLATFORM Win32 CACHE INTERNAL "Force 32-bit compilation")
3 changes: 2 additions & 1 deletion toolchains/gnu-linux-arm32.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_FIND_ROOT_PATH /usr/bin)
set(CMAKE_FIND_ROOT_PATH /usr)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
3 changes: 2 additions & 1 deletion toolchains/gnu-linux-arm64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR AARCH64)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH /usr/bin)
set(CMAKE_FIND_ROOT_PATH /usr)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
3 changes: 2 additions & 1 deletion toolchains/gnu-linux-x64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_FIND_ROOT_PATH /usr/bin)
set(CMAKE_FIND_ROOT_PATH /usr)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
3 changes: 2 additions & 1 deletion toolchains/gnu-linux-x86.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_FIND_ROOT_PATH /usr/bin)
set(CMAKE_FIND_ROOT_PATH /usr)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
2 changes: 2 additions & 0 deletions toolchains/msvc-win-x64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ set(CMAKE_FIND_ROOT_PATH /)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_GENERATOR_PLATFORM x64 CACHE INTERNAL "Force 64-bit compilation")
2 changes: 2 additions & 0 deletions toolchains/msvc-win-x86.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ set(CMAKE_FIND_ROOT_PATH /)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_GENERATOR_PLATFORM Win32 CACHE INTERNAL "Force 32-bit compilation")

0 comments on commit ad4df51

Please sign in to comment.