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

Extend the Curses dependency to use config tools and hand rolled search #7757

Merged
merged 10 commits into from Sep 30, 2020

Conversation

dcbaker
Copy link
Member

@dcbaker dcbaker commented Sep 18, 2020

Like many other classic unix libraries curses is a portability pain, there's a bunch of slightly different implementations, that are found different ways. Meson already provides abstractions for making other widely available but not always easy to find libraries easier to use.

This adds all of the methods, and is tested on linux. I can test it on illumos/OpenIndiana and FreeBSD later if needed.

This doesn't resolve the fact that users will likely need to know which header they should #include. But that's a bigger change to dependencies.

Fixes #7693

@dcbaker
Copy link
Member Author

dcbaker commented Sep 18, 2020

There's also a zlib fix in here, I can split that out if others prefer.

@dcbaker
Copy link
Member Author

dcbaker commented Sep 18, 2020

Hmmmm, not sure why msys fails while everything else succeeds.

@The-King-of-Toasters
Copy link
Contributor

The-King-of-Toasters commented Sep 19, 2020

I have access to a couple of systems, will mark off when tested:

  • OpenBSD - current and stable (uses system).
  • OmniOS (can use pkg-config, config-tool and system).
  • Arch Linux (can use pkg-config, config-tool and system).
  • FreeBSD (system with base ncurses, pkg-config with ncurses 6 from ports).
  • macOS Catalina KVM (can use pkg-config with homebrew, config-tool installed as ncurse5.4-config???).

Copy link
Member

@nirbheek nirbheek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minus typos already pointed out.

@lygstate
Copy link
Contributor

Also, hope msys2/mingw to be tested.

@lygstate
Copy link
Contributor

@dcbaker do you have time to update the pull request?

@dcbaker
Copy link
Member Author

dcbaker commented Sep 23, 2020

Yes, I have the comments addressed locally, in just trying to get an msys environment set up to figure out why that's failing

@lygstate
Copy link
Contributor

Yes, I have the comments addressed locally, in just trying to get an msys environment set up to figure out why that's failing

maybe I can help the msys environment, I've already steup it.

@lygstate
Copy link
Contributor

2020-09-18T20:33:47.0655611Z Source dir: D:\a\1\s\test cases\frameworks\31 curses
2020-09-18T20:33:47.0655960Z Build dir: D:\a\1\s\b efdeae105d
2020-09-18T20:33:47.0656322Z Build type: native build
2020-09-18T20:33:47.0656605Z Project name: curses
2020-09-18T20:33:47.0656884Z Project version: undefined
2020-09-18T20:33:47.0657356Z C compiler for the host machine: cc (gcc 10.2.0 "cc (Rev1, Built by MSYS2 project) 10.2.0")
2020-09-18T20:33:47.0657807Z C linker for the host machine: cc ld.bfd 2.35
2020-09-18T20:33:47.0658199Z Host machine cpu family: x86
2020-09-18T20:33:47.0658494Z Host machine cpu: x86
2020-09-18T20:33:47.0658943Z ncursesw6-config found: YES (sh D:\a\msys64\mingw32\bin\ncursesw6-config) 6.2.20200212
2020-09-18T20:33:47.0659413Z Run-time dependency curses found: YES 6.2.20200212
2020-09-18T20:33:47.0659925Z Dependency curses found: NO found 6.2.20200212 but need: '> 1000000' (cached)
2020-09-18T20:33:47.0660557Z WARNING: Project targeting '>= 0.51.1' but tried to use feature introduced in '0.53.0': assert function without message argument.
2020-09-18T20:33:47.0661082Z Build targets in project: 1
2020-09-18T20:33:47.0661653Z WARNING: Project specifies a minimum meson_version '>= 0.51.1' but uses features which were added in newer versions:
2020-09-18T20:33:47.0662328Z  * 0.53.0: {'assert function without message argument'}
2020-09-18T20:33:47.0662753Z WARNING: Deprecated features used:
2020-09-18T20:33:47.0663072Z  * 0.48.0: {'python3 module'}
2020-09-18T20:33:47.0663451Z  * 0.55.0: {'cmake_options arg in subproject'}
2020-09-18T20:33:47.0663697Z 
2020-09-18T20:33:47.0663987Z Found ninja-1.10.1 at D:\a\msys64\mingw32\bin\ninja.EXE
2020-09-18T20:33:47.0664988Z [1/2] "cc" "-Ibasic.exe.p" "-I." "-I..\test cases\frameworks\31 curses" "-I/mingw32/include/ncursesw" "-I/mingw32/include" "-fdiagnostics-color=always" "-pipe" "-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-g" "-D_XOPEN_SOURCE=600" "-D_POSIX_C_SOURCE=199506L" -MD -MQ basic.exe.p/main.c.obj -MF "basic.exe.p\main.c.obj.d" -o basic.exe.p/main.c.obj "-c" "../test cases/frameworks/31 curses/main.c"
2020-09-18T20:33:47.0666017Z FAILED: basic.exe.p/main.c.obj 
2020-09-18T20:33:47.0666917Z "cc" "-Ibasic.exe.p" "-I." "-I..\test cases\frameworks\31 curses" "-I/mingw32/include/ncursesw" "-I/mingw32/include" "-fdiagnostics-color=always" "-pipe" "-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-g" "-D_XOPEN_SOURCE=600" "-D_POSIX_C_SOURCE=199506L" -MD -MQ basic.exe.p/main.c.obj -MF "basic.exe.p\main.c.obj.d" -o basic.exe.p/main.c.obj "-c" "../test cases/frameworks/31 curses/main.c"
2020-09-18T20:33:47.0668018Z ../test cases/frameworks/31 curses/main.c:1:10: fatal error: curses.h: No such file or directory
2020-09-18T20:33:47.0668507Z     1 | #include "curses.h"
2020-09-18T20:33:47.0668792Z       |          ^~~~~~~~~~
2020-09-18T20:33:47.0669129Z compilation terminated.
2020-09-18T20:33:47.0669439Z ninja: build stopped: subcommand failed.
2020-09-18T20:33:47.0670093Z  
2020-09-18T20:33:47.0670309Z 
2020-09-18T20:33:47.0671771Z CI COMMAND ci_include:
2020-09-18T20:33:47.0722277Z Included file D:\a\1\s\b efdeae105d\build.ninja:
2020-09-18T20:33:47.0722991Z # This is the build file for project "curses"
2020-09-18T20:33:47.0723956Z # It is autogenerated by the Meson build system.
2020-09-18T20:33:47.0724462Z # Do not edit by hand.
2020-09-18T20:33:47.0724869Z 
2020-09-18T20:33:47.0725252Z ninja_required_version = 1.7.1

didn't found this header

@lygstate
Copy link
Contributor

Hi, I've found the cause of the msys2 error:


lygstate@DESKTOP-94PU0GB MINGW64 ~
$ pkg-config ncursesw --cflags
-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-Tools/msys64/mingw64/include/ncursesw

lygstate@DESKTOP-94PU0GB MINGW64 ~
$ ncursesw6-config --cflags
-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -I/mingw64/include/ncursesw -I/mingw64/include


The ncursesw6-config are showing the msys2 style path, but pkg-config ncursesw --cflags showing the windows style path, and the mingw/gcc compiler just recoginize the windows sytle path, didn't recognize the msys2 style path, so we should return the windows style path instead.

@lygstate
Copy link
Contributor

also, lack of pdcurses detection on msys2

@lygstate
Copy link
Contributor

@dcbaker Hi, I've fixes the msys2 for you pull request and add pdcurses support on msys2, you can cherry pick my patches
at
#7773

@lygstate
Copy link
Contributor

I didn't fixes the reviews for your pull reqeust, I create that just used to verify if the CI passed

@dcbaker
Copy link
Member Author

dcbaker commented Sep 23, 2020

@lazka I'm not sure what to do about the config-tool thing. Is there someway for us to patch up the path so that it works correctly?

@dcbaker
Copy link
Member Author

dcbaker commented Sep 23, 2020

@lazka: is there something we can do to fix the config tools (or should I open a bug against msys somewhere?)

@lygstate I pulled your patches in, but I split the adding of pdcurses and disabling of configtool on windows into two separate patches.

@lygstate
Copy link
Contributor

@lazka: is there something we can do to fix the config tools (or should I open a bug against msys somewhere?)

@lygstate I pulled your patches in, but I split the adding of pdcurses and disabling of configtool on windows into two separate patches.

No problem, I found my pull request still have problem, and I know why, on msys2/mingw when the curses are detect by system
we need add the include path manually, Don't know if other system also need that.

@dcbaker
Copy link
Member Author

dcbaker commented Sep 23, 2020

Not that I've seen macos, linux, freebsd, and openindiana all just work.

@lygstate
Copy link
Contributor

Not that I've seen macos, linux, freebsd, and openindiana all just work.

Yeap, mingw maybe a differen things, but from qemu, there must some platform need the include

@lygstate
Copy link
Contributor

I see why things goes wrong
The mingw path convert procedure are not properly handled

    def _convert_mingw_paths(self, args: T.List[str]) -> T.List[str]:
        '''
        Both MSVC and native Python on Windows cannot handle MinGW-esque /c/foo
        paths so convert them to C:/foo. We cannot resolve other paths starting
        with / like /home/foo so leave them as-is so that the user gets an
        error/warning from the compiler/linker.
        '''
        if not mesonlib.is_windows():
            return args
        converted = []
        for arg in args:
            pargs = []
            # Library search path
            if arg.startswith('-L/'):
                pargs = PurePath(arg[2:]).parts
                tmpl = '-L{}:/{}'
            elif arg.startswith('-I/'):
                pargs = PurePath(arg[2:]).parts
                tmpl = '-I{}:/{}'
            # Full path to library or .la file
            elif arg.startswith('/'):
                pargs = PurePath(arg).parts
                tmpl = '{}:/{}'
            elif arg.startswith(('-L', '-I')) or (len(arg) > 2 and arg[1] == ':'):
                # clean out improper '\\ ' as comes from some Windows pkg-config files
                arg = arg.replace('\\ ', ' ')
            if len(pargs) > 1 and len(pargs[1]) == 1:
                arg = tmpl.format(pargs[1], '/'.join(pargs[2:]))
            converted.append(arg)
        return converted

So we have no need to disable CursesConfigToolDependency on windows
Just need to fixes _convert_mingw_paths, and this is also whey qemu building with meson failed.

@lygstate
Copy link
Contributor

@dcbaker I've rebase and update with #7773 to fixes the CI, and from that we know the existing mingw path handling are error prone. we need use cygpath to do proper path convert.

So the pkg-config and custom config-tool both need use that.

@lazka
Copy link
Contributor

lazka commented Sep 24, 2020

@lazka: is there something we can do to fix the config tools (or should I open a bug against msys somewhere?)

I've filed msys2/MINGW-packages#7025

@lygstate
Copy link
Contributor

@lazka: is there something we can do to fix the config tools (or should I open a bug against msys somewhere?)

I've filed msys2/MINGW-packages#7025

I've fixes it consistence with pkg-config in pull request #7773
So there is no need the mingw bug anymore

@lazka
Copy link
Contributor

lazka commented Sep 24, 2020

So there is no need the mingw bug anymore

I assume fixing it doesn't hurt though? I've done so in msys2/MINGW-packages#7026

@lygstate
Copy link
Contributor

lygstate commented Sep 24, 2020

So there is no need the mingw bug anymore

I assume fixing it doesn't hurt though? I've done so in msys2/MINGW-packages#7026

Not hurt:), just a bit boring, every package need consider that

@lygstate
Copy link
Contributor

@dcbaker I've updated #7773 (comment) and fixes all compiling issues under win32, please have a look and cherry-pick it

@jpakkane
Copy link
Member

How does this tie in with #7773 then? Should both of them be merged or only one? If one, which one?

@dcbaker
Copy link
Member Author

dcbaker commented Sep 29, 2020

What I think I'd like to do, is just work around the windows issue for now and merge this, then we'll take the msys issues @lygstate is trying to fix one at a time in a separate MR. does that sound reasonable?

The big difference between them is that 7773 is trying to fix a bunch of msys issues as well (that break using this dependency)

dcbaker and others added 10 commits September 29, 2020 14:58
look for (in order): ncursesw, ncurses, curses.
These are mostly duplicated with pkg-config, but maybe someone has one
but not another, and they're easy to turn on with the
ConfigToolDependency.
has_header returns a tuple of (found: bool, cached: bool), so `if
has_header` will always return true because the tuple is non-empty. We
need to check if the found value is true or not.
That calls find_library and has_header in conjunction to look for curses
implementations that are baked into the system without any other find
method.
This is mostly important for the system dependency where we need to roll
the version check ourselves.
On win32 there is pdcurses, so we detect it first, because python
depends on ncursesw, so if we don't want to use ncursesw, we should make
sure pdcurses detect before ncursesw
… windows

with msys ncurses-config returns a unix style path (currently, though
it's been fixed upstream), which the compilers don't understand, so we
can't do that. Additionally, while the system search does work, there's
missing include directories that need to be added.
@lygstate
Copy link
Contributor

What I think I'd like to do, is just work around the windows issue for now and merge this, then we'll take the msys issues @lygstate is trying to fix one at a time in a separate MR. does that sound reasonable?

The big difference between them is that 7773 is trying to fix a bunch of msys issues as well (that break using this dependency)

reasonable

@dcbaker dcbaker merged commit ce2d927 into mesonbuild:master Sep 30, 2020
@dcbaker dcbaker deleted the submit/curses-dependency branch September 30, 2020 16:33
@dcbaker
Copy link
Member Author

dcbaker commented Sep 30, 2020

Okay, I've gone ahead and merged this, let me go take a closer look at 7773 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve curses detection
6 participants