From 04f8a042595ccb0c8a1f0a895c33fee2d23aebc1 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Mon, 25 May 2020 12:54:51 -0700 Subject: [PATCH] ci: Add Ubuntu build tarball --- .github/workflows/build.yml | 41 +++++++++++++++++++++++++++++++++++-- build.sh | 21 ++++++++++++------- ui/xemu-data.c | 10 +++++++++ 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 734af51609..457b36080c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,6 +38,9 @@ jobs: print('::set-env name=ARTIFACT_NAME::xemu-win-release.zip') - name: Clone Tree uses: actions/checkout@v2 + - name: Clone Tree (Unshallow) + run: | + git fetch --prune --unshallow --tags - name: Install Dependencies run: | echo "Downloading MSYS2 environment..." @@ -86,13 +89,16 @@ jobs: if "${{ matrix.configuration }}" == "Debug": print('Configuring for Debug') print('::set-env name=BUILD_PARAM::--debug') - print('::set-env name=ARTIFACT_NAME::xemu-ubuntu-debug') + print('::set-env name=ARTIFACT_NAME::xemu-ubuntu-debug.tgz') else: print('Configuring for Release') print('::set-env name=BUILD_PARAM::') - print('::set-env name=ARTIFACT_NAME::xemu-ubuntu-release') + print('::set-env name=ARTIFACT_NAME::xemu-ubuntu-release.tgz') - name: Clone Tree uses: actions/checkout@v2 + - name: Clone Tree (Unshallow) + run: | + git fetch --prune --unshallow --tags - name: Install Dependencies run: | sudo apt-get update @@ -117,6 +123,12 @@ jobs: ./build.sh ${{ env.BUILD_PARAM }} echo -e "\nCompiler Cache Stats:" ccache -s -c + tar -czvf ${{env.ARTIFACT_NAME}} --transform "s#^dist#xemu#" dist + - name: Upload Build Artifact + uses: actions/upload-artifact@v1 + with: + name: dist + path: ${{env.ARTIFACT_NAME}} macOS: runs-on: macOS-latest @@ -138,6 +150,9 @@ jobs: print('::set-env name=ARTIFACT_NAME::xemu-macos-release.zip') - name: Clone Tree uses: actions/checkout@v2 + - name: Clone Tree (Unshallow) + run: | + git fetch --prune --unshallow --tags - name: Install Dependencies run: | brew update @@ -242,3 +257,25 @@ jobs: asset_name: xemu-macos-debug.zip asset_path: dist/xemu-macos-debug.zip asset_content_type: application/zip + - name: Upload Release Assets (Ubuntu Release Build) + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + id: upload-release-asset-ubuntu-release + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: xemu-ubuntu-release.tgz + asset_path: dist/xemu-ubuntu-release.tgz + asset_content_type: application/gzip + - name: Upload Release Assets (Ubuntu Debug Build) + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + id: upload-release-asset-ubuntu-debug + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: xemu-ubuntu-debug.tgz + asset_path: dist/xemu-ubuntu-debug.tgz + asset_content_type: application/gzip diff --git a/build.sh b/build.sh index 3117783d0a..21318ea4e2 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,8 @@ set -e # exit if a command fails set -o pipefail # Will return the exit status of make if it fails -package_windows() { # Script to prepare the windows exe +package_windows() { + rm -rf dist mkdir -p dist cp i386-softmmu/qemu-system-i386.exe dist/xemu.exe cp i386-softmmu/qemu-system-i386w.exe dist/xemuw.exe @@ -77,13 +78,19 @@ package_macos() { EOF } +package_linux() { + rm -rf dist + mkdir -p dist + cp i386-softmmu/qemu-system-i386 dist/xemu + cp -r data dist +} + postbuild='' debug_opts='' -user_opts='' build_cflags='-O3' job_count='12' -while [ ! -z ${1} ] +while [ ! -z "${1}" ] do case "${1}" in '-j'*) @@ -96,8 +103,7 @@ do shift ;; *) - user_opts="${user_opts} ${1}" - shift + break ;; esac done @@ -107,8 +113,9 @@ readlink=$(command -v readlink) case "$(uname -s)" in # Adjust compilation options based on platform Linux) echo 'Compiling for Linux...' - sys_cflags='-march=native -Wno-error=redundant-decls -Wno-error=unused-but-set-variable' + sys_cflags='-Wno-error=redundant-decls -Wno-error=unused-but-set-variable' sys_opts='--enable-kvm --disable-xen --disable-werror' + postbuild='package_linux' ;; Darwin) echo 'Compiling for MacOS...' @@ -206,7 +213,7 @@ set -x # Print commands from now on --without-default-devices \ --disable-blobs \ --disable-slirp \ - ${user_opts} + "$@" time make -j"${job_count}" 2>&1 | tee build.log diff --git a/ui/xemu-data.c b/ui/xemu-data.c index 955dae4fad..3fdc437bce 100644 --- a/ui/xemu-data.c +++ b/ui/xemu-data.c @@ -66,6 +66,16 @@ const char *xemu_get_resource_path(const char *filename) return resource_path; } +#if defined(__linux__) + // /usr/share/xemu/data when installed + snprintf(resource_path, resource_path_buffer_len, "/usr/share/xemu/data/%s", + filename); + + if (path_exists(resource_path)) { + return resource_path; + } +#endif + // Path not found or file not readable assert(0); return NULL;