Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

CURA-2150: Initial Windows support #89

Conversation

thopiekar
Copy link
Contributor

@thopiekar thopiekar commented Oct 25, 2016

Now everything works, like shown on JIRA.

cura-build itself is not a C/C++ project, like set as default in CMake.

Contributes to CURA-2150
@thopiekar
Copy link
Contributor Author

Need a CMake guru here. Got a message that doesn't make any sense to me: 🙄 👈

CMake Error at C:/Program Files/CMake/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find Protobuf (missing: Protobuf_LIBRARIES) (found suitable
  version "3.0.0", minimum required is "3.0.0")

Made sure cura-build-environment works, but running it on Linux and merged some changes. Will go to IRC about this in the meantime..

@thopiekar
Copy link
Contributor Author

@awhiemstra , @sedwards2009 , @jackha : ping

@thopiekar
Copy link
Contributor Author

Ok, got a bit further.. For a reason my Protobuf build doesn't produce libprotobuf.dll, but I so no differences compared to old code. Additionally the old cura-build doesn't produce any .dll-files, too.
😞

Also don't like this solution of setting the location of the libraries
manually, but CMake can't manage to find the libraries on it's own.

Contributes to CURA-2150
@thopiekar
Copy link
Contributor Author

Followed a hint on IRC and switched from static to dynamic linked libraries.
Would be great if you could tell me whether it is a good or bad idea here.

I ended up with hardcoding the paths of the libraries. Very ugly but it works 😕

@Ghostkeeper
Copy link
Contributor

Haha, that is a very cryptic error message indeed!

I'm usually a proponent of static linking. It makes it easier to distribute and build in most cases, and can even provide some performance boost via compiler optimisation (though not for Protobuf, really). It's not the best choice if multiple applications use the same library, but that's not really our use case. So if it's up to me, go for static.

Hardcoding the paths of the libraries is not a good idea though, and we'd prefer to keep those out of the code. See if you can get it out, and don't be afraid to ask for help. Most of our developers are online on irc.freenode.net #ultimaker during the day.

@thopiekar
Copy link
Contributor Author

Ok, thanks. Will be there tomorrow.
It is the only thing that really hurts here.

Yes, building statically makes more sense here. Will try to find an alternative solution for this problem here.

Thank you for your feedback @Ghostkeeper and good night 😉

Also added a comment why it is needed.

Contributes to CURA-2150
Moreover it makes sure that the usage of "\" and "/" in the given path
is correct.
Without you'll run into this problem during building an NSIS installer
on Windows:

Running cx_Freeze
File "setup.py", line 29
search_path.insert(2,
"C:\Users\thopi\Documents\GitHub\cura-build-environment\build\env/lib/python3.5/site-packages/")
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in
position 2-3: truncated \UXXXXXXXX escape
CMakeFiles\build_bundle.dir\build.make:56: recipe for target
'build_bundle' failed
mingw32-make[2]: *** [build_bundle] Error 1
CMakeFiles\Makefile2:407: recipe for target
'CMakeFiles/build_bundle.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/build_bundle.dir/all] Error 2
makefile:137: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Contributes to CURA-2150
Is partial based on the script for OSX. Also had to add little changes
for PyQt5, as it is preinstalled on Windows and not built by
cura-build-environment.

Contributes to CURA-2150
We don't build deb's anymore..
Can't say anything special here. The difference between this and the
"old" cura-build is that we are calling now a python script, which is
now using cx_Freeze. The results are then moved like before from Py2Exe
to NSIS and then the installer is built (triggered by CPack).

Contributes to CURA-2150
A very well known signing tool comes from Microsoft itself. Following
their manual and some examples gives on the internet I made this script.
(See https://msdn.microsoft.com/de-de/library/8s9b9yaz(v=vs.110).aspx)
To make signing work, you'll needed here a pfx file. The script will
check whether it exists and if there is no file, it will warn about this
and skip signing.
There is also a way to pass the password for signtool.exe by setting
WINDOWS_IDENTITIY_PFX_PASSWORD.
But the user will be warned about the usage of this for security
reasons.

Contributes to 2150
@thopiekar thopiekar changed the title WIP: CURA-2150: Windows support CURA-2150: Windows support Oct 27, 2016
Useful when it is needed to add private sources into the build.
Now finally signs Cura.exe, CuraEngine.exe and the installer.
As we can't make the sign command depend on the "package" target as it
is an built-in command, you'll need to execute "sign_installer" here.

Contributes to CURA-2150
Contributes to CURA-2473
Copy link
Contributor

@awhiemstra awhiemstra left a comment

Choose a reason for hiding this comment

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

Nice work! I have posted a bunch of comments but most of them should be fairly minor.

* **SciPy** (http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy)
You'll need to download a .whl from this site for Python 3.5 and install it via `pip install <your_whl_file>.whl`.
* **Protobuf** (https://pypi.python.org/pypi/protobuf/3.1.0.post1)
It can be easyly installed via `pip3 install protobuf`
Copy link
Contributor

Choose a reason for hiding this comment

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

s/easyly/easily/g ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooops 😅

You'll need to download a .whl from this site for Python 3.5 and install it via `pip install <your_whl_file>.whl`.
* **SciPy** (http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy)
You'll need to download a .whl from this site for Python 3.5 and install it via `pip install <your_whl_file>.whl`.
* **Protobuf** (https://pypi.python.org/pypi/protobuf/3.1.0.post1)
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not need the Protobuf Python bindings. They have been replaced by the Arcus Python bindings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes, we are building our binding using the protobuf tools, but don't need the protobuf python binding, isn't it?

configure_file(${CMAKE_CURRENT_LIST_DIR}/setup_win32.py.in setup.py @ONLY)
add_custom_target(build_bundle)
add_dependencies(packaging build_bundle)
add_dependencies(build_bundle cura-binary-data)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably depend on the projects target, not a random project target. Depending on projects will trigger building the build_bundle target after all projects have built.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I'm not wrong I found these lines somewhere in the old cura-build and as I didn't know why it was set like that I just kept it like that.
Missed to ask about it sorry. But yes, makes sense!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

# TODO: Find a variable which holds the needed "win32"/"win64"
# There is a CPACK* variable which holds this variable, but it doesn't exist at this moment here...
if(${BUILD_OS_WIN32})
set(NSIS_SCRIPT_COPY_PATH "${CMAKE_BINARY_DIR}/_CPack_Packages/win32/${CPACK_GENERATOR}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than try and divine the win32/win64 here, why not set CPACK_PACKAGE_DIRECTORY to something known? Doing 32-bit/64-bit builds from the same build directory is not supported anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just the other way around ^^' Good idea! Will see how it works!

Thanks!

# Signing Cura.exe
add_custom_command(
TARGET signing PRE_BUILD
COMMAND signtool sign ${signtool_OPTIONS} Cura.exe
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to add a FindSigntool.cmake or similar file that searches for the signtool binary. That way we will have a bit more flexibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, but the path to signtool.exe needs to be set in PATH anyway.

WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
else()
message(FATAL_ERROR "Could not find the PFX file. Can not sign the executables!")
Copy link
Contributor

Choose a reason for hiding this comment

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

Failing to sign should not be a fatal error in my opinion, it should just fail to sign but still build.

"excludes": [ ]
}

# Extra libraries for numpy.core*
print("Copy numpy DLLs")
numpy_core_dir = os.path.dirname(numpy.core.__file__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still needed with cx_Freeze? As far as I know it has better handling of dependencies so we do not need code like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, can't remember. I just focused on the old code and tried to convert it to be used with cx_Freeze.
I'll retry without.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, @awhiemstra. Made one rebuild with and without and compared with Meld for missing files. Both were the same 👍

SectionEnd

Section /o "Open 3MF files with Cura"
${RegisterExtension} "$INSTDIR\Cura.exe" ".3mf" "Cura.model.3MF"
SectionEnd

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to add an X3D entry too? Or maybe we even want to make this more dynamic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and sorted all types..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PS: Do you know a way to make for loops in NSIS? I couldn't find any 😕

Copy link
Contributor

Choose a reason for hiding this comment

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

NSIS script is pretty limited and lacks decent control structures. The only thing I can think of is some trickery with the jump instructions. But I'd personally stay away from that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

We only need the protobuf compiler to generate our Arcus binding. No
need for the protobuf Python module.

Contributes to CURA-2150
Contributes to CURA-2150
In Py2Exe we had to care about adding additional libraries for NumPy.
Now cx_Freeze does this job for us.

Contributes to CURA-2150
This was mixed up before. Variables related to NSIS packaging were at
signing before.
Now everything related to NSIS is in packaging/windows.cmake.

Contributes to CURA-2150
Contributes to CURA-2150
Added a TODO to check whether CPACK_SYSTEM_NAME is "win64", like
expected.

Contributes to CURA-2150
Contributes to CURA-2150
@thopiekar
Copy link
Contributor Author

@awhiemstra Thanks!

A change that I forget to remove, while experimenting on getting a rid of ${CMAKE_BINARY_DIR}/_CPack_Packages/${CPACK_SYSTEM_NAME}/NSIS

Contributes to CURA-2150
@thopiekar thopiekar changed the title CURA-2150: Windows support CURA-2150: Initial Windows support Nov 15, 2016
These lines are necessary to get a working Cura installation!

This reverts commit d2a8d3c.
At the moment the plugins directory of cura and uranium are moved into a
new plugins directory. So finally are plugins are installed at
{INSTALL_DIR}/plugins/plugins
This change moves all plugins back to {INSTALL_DIR}/plugins.

Contributes to CURA-2150
@awhiemstra awhiemstra merged commit a7a4893 into Ultimaker:environment_split Feb 16, 2017
@thopiekar thopiekar deleted the master-environment_split-windows-support branch December 27, 2017 19:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants