flatpak / flatpak-builder

Tool to build flatpaks from source
GNU Lesser General Public License v2.1
141 stars 93 forks source link

Add support for xmake build tool #622

Closed paulross80 closed 1 month ago

paulross80 commented 1 month ago

Checklist

Suggestion

Please add support for this cool open source build tool https://xmake.io/#/

I have tried to use it as "buildsystem: simple" in my manifest file, but flatpak builder doesn't find it

TingPing commented 1 month ago

I don't believe any more build system types will be added, xmake doesn't look particularly popular.

I have tried to use it as "buildsystem: simple" in my manifest file, but flatpak builder doesn't find it

This is the correct way to do it. If you post an example maybe something obvious can be seen. You of course have to build xmake in your manifest.

paulross80 commented 1 month ago

I don't believe any more build system types will be added

Very sorry to hear that

You of course have to build xmake in your manifest

Oh I see, that's interesting. Will try that, thanks!

paulross80 commented 1 month ago

I had a problem. The build tool compiled just fine, but then flatpak-builder cannot find it

My manifest file (com.my_apps.JustCpp.yml):

id: com.my_apps.JustCpp
runtime: org.freedesktop.Platform
runtime-version: '23.08'
sdk: org.freedesktop.Sdk
command: main
modules:
  - name: xmake
    buildsystem: simple
    build-commands:
      # https://xmake.io/#/guide/installation
      - cd ./xmake
      # git submodule update --init # enable if needed!
      - ./configure
      - make
      - ./scripts/get.sh __local__ __install_only__
      # - source ~/.xmake/profile # ?
      # /bin/sh: line 1: /home/paul/.xmake/profile: No such file or directory

    sources:
      - type: git
        url: https://github.com/xmake-io/xmake.git

    # Module does not need to be shipped in the final Flatpak package
    cleanup:
      - '*'

  - name: just_cpp
    buildsystem: simple
    build-commands:
      # ${FLATPAK_DEST} ?
      - xmake f -m debug
      - xmake

    sources:
      - type: dir
        path: .

# finish-args:

Command: flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo --install fpak com.my_apps.JustCpp.yml

Error:

linking.release build/xmake
installing build/xmake to /home/paul/.local/bin
xmake v2.9.5+master.a7aab9d, A cross-platform build utility based on Lua
Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io
                         _
    __  ___ __  __  __ _| | ______
    \ \/ / |  \/  |/ _  | |/ / __ \
     >  <  | \__/ | /_| |   <  ___/
    /_/\_\_|_|  |_|\__ \|_|\_\____|
                         by ruki, xmake.io

    👉  Manual: https://xmake.io/#/getting_started
    🙏  Donate: https://xmake.io/#/sponsor

  => installing shell integration to ~/.profile .. ok
Reload shell profile by running the following command now!
source ~/.xmake/profile
Committing stage build-xmake to cache
========================================================================
Building module just_cpp in /home/paul/projects/cpp/just_cpp/.flatpak-builder/build/just_cpp-1
========================================================================
Running: xmake f -m debug
/bin/sh: line 1: xmake: command not found
Error: module just_cpp: Child process exited with code 127
TingPing commented 1 month ago
  - ./scripts/get.sh __local__ __install_only__

Does it not support make install? The main thing you need to make sure of it is that it uses PREFIX=/app not ~/.local, probably removing __local__ helps but it may default to /usr/local.

  # - source ~/.xmake/profile # ?

This does nothing useful. The shell only exists for that module.

  # git submodule update --init # enable if needed!

This also will do nothing. No network access.

  - cd ./xmake

You can replace this with subdir: xmake if needed.

paulross80 commented 1 month ago

Does it not support make install?

I saw this part from the get.sh script:

# do install
if test_z "$prefix"; then
    prefix=~/.local
fi
if test_nz "$prefix"; then
    $make -C $projectdir --no-print-directory install PREFIX="$prefix" || raise "install failed!"
else
    $sudoprefix $make -C $projectdir --no-print-directory install || raise "install failed!"
fi

Should I add this as parameter to that script? PREFIX=/app. Or this should be an env var?

TingPing commented 1 month ago

I would do this:

  - name: xmake
    make-install-args: ['PREFIX=/app']
    subdir: xmake
    cleanup: ['*']
    sources:
      - type: git
        url: https://github.com/xmake-io/xmake.git
paulross80 commented 1 month ago

I have pasted your exact code. I got a new error

========================================================================
Building module xmake in /home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-1
========================================================================
Switched to branch 'master'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-1/core/src/tbox/tbox'...
Submodule path 'core/src/tbox/tbox': checked out 'f815e56521cca02b35156bf65cdc66dd4e38712c'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-1/core/src/luajit/luajit'...
Submodule path 'core/src/luajit/luajit': checked out '7cdc078416037cd0a16a79553509a7f153fe629d'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-1/core/src/sv/sv'...
Submodule path 'core/src/sv/sv': checked out 'b3363a3cb2f499a735eaebe87a8a3491593e3289'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-1/core/src/pdcurses/pdcurses'...
Submodule path 'core/src/pdcurses/pdcurses': checked out '5c62af03e9a05e3a3ae8c8354c1234b772dcf4b0'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-1/core/src/lua-cjson/lua-cjson'...
Submodule path 'core/src/lua-cjson/lua-cjson': checked out 'ddcecf3b24b71421e7b4a2962f1fbcc0297e0c1e'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-1/core/src/lua/lua'...
Submodule path 'core/src/lua/lua': checked out 'eadd8c7178c79c814ecca9652973a9b9dd4cc71b'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-1/core/src/lz4/lz4'...
Submodule path 'core/src/lz4/lz4': checked out 'ebb370ca83af193212df4dcbadcc5d87bc0de2f0'
Error: module xmake: Can't find autogen, autogen.sh or bootstrap

How can I fix it?

TingPing commented 1 month ago

Add no-autogen: true, I was thinking it would be optional.

paulross80 commented 1 month ago

Manifest:

modules:
  - name: xmake
    # From the post (TingPing)
    make-install-args: ['PREFIX=/app']
    no-autogen: true
    subdir: xmake
    cleanup: ['*']
    sources:
      - type: git
        url: https://github.com/xmake-io/xmake.git

Output:

========================================================================
Building module xmake in /home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-2
========================================================================
Switched to branch 'master'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-2/core/src/tbox/tbox'...
Submodule path 'core/src/tbox/tbox': checked out 'f815e56521cca02b35156bf65cdc66dd4e38712c'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-2/core/src/luajit/luajit'...
Submodule path 'core/src/luajit/luajit': checked out '7cdc078416037cd0a16a79553509a7f153fe629d'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-2/core/src/sv/sv'...
Submodule path 'core/src/sv/sv': checked out 'b3363a3cb2f499a735eaebe87a8a3491593e3289'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-2/core/src/pdcurses/pdcurses'...
Submodule path 'core/src/pdcurses/pdcurses': checked out '5c62af03e9a05e3a3ae8c8354c1234b772dcf4b0'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-2/core/src/lua-cjson/lua-cjson'...
Submodule path 'core/src/lua-cjson/lua-cjson': checked out 'ddcecf3b24b71421e7b4a2962f1fbcc0297e0c1e'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-2/core/src/lua/lua'...
Submodule path 'core/src/lua/lua': checked out 'eadd8c7178c79c814ecca9652973a9b9dd4cc71b'
Cloning into '/home/paul/projects/cpp/just_cpp/.flatpak-builder/build/xmake-2/core/src/lz4/lz4'...
Submodule path 'core/src/lz4/lz4': checked out 'ebb370ca83af193212df4dcbadcc5d87bc0de2f0'
Error: module xmake: Can't find makefile

I have also tried to modify the original code, but it keeps installing to the default path instead of /app

buildsystem: simple
    build-commands:
      # https://xmake.io/#/guide/installation
      - cd ./xmake
      - ./configure --prefix=/app
      - make
      - ./scripts/get.sh __local__ __install_only__ prefix=/app
    sources:
      - type: git
        url: https://github.com/xmake-io/xmake.git
TingPing commented 1 month ago

Oh you don't need subdir: xmake, I was just going off your cd.

paulross80 commented 1 month ago

Almost there! I configure my build tool to output to /app

- name: just_cpp
    buildsystem: simple
    build-commands:
      # ${FLATPAK_DEST} ?
      - xmake f -m debug -o /app
      - xmake

But now it doesn't find a header from the C++ std library

========================================================================
Building module just_cpp in /home/paul/projects/cpp/just_cpp/.flatpak-builder/build/just_cpp-3
========================================================================
Running: xmake f -m debug -o /app
checking for platform ... linux
checking for architecture ... x86_64
Running: xmake
[ 50%]: cache compiling.debug main.cpp
error: main.cpp:1:10: fatal error: print: No such file or directory
    1 | #include <print>
      |          ^~~~~~~
compilation terminated.
  > in main.cpp
Error: module just_cpp: Child process exited with code 255

(When I compile my app outside flatpak-builder, it works, there is no error in the source code of my app)

TingPing commented 1 month ago

<print> is part of C++23, the compiler maybe too old or need to the flag for that to be enabled. Worst case clang is available also.

(It is insane for a buildsystem to depend on C++23, maybe there is an option)

paulross80 commented 1 month ago

I'm sorry if I wasn't clear enough. The build tool (xmake) seems to be compiling and working fine now. The problem is now with my app. My gcc compiler is the latest:

g++ --version
g++ (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3)

My main.cpp file

#include <print>

int main()
{
    std::println("Hello World!");
    return 0;
}

Starting of my xmake project file:

-- Project name
set_project("just_cpp")

-- Global settings
-- C++ standard
set_languages("c++23")

I'm specifically asking the build tool to enable C++23 for me. When I compile this project without flatpak-builder, everything compiles and runs just fine:

➜  just_cpp git:(main) ✗ xmake
[100%]: build ok, spent 0.174s
➜  just_cpp git:(main) ✗ xmake run 
Hello World!
TingPing commented 1 month ago

My gcc compiler is the latest:

The compiler is in the flatpak runtime. flatpak run --command=g++ org.freedesktop.Sdk//24.08 --version

TingPing commented 1 month ago

Oh switch your runtime to 24.08 not 23.08 which is a year old.

paulross80 commented 1 month ago

Flatpak runs its own compiler? I'm sorry, I didn't know that. And we've got a new error (I have previously completely erased the build folder and the hidden .flatpak-builder/)

installing build/xmake to /app/bin
Committing stage build-xmake to cache
========================================================================
Building module just_cpp in /home/paul/projects/cpp/just_cpp/.flatpak-builder/build/just_cpp-1
========================================================================
Running: xmake f -m debug -o /app
checking for platform ... linux
checking for architecture ... x86_64
Running: xmake
[ 50%]: cache compiling.debug main.cpp
error: save /app/.deps/main/linux/x86_64/debug/./main.cpp.o.d failed, cannot open file: /app/.deps/main/linux/x86_64/debug/./main.cpp.o.d, No such file or directory!
Error: module just_cpp: Child process exited with code 255
TingPing commented 1 month ago

xmake f -m debug -o /app

You probably don't want to output binaries to /app, maybe to $FLATPAK_BUILDER_BUILDDIR. Then you would install the binaries you care about. I assume xmake features that.

TingPing commented 1 month ago

I'm going to close this since the feature won't be added. I hope I've pointed you in the right direction, now its just about using xmake properly which I don't know anything about.