Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Support, Clean-Up, Simplify Build Process #98

Open
wants to merge 21 commits into
base: new
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 26 additions & 148 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,161 +1,39 @@
name: Build AltServer

on:
push:
workflow_dispatch:
inputs:
sync_upstream:
required: false
default: false
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
repository_dispatch:

schedule:
- cron: "0 */4 * * *" # min hour day week year


env:
REGISTRY: ghcr.io
push:
branches: ["**"]
paths-ignore:
- "**/*.md"

name: Build Binary
jobs:
check:
runs-on: ubuntu-latest
name: "Check Upstream Updates"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive

- name: Check If Need Checking
id: needCheck
if: ${{ github.event_name == 'schedule' || ( github.event_name == 'workflow_dispatch' && github.event.inputs.sync_upstream ) }}
run: |
echo "needCheck=1" >> $GITHUB_ENV

- name: Check Upstream Version
id: check
run: |
if [[ "$needCheck" == 1 ]]; then
echo "Checking changes in upstream_repo..."

current_upstream=$(git ls-tree HEAD upstream_repo | awk '{ print $3 }')
echo "Current Upstream Commit: $current_upstream"

git submodule update --remote -- upstream_repo
new_upstream=$( cd upstream_repo; git show -s --format=%H )
echo "New Upstream Commit: $new_upstream"

git reset --hard
git submodule update --init
if [[ "$current_upstream" != "$new_upstream" ]]; then
echo "Upstream got new commits, go updating!"
echo "::set-output name=updated::1"
else
echo "Upstream no change~"
echo "::set-output name=updated::0"
fi
else
echo "Needn't to check changes, directly return~"
echo "::set-output name=updated::0"
fi

- uses: gautamkrishnar/keepalive-workflow@master
with:
commit_message: "[proj] keepalive-workflow auto commit"
outputs:
updated: ${{ steps.check.outputs.updated }}

build:
needs: [check]
runs-on: ubuntu-latest
container: greyltc/archlinux-aur:paru
strategy:
fail-fast: false
matrix:
builder: [ghcr.io/nyamisty/altserver_builder_alpine_armv7, ghcr.io/nyamisty/altserver_builder_alpine_aarch64, ghcr.io/nyamisty/altserver_builder_alpine_amd64, ghcr.io/nyamisty/altserver_builder_alpine_i386]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
- name: Do Submodule Update
if: ${{ needs.check.outputs.updated == '1' }}
run:
git submodule update --remote -- upstream_repo
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare build
run: mkdir /tmp/build_output
- name: Build
run: |
image=${{ matrix.builder }}
docker pull $image
docker run -v ${PWD}:/workdir -w /workdir $image bash -c 'mkdir build; cd build; make -f ../Makefile -j3'
cp build/AltServer-* /tmp/build_output; chmod +x /tmp/build_output/*
sudo rm -rf build
git clean -fdX
- name: Upload to github artifact
uses: NyaMisty/upload-artifact-as-is@master
with:
path: /tmp/build_output
language: ["cpp"]

release:
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs: [build]
name: "release"
steps:
- name: "Create artifact directory"
run: |
mkdir -p build_output
- name: "Download all artifacts"
uses: actions/download-artifact@v2
with:
path: build_output
- name: "Rearrange artifacts"
run: |
find build_output
mkdir -p build_release
mv build_output/*/* build_release
ls build_release
if [ "$(ls -A build_release)" ]; then exit 0; else exit 1; fi
- name: Release
uses: softprops/action-gh-release@v1
with:
files: build_release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

update_submodule:
runs-on: ubuntu-latest
needs: [check, build]
if: ${{ needs.check.outputs.updated == '1' }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Commit Submodule Update
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git submodule update --remote -- upstream_repo
git commit -m "[server] Sync Upstream Repo commit" upstream_repo
- name: Push changes
uses: ad-m/github-push-action@master

- name: Install build dependencies
run: "paru --noconfirm -Syu base-devel cmake clang ninja git make boost zlib python3 avahi && aur-install libcorecrypto-git"

- name: Compile
run: >
mkdir build && cd build
&& cmake -GNinja -DBUILD_SHARED_LIBS=OFF .. && cmake --build . --config Release -- -j 8

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

name: build
path: |
build/
!build/cmake
!build/_deps
37 changes: 0 additions & 37 deletions .github/workflows/build_docker.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/build
*.o
.vscode
.cache
.vscode
upstream_patched
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
[submodule "libraries/libimobiledevice"]
path = libraries/libimobiledevice
url = https://github.com/libimobiledevice/libimobiledevice
[submodule "libraries/ideviceinstaller"]
path = libraries/ideviceinstaller
url = https://github.com/libimobiledevice/ideviceinstaller
[submodule "libraries/libimobiledevice-glue"]
path = libraries/libimobiledevice-glue
url = https://github.com/libimobiledevice/libimobiledevice-glue
68 changes: 68 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 3.12)
project(altserver-linux VERSION 0.0.5)

set(ALTSERVER_DIR "${CMAKE_CURRENT_SOURCE_DIR}")

# -------------------------------------------------------------------------------------------------------------------------------
# Options
# -------------------------------------------------------------------------------------------------------------------------------

option(altserver_cli "Whether or not to build the cli" ON)

# -------------------------------------------------------------------------------------------------------------------------------
# Patch upstream project
# -------------------------------------------------------------------------------------------------------------------------------

include(cmake/patch.cmake)

patch_prepare()

patch(altserver PATTERN "AltServer/*.[ch]*" EXCLUDE_PATTERN "AltServer/AltServer.cpp" "AltServer/WiredConnection.cpp" "AltServer/AnisetteDataManager.cpp")
patch(altsign PATTERN "AltSign/*.[ch]*")
patch(ldid PATTERN "ldid/*.[ch]*")

# -------------------------------------------------------------------------------------------------------------------------------
# Compile options
# -------------------------------------------------------------------------------------------------------------------------------

add_definitions(-w) # Ouch, we need this because cpprestsdk might cause fat errors otherwise.

# -------------------------------------------------------------------------------------------------------------------------------
# Force Include some shims
# -------------------------------------------------------------------------------------------------------------------------------

# This is really bad
add_definitions(-include "${ALTSERVER_DIR}/src/common.h" -include "${ALTSERVER_DIR}/shims/windows_shim.h")

# -------------------------------------------------------------------------------------------------------------------------------
# Setup Dependencies
# -------------------------------------------------------------------------------------------------------------------------------

# This is also pretty bad practice imo, but exporting all of the defines into cmake would also be retarded
add_definitions(-include "${ALTSERVER_DIR}/config/libimobiledevice.h" -include "${ALTSERVER_DIR}/config/dnssd.h")

add_subdirectory(cmake/ldid)
add_subdirectory(cmake/minizip)
add_subdirectory(cmake/libplist)
add_subdirectory(cmake/CoreCrypto)
add_subdirectory(libraries/dnssd_loader)
add_subdirectory(cmake/libimobiledevice)
add_subdirectory(cmake/libimobiledevice-glue)

add_subdirectory(cmake/AltSign)
add_subdirectory(cmake/AltServer)

# -------------------------------------------------------------------------------------------------------------------------------
# Setup Executable
# -------------------------------------------------------------------------------------------------------------------------------

if (altserver_cli)
file(GLOB src "src/*.cpp")
add_executable(${PROJECT_NAME} ${src})

target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)

add_subdirectory(cmake/libusbmuxd)
target_link_libraries(${PROJECT_NAME} PUBLIC usbmuxd uuid altserver altsign ${Boost_LIBRARIES} )
endif()
Loading