Skip to content

universal-windows: Port to winrt #17

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

Closed
wants to merge 5 commits into from

Conversation

mauve
Copy link
Contributor

@mauve mauve commented Oct 4, 2015

This makes fileiter.cpp compile when targeting universal windows (b2 windows-api=store) I still need to port w32_regex_traits for the entire library to build so this PR can wait but I thought I could push it as soon as possible to gather feedback.

UPDATE: everything compiles. w32_regex_traits has been ifdeffed-out though (see commit-message)

@@ -378,7 +396,11 @@ inline _fi_find_handle find_first_file(const char* wild, _fi_find_data& data)
if (::MultiByteToWideChar(CP_ACP, 0, wild, wild_size, wide_wild, wild_size + 1) == 0)
return _fi_invalid_handle;

# if BOOST_PLAT_WINDOWS_RUNTIME
return FindFirstFileExW(wide_wild, FindExInfoStandard, &data, FindExSearchNameMatch, NULL, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the MSDN library documentation, FindFirstFileExW is available in Windows XP and Server 2003, so maybe it can be used unconditionally (like in your filesystem pull request)?

And the boost/predef/platform.h include for the BOOST_PLAT_* macros seems to be missing, also in your filesystem and test pull requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(thanks for the review: @MarcelRaad )

I will switch to unconditionally use FindFirstFileExW.

As it were boost.predef was being pulled in by something else which is the reason why it worked. I guess it is ok to add a dependency to boost.predef?

@mauve mauve changed the title universal-windows: Port fileiter universal-windows: Port to winrt Oct 4, 2015
@mauve
Copy link
Contributor Author

mauve commented Oct 6, 2015

@MarcelRaad care to take another look?

@MarcelRaad
Copy link
Contributor

Looks good to me!

@mauve mauve force-pushed the winrt-fileiter branch 2 times, most recently from e6c49b8 to 80ada9f Compare October 6, 2015 08:27
@mauve
Copy link
Contributor Author

mauve commented Oct 6, 2015

@MarcelRaad I just pushed a fixed version which re-enables boost::wregex again.

@jzmaddock
Copy link
Collaborator

Thanks for the patches, will investigate shortly.

@mauve
Copy link
Contributor Author

mauve commented Oct 6, 2015

@jzmaddock thanks

@jzmaddock
Copy link
Collaborator

I still see errors when building for windows store with msvc-14.0:

compile-c-c++ ..\..\..\bin.v2\libs\regex\build\msvc-14.0\debug\threading-multi\windows-api-store\fileiter.obj
fileiter.cpp
..\..\..\libs\regex\build\..\src\fileiter.cpp(108): error C3861: 'CreateFileA': identifier not found
..\..\..\libs\regex\build\..\src\fileiter.cpp(112): error C3861: 'CreateFileMapping': identifier not found
..\..\..\libs\regex\build\..\src\fileiter.cpp(121): error C3861: 'MapViewOfFile': identifier not found

@mauve
Copy link
Contributor Author

mauve commented Oct 6, 2015

@jzmaddock I think you need this in your local boost.config: boostorg/config#80 sorry for not mentioning.

@jzmaddock
Copy link
Collaborator

Nope, still get:

compile-c-c++ ..\..\..\bin.v2\libs\regex\build\msvc-14.0\debug\threading-multi\windows-api-store\fileiter.obj
fileiter.cpp
..\..\..\libs\regex\build\..\src\fileiter.cpp(112): error C3861: 'CreateFileMapping': identifier not found
..\..\..\libs\regex\build\..\src\fileiter.cpp(121): error C3861: 'MapViewOfFile': identifier not found

And this page: https://msdn.microsoft.com/en-gb/library/windows/desktop/aa366537%28v=vs.85%29.aspx suggests it's a desktop only API. The headers seem to confirm that as it's declared inside a #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) block.

Given that your patch disables w32_regex_traits anyway, and the only reason for using the Windows API in fileiter.cpp is to use memory mapped files, there would seem to be a much simpler patch that just involves setting BOOST_REGEX_NO_W32 in regex/config.hpp ??

@mauve
Copy link
Contributor Author

mauve commented Oct 6, 2015

Ok sorry for wasting your time like this. I will investigate as soon as I have had dinner and spent some time with my kids.

mauve added 5 commits October 6, 2015 21:01
The use of LCID is deprecated since Vista (but still available). Also
LoadString() is not available at all when targeting winrt so the
w32_regex_traits will need a larger rewrite. Fall back to
cpp_regex_traits for now.
Just as on VC10 this causes linker errors with std::collate<unsigned short>::id.
@mauve
Copy link
Contributor Author

mauve commented Oct 6, 2015

@jzmaddock ok I just tested again:

  1. I checked out the last boost super-module from master
  2. cd libs/config, git fetch origin, git checkout develop
    2.1) verify that the following commit is in config: ad3141c - universal-windows: Dont use Windows ANSI APIs when compiling for winrt (2 days ago) <Mikael Olenfalk>
  3. cd libs/regex, git checkout mauve/winrt-fileiter
  4. cd libs/regex/build, ../../../b2 windows-api=store
  5. Profit!
   Creating library ..\..\..\bin.v2\libs\regex\build\msvc-14.0\debug\threading-multi\windows-api-store\boost_regex-vc140-mt-gd-1_59.lib and object ..\..\..\bin.v2\libs\regex\build\msvc-14.0\debug\threading-multi\windows-api-store\boost_regex-vc140-mt-gd-1_59.exp
   msvc.manifest.dll ..\..\..\bin.v2\libs\regex\build\msvc-14.0\debug\threading-multi\windows-api-store\boost_regex-vc140-mt-gd-1_59.dll
   ...updated 15 targets...

I think the problem might have been that my local versions were too old, I have therefore rebase mauve/winrt-fileiter on the latest origin/develop and repushed to this PR again.

Again sorry if I wasted your time.

@MarcelRaad
Copy link
Contributor

Works for me too, it's defined in memoryapi.h from the Windows 10 SDK, even when building for Windows 8.0 or 8.1. Perhaps you're using the Windows 8.1 SDK @jzmaddock ? There it's only defined for WINAPI_PARTITION_DESKTOP.

If installed, the Windows 10 SDK should be the default one when building from the command line.

@mauve
Copy link
Contributor Author

mauve commented Oct 6, 2015

it compiles for me even if I compile with ..\..\..\b2.exe cxxflags=-D_WIN32_WINNT=0x0602 (windows 8) and I don't think we want to require the windows 10 sdk.

@mauve
Copy link
Contributor Author

mauve commented Oct 7, 2015

I have now verified on a fresh install, in order for this to build you need to have the windows 10 sdk but given that we have set _WIN32_WINNT to 0x0602, the produced binary should still work on windows 8:

src/tools/msvc.jam:290:feature.compose <windows-api>store : <define>WINAPI_FAMILY=WINAPI_FAMILY_APP <define>_WIN32_WINNT=0x0602

@jzmaddock how do you want to proceed? is it ok to require the windows 10 sdk for building?

@jzmaddock
Copy link
Collaborator

@jzmaddock https://github.com/jzmaddock how do you want to proceed?
is it ok to require the windows 10 sdk for building?

I realise it didn't build before so we're not breaking anything by
requiring that, but I'm not really happy about requiring a specific SDK.

OK, lets think a little... the only difference between this approach and
just "disable all windows api usage" is the behaviour of fileiter.cpp
right? And that's only used by the deprecated RegEx class, so it seems
like the simpler option of just not using the Windows API for store
applications is the way to go?

@mauve
Copy link
Contributor Author

mauve commented Oct 8, 2015

@jzmaddock ok I didn't know that fileiter was only used by deprecated code, in that case it makes sense to just define BOOST_REGEX_NO_W32 when targeting windows store. I will whip-up a patch.

@mauve
Copy link
Contributor Author

mauve commented Oct 8, 2015

New try: #18

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

Successfully merging this pull request may close these issues.

3 participants