From 70abbbe89d4d41815368274996de6efb5834426c Mon Sep 17 00:00:00 2001 From: HerrNamenlos123 Date: Mon, 25 Dec 2023 23:07:29 +0100 Subject: [PATCH] Remove Docker and upload Python build scripts for libcurl, mbedtls and freeimage --- .github/actions/build-package/action.yaml | 41 +++ .github/workflows/build-freeimage.yaml | 67 +++++ .github/workflows/build-libcurl.yaml | 67 +++++ .github/workflows/build-mbedtls.yaml | 67 +++++ README.md | 18 +- build.py | 32 +++ cmake/generic/import.cmake | 17 -- docker/clang-cl/Dockerfile | 34 --- docker/generic/Dockerfile | 22 -- docker/msvc/Dockerfile | 33 --- packages/freeimage/build.py | 15 ++ packages/glm/build.py | 11 - packages/glm/docker-compose.yaml | 23 -- packages/libcurl/build.py | 56 ++-- packages/libcurl/docker-compose.yaml | 77 ------ packages/mbedtls/build.py | 14 + packages/mbedtls/requirements.txt | 2 + packages/openssl/build.py | 44 ---- packages/openssl/docker-compose.yaml | 77 ------ requirements.txt | 1 + scripts/__init__.py | 0 scripts/tools.py | 298 ++++++++++++---------- test/Dockerfile | 20 -- test/app/build.bat | 74 ------ test/app/start.ps1 | 206 --------------- test/docker-compose.yaml | 23 -- 26 files changed, 511 insertions(+), 828 deletions(-) create mode 100644 .github/actions/build-package/action.yaml create mode 100644 .github/workflows/build-freeimage.yaml create mode 100644 .github/workflows/build-libcurl.yaml create mode 100644 .github/workflows/build-mbedtls.yaml create mode 100644 build.py delete mode 100644 cmake/generic/import.cmake delete mode 100644 docker/clang-cl/Dockerfile delete mode 100644 docker/generic/Dockerfile delete mode 100644 docker/msvc/Dockerfile create mode 100644 packages/freeimage/build.py delete mode 100644 packages/glm/build.py delete mode 100644 packages/glm/docker-compose.yaml delete mode 100644 packages/libcurl/docker-compose.yaml create mode 100644 packages/mbedtls/build.py create mode 100644 packages/mbedtls/requirements.txt delete mode 100644 packages/openssl/build.py delete mode 100644 packages/openssl/docker-compose.yaml create mode 100644 requirements.txt delete mode 100644 scripts/__init__.py delete mode 100644 test/Dockerfile delete mode 100644 test/app/build.bat delete mode 100644 test/app/start.ps1 delete mode 100644 test/docker-compose.yaml diff --git a/.github/actions/build-package/action.yaml b/.github/actions/build-package/action.yaml new file mode 100644 index 0000000..f3a3eeb --- /dev/null +++ b/.github/actions/build-package/action.yaml @@ -0,0 +1,41 @@ +name: Build Package + +runs: + using: composite + + steps: + - uses: seanmiddleditch/gha-setup-ninja@master + + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{matrix.cfg.ARCHITECTURE}} + + - uses: shogo82148/actions-setup-perl@v1 + with: + perl-version: '5.32' + + - name: Install Python deps + shell: bash + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r requirements.txt + [ -f packages/$PACKAGE/requirements.txt ] && python3 -m pip install -r packages/$PACKAGE/requirements.txt || true + + - name: Invoke Python build script + shell: bash + run: | + FULL_PACKAGE_NAME=${{matrix.cfg.FULL_PACKAGE_NAME}} \ + CC_COMPILER=${{matrix.cfg.CC_COMPILER}} \ + CC_COMPILER_PACKAGE=${{matrix.cfg.CC_COMPILER_PACKAGE}} \ + CXX_COMPILER=${{matrix.cfg.CXX_COMPILER}} \ + CXX_COMPILER_PACKAGE=${{matrix.cfg.CXX_COMPILER_PACKAGE}} \ + TOOLCHAIN_FILE=${{matrix.cfg.TOOLCHAIN_FILE}} \ + python3 build.py $PACKAGE + + - name: Upload files to a GitHub release + uses: svenstaro/upload-release-action@2.6.1 + with: + file: out/**.tar.gz + file_glob: true + tag: latest + overwrite: true diff --git a/.github/workflows/build-freeimage.yaml b/.github/workflows/build-freeimage.yaml new file mode 100644 index 0000000..c545090 --- /dev/null +++ b/.github/workflows/build-freeimage.yaml @@ -0,0 +1,67 @@ +name: Build freeimage + +on: + push: + paths: + - .github/workflows/build-freeimage.yml + - packages/freeimage/** + - build.py + - scripts/tools.py + +jobs: + build: + runs-on: ${{ matrix.cfg.os }} + + env: + PACKAGE: freeimage + + strategy: + fail-fast: false + matrix: + cfg: + - { os: ubuntu-20.04, + CC_COMPILER_PACKAGE: gcc-9, + CXX_COMPILER_PACKAGE: g++-9, + CC_COMPILER: gcc-9, + CXX_COMPILER: g++-9, + TOOLCHAIN_FILE: "", + ARCHITECTURE: amd64 + } + - { os: windows-2022, + CC_COMPILER_PACKAGE: msvc, + CXX_COMPILER_PACKAGE: msvc, + CC_COMPILER: msvc, + CXX_COMPILER: msvc, + TOOLCHAIN_FILE: "", + ARCHITECTURE: amd64 + } + # - { os: windows, architecture: x64, compiler: mingw } + # - { os: windows, architecture: x64, compiler: msys2 } + # - { os: windows, architecture: x64, compiler: clang } + # - { os: linux, architecture: x64, compiler: gcc } + # - { os: linux, architecture: x64, compiler: clang } + # - { os: linux, architecture: x64, compiler: mingw } + # - { os: linux, architecture: arm64, compiler: gcc } + # - { os: linux, architecture: arm64, compiler: clang } + # - { os: linux, architecture: arm64, compiler: mingw } + # - { os: android, architecture: arm64, compiler: gcc } + # - { os: android, architecture: arm64, compiler : clang } + # - { os: emscripten, architecture: emscripten, compiler: emscripten } + # - { os: macos, architecture: x64, compiler: gcc } + # - { os: macos, architecture: x64, compiler: clang } + # - { os: macos, architecture: arm64, compiler: gcc } + # - { os: macos, architecture: arm64, compiler: clang } + # - { os: tvos, architecture: x64, compiler: gcc } + # - { os: tvos, architecture: x64, compiler: clang } + # - { os: tvos, architecture: arm64, compiler: gcc } + # - { os: tvos, architecture: arm64, compiler: clang } + # - { os: ios, architecture: arm64, compiler: gcc } + # - { os: ios, architecture: arm64, compiler: clang } + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build package + uses: ./.github/actions/build-package + diff --git a/.github/workflows/build-libcurl.yaml b/.github/workflows/build-libcurl.yaml new file mode 100644 index 0000000..eeb9d63 --- /dev/null +++ b/.github/workflows/build-libcurl.yaml @@ -0,0 +1,67 @@ +name: Build libcurl + +on: + push: + paths: + - .github/workflows/build-libcurl.yml + - packages/libcurl/** + - build.py + - scripts/tools.py + +jobs: + build: + runs-on: ${{ matrix.cfg.os }} + + env: + PACKAGE: libcurl + + strategy: + fail-fast: false + matrix: + cfg: + - { os: ubuntu-20.04, + CC_COMPILER_PACKAGE: gcc-9, + CXX_COMPILER_PACKAGE: g++-9, + CC_COMPILER: gcc-9, + CXX_COMPILER: g++-9, + TOOLCHAIN_FILE: "", + ARCHITECTURE: amd64 + } + - { os: windows-2022, + CC_COMPILER_PACKAGE: msvc, + CXX_COMPILER_PACKAGE: msvc, + CC_COMPILER: msvc, + CXX_COMPILER: msvc, + TOOLCHAIN_FILE: "", + ARCHITECTURE: amd64 + } + # - { os: windows, architecture: x64, compiler: mingw } + # - { os: windows, architecture: x64, compiler: msys2 } + # - { os: windows, architecture: x64, compiler: clang } + # - { os: linux, architecture: x64, compiler: gcc } + # - { os: linux, architecture: x64, compiler: clang } + # - { os: linux, architecture: x64, compiler: mingw } + # - { os: linux, architecture: arm64, compiler: gcc } + # - { os: linux, architecture: arm64, compiler: clang } + # - { os: linux, architecture: arm64, compiler: mingw } + # - { os: android, architecture: arm64, compiler: gcc } + # - { os: android, architecture: arm64, compiler : clang } + # - { os: emscripten, architecture: emscripten, compiler: emscripten } + # - { os: macos, architecture: x64, compiler: gcc } + # - { os: macos, architecture: x64, compiler: clang } + # - { os: macos, architecture: arm64, compiler: gcc } + # - { os: macos, architecture: arm64, compiler: clang } + # - { os: tvos, architecture: x64, compiler: gcc } + # - { os: tvos, architecture: x64, compiler: clang } + # - { os: tvos, architecture: arm64, compiler: gcc } + # - { os: tvos, architecture: arm64, compiler: clang } + # - { os: ios, architecture: arm64, compiler: gcc } + # - { os: ios, architecture: arm64, compiler: clang } + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build package + uses: ./.github/actions/build-package + diff --git a/.github/workflows/build-mbedtls.yaml b/.github/workflows/build-mbedtls.yaml new file mode 100644 index 0000000..5cd2710 --- /dev/null +++ b/.github/workflows/build-mbedtls.yaml @@ -0,0 +1,67 @@ +name: Build mbedtls + +on: + push: + paths: + - .github/workflows/build-mbedtls.yml + - packages/mbedtls/** + - build.py + - scripts/tools.py + +jobs: + build: + runs-on: ${{ matrix.cfg.os }} + + env: + PACKAGE: mbedtls + + strategy: + fail-fast: false + matrix: + cfg: + - { os: ubuntu-20.04, + CC_COMPILER_PACKAGE: gcc-9, + CXX_COMPILER_PACKAGE: g++-9, + CC_COMPILER: gcc-9, + CXX_COMPILER: g++-9, + TOOLCHAIN_FILE: "", + ARCHITECTURE: amd64 + } + - { os: windows-2022, + CC_COMPILER_PACKAGE: msvc, + CXX_COMPILER_PACKAGE: msvc, + CC_COMPILER: msvc, + CXX_COMPILER: msvc, + TOOLCHAIN_FILE: "", + ARCHITECTURE: amd64 + } + # - { os: windows, architecture: x64, compiler: mingw } + # - { os: windows, architecture: x64, compiler: msys2 } + # - { os: windows, architecture: x64, compiler: clang } + # - { os: linux, architecture: x64, compiler: gcc } + # - { os: linux, architecture: x64, compiler: clang } + # - { os: linux, architecture: x64, compiler: mingw } + # - { os: linux, architecture: arm64, compiler: gcc } + # - { os: linux, architecture: arm64, compiler: clang } + # - { os: linux, architecture: arm64, compiler: mingw } + # - { os: android, architecture: arm64, compiler: gcc } + # - { os: android, architecture: arm64, compiler : clang } + # - { os: emscripten, architecture: emscripten, compiler: emscripten } + # - { os: macos, architecture: x64, compiler: gcc } + # - { os: macos, architecture: x64, compiler: clang } + # - { os: macos, architecture: arm64, compiler: gcc } + # - { os: macos, architecture: arm64, compiler: clang } + # - { os: tvos, architecture: x64, compiler: gcc } + # - { os: tvos, architecture: x64, compiler: clang } + # - { os: tvos, architecture: arm64, compiler: gcc } + # - { os: tvos, architecture: arm64, compiler: clang } + # - { os: ios, architecture: arm64, compiler: gcc } + # - { os: ios, architecture: arm64, compiler: clang } + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build package + uses: ./.github/actions/build-package + diff --git a/README.md b/README.md index 00d5c59..e0bd8ee 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,21 @@ This repository is the continuation of [apothecary](https://github.com/openframeworks/apothecary). It is the central place where all [openFrameworks](https://github.com/openframeworks/openframeworks) dependencies are built and managed, so they can be downloaded and linked into openFrameworks projects. -## Building manually locally +All packages are built and served completely automated with CI, so all you have to do is commit something and wait. The package is automatically built and uploaded into the latest Release. -You can build the dependencies locally by running the following command: +## Building a package locally + +You can build a single package locally, using the compiler that is being picked up by CMake. ```bash -cd packages/ -docker-compose up --build +python build.py +# Example: python build.py freeimage ``` -This should build the package and place all archive files into a `packages//out` folder. [Docker](https://www.docker.com) and [Docker-Compose](https://docs.docker.com/compose/) are required to run this command. Most CI environments and Linux servers have Docker pre-installed. \ No newline at end of file +The selected package will be built locally using the compiler chosen by CMake. Thus, you can only test packages for the compiler and architecture you are running on. See the workflow files to see what environment variables to set, if you are on Linux and want to test cross-compilation locally. + +When the package finished building, an archive package consisting of all binaries, headers and CMake files will be generated in an `out/` directory. + +You need a working Ninja backend. + +Some packages also include a `requirements.txt` file which contains pip dependencies. You might need to manually install these too. diff --git a/build.py b/build.py new file mode 100644 index 0000000..43ca012 --- /dev/null +++ b/build.py @@ -0,0 +1,32 @@ +import sys +import importlib + +# Usage: python build.py + +def main(): + if len(sys.argv) != 2: + print('Usage: python build.py ') + sys.exit(1) + + package_name = sys.argv[1] + builder = getattr(importlib.import_module(f'packages.{package_name}.build'), 'Builder')() + + builder.install_build_dependencies() + + if hasattr(builder, 'source'): + builder.source() + + if hasattr(builder, 'patch_sources'): + builder.patch_sources() + + if hasattr(builder, 'depends'): + builder.depends() + + if hasattr(builder, 'build'): + builder.build() + + if hasattr(builder, 'package'): + builder.package() + +if __name__ == '__main__': + main() diff --git a/cmake/generic/import.cmake b/cmake/generic/import.cmake deleted file mode 100644 index 8a08e61..0000000 --- a/cmake/generic/import.cmake +++ /dev/null @@ -1,17 +0,0 @@ - -set(PACKAGE_NAME {{ package_name }}) -set(LIBRARY_NAME {{ library_name }}) -set(FULL_LIBRARY_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}${LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) - -add_library(${PACKAGE_NAME} STATIC IMPORTED) -add_library(${PACKAGE_NAME}::${PACKAGE_NAME} ALIAS ${PACKAGE_NAME}) - -set_target_properties(${PACKAGE_NAME} - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_LIST_DIR}/$,debug,release>/include -) - -set_target_properties(${PACKAGE_NAME} PROPERTIES IMPORTED_LOCATION_DEBUG ${CMAKE_CURRENT_LIST_DIR}/debug/lib/${FULL_LIBRARY_NAME}) -set_target_properties(${PACKAGE_NAME} PROPERTIES IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_LIST_DIR}/release/lib/${FULL_LIBRARY_NAME}) -set_target_properties(${PACKAGE_NAME} PROPERTIES IMPORTED_LOCATION_MINSIZEREL ${CMAKE_CURRENT_LIST_DIR}/release/lib/${FULL_LIBRARY_NAME}) -set_target_properties(${PACKAGE_NAME} PROPERTIES IMPORTED_LOCATION_RELWITHDEBINFO ${CMAKE_CURRENT_LIST_DIR}/release/lib/${FULL_LIBRARY_NAME}) \ No newline at end of file diff --git a/docker/clang-cl/Dockerfile b/docker/clang-cl/Dockerfile deleted file mode 100644 index ef22b73..0000000 --- a/docker/clang-cl/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -FROM ubuntu:22.04 - -RUN apt-get update && apt-get upgrade -y -RUN apt-get install -y git python3 msitools python3-simplejson python3-six ca-certificates -RUN git clone https://github.com/mstorsjo/msvc-wine.git /msvc-wine -RUN /msvc-wine/vsdownload.py --dest /msvc --accept-license -RUN /msvc-wine/install.sh /msvc - -RUN apt-get install -y cmake ninja-build llvm-15 clang-tools-15 lld-15 wget -RUN wget -O llvm.tar.gz https://github.com/llvm/llvm-project/archive/main.tar.gz # Download as archive because git takes ages -RUN mkdir /llvm -RUN tar -xzf llvm.tar.gz -C /llvm --strip-components=1 - -ARG PACKAGE_NAME -ARG FULL_PACKAGE_NAME -ARG CC_COMPILER_PACKAGE -ARG CXX_COMPILER_PACKAGE -ARG CC_COMPILER -ARG CXX_COMPILER -ARG TOOLCHAIN_FILE -ARG GIT_REPOSITORY -ARG GIT_TAG - -ENV PACKAGE_NAME=$PACKAGE_NAME -ENV FULL_PACKAGE_NAME=$FULL_PACKAGE_NAME -ENV CC_COMPILER_PACKAGE=$CC_COMPILER_PACKAGE -ENV CXX_COMPILER_PACKAGE=$CXX_COMPILER_PACKAGE -ENV CC_COMPILER=$CC_COMPILER -ENV CXX_COMPILER=$CXX_COMPILER -ENV TOOLCHAIN_FILE=$TOOLCHAIN_FILE -ENV GIT_REPOSITORY=$GIT_REPOSITORY -ENV GIT_TAG=$GIT_TAG - -ENTRYPOINT [ "/bin/bash", "-c", "cd /repo && python3 -m packages.$PACKAGE_NAME.build" ] \ No newline at end of file diff --git a/docker/generic/Dockerfile b/docker/generic/Dockerfile deleted file mode 100644 index af575a6..0000000 --- a/docker/generic/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM debian:10 - -RUN apt-get update && apt-get upgrade -y -RUN apt-get install -y cmake git python3 ninja-build - -ARG PACKAGE_NAME -ARG FULL_PACKAGE_NAME -ARG CC_COMPILER_PACKAGE -ARG CXX_COMPILER_PACKAGE -ARG CC_COMPILER -ARG CXX_COMPILER -ARG TOOLCHAIN_FILE - -ENV PACKAGE_NAME=$PACKAGE_NAME -ENV FULL_PACKAGE_NAME=$FULL_PACKAGE_NAME -ENV CC_COMPILER_PACKAGE=$CC_COMPILER_PACKAGE -ENV CXX_COMPILER_PACKAGE=$CXX_COMPILER_PACKAGE -ENV CC_COMPILER=$CC_COMPILER -ENV CXX_COMPILER=$CXX_COMPILER -ENV TOOLCHAIN_FILE=$TOOLCHAIN_FILE - -ENTRYPOINT [ "/bin/bash", "-c", "cd /repo && python3 -m packages.$PACKAGE_NAME.build" ] \ No newline at end of file diff --git a/docker/msvc/Dockerfile b/docker/msvc/Dockerfile deleted file mode 100644 index fef5da7..0000000 --- a/docker/msvc/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM ubuntu:22.04 - -RUN apt-get update && apt-get install -y git python3 msitools python3-simplejson python3-six ca-certificates -RUN git clone https://github.com/mstorsjo/msvc-wine.git /msvc-wine -RUN /msvc-wine/vsdownload.py --dest /msvc --accept-license -RUN /msvc-wine/install.sh /msvc - -RUN apt-get update && apt-get install -y cmake ninja-build llvm-15 clang-tools-15 lld-15 wget -RUN wget -O llvm.tar.gz https://github.com/llvm/llvm-project/archive/main.tar.gz # Download as archive because git takes ages -RUN mkdir /llvm -RUN tar -xzf llvm.tar.gz -C /llvm --strip-components=1 - -ARG PACKAGE_NAME -ARG FULL_PACKAGE_NAME -ARG CC_COMPILER_PACKAGE -ARG CXX_COMPILER_PACKAGE -ARG CC_COMPILER -ARG CXX_COMPILER -ARG TOOLCHAIN_FILE -ARG GIT_REPOSITORY -ARG GIT_TAG - -ENV PACKAGE_NAME=$PACKAGE_NAME -ENV FULL_PACKAGE_NAME=$FULL_PACKAGE_NAME -ENV CC_COMPILER_PACKAGE=$CC_COMPILER_PACKAGE -ENV CXX_COMPILER_PACKAGE=$CXX_COMPILER_PACKAGE -ENV CC_COMPILER=$CC_COMPILER -ENV CXX_COMPILER=$CXX_COMPILER -ENV TOOLCHAIN_FILE=$TOOLCHAIN_FILE -ENV GIT_REPOSITORY=$GIT_REPOSITORY -ENV GIT_TAG=$GIT_TAG - -ENTRYPOINT [ "/bin/bash", "-c", "cd /repo && python3 -m packages.$PACKAGE_NAME.build" ] \ No newline at end of file diff --git a/packages/freeimage/build.py b/packages/freeimage/build.py new file mode 100644 index 0000000..50a55b5 --- /dev/null +++ b/packages/freeimage/build.py @@ -0,0 +1,15 @@ +from scripts.tools import LibraryBuilder + +class Builder(LibraryBuilder): + name = "freeimage" + version = "3.19.0" + + def source(self): + # self.source_git_repo("https://github.com/danoli3/FreeImage.git", "test3.19.0") + self.source_git_repo("https://github.com/HerrNamenlos123/danoli3-FreeImage.git", "master") + + def build(self): + self.build_generic_cmake_project() + + def package(self): + self.archive_generic_package() diff --git a/packages/glm/build.py b/packages/glm/build.py deleted file mode 100644 index 2ad2939..0000000 --- a/packages/glm/build.py +++ /dev/null @@ -1,11 +0,0 @@ -from scripts import tools - -tools.install_build_requirements(extra_unix_dependencies = []) - -tools.clone_git_repository(git_repository = "https://github.com/g-truc/glm", - git_tag = "0.9.9.8") - -tools.archive_manual_package([ - ["CMakeLists.txt", "CMakeLists.txt"], - ["glm", "include/glm"], -]) \ No newline at end of file diff --git a/packages/glm/docker-compose.yaml b/packages/glm/docker-compose.yaml deleted file mode 100644 index 315bd58..0000000 --- a/packages/glm/docker-compose.yaml +++ /dev/null @@ -1,23 +0,0 @@ -version: '3.4' - -x-package: &default - volumes: - - .:/package - - ../..:/repo - -x-build: &build - context: . - -services: - glm-universal: - <<: *default - build: - <<: *build - dockerfile: ../../docker/generic/Dockerfile - args: - - PACKAGE_NAME=glm - - FULL_PACKAGE_NAME=glm-universal - - CC_COMPILER_PACKAGE= - - CC_COMPILER= - - CXX_COMPILER_PACKAGE= - - CXX_COMPILER= \ No newline at end of file diff --git a/packages/libcurl/build.py b/packages/libcurl/build.py index 5da68d2..9f0fb2b 100644 --- a/packages/libcurl/build.py +++ b/packages/libcurl/build.py @@ -1,34 +1,34 @@ -from scripts import tools +from scripts.tools import LibraryBuilder import os -tools.install_build_requirements(extra_unix_dependencies = ["python3", "python3-pip"]) -tools.cmd("pip3 install jsonschema jinja2") +class Builder(LibraryBuilder): + name = "libcurl" + version = "8.5.0" -tools.clone_git_repository(git_repository = "https://github.com/Mbed-TLS/mbedtls.git", - git_tag = "v3.4.0", - working_dir = "/mbedtls") + def source(self): + self.source_git_repo("https://github.com/curl/curl.git", "curl-8_5_0") -tools.insert_before_file(file = "/mbedtls/source/CMakeLists.txt", insert = "set(CMAKE_C_COMPILER_ID MSVC)\n") # Patching so it thinks it's MSVC + def patch_sources(self): + self.remove_file(file = os.path.join(self.source_dir, "CMake", "FindMbedTLS.cmake")) + self.append_to_file( + file = os.path.join(self.source_dir, "CMakeLists.txt"), + append = "target_link_libraries(libcurl_static PUBLIC MbedTLS::mbedtls)\n", + ) -tools.build_generic_cmake_project(working_dir = "/mbedtls", - cmake_args = ["-DENABLE_TESTING=OFF", - "-DENABLE_PROGRAMS=OFF", - "-DBUILD_SHARED_LIBS=OFF", - "-DGEN_FILES=ON"]) + def depends(self): + self.pull_of_dependency("mbedtls", "3.4.0") -tools.clone_git_repository(git_repository = "https://github.com/curl/curl.git", - git_tag = "curl-8_1_2") - -tools.build_generic_cmake_project(cmake_args = ["-DBUILD_SHARED_LIBS=OFF", - "-DBUILD_CURL_EXE=OFF", - "-DENABLE_UNICODE=ON", - "-DCURL_USE_MBEDTLS=ON"]) - -tools.archive_generic_package(files = [ - [tools.SOURCE_DIR + "/include/openssl", "include/openssl"], - [tools.SOURCE_DIR + "/include/crypto", "include/crypto"], - [tools.INSTALL_DIR_DEBUG + f"/lib64/{tools.release_lib_name('crypto')}", f"lib-debug/{tools.release_lib_name('crypto')}"], - [tools.INSTALL_DIR_DEBUG + f"/lib64/{tools.release_lib_name('ssl')}", f"lib-debug/{tools.release_lib_name('ssl')}"], - [tools.INSTALL_DIR_RELEASE + f"/lib64/{tools.release_lib_name('crypto')}", f"lib-release/{tools.release_lib_name('crypto')}"], - [tools.INSTALL_DIR_RELEASE + f"/lib64/{tools.release_lib_name('ssl')}", f"lib-release/{tools.release_lib_name('ssl')}"], -]) \ No newline at end of file + def build(self): + self.build_generic_cmake_project( + [ + "-DBUILD_SHARED_LIBS=OFF", + "-DBUILD_CURL_EXE=OFF", + "-DENABLE_UNICODE=ON", + "-DCURL_USE_MBEDTLS=ON", + "-DSHARE_LIB_OBJECT=OFF", + f'-DCMAKE_PREFIX_PATH="{self.get_dependency_dir("mbedtls")}"', + ] + ) + + def package(self): + self.archive_generic_package() diff --git a/packages/libcurl/docker-compose.yaml b/packages/libcurl/docker-compose.yaml deleted file mode 100644 index 1e0ee5c..0000000 --- a/packages/libcurl/docker-compose.yaml +++ /dev/null @@ -1,77 +0,0 @@ -version: '3.4' - -x-package: &default - volumes: - - .:/package - - ../..:/repo - -x-build: &build - context: . - -services: - - # libcurl-linux-x64-gcc8: - # <<: *default - # build: - # <<: *build - # dockerfile: ../../docker/generic/Dockerfile - # args: - # - PACKAGE_NAME=libcurl - # - FULL_PACKAGE_NAME=libcurl-linux-x64-gcc8 - # - CC_COMPILER_PACKAGE=gcc-8 - # - CC_COMPILER=gcc-8 - # - CXX_COMPILER_PACKAGE=g++-8 - # - CXX_COMPILER=g++-8 - - # libcurl-linux-x64-clang7: - # <<: *default - # build: - # <<: *build - # dockerfile: ../../docker/generic/Dockerfile - # args: - # - PACKAGE_NAME=libcurl - # - FULL_PACKAGE_NAME=libcurl-linux-x64-clang7 - # - CC_COMPILER_PACKAGE=clang-7 - # - CC_COMPILER=clang-7 - # - CXX_COMPILER_PACKAGE=clang++-7 - # - CXX_COMPILER=clang++-7 - - # libcurl-linux-x64-mingw: - # <<: *default - # build: - # <<: *build - # dockerfile: ../../docker/generic/Dockerfile - # args: - # - PACKAGE_NAME=libcurl - # - FULL_PACKAGE_NAME=libcurl-linux-x64-mingw - # - CC_COMPILER_PACKAGE=gcc-mingw-w64 - # - CC_COMPILER=x86_64-w64-mingw32-gcc - # - CXX_COMPILER_PACKAGE=g++-mingw-w64 - # - CXX_COMPILER=x86_64-w64-mingw32-g++ - # - TOOLCHAIN_FILE=/repo/toolchains/mingw.cmake # MinGW toolchain file - - # libcurl-linux-arm64-gcc8: - # <<: *default - # build: - # <<: *build - # dockerfile: ../../docker/generic/Dockerfile - # args: - # - PACKAGE_NAME=libcurl - # - FULL_PACKAGE_NAME=libcurl-linux-arm64-gcc8 - # - CC_COMPILER_PACKAGE=gcc-8-aarch64-linux-gnu - # - CC_COMPILER=aarch64-linux-gnu-gcc-8 - # - CXX_COMPILER_PACKAGE=g++-8-aarch64-linux-gnu - # - CXX_COMPILER=aarch64-linux-gnu-g++-8 - - libcurl-windows-amd64-msvc: - <<: *default - build: - <<: *build - dockerfile: ../../docker/msvc/Dockerfile - args: - - PACKAGE_NAME=libcurl - - FULL_PACKAGE_NAME=libcurl-windows-amd64-msvc - - CC_COMPILER_PACKAGE=msvc - - CC_COMPILER=msvc - - CXX_COMPILER_PACKAGE=msvc - - CXX_COMPILER=msvc \ No newline at end of file diff --git a/packages/mbedtls/build.py b/packages/mbedtls/build.py new file mode 100644 index 0000000..a4e79ad --- /dev/null +++ b/packages/mbedtls/build.py @@ -0,0 +1,14 @@ +from scripts.tools import LibraryBuilder + +class Builder(LibraryBuilder): + name = "mbedtls" + version = "3.4.0" + + def source(self): + self.source_git_repo("https://github.com/Mbed-TLS/mbedtls.git", "v3.4.0") + + def build(self): + self.build_generic_cmake_project(["-DENABLE_TESTING=OFF", "-DENABLE_PROGRAMS=OFF", "-DGEN_FILES=ON"]) + + def package(self): + self.archive_generic_package() diff --git a/packages/mbedtls/requirements.txt b/packages/mbedtls/requirements.txt new file mode 100644 index 0000000..5faa524 --- /dev/null +++ b/packages/mbedtls/requirements.txt @@ -0,0 +1,2 @@ +jsonschema +jinja2 \ No newline at end of file diff --git a/packages/openssl/build.py b/packages/openssl/build.py deleted file mode 100644 index 1695b0c..0000000 --- a/packages/openssl/build.py +++ /dev/null @@ -1,44 +0,0 @@ -from scripts import tools -import os - -def build_openssl(): - os.makedirs(tools.BUILD_DIR_DEBUG) - os.makedirs(tools.BUILD_DIR_RELEASE) - - platform = '' - if os.environ["CXX_COMPILER"] == 'msvc': - tools.cmd('export CC=clang-cl') - tools.cmd('export CXX=clang-cl++') - tools.cmd('export AR=llvm-ar') - tools.cmd('export RANLIB=llvm-ranlib') - platform = 'VC-WIN64A' - - # https://aka.ms/vs/15/release/vs_BuildTools.exe - perl = 'wine /strawberry-perl/perl/bin/perl.exe' - os.chdir(tools.BUILD_DIR_DEBUG) - tools.cmd(f'{perl} --version') - tools.cmd(f'{perl} {tools.SOURCE_DIR}/Configure {platform} --prefix={tools.INSTALL_DIR_DEBUG} --debug no-tests no-shared no-asm') - # tools.cmd(f'{perl} {tools.SOURCE_DIR}/Configure') - tools.cmd(f'make -j $(nproc)') - tools.cmd(f'make install_sw') - - os.chdir(tools.BUILD_DIR_RELEASE) - tools.cmd(f'{perl} {tools.SOURCE_DIR}/Configure {platform} --prefix={tools.INSTALL_DIR_RELEASE} --release no-tests no-shared no-asm') - tools.cmd(f'make -j $(nproc)') - tools.cmd(f'make install_sw') - -tools.install_build_requirements(extra_unix_dependencies = []) - -tools.clone_git_repository(git_repository = "https://github.com/openssl/openssl.git", - git_tag = "openssl-3.1.1") - -build_openssl() - -tools.archive_generic_package(files = [ - [tools.SOURCE_DIR + "/include/openssl", "include/openssl"], - [tools.SOURCE_DIR + "/include/crypto", "include/crypto"], - [tools.INSTALL_DIR_DEBUG + f"/lib64/{tools.release_lib_name('crypto')}", f"lib-debug/{tools.release_lib_name('crypto')}"], - [tools.INSTALL_DIR_DEBUG + f"/lib64/{tools.release_lib_name('ssl')}", f"lib-debug/{tools.release_lib_name('ssl')}"], - [tools.INSTALL_DIR_RELEASE + f"/lib64/{tools.release_lib_name('crypto')}", f"lib-release/{tools.release_lib_name('crypto')}"], - [tools.INSTALL_DIR_RELEASE + f"/lib64/{tools.release_lib_name('ssl')}", f"lib-release/{tools.release_lib_name('ssl')}"], -]) \ No newline at end of file diff --git a/packages/openssl/docker-compose.yaml b/packages/openssl/docker-compose.yaml deleted file mode 100644 index a97cb8e..0000000 --- a/packages/openssl/docker-compose.yaml +++ /dev/null @@ -1,77 +0,0 @@ -version: '3.4' - -x-package: &default - volumes: - - .:/package - - ../..:/repo - -x-build: &build - context: . - -services: - - # openssl-linux-x64-gcc8: - # <<: *default - # build: - # <<: *build - # dockerfile: ../../docker/generic/Dockerfile - # args: - # - PACKAGE_NAME=openssl - # - FULL_PACKAGE_NAME=openssl-linux-x64-gcc8 - # - CC_COMPILER_PACKAGE=gcc-8 - # - CC_COMPILER=gcc-8 - # - CXX_COMPILER_PACKAGE=g++-8 - # - CXX_COMPILER=g++-8 - - # openssl-linux-x64-clang7: - # <<: *default - # build: - # <<: *build - # dockerfile: ../../docker/generic/Dockerfile - # args: - # - PACKAGE_NAME=openssl - # - FULL_PACKAGE_NAME=openssl-linux-x64-clang7 - # - CC_COMPILER_PACKAGE=clang-7 - # - CC_COMPILER=clang-7 - # - CXX_COMPILER_PACKAGE=clang++-7 - # - CXX_COMPILER=clang++-7 - - # openssl-linux-x64-mingw: - # <<: *default - # build: - # <<: *build - # dockerfile: ../../docker/generic/Dockerfile - # args: - # - PACKAGE_NAME=openssl - # - FULL_PACKAGE_NAME=openssl-linux-x64-mingw - # - CC_COMPILER_PACKAGE=gcc-mingw-w64 - # - CC_COMPILER=x86_64-w64-mingw32-gcc - # - CXX_COMPILER_PACKAGE=g++-mingw-w64 - # - CXX_COMPILER=x86_64-w64-mingw32-g++ - # - TOOLCHAIN_FILE=/repo/toolchains/mingw.cmake # MinGW toolchain file - - # openssl-linux-arm64-gcc8: - # <<: *default - # build: - # <<: *build - # dockerfile: ../../docker/generic/Dockerfile - # args: - # - PACKAGE_NAME=openssl - # - FULL_PACKAGE_NAME=openssl-linux-arm64-gcc8 - # - CC_COMPILER_PACKAGE=gcc-8-aarch64-linux-gnu - # - CC_COMPILER=aarch64-linux-gnu-gcc-8 - # - CXX_COMPILER_PACKAGE=g++-8-aarch64-linux-gnu - # - CXX_COMPILER=aarch64-linux-gnu-g++-8 - - openssl-windows-amd64-msvc: - <<: *default - build: - <<: *build - dockerfile: ../../docker/msvc/Dockerfile - args: - - PACKAGE_NAME=openssl - - FULL_PACKAGE_NAME=openssl-windows-amd64-msvc - - CC_COMPILER_PACKAGE=msvc - - CC_COMPILER=msvc - - CXX_COMPILER_PACKAGE=msvc - - CXX_COMPILER=msvc \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..64b1ada --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +GitPython diff --git a/scripts/__init__.py b/scripts/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/tools.py b/scripts/tools.py index eed5bfb..daa80c2 100644 --- a/scripts/tools.py +++ b/scripts/tools.py @@ -1,139 +1,169 @@ import os +import sys +import git import shutil - -LLVM_NATIVE_TOOLCHAIN = '/usr/lib/llvm-15' -MSVC_TOOLCHAIN_FILE = '/llvm/llvm/cmake/platforms/WinMsvc.cmake' -MSVC_HOST_ARCH = 'x86_64' -LLVM_WINSYSROOT = '/msvc' -MSVC_VER = '14.36.32532' -WINSDK_VER = '10.0.22000.0' - -WORKING_DIR = '/temp' -SOURCE_DIR = '/source' -BUILD_DIR_DEBUG = '/build-debug' -BUILD_DIR_RELEASE = '/build-release' -INSTALL_DIR_DEBUG = '/install-debug' -INSTALL_DIR_RELEASE = '/install-release' - -def cmd(command): - if os.system(command) != 0: - raise Exception(f'Failed to execute command: {command}') - -def debug_lib_name(name, is_debug = False): - if (os.environ['CXX_COMPILER'] == 'msvc'): - return f'{name}d.lib' - else: - return f'lib{name}d.a' - -def release_lib_name(name, is_debug = False): - if (os.environ['CXX_COMPILER'] == 'msvc'): - return f'{name}.lib' - else: - return f'lib{name}.a' - -def native_pdb_name(name): - return f'{name}.pdb' - -def replace_in_file(file, find, replace): - with open(file, 'r') as f: - content = f.read() - content = content.replace(find, replace) - with open(file, 'w') as f: - f.write(content) - -def insert_before_file(file, insert): - with open(file, 'r') as f: - content = f.read() - content = insert + content - with open(file, 'w') as f: - f.write(content) - -def clone_git_repository(git_repository, git_tag, working_dir = WORKING_DIR): - if (os.path.exists(working_dir)): - shutil.rmtree(working_dir) - - cmd('git config --global advice.detachedHead false') - cmd(f'git clone {git_repository} {working_dir + SOURCE_DIR} --depth=1 --single-branch --branch={git_tag}') - -def install_build_requirements(extra_unix_dependencies = []): - if (os.environ['CXX_COMPILER'] != 'msvc'): - extra_unix_dependencies += os.environ['CC_COMPILER_PACKAGE'] - extra_unix_dependencies += os.environ['CXX_COMPILER_PACKAGE'] - deps = ' '.join(extra_unix_dependencies) - cmd(f'apt-get update && apt-get install -y {deps}') - -def build_generic_cmake_project(cmake_args = [], working_dir = WORKING_DIR): - if (os.environ['CXX_COMPILER'] == 'msvc'): - cmake_args.append(f'-DCMAKE_SYSTEM_NAME=Windows') - cmake_args.append(f'-DCMAKE_TOOLCHAIN_FILE={MSVC_TOOLCHAIN_FILE}') - cmake_args.append(f'-DHOST_ARCH={MSVC_HOST_ARCH}') - cmake_args.append(f'-DLLVM_NATIVE_TOOLCHAIN={LLVM_NATIVE_TOOLCHAIN}') - cmake_args.append(f'-DLLVM_WINSYSROOT={LLVM_WINSYSROOT}') - cmake_args.append(f'-DMSVC_VER={MSVC_VER}') - cmake_args.append(f'-DWINSDK_VER={WINSDK_VER}') - else: - cmake_args.append(f'-DCMAKE_C_COMPILER={os.environ["CC_COMPILER"]}') - cmake_args.append(f'-DCMAKE_CXX_COMPILER={os.environ["CXX_COMPILER"]}') - if (os.environ["TOOLCHAIN_FILE"] != ''): - cmake_args.append(f'-DCMAKE_TOOLCHAIN_FILE={os.environ["TOOLCHAIN_FILE"]}') - - cmake_args.append(f'-DBUILD_SHARED_LIBS=OFF') - - os.makedirs(working_dir + BUILD_DIR_DEBUG, exist_ok=True) - os.makedirs(working_dir + BUILD_DIR_RELEASE, exist_ok=True) - - cmd(f'cmake -G Ninja {working_dir + SOURCE_DIR} -B {working_dir + BUILD_DIR_DEBUG} {" ".join(cmake_args)} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX={working_dir + INSTALL_DIR_DEBUG}') - cmd(f'cmake -G Ninja {working_dir + SOURCE_DIR} -B {working_dir + BUILD_DIR_RELEASE} {" ".join(cmake_args)} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={working_dir + INSTALL_DIR_RELEASE}') - - cmd(f'cmake --build {working_dir + BUILD_DIR_DEBUG} -j $(nproc)') - cmd(f'cmake --build {working_dir + BUILD_DIR_DEBUG} --target install') - - cmd(f'cmake --build {working_dir + BUILD_DIR_RELEASE} -j $(nproc)') - cmd(f'cmake --build {working_dir + BUILD_DIR_RELEASE} --target install') - -def rename_debug_libfile(name, - install_dir_debug = WORKING_DIR + INSTALL_DIR_DEBUG, - install_dir_release = WORKING_DIR + INSTALL_DIR_RELEASE): - if os.path.exists(install_dir_debug + f'/lib/{name}d.lib'): - os.rename(install_dir_debug + f'/lib/{name}d.lib', install_dir_debug + f'/lib/{name}.lib') - - if os.path.exists(install_dir_release + f'/lib/{name}d.lib'): - os.rename(install_dir_release + f'/lib/{name}d.lib', install_dir_release + f'/lib/{name}.lib') - -# def archive_generic_package(files, -# cmake_file = '/repo/cmake/generic/import.cmake'): -# os.makedirs(WORKING_DIR + '/archive/debug/lib', exist_ok=True) -# os.makedirs(WORKING_DIR + '/archive/release/lib', exist_ok=True) -# os.makedirs('/package/out', exist_ok=True) - -# shutil.copy(cmake_file, WORKING_DIR + '/archive/') -# shutil.copy(INSTALL_DIR_DEBUG + f'/lib/{native_lib_name(output_library_name)}', WORKING_DIR + '/archive/debug/lib/') -# shutil.copy(INSTALL_DIR_RELEASE + f'/lib/{native_lib_name(output_library_name)}', WORKING_DIR + '/archive/release/lib/') - -# if os.path.exists(INSTALL_DIR_DEBUG + f'/lib/{native_pdb_name(output_library_name)}'): -# shutil.copy(INSTALL_DIR_DEBUG + f'/lib/{native_pdb_name(output_library_name)}', WORKING_DIR + '/archive/debug/lib/') - -# shutil.copytree(INSTALL_DIR_DEBUG + '/include', WORKING_DIR + '/archive/debug/include') -# shutil.copytree(INSTALL_DIR_RELEASE + '/include', WORKING_DIR + '/archive/release/include') - -# cmd(f'cd {WORKING_DIR}/archive && tar -zcvf /package/out/{os.environ["FULL_PACKAGE_NAME"]}.tar.gz *') - -def archive_generic_package(files, working_dir = WORKING_DIR, default_cmake_file = True): - os.makedirs(working_dir + '/archive', exist_ok=True) - os.makedirs('/package/out', exist_ok=True) - - if default_cmake_file: - shutil.copy('/repo/cmake/generic/import.cmake', working_dir + '/archive/') - - for file in files: - sourcefile = file[0] - targetfile = working_dir + '/archive/' + file[1] - - os.makedirs(os.path.dirname(targetfile), exist_ok=True) +import tarfile +import platform +import urllib.request + +class LibraryBuilder: + def __init__(self): + self.cc_compiler = os.environ.get('CC_COMPILER', "unknown") + self.cxx_compiler = os.environ.get('CXX_COMPILER', "unknown") + self.cc_compiler_package = os.environ.get('CC_COMPILER_PACKAGE', None) + self.cxx_compiler_package = os.environ.get('CXX_COMPILER_PACKAGE', None) + self.toolchain_file = os.environ.get('TOOLCHAIN_FILE', None) + + self.repo_dir = os.getcwd() + self.working_dir = os.path.join(self.repo_dir, 'temp', self.name) + self.source_dir = os.path.join(self.working_dir, 'source') + self.debug_build_dir = os.path.join(self.working_dir, 'build_debug') + self.release_build_dir = os.path.join(self.working_dir, 'build_release') + self.install_dir = os.path.join(self.working_dir, 'install') + self.archive_dir = os.path.join(self.working_dir, 'archive') + self.output_dir = os.path.join(self.repo_dir, 'out') + + self.package_suffix = f"-{self.version}-{platform.system().lower()}-{platform.machine().lower()}-{self.cc_compiler}" + self.archive_filename = f'{self.name}{self.package_suffix}.tar.gz' + + print(f'>> Building package {self.name}/{self.version}') + print(f'>> Cleaning working directory {self.working_dir} ...') + if os.path.exists(self.working_dir): + git.rmtree(self.working_dir) + print(f'>> Cleaning working directory {self.working_dir} ... Done') + + def cmd(self, command): + if os.system(command) != 0: + raise Exception(f'Failed to execute command: {command}') + + def replace_in_file(self, file, find, replace): + with open(file, 'r') as f: + content = f.read() + content = content.replace(find, replace) + with open(file, 'w') as f: + f.write(content) + + def append_to_file(self, file, append): + with open(file, 'a') as f: + f.write(append) + + def remove_file(self, file): + os.remove(file) + + def insert_head_file(self, file, insert): + with open(file, 'r') as f: + content = f.read() + content = insert + content + with open(file, 'w') as f: + f.write(content) + + def source_git_repo(self, git_repository, git_tag): + self.cmd('git config --global advice.detachedHead false') + self.cmd(f'git clone {git_repository} {self.source_dir} --depth=1 --single-branch --branch={git_tag}') + + def install_build_dependencies(self, extra_unix_dependencies = []): + if platform.system() == 'Linux': + if self.cc_compiler != "unknown" and self.cc_compiler != 'msvc': + extra_unix_dependencies.append(os.environ['CC_COMPILER_PACKAGE']) + + if self.cxx_compiler != "unknown" and self.cxx_compiler != 'msvc': + extra_unix_dependencies.append(os.environ['CXX_COMPILER_PACKAGE']) + + deps = ' '.join(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}') + + def pull_of_dependency(self, package, version): + depsdir = self.get_dependency_dir(package) + print(f'>> Pulling dependency {package}/{version} ...') + if not os.path.exists(depsdir): + # Download archive from GitHub + url = "https://github.com/HerrNamenlos123/openFrameworks-packages/releases/download/master/" + package + "-" + version + "-" + platform.system().lower() + "-" + platform.machine().lower() + "-" + self.cc_compiler + ".tar.gz" + archive = tarfile.open(fileobj=urllib.request.urlopen(url), mode="r|gz") + archive.extractall(path=depsdir) + archive.close() + print(f'>> Pulling dependency {package}/{version} ... Done') + + def get_dependency_dir(self, package): + return os.path.join(self.working_dir, 'deps', package).replace("\\", "/") + + def build_generic_cmake_project(self, + cmake_args = [], + cmake_module_paths = [], + cmake_args_debug = [], + cmake_args_release = []): + + if self.cc_compiler != "unknown" and self.cc_compiler != 'msvc': + cmake_args.append(f'-DCMAKE_C_COMPILER={self.cc_compiler}') + + if self.cxx_compiler != "unknown" and self.cxx_compiler != 'msvc': + cmake_args.append(f'-DCMAKE_CXX_COMPILER={self.cxx_compiler}') - if os.path.isdir(sourcefile): - shutil.copytree(sourcefile, targetfile) + if self.toolchain_file != None: + cmake_args.append(f'-DCMAKE_TOOLCHAIN_FILE={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)}') + + if cmake_module_paths != []: + cmake_args.append(f'-DCMAKE_MODULE_PATH={";".join(cmake_module_paths)}') + + os.makedirs(self.debug_build_dir, exist_ok=True) + os.makedirs(self.release_build_dir, exist_ok=True) + + args_debug = [] + args_debug.append(f'-DCMAKE_BUILD_TYPE=Debug') + args_debug.append(f'-DCMAKE_INSTALL_PREFIX={self.install_dir}') + args_debug.append(' '.join(cmake_args)) + args_debug.append(' '.join(cmake_args_debug)) + args_debug.append('-DCMAKE_DEBUG_POSTFIX=-d') + + args_release = [] + args_release.append(f'-DCMAKE_BUILD_TYPE=Release') + args_release.append(f'-DCMAKE_INSTALL_PREFIX={self.install_dir}') + args_release.append(' '.join(cmake_args)) + args_release.append(' '.join(cmake_args_release)) + + print(f'>> Building Debug configuration ...') + self.cmd(f'cmake -G Ninja {self.source_dir} -B {self.debug_build_dir} {" ".join(args_debug)}') + self.cmd(f'cmake --build {self.debug_build_dir} --config Debug --target install') + print(f'>> Building Debug configuration ... Done') + + print(f'>> Building Release configuration ...') + self.cmd(f'cmake -G Ninja {self.source_dir} -B {self.release_build_dir} {" ".join(args_release)}') + self.cmd(f'cmake --build {self.release_build_dir} --config Release --target install') + print(f'>> Building Release configuration ... Done') + + def archive_generic_package(self, files = None): + os.makedirs(self.archive_dir, exist_ok=True) + os.makedirs(self.output_dir, exist_ok=True) + + if files != None: + for file in files: + sourcefile = '' + targetfile = '' + + if len(file) == 2: + sourcefile = file[0] + targetfile = os.path.join(self.archive_dir, file[1]) + else: + sourcefile = os.path.join(file[0], file[1]) + targetfile = os.path.join(self.archive_dir, file[2]) + + if os.path.isdir(sourcefile): + shutil.copytree(sourcefile, targetfile, dirs_exist_ok=True) + else: + os.makedirs(os.path.dirname(targetfile), exist_ok=True) + shutil.copy(sourcefile, targetfile) else: - shutil.copy(sourcefile, targetfile) + shutil.copytree(self.install_dir, self.archive_dir, dirs_exist_ok=True) + + archive = os.path.join(self.output_dir, self.archive_filename) + if os.path.exists(archive): + os.remove(archive) - cmd(f'cd {working_dir}/archive && tar -zcvf /package/out/{os.environ["FULL_PACKAGE_NAME"]}.tar.gz *') \ No newline at end of file + with tarfile.open(archive, 'x:gz') as tar: + for file in os.listdir(os.path.abspath(self.archive_dir)): + filepath = os.path.join(self.archive_dir, file) + tar.add(filepath, arcname = os.path.basename(filepath)) diff --git a/test/Dockerfile b/test/Dockerfile deleted file mode 100644 index ee4bfdd..0000000 --- a/test/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM ubuntu:22.04 - -RUN apt-get update && apt-get upgrade -y -RUN dpkg --add-architecture i386 && apt-get update && apt-get install -y wget unzip - -# RUN wget https://github.com/PowerShell/PowerShell/releases/download/v7.3.5/PowerShell-7.3.5-win-x86.zip -# RUN wineboot -# RUN unzip PowerShell-7.3.5-win-x86.zip -d /powershell -# RUN wine cmd /c "powershell\pwsh.exe --version" && exit 1 -# RUN wine "Z:/powershell/pwsh.exe" --version - -RUN mkdir -pm755 /etc/apt/keyrings -RUN wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key -RUN wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources -RUN apt-get update && apt-get install -y --install-recommends winehq-staging - -RUN wget https://github.com/PietJankbal/powershell-wrapper-for-wine/raw/master/install_pwshwrapper.exe -RUN wine install_pwshwrapper.exe -RUN wine powershell -noni -c 'echo "done"' -RUN wine powershell -noni -c 'echo "done"' && exit 1 \ No newline at end of file diff --git a/test/app/build.bat b/test/app/build.bat deleted file mode 100644 index 520737e..0000000 --- a/test/app/build.bat +++ /dev/null @@ -1,74 +0,0 @@ -@echo off - -rem -rem Copyright (c) 2017 Marat Abrarov (abrarov@gmail.com) -rem -rem Distributed under the MIT License (see accompanying LICENSE) -rem - -set exit_code=0 - -set "PATH=%STRAWBERRY_PERL_HOME%\perl\bin;%PATH%" - -call "%MSVC_BUILD_DIR%\%MSVC_CMD_BOOTSTRAP%" -set exit_code=%errorlevel% -if %exit_code% neq 0 goto exit - -if not "--%OPENSSL_PATCH_FILE%" == "--" ( - "%MSYS_HOME%\usr\bin\patch.exe" -uNf -p0 -i "%OPENSSL_PATCH_FILE%" - set exit_code=%errorlevel% - if %exit_code% neq 0 goto exit -) - -perl Configure --prefix="%OPENSSL_STAGE_DIR%" "%OPENSSL_TOOLSET%" enable-static-engine no-asm -set exit_code=%errorlevel% -if %exit_code% neq 0 goto exit - -perl util\mkfiles.pl > MINFO -set exit_code=%errorlevel% -if %exit_code% neq 0 goto exit - -if /i "%OPENSSL_ADDRESS_MODEL%" == "32" ( - perl util\mk1mf.pl %OPENSSL_DLL_STR% %OPENSSL_BUILD_STR_PLAIN% %OPENSSL_BUILD_STR% %OPENSSL_LINK_STR% no-asm "%OPENSSL_BASE_TOOLSET%" > "ms\nt%OPENSSL_DLL_STR%-%OPENSSL_ARCH%.mak" - set exit_code=%errorlevel% - if %exit_code% neq 0 goto exit -) else ( - perl ms\uplink-x86_64.pl masm > ms\uptable.asm - set exit_code=%errorlevel% - if %exit_code% neq 0 goto exit - - ml64 -c -Foms\uptable.obj ms\uptable.asm - set exit_code=%errorlevel% - if %exit_code% neq 0 goto exit - - perl util\mk1mf.pl %OPENSSL_DLL_STR% %OPENSSL_BUILD_STR_PLAIN% %OPENSSL_BUILD_STR% %OPENSSL_LINK_STR% "%OPENSSL_BASE_TOOLSET%" > "ms\nt%OPENSSL_DLL_STR%-%OPENSSL_ARCH%.mak" - set exit_code=%errorlevel% - if %exit_code% neq 0 goto exit -) - -perl util\mkdef.pl %OPENSSL_BUILD_STR% %OPENSSL_LINK_STR% 32 libeay > "ms\libeay32%OPENSSL_RUNTIME_FULL_SUFFIX%.def" -set exit_code=%errorlevel% -if %exit_code% neq 0 goto exit - -perl util\mkdef.pl %OPENSSL_BUILD_STR% %OPENSSL_LINK_STR% 32 ssleay > "ms\ssleay32%OPENSSL_RUNTIME_FULL_SUFFIX%.def" -set exit_code=%errorlevel% -if %exit_code% neq 0 goto exit - -set "make_file=%OPENSSL_HOME%\ms\nt%OPENSSL_DLL_STR%-%OPENSSL_ARCH%.mak" - -nmake -f "%make_file%" -set exit_code=%errorlevel% -if %exit_code% neq 0 goto exit - -if not "--%OPENSSL_TEST%" == "--" ( - nmake -f "%make_file%" test - set exit_code=%errorlevel% - if %exit_code% neq 0 goto exit -) - -nmake -f "%make_file%" install -set exit_code=%errorlevel% -if %exit_code% neq 0 goto exit - -:exit -exit /B %exit_code% \ No newline at end of file diff --git a/test/app/start.ps1 b/test/app/start.ps1 deleted file mode 100644 index a1f0426..0000000 --- a/test/app/start.ps1 +++ /dev/null @@ -1,206 +0,0 @@ -# -# Copyright (c) 2017 Marat Abrarov (abrarov@gmail.com) -# -# Distributed under the MIT License (see accompanying LICENSE) -# - -# Stop immediately if any error happens -$ErrorActionPreference = "Stop" - -# Enable all versions of TLS -[System.Net.ServicePointManager]::SecurityProtocol = @("Tls12","Tls11","Tls","Ssl3") - -# Find location of Visual Studio -$env:MSVS_INSTALL_DIR = &vswhere --% -latest -products Microsoft.VisualStudio.Product.Community -version [15.0,16.0) -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath -$env:MSVC_AUXILARY_DIR = "${env:MSVS_INSTALL_DIR}\VC\Auxiliary" -$env:MSVC_BUILD_DIR = "${env:MSVC_AUXILARY_DIR}\Build" - -# Extension of static library files -$lib_file_extensions = @("a", "lib", "so", "dll") - -# List of sub-directories with libraries in OpenSSL install directory -$openssl_lib_dirs = @("lib") - -$openssl_download_url = "${env:OPENSSL_URL}/openssl-${env:OPENSSL_VERSION}.tar.gz" - -$openssl_archive_file = "${env:DOWNLOAD_DIR}\openssl-${env:OPENSSL_VERSION}.tar.gz" -$openssl_tar_archive_dir = "${env:TMP}" -$openssl_tar_archive_file_name = "openssl-${env:OPENSSL_VERSION}.tar" -$openssl_tar_archive_file = "${openssl_tar_archive_dir}\${openssl_tar_archive_file_name}" - -# Prepare patch for OpenSSL -if (-not (Test-Path env:OPENSSL_PATCH_FILE)) { - $env:OPENSSL_PATCH_FILE = "${PSScriptRoot}\patches\openssl-${env:OPENSSL_VERSION}.patch" -} -if (-not (Test-Path -Path "${env:OPENSSL_PATCH_FILE}")) { - Write-Warning "Patch for chosen version of OpenSSL (${env:OPENSSL_VERSION}) was not found at ${env:OPENSSL_PATCH_FILE}" - $env:OPENSSL_PATCH_FILE = "" -} - -# Build OpenSSL -$address_models = @("64", "32") -$openssl_linkages = @("shared", "static") -$openssl_build_types = @("release", "debug") - -# Limit build configurations if user asked for that -if (Test-Path env:OPENSSL_ADDRESS_MODEL) { - $address_models = @("${env:OPENSSL_ADDRESS_MODEL}") -} -if (Test-Path env:OPENSSL_LINKAGE) { - $openssl_linkages = @("${env:OPENSSL_LINKAGE}") -} - -$openssl_downloaded = $false - -foreach ($address_model in ${address_models}) { - $env:OPENSSL_ADDRESS_MODEL = ${address_model} - - # Determine parameters dependent on address model - switch (${env:OPENSSL_ADDRESS_MODEL}) { - "32" { - $env:MSVC_CMD_BOOTSTRAP = "vcvars32.bat" - $env:OPENSSL_BASE_TOOLSET = "VC-WIN32" - $env:OPENSSL_ARCH = "x86" - $address_model_target_dir_suffix = "x86" - } - "64" { - $env:MSVC_CMD_BOOTSTRAP = "vcvars64.bat" - $env:OPENSSL_BASE_TOOLSET = "VC-WIN64A" - $env:OPENSSL_ARCH = "x64" - $address_model_target_dir_suffix = "x64" - } - default { - throw "Unsupported address model: ${env:OPENSSL_ADDRESS_MODEL}" - } - } - - foreach ($openssl_linkage in ${openssl_linkages}) { - $env:OPENSSL_LINKAGE = ${openssl_linkage} - - # Determine parameters dependent on linkage - switch (${env:OPENSSL_LINKAGE}) { - "shared" { - $env:OPENSSL_DLL_STR = "dll" - $env:OPENSSL_LINK_STR = "" - $openssl_runtime_suffix = "MD" - } - "static" { - $env:OPENSSL_DLL_STR = "" - $env:OPENSSL_LINK_STR = "static_lib" - $openssl_runtime_suffix = "MT" - } - default { - throw "Unsupported linkage: ${env:OPENSSL_LINKAGE}" - } - } - - foreach ($openssl_build_type in ${openssl_build_types}) { - $env:OPENSSL_BUILD_TYPE = ${openssl_build_type} - - if (${env:OPENSSL_BUILD_TYPE} -eq "debug") { - $env:OPENSSL_TOOLSET = "debug-${env:OPENSSL_BASE_TOOLSET}" - $env:OPENSSL_BUILD_STR_PLAIN = "debug" - $env:OPENSSL_BUILD_STR = "debug_lib" - $openssl_libsuffix = "d" - } else { - $env:OPENSSL_TOOLSET = "${env:OPENSSL_BASE_TOOLSET}" - $env:OPENSSL_BUILD_STR_PLAIN = "" - $env:OPENSSL_BUILD_STR = "" - $openssl_libsuffix = "" - } - - $env:OPENSSL_RUNTIME_FULL_SUFFIX = "${openssl_runtime_suffix}${openssl_libsuffix}" - - $env:OPENSSL_BUILD_DIR = "${env:BUILD_DIR}\openssl-${env:OPENSSL_VERSION}\${address_model}\${env:OPENSSL_LINKAGE}\${env:OPENSSL_BUILD_TYPE}" - $env:OPENSSL_HOME = "${env:OPENSSL_BUILD_DIR}\openssl-${env:OPENSSL_VERSION}" - Write-Host "Assuming root folder for sources is: ${env:OPENSSL_HOME}" - - if (Test-Path -Path "${env:OPENSSL_HOME}") { - Write-Host "Found existing folder ${env:OPENSSL_HOME}, assuming that sources are in place and skipping downloading and unpacking of sources" - } else { - if (-not ${openssl_downloaded}) { - if (Test-Path -Path "${openssl_archive_file}") { - Write-Host "Found existing file ${openssl_archive_file}, assuming that sources are downloaded and skipping downloading of sources" - } else { - # Download OpenSSL - Write-Host "Downloading OpenSSL (source code archive) from: ${openssl_download_url} into: ${openssl_archive_file}" - (New-Object System.Net.WebClient).DownloadFile("${openssl_download_url}", "${openssl_archive_file}") - } - $openssl_downloaded = $true - } - - if (-not (Test-Path -Path "${env:OPENSSL_BUILD_DIR}")) { - New-Item -Path "${env:OPENSSL_BUILD_DIR}" -ItemType "directory" | out-null - } - - # Unpack OpenSSL - Write-Host "Extracting source code archive from ${openssl_archive_file} to ${env:OPENSSL_BUILD_DIR}" - Set-Location -Path "${env:OPENSSL_BUILD_DIR}" - $openssl_archive_msys_file = "${openssl_archive_file}" -replace "\\", "/" - $openssl_archive_msys_file = "${openssl_archive_msys_file}" -replace "^(C):", "/c" - # Path is required to be changed for Gnu tar shipped with MSYS2 - $path_backup = "${env:PATH}" - $env:PATH = "${env:MSYS_HOME}\usr\bin;${env:PATH}" - & tar.exe xzf "${openssl_archive_msys_file}" - $tar_exit_code = ${LastExitCode} - $env:PATH = "${path_backup}" - if (${tar_exit_code} -ne 0) { - throw "Failed to extract OpenSSL from ${openssl_archive_file} to ${env:OPENSSL_BUILD_DIR}" - } - Write-Host "Extracted source code archive" - } - - $env:OPENSSL_INSTALL_DIR = "${env:TARGET_DIR}\openssl-${env:OPENSSL_VERSION}-${address_model_target_dir_suffix}-vs2017-${env:OPENSSL_LINKAGE}" - $env:OPENSSL_STAGE_DIR = "${env:OPENSSL_HOME}\dist" - - Set-Location -Path "${env:OPENSSL_HOME}" - - Write-Host "Building OpenSSL with these parameters:" - Write-Host "MSVS_INSTALL_DIR : ${env:MSVS_INSTALL_DIR}" - Write-Host "MSVC_BUILD_DIR : ${env:MSVC_BUILD_DIR}" - Write-Host "MSVC_CMD_BOOTSTRAP : ${env:MSVC_CMD_BOOTSTRAP}" - Write-Host "STRAWBERRY_PERL_HOME : ${env:STRAWBERRY_PERL_HOME}" - Write-Host "MSYS_HOME : ${env:MSYS_HOME}" - Write-Host "OPENSSL_HOME : ${env:OPENSSL_HOME}" - Write-Host "OPENSSL_INSTALL_DIR : ${env:OPENSSL_INSTALL_DIR}" - Write-Host "OPENSSL_STAGE_DIR : ${env:OPENSSL_STAGE_DIR}" - Write-Host "OPENSSL_ADDRESS_MODEL : ${env:OPENSSL_ADDRESS_MODEL}" - Write-Host "OPENSSL_LINKAGE : ${env:OPENSSL_LINKAGE}" - Write-Host "OPENSSL_BUILD_TYPE : ${env:OPENSSL_BUILD_TYPE}" - Write-Host "OPENSSL_BASE_TOOLSET : ${env:OPENSSL_BASE_TOOLSET}" - Write-Host "OPENSSL_TOOLSET : ${env:OPENSSL_TOOLSET}" - Write-Host "OPENSSL_BUILD_STR_PLAIN : ${env:OPENSSL_BUILD_STR_PLAIN}" - Write-Host "OPENSSL_BUILD_STR : ${env:OPENSSL_BUILD_STR}" - Write-Host "OPENSSL_LINK_STR : ${env:OPENSSL_LINK_STR}" - Write-Host "OPENSSL_DLL_STR : ${env:OPENSSL_DLL_STR}" - Write-Host "OPENSSL_ARCH : ${env:OPENSSL_ARCH}" - Write-Host "OPENSSL_RUNTIME_FULL_SUFFIX: ${env:OPENSSL_RUNTIME_FULL_SUFFIX}" - Write-Host "OPENSSL_PATCH_FILE : ${env:OPENSSL_PATCH_FILE}" - - & "${PSScriptRoot}\build.bat" - if (${LastExitCode} -ne 0) { - throw "Failed to build OpenSSL with OPENSSL_ADDRESS_MODEL = ${env:OPENSSL_ADDRESS_MODEL}, OPENSSL_LINKAGE = ${env:OPENSSL_LINKAGE}, OPENSSL_BUILD_TYPE = ${env:OPENSSL_BUILD_TYPE}" - } - - if (-not (Test-Path -Path "${env:OPENSSL_INSTALL_DIR}")) { - Write-Host "Copying built OpenSSL from ${env:OPENSSL_STAGE_DIR} to ${env:OPENSSL_INSTALL_DIR}" - Copy-Item -Force -Recurse -Path "${env:OPENSSL_STAGE_DIR}" -Destination "${env:OPENSSL_INSTALL_DIR}" - } else { - Write-Host "Found existing ${env:OPENSSL_INSTALL_DIR}, copying just built libraries" - foreach ($openssl_lib_dir in ${openssl_lib_dirs}) { - foreach ($lib_file_extension in ${lib_file_extensions}) { - Write-Host "Copying built OpenSSL libraries (${lib_file_extension}) from ${env:OPENSSL_STAGE_DIR}\${openssl_lib_dir} to ${env:OPENSSL_INSTALL_DIR}\${openssl_lib_dir}" - $lib_files = Get-ChildItem "${env:OPENSSL_STAGE_DIR}\${openssl_lib_dir}\*.${lib_file_extension}" - foreach ($lib_file in ${lib_files}) { - $lib_file_name = ${lib_file} | % {$_.Name} - Copy-Item -Force -Path "${lib_file}" ` - -Destination "${env:OPENSSL_INSTALL_DIR}\${openssl_lib_dir}\${lib_file_name}" - } - } - } - } - } - } -} - -Write-Host "Build completed successfully" \ No newline at end of file diff --git a/test/docker-compose.yaml b/test/docker-compose.yaml deleted file mode 100644 index 2a3d24d..0000000 --- a/test/docker-compose.yaml +++ /dev/null @@ -1,23 +0,0 @@ -version: '3.4' - -x-package: &default - volumes: - - .:/package - - ../..:/repo - -x-build: &build - context: . - -services: - openssl-windows-amd64-msvc: - <<: *default - build: - <<: *build - dockerfile: Dockerfile - args: - - PACKAGE_NAME=openssl - - FULL_PACKAGE_NAME=openssl-windows-amd64-msvc - - CC_COMPILER_PACKAGE=msvc - - CC_COMPILER=msvc - - CXX_COMPILER_PACKAGE=msvc - - CXX_COMPILER=msvc \ No newline at end of file