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

XMake - Build System #6169

Closed
kassane opened this issue Feb 6, 2020 · 34 comments
Closed

XMake - Build System #6169

kassane opened this issue Feb 6, 2020 · 34 comments

Comments

@kassane
Copy link
Contributor

kassane commented Feb 6, 2020

Would it be possible to join this build system in the package?
XMAKE_PKBUILD-ARCH

@Biswa96
Copy link
Member

Biswa96 commented Feb 8, 2020

Is there any guideline about how to build xmake in Windows?

@kassane
Copy link
Contributor Author

kassane commented Feb 8, 2020

Is there any guideline about how to build xmake in Windows?

https://github.com/xmake-io/xmake/blob/master/.appveyor.yml

@waruqi
Copy link
Contributor

waruqi commented Feb 9, 2020

new install script, install to ~/.local and add sh profile (recommended)

https://xmake.io/#/guide/installation?id=installation

make build
./scripts/get.sh __local__ __install_only__

old install script, install to /usr

https://github.com/Homebrew/linuxbrew-core/blob/041241d3008cb5a0a7f2b651628c85d6b1e37a28/Formula/xmake.rb

make build
./install installdir

I'm not sure it support using mingw/make to build xmake on windows. Maybe we need modify some makefiles and code files to support it.

Now we can only use xmake to build xmake or use nsis installation package to install it directly.

You can open a issue in xmake/issues if compile errors on msys/mingw. I will attempt to support it.

@waruqi
Copy link
Contributor

waruqi commented Feb 9, 2020

I will add core/plat/mingw in these days.

@waruqi
Copy link
Contributor

waruqi commented Feb 11, 2020

I have improved xmake to compile it on mingw/msys. It has been compiled successfully on msys/mingw for xmake/dev branch.

compile and install xmake:

make build
make install prefix=/usr

You can try it again. however, there are still some problems during operation, such as process execution. e.g.

$ xmake l os.exec "echo hello"
      1 [main] xmake 1887 dofork: child -1 - forked process 4512 died unexpectedly, retry 0, exit code 0xC0000135, errno 11
error: exec(echo hello) failed(-1)!

I attempt to run cmd /c "c:\msys64\usr\bin\dash.exe /usr/bin/rebaseall -v" command, it seems to have no effect.

@StarWolf3000
Copy link
Contributor

@waruqi Hold your horses. What is your build environment? From your last message it seems you're building under MSYS2, but in your opening comment you asked as package under MINGW. Do not mix them up.

The prefix for make install should be /mingw32|64, not /usr.

@waruqi
Copy link
Contributor

waruqi commented Feb 12, 2020

@waruqi Hold your horses. What is your build environment? From your last message it seems you're building under MSYS2, but in your opening comment you asked as package under MINGW. Do not mix them up.

The prefix for make install should be /mingw32|64, not /usr.

I have tested both the msys and mingw environments.

ruki@DESKTOP-A6MFTOV MINGW64 ~
$ uname
MINGW64_NT-10.0-14393

ruki@DESKTOP-A6MFTOV MINGW64 ~
$ which xmake
/usr/bin/xmake

ruki@DESKTOP-A6MFTOV MINGW64 ~
$ xmake l os.exec "echo hello"
      1 [main] xmake 1000 dofork: child -1 - forked process 4844 died unexpectedly, retry 0, exit code 0xC0000135, errno 11
error: exec(echo hello) failed(-1)!
ruki@DESKTOP-A6MFTOV MSYS ~
$ uname
MSYS_NT-10.0-14393

ruki@DESKTOP-A6MFTOV MSYS ~
$ which xmake
/usr/bin/xmake

ruki@DESKTOP-A6MFTOV MSYS ~
$ xmake l os.exec "echo hello"
      0 [main] xmake 1308 dofork: child -1 - forked process 1580 died unexpectedly, retry 0, exit code 0xC0000135, errno 11
error: exec(echo hello) failed(-1)!

@waruqi
Copy link
Contributor

waruqi commented Feb 16, 2020

@Biswa96

I have supported compiling xmake on msys/mingw and it worked very well. But we must use mingw-w64-[i686|x86_64]-gcc to compile xmake (dev branch).

$ pacman -S mingw-w64-x86_64-gcc
$ which gcc
/mingw64/bin/gcc
$ cd xmake
$ make build
$ make install prefix=/usr

run xmake to compile program:

ruki@DESKTOP-A6MFTOV MINGW64 /tmp
$ xmake create test
create test ...
  [+]: src\main.cpp
  [+]: xmake.lua
  [+]: .gitignore
create ok!
$ cd test
$ xmake
checking for the architecture ... x86_64
[  0%]: compiling.release src\main.cpp
[100%]: linking.release test.exe

Currently it is not supported to compile it with msys /gcc, because the generated xmake still has some running problems during the running process.

And I alse improved the PKGBUILD, you can see
https://github.com/xmake-io/xmake/blob/dev/scripts/PKGBUILD

@StarWolf3000
Copy link
Contributor

@waruqi Like I said, do not mixup MSYS2 and MINGW.

This line is wrong:
$ make install prefix=/usr

Should be:
$ make install prefix=/mingw64 and $ make install prefix=/mingw32

MINGW binaries should NEVER go into /usr/bin and MSYS2 binaries should NEVER go into /mingw32|64/bin.

@waruqi
Copy link
Contributor

waruqi commented Feb 16, 2020

@waruqi Like I said, do not mixup MSYS2 and MINGW.

This line is wrong:
$ make install prefix=/usr

Should be:
$ make install prefix=/mingw64 and $ make install prefix=/mingw32

MINGW binaries should NEVER go into /usr/bin and MSYS2 binaries should NEVER go into /mingw32|64/bin.

Got it, thanks! @StarWolf3000

$ pacman -S mingw-w64-x86_64-gcc
$ which gcc
/mingw64/bin/gcc
$ cd xmake
$ make build
$ make install prefix=/mingw64

Or

$ pacman -S mingw-w64-i686-gcc
$ which gcc
/mingw32/bin/gcc
$ cd xmake
$ make build
$ make install prefix=/mingw32

@Biswa96
Copy link
Member

Biswa96 commented Feb 16, 2020

The linked PKGBUILD does not work in mingw-w64-x86_64 but the dev branch complied successfully.

@waruqi
Copy link
Contributor

waruqi commented Feb 16, 2020

The linked PKGBUILD does not work in mingw-w64-x86_64 but the dev branch complied successfully.

I haven’t published a new release version, the 2.2.9 version in PKGBUILD cannot be compiled. I only update PKGBUILD to use make install instead of package() {} scripts.

@waruqi
Copy link
Contributor

waruqi commented Feb 23, 2020

@Biswa96 I have published the release version (v2.3.1) and support mingw.

@Biswa96
Copy link
Member

Biswa96 commented Feb 23, 2020

@StarWolf3000
Copy link
Contributor

StarWolf3000 commented Feb 23, 2020

@Biswa96 Did you use makepkg or makepkg-mingw to run?

@Biswa96
Copy link
Member

Biswa96 commented Feb 23, 2020

Both shows the error.

@waruqi
Copy link
Contributor

waruqi commented Feb 23, 2020

Here is the link https://github.com/Biswa96/MINGW-packages/blob/add_xmake/mingw-w64-xmake/PKGBUILD

I will look at it later.

@waruqi
Copy link
Contributor

waruqi commented Feb 24, 2020

I have created a test PKGBUILD file. But it shows some error in package step. Here is the output:

==> Starting package()...
installing to /c/MyFiles/xmake/pkg/mingw-w64-x86_64-xmake ...
plat: msys
arch: x86_64
cp: cannot create regular file '/c/MyFiles/xmake/pkg/mingw-w64-x86_64-xmake/bin/xmake.exe': No such file or directory
make: *** [makefile:109: install] Error 1

@Biswa96 It was because the pkg/bin directory was not created during running make install.

I have fixed this problem in the dev branch. But in the current version, you can temporarily modify PKGBUILD to solve this problem.

package() {
    cd "$srcdir"
    mkdir "${pkgdir}/bin" .  <--  ensure to create bin directory
    make install prefix="${pkgdir}"
}

@Biswa96
Copy link
Member

Biswa96 commented Feb 24, 2020

Some issues:

  • The /bin/xmake file contains absolute path including the folder in which the package is built.
  • Where is the executable after running make install?
  • Why does make build automatically delete compiled object files? Shouldn't those be deleted with make clean command?

@waruqi
Copy link
Contributor

waruqi commented Feb 24, 2020

The /bin/xmake file contains absolute path including the folder in which the package is built.

This is indeed a problem, I need to improve make install.

Where is the executable after running make install?

/mingw64/bin/xmake.exe

Why does make build automatically delete compiled object files? Shouldn't those be deleted with make clean command?

It is just a legacy problem. xmake/core/makefile currently does not support uses depfile to incrementally compile, so make clean will be executed before make build.

core/makefile

build:
	@echo compiling xmake-core ...
	@if [ -f core/.config.mak ]; then rm core/.config.mak; fi
	@$(MAKE) -C core --no-print-directory f DEBUG=$(debug)
	@$(MAKE) -C core --no-print-directory c             <--------------- clean first
	@$(MAKE) -C core --no-print-directory

@waruqi
Copy link
Contributor

waruqi commented Feb 24, 2020

@Biswa96 I have updated xmake-v2.3.1.tar.gz and imrpove make install script.

You can update PKGBUILD and try it again.

# Maintainer: <waruqi@gmail.com>

_realname=xmake
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.3.1
pkgrel=1
pkgdesc="A make-like build utility based on Lua"
arch=('i686' 'x86_64')
url="https://github.com/xmake-io/xmake"
license=('Apache')
depends=("${MINGW_PACKAGE_PREFIX}-ncurses"
         "${MINGW_PACKAGE_PREFIX}-readline")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/xmake-io/${_realname}/releases/download/v${pkgver}/${_realname}-v${pkgver}.tar.gz")
sha256sums=('94ba21b4ca9586509b78d1bb1e788be966f19c5b9cb6f6ea8fcab26c69f9bda2')

build() {
    cd "$srcdir"
    make build
}

package() {
    cd "$srcdir"
    make install DESTDIR="${pkgdir}" PREFIX="/usr"
}

@Biswa96
Copy link
Member

Biswa96 commented Feb 24, 2020

  • make install DESTDIR="${pkgdir}" generates export XMAKE_PROGRAM_DIR=/usr/local/share/xmake.
  • At least, make install DESTDIR="${pkgdir}" prefix="${MINGW_PREFIX}" creates correct path i.e. /mingw64/bin/xmake.exe but it does not exist. I think the demo.b is not copied.

@waruqi
Copy link
Contributor

waruqi commented Feb 24, 2020

  • make install DESTDIR="${pkgdir}" generates export XMAKE_PROGRAM_DIR=/usr/local/share/xmake.
  • At least, make install DESTDIR="${pkgdir}" prefix="${MINGW_PREFIX}" creates correct path i.e. /mingw64/bin/xmake.exe but it does not exist. I think the demo.b is not copied.

I have fixed it, please update sha256 and redownload tar.gz to makepkg.

sha256sums=('7aea3ccd4cdd80efad6825761fd75b2de5813a72e08e7fc4b7c4eb0671d6ff28')

When run mv /tmp/xmake /usr/bin/xmake, it removed /usr/bin/xmake.exe on msys automatically. : (

@Biswa96
Copy link
Member

Biswa96 commented Feb 24, 2020

Ohh... forgot to check the 32bit build. The 32bit build failed. See the linked PR CI build.

@waruqi
Copy link
Contributor

waruqi commented Feb 24, 2020

Ohh... forgot to check the 32bit build. The 32bit build failed. See the linked PR CI build.

You can try make build ARCH=i386 first.

If it still fails, I'll take a look tomorrow.

@waruqi
Copy link
Contributor

waruqi commented Feb 25, 2020

Ohh... forgot to check the 32bit build. The 32bit build failed. See the linked PR CI build.

I have fixed it on mingw32, you can update sha256 and try it again.

b2e46d9b4dd48fb70d32a314ca4ba12d42b0b294f5e2179c5c09c56f9c52933b

@waruqi
Copy link
Contributor

waruqi commented Feb 26, 2020

xmake have been merged. #6224

@StarWolf3000
Copy link
Contributor

@waruqi Please close this.

@waruqi
Copy link
Contributor

waruqi commented Feb 26, 2020

@waruqi Please close this.

@StarWolf3000 I cannot close it.
@kassane Can you close this issue?

@waruqi
Copy link
Contributor

waruqi commented Feb 26, 2020

Why has xmake been merged and I executed pacman to update the database and still can't find it?

$ pacman -Syu
 mingw32 is up to date
 mingw64 is up to date
 msys is up to date
$ pacman -S mingw-w64-x86_64-xmake
error: target not found: mingw-w64-x86_64-xmake

@StarWolf3000
Copy link
Contributor

@waruqi What you do here and what is done in the repositories is not synchronized. @Alexpux uploads the packages and updates the databases, when he has free time.

@waruqi
Copy link
Contributor

waruqi commented Feb 26, 2020

@StarWolf3000 Got it, thanks!

@kassane
Copy link
Contributor Author

kassane commented Feb 26, 2020

@waruqi
I tested it using in msys-terminal the following parameter and this error was reported. But it works at the command prompt.

xmake f -p mingw --mingw=/mingw64

output:
checking for the architecture ... x86_64
checking for the mingw directory ... C:/msys64/mingw64

xmake

output:
[ 0%]: ccache compiling.release src\main.cpp
error: ccache: error: Could not find compiler "C:\msys64\mingw64\bin\gcc" in PATH

@waruqi
Copy link
Contributor

waruqi commented Feb 26, 2020

@waruqi
I tested it using in msys-terminal the following parameter and this error was reported. But it works at the command prompt.

xmake f -p mingw --mingw=/mingw64

output:
checking for the architecture ... x86_64
checking for the mingw directory ... C:/msys64/mingw64

xmake

output:
[ 0%]: ccache compiling.release src\main.cpp
error: ccache: error: Could not find compiler "C:\msys64\mingw64\bin\gcc" in PATH

please open new issues in xmake/issues.

you can only use the default platform on msys/mingw64

xmake f -c
xmake

@kassane kassane closed this as completed Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants