Skip to content

Commit

Permalink
Add toolchain files for all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrNamenlos123 committed Apr 7, 2024
1 parent ebbeedc commit 7711405
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 111 deletions.
5 changes: 5 additions & 0 deletions .github/actions/build-package/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ runs:
with:
perl-version: '5.32'

- name: Install additional packages
if: matrix.cfg.os == 'ubuntu-20.04'
shell: bash
run: sudo apt update && sudo apt install -y g++-9 g++-9-arm-linux-gnueabi g++-9-aarch64-linux-gnu clang++-10

- name: Install Python deps
shell: bash
run: |
Expand Down
4 changes: 0 additions & 4 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ def main():

package_name = sys.argv[1]
builder = getattr(importlib.import_module(f'packages.{package_name}.build'), 'Builder')()

tools.log("Installing build dependencies ...")
builder.install_build_dependencies()
tools.log("Installing build dependencies ... Done")

if hasattr(builder, 'source'):
tools.log("Sourcing build files ...")
Expand Down
64 changes: 3 additions & 61 deletions scripts/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,7 @@ def log(msg):
class LibraryBuilder:
def __init__(self):
self.triple = os.environ.get('TRIPLE')

# All of this is only valid for ubuntu-20.04 and windows-2022
if self.triple == "linux-x64-gcc9":
self.cc_compiler = "gcc"
self.cxx_compiler = "g++"
self.cc_compiler_package = "gcc"
self.cxx_compiler_package = "g++"
self.toolchain_file = ""
elif self.triple == "linux-x64-clang10":
self.cc_compiler = "clang"
self.cxx_compiler = "clang++"
self.cc_compiler_package = "clang"
self.cxx_compiler_package = "clang++"
self.toolchain_file = ""
elif self.triple == "linux-armv7-gcc9":
self.cc_compiler = ""
self.cxx_compiler = ""
self.cc_compiler_package = "gcc-9-arm-linux-gnueabi"
self.cxx_compiler_package = "g++-9-arm-linux-gnueabi"
self.toolchain_file = "toolchains/gcc-armv7.cmake"
elif self.triple == "linux-aarch64-gcc9":
self.cc_compiler = ""
self.cxx_compiler = ""
self.cc_compiler_package = "gcc-9-aarch64-linux-gnu"
self.cxx_compiler_package = "g++-9-aarch64-linux-gnu"
self.toolchain_file = "toolchains/gcc-aarch64.cmake"
elif self.triple == "windows-x64-mingw64":
self.cc_compiler = "cc"
self.cxx_compiler = "c++"
self.cc_compiler_package = ""
self.cxx_compiler_package = ""
self.toolchain_file = ""
elif self.triple == "windows-x64-msvc":
self.cc_compiler = "msvc"
self.cxx_compiler = "msvc"
self.cc_compiler_package = ""
self.cxx_compiler_package = ""
self.toolchain_file = ""
else:
raise LookupError(f"Triple {self.triple} is not known to the system")
self.toolchain_file = f"toolchains/{self.triple}.cmake"

self.repo_dir = os.getcwd()
self.working_dir = os.path.join(self.repo_dir, 'temp', self.name)
Expand Down Expand Up @@ -107,19 +68,6 @@ def source_git_repo(self, git_repository, git_tag):
self.cmd(f'git clone {git_repository} {self.source_dir} --depth=1 --single-branch --branch={git_tag}')
log(f"Sourcing git repository {git_repository}:{git_tag} ... Done")

def install_build_dependencies(self, extra_unix_dependencies = []):
if platform.system() == 'Linux':
if self.cc_compiler_package != "":
extra_unix_dependencies.append(self.cc_compiler_package)
if self.cxx_compiler_package != "":
extra_unix_dependencies.append(self.cxx_compiler_package)

deps = ' '.join(extra_unix_dependencies)
log(f"Installing extra unix dependencies ...")
if os.system(f'apt-get update && apt-get install -y {deps}') != 0:
self.cmd(f'sudo apt-get update && sudo apt-get install -y {deps}')
log(f"Installing extra unix dependencies ... Done")

def pull_of_dependency(self, package, version):
depsdir = self.get_dependency_dir(package)
log(f'Fetching package {package}/{version} ...')
Expand All @@ -141,13 +89,7 @@ def build_generic_cmake_project(self,
cmake_args_debug = [],
cmake_args_release = []):

if self.toolchain_file != None and self.toolchain_file != "":
cmake_args.append(f'-DCMAKE_TOOLCHAIN_FILE={os.path.join(self.repo_dir, self.toolchain_file)}')
else:
if self.cc_compiler != 'msvc':
cmake_args.append(f'-DCMAKE_C_COMPILER={self.cc_compiler}')
cmake_args.append(f'-DCMAKE_CXX_COMPILER={self.cxx_compiler}')

cmake_args.append(f'-DCMAKE_TOOLCHAIN_FILE={os.path.join(self.repo_dir, self.toolchain_file)}')
cmake_args.append(f'-DBUILD_SHARED_LIBS=OFF')
cmake_args.append(f'-DPython_ROOT_DIR={os.path.dirname(sys.executable)}')
cmake_args.append(f'-DPython3_ROOT_DIR={os.path.dirname(sys.executable)}')
Expand All @@ -172,7 +114,7 @@ def build_generic_cmake_project(self,
args_release.append(' '.join(cmake_args_release))

cmake_build_args = []
if self.cc_compiler != 'msvc':
if self.triple.find('msvc') == -1:
cmake_build_args.append(f'-j{os.cpu_count()}')

log(f'Building Debug configuration ...')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc-9)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++-9)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
6 changes: 6 additions & 0 deletions toolchains/linux-armv7-gcc9.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc-9)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++-9)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_C_COMPILER clang-10)
set(CMAKE_CXX_COMPILER clang++-10)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
6 changes: 6 additions & 0 deletions toolchains/linux-x64-gcc9.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER gcc-9)
set(CMAKE_CXX_COMPILER g++-9)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
15 changes: 0 additions & 15 deletions toolchains/mingw-linux.cmake

This file was deleted.

27 changes: 0 additions & 27 deletions toolchains/mingw-windows.cmake

This file was deleted.

7 changes: 7 additions & 0 deletions toolchains/windows-x64-mingw64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set (CMAKE_SYSTEM_NAME Windows)
set (CMAKE_C_COMPILER cc)
set (CMAKE_CXX_COMPILER c++)
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)
6 changes: 6 additions & 0 deletions toolchains/windows-x64-msvc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set (CMAKE_SYSTEM_NAME Windows)

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)

0 comments on commit 7711405

Please sign in to comment.