diff --git a/.github/workflows/ecode-nightly.yml b/.github/workflows/ecode-nightly.yml index 7a2f67e1e..a0154779d 100644 --- a/.github/workflows/ecode-nightly.yml +++ b/.github/workflows/ecode-nightly.yml @@ -12,7 +12,7 @@ permissions: write-all jobs: release: name: Create Nightly Release - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} version: ${{ steps.tag.outputs.version }} @@ -42,18 +42,14 @@ jobs: body: > Builds that include most recent changes as they happen. For stable releases check the whole list of [releases](https://github.com/SpartanJ/ecode/releases). - build_linux: + build_linux_x86_64: name: Linux Nightly needs: release strategy: matrix: config: - - compiler: default - arch: x86_64 - container: ubuntu-22.04 - - compiler: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - arch: aarch64 - container: ubuntu-22.04 + - arch: x86_64 + container: ubuntu-20.04 runs-on: ${{ matrix.config.container }} env: CC: gcc @@ -67,54 +63,75 @@ jobs: echo "$HOME/.local/bin" >> "$GITHUB_PATH" echo "/usr/lib/ccache" >> "$GITHUB_PATH" echo "INSTALL_REF=${{ needs.release.outputs.version }}" >> "$GITHUB_ENV" - if [[ $(uname -m) != ${{ matrix.config.arch }} ]]; then - echo "CC=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" - echo "CXX=aarch64-linux-gnu-g++" >> "$GITHUB_ENV" - echo "RARCH=arm64" >> "$GITHUB_ENV" - else - echo "RARCH=$(uname -m)" >> "$GITHUB_ENV" - fi + echo "RARCH=$(uname -m)" >> "$GITHUB_ENV" + echo $(ldd --version) + echo $(gcc --version) - name: Update Packages run: | - if [[ $(uname -m) = ${{ matrix.config.arch }} ]]; then - sudo add-apt-repository -y universe - sudo add-apt-repository -y multiverse - sudo apt-get update - else - url="http://ports.ubuntu.com/ubuntu-ports" - repos="main restricted universe multiverse" - echo "deb [arch=arm64] $url jammy $repos" > arm64.list - echo "deb [arch=arm64] $url jammy-updates $repos" >> arm64.list - echo "deb [arch=arm64] $url jammy-security $repos" >> arm64.list - echo "deb [arch=arm64] $url jammy-backports $repos" >> arm64.list - sudo mv arm64.list /etc/apt/sources.list.d/ - sudo apt-get update - sudo dpkg --add-architecture arm64 - fi + sudo add-apt-repository -y universe + sudo add-apt-repository -y multiverse + sudo apt-get update - name: Install dependencies run: | - sudo apt-get install -y premake4 libfuse2 fuse - if [[ $(uname -m) = "x86_64" ]]; then - wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-linux.tar.gz - tar xvzf premake-5.0.0-beta2-linux.tar.gz - fi - if [[ $(uname -m) = ${{ matrix.config.arch }} ]]; then - sudo apt install -y gcc-12 g++-12 libsdl2-2.0-0 libsdl2-dev - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 10 - sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 - sudo update-alternatives --set cc /usr/bin/gcc - sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 - sudo update-alternatives --set c++ /usr/bin/g++ - sudo update-alternatives --config gcc - sudo update-alternatives --config g++ - bash projects/linux/scripts/install_sdl2.sh - else - sudo apt-get install -y libsdl2-dev:arm64 libsdl2-2.0-0:arm64 - fi - - name: Install Cross Compiler - if: ${{ matrix.config.compiler != 'default' }} - run: sudo apt-get install -y ${{ matrix.config.compiler }} + sudo apt-get install -y libfuse2 fuse premake4 mesa-common-dev libgl1-mesa-dev + bash projects/linux/scripts/install_sdl2.sh + - name: Build ecode + run: | + bash projects/linux/ecode/build.app.sh --version ${{ env.INSTALL_REF }} --arch ${{ matrix.config.arch }} + - name: Upload Files + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.release.outputs.version }} + draft: false + prerelease: true + files: | + projects/linux/ecode/ecode-linux-${{ env.INSTALL_REF }}-${{ env.RARCH }}.AppImage + projects/linux/ecode/ecode-linux-${{ env.INSTALL_REF }}-${{ env.RARCH }}.tar.gz + + build_linux_arm64: + name: Linux Nightly + needs: release + strategy: + matrix: + config: + - arch: aarch64 + container: ubuntu-20.04 + runs-on: ${{ matrix.config.container }} + env: + CC: gcc + CXX: g++ + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: { fetch-depth: 0, submodules: 'recursive' } + - name: Set Environment Variables + run: | + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + echo "/usr/lib/ccache" >> "$GITHUB_PATH" + echo "INSTALL_REF=${{ needs.release.outputs.version }}" >> "$GITHUB_ENV" + echo "CC=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" + echo "CXX=aarch64-linux-gnu-g++" >> "$GITHUB_ENV" + echo "AR=aarch64-linux-gnu-ar" >> "$GITHUB_ENV" + echo "RANLIB=aarch64-linux-gnu-ranlib" >> "$GITHUB_ENV" + echo "STRIP=aarch64-linux-gnu-strip" >> "$GITHUB_ENV" + echo "RARCH=arm64" >> "$GITHUB_ENV" >> "$GITHUB_ENV" + echo $(ldd --version) + echo $(gcc --version) + - name: Update Packages + run: | + url="http://ports.ubuntu.com/ubuntu-ports" + repos="main restricted universe multiverse" + echo "deb [arch=arm64] $url focal $repos" > arm64.list + echo "deb [arch=arm64] $url focal-updates $repos" >> arm64.list + echo "deb [arch=arm64] $url focal-security $repos" >> arm64.list + echo "deb [arch=arm64] $url focal-backports $repos" >> arm64.list + sudo mv arm64.list /etc/apt/sources.list.d/ + sudo apt-get update + sudo dpkg --add-architecture arm64 + - name: Install dependencies + run: | + sudo apt-get install -y premake4 libfuse2 fuse gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libsdl2-dev:arm64 libsdl2-2.0-0:arm64 + bash projects/linux/scripts/install_sdl2.sh --aarch64 - name: Build ecode run: | bash projects/linux/ecode/build.app.sh --version ${{ env.INSTALL_REF }} --arch ${{ matrix.config.arch }} diff --git a/projects/linux/ecode/build.app.sh b/projects/linux/ecode/build.app.sh index f7b4e86ff..41a6194bb 100755 --- a/projects/linux/ecode/build.app.sh +++ b/projects/linux/ecode/build.app.sh @@ -22,7 +22,7 @@ for i in "$@"; do shift shift ;; - -*|--*) + -*) echo "Unknown option $i" exit 1 ;; @@ -35,19 +35,22 @@ if [ "$ARCH" = "aarch64" ]; then ARCH="arm64" fi +CONFIG_NAME= if command -v premake4 &> /dev/null then premake4 $DEBUG_SYMBOLS gmake || exit + CONFIG_NAME=release elif command -v premake5 &> /dev/null then premake5 $DEBUG_SYMBOLS gmake2 || exit + CONFIG_NAME=release_"$ARCH" else echo "Neither premake5 nor premake4 is available. Please install one." exit 1 fi cd make/linux || exit -make -j"$(nproc)" config=release ecode || exit +make -j"$(nproc)" config="$CONFIG_NAME" ecode || exit cd "$DIRPATH" || exit rm -rf ./ecode.app mkdir -p ecode.app/assets @@ -58,8 +61,8 @@ cp ecode.desktop ecode.app/ cp ../../../bin/assets/icon/ecode.png ecode.app/ecode.png cp ../../../libs/linux/libeepp.so ecode.app/libs/ cp ../../../bin/ecode ecode.app/ecode.bin -cp -L "$(whereis libSDL2-2.0.so.0 | awk '{print $NF}')" ecode.app/libs/ -strip ecode.app/libs/libSDL2-2.0.so.0 +cp -L "$(whereis libSDL2-2.0.so.0 | awk '{print $NF}')" ecode.app/libs/ || exit +${STRIP:-strip} ecode.app/libs/libSDL2-2.0.so.0 mkdir -p ecode.app/assets/colorschemes mkdir -p ecode.app/assets/fonts mkdir -p ecode.app/assets/i18n diff --git a/projects/linux/scripts/install_sdl2.sh b/projects/linux/scripts/install_sdl2.sh index 043ae780e..5e4d6f3a3 100644 --- a/projects/linux/scripts/install_sdl2.sh +++ b/projects/linux/scripts/install_sdl2.sh @@ -3,15 +3,46 @@ # Define SDL version and download URL SDL_VERSION="2.30.8" SDL_URL="https://libsdl.org/release/SDL2-${SDL_VERSION}.zip" +ARCH="x86_64" # Default architecture for host -# Install necessary dependencies -sudo apt-get update -sudo apt-get install -y build-essential unzip wget libasound2-dev libpulse-dev libudev-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxss-dev libxkbcommon-dev +# Function to install dependencies +install_dependencies() { + sudo apt-get update + sudo apt-get install -y build-essential unzip wget libasound2-dev libpulse-dev \ + libudev-dev libx11-dev libxext-dev libxrandr-dev \ + libxcursor-dev libxi-dev libxinerama-dev libxss-dev \ + libxkbcommon-dev libwayland-dev wayland-protocols \ + libegl1-mesa-dev libgbm-dev || exit +} + +# Function to install cross-compile dependencies for aarch64 +install_cross_dependencies() { + sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu || exit +} + +# Function to configure for cross-compilation +configure_for_aarch64() { + export CC=aarch64-linux-gnu-gcc + export CXX=aarch64-linux-gnu-g++ + export AR=aarch64-linux-gnu-ar + export RANLIB=aarch64-linux-gnu-ranlib + export STRIP=aarch64-linux-gnu-strip + ./configure --host=aarch64-linux-gnu --enable-video-x11 --enable-video-wayland --enable-wayland-shared || exit +} + +# Parse options +if [ "$1" == "--aarch64" ]; then + ARCH="aarch64" + install_cross_dependencies +fi # Create a temporary directory for the SDL2 build mkdir -p ./sdl2_build cd ./sdl2_build || exit +# Install dependencies +install_dependencies + # Download SDL2 source code echo "Downloading SDL2 version ${SDL_VERSION}..." wget "${SDL_URL}" -O SDL2.zip || exit @@ -23,12 +54,18 @@ unzip SDL2.zip || exit # Enter the SDL2 directory cd "SDL2-${SDL_VERSION}" || exit -# Configure, build, and install SDL2 -echo "Configuring SDL2..." -./configure || exit +# Configure the build (with optional cross-compilation) +if [ "$ARCH" == "aarch64" ]; then + echo "Configuring SDL2 for aarch64 cross-compilation..." + configure_for_aarch64 +else + echo "Configuring SDL2 for host system..." + ./configure --enable-video-x11 --enable-video-wayland --enable-wayland-shared || exit +fi -echo "Building SDL2..." -make -j"$(nproc)" || exit +# Build and install SDL2 +echo "Building SDL2 for ${ARCH}..." +make -j"$(nproc)" echo "Installing SDL2..." sudo make install || exit @@ -40,4 +77,4 @@ rm -rf ./sdl2_build # Update shared library cache sudo ldconfig -echo "SDL2 version ${SDL_VERSION} installed successfully!" +echo "SDL2 version ${SDL_VERSION} installed successfully for ${ARCH}!"