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

Allow disabling gui at compile time #260

Merged
merged 7 commits into from
Jan 21, 2025

Conversation

austenadler
Copy link

Allows users to disable the GUI at compile time by using --no-default-features

@austenadler austenadler force-pushed the feature/allow-disabling-gui branch from d648bcc to ab21b88 Compare January 11, 2025 03:49
Copy link
Contributor

@benjamin051000 benjamin051000 left a comment

Choose a reason for hiding this comment

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

I did not do code review, but nice work. I can test this in two days when I'm home.

We definitely should discuss how this might work with releases... having two executables, one with gui, one without, is kinda weird. Maybe this shouldn't be a compile feature... I don't know. Maybe the gui should live in its own repo. 🤷‍♂️ things to discuss I guess

README.md Outdated Show resolved Hide resolved
@benjamin051000
Copy link
Contributor

benjamin051000 commented Jan 11, 2025

Oh, this also needs CI testing. We need to ensure it compiles with and without gui. I assume that shouldn't be too hard to add into the github workflow matrix thing.

@benjamin051000
Copy link
Contributor

Resolves #159

@amir16yp
Copy link
Contributor

amir16yp commented Jan 11, 2025

if this is merged i can submit a PR that will add CLI-only version to releases with the workflows

@louis-e
Copy link
Owner

louis-e commented Jan 11, 2025

Sounds very good to me, I'll look into this asap! :)

@louis-e
Copy link
Owner

louis-e commented Jan 12, 2025

A few thoughts from my side, I like this implementation and I think it makes sense to do it in this way. Sadly there seems to be no way to make this line, which suppresses the command line, optional for a single release:

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

That's why I'm okay with a seperate CLI only release asset, as long as it's clearly distinguishable via the asset name (e.g. "arnis-cli.exe").
Also I somehow can't get this to run in CLI only mode, can you confirm that this is the correct way to execute it?
image

@austenadler
Copy link
Author

Sadly there seems to be no way to make this line, which suppresses the command line, optional for a single release

Also I somehow can't get this to run in CLI only mode, can you confirm that this is the correct way to execute it?

Hmm I am not on Windows and I didn't try it there. I will check it out today and see why it's failing for windows builds. It might be the windows_subsystem line that's preventing an actual error from being printed?

@austenadler
Copy link
Author

There are a few points here.

1: Your coordinates aren't generating any data, which is why it exited unsuccessfully. The output should have been:

[1/5] Fetching data...
Error! No data available in this region.
error: process didn't exit successfully: `target\release\arnis.exe --path=C:\Users\user\Downloads\superflat --bbox=48.139631,11.564054,48.145014,11.574440` (exit code: 1)

It works if you use a different set of coordinates (for example: cargo r -r -- "--path=C:\Users\user\Downloads\superflat" --bbox=-80.849226,34.117578,-80.841286,34.123032

2: Windows does not send anything to stdout/stderr if you use windows_subsystem = "windows" (by default). So you were not seeing that error message in Windows, but it would show up for linux. According to this and this, you can reattach to the parent console at runtime.

If you double click the .exe, you get the GUI. If you run .\arnis.exe, you get the GUI. If you specify --path=... --bbox=..., you get stdout. It's the best of both worlds.

3: According to the FreeConsole and AttachConsole documentation, you can safely free if not already attached, and I don't see any warnings about using these functions, so they should be fine to use even though they have to be in an unsafe block.

I pushed the fix to this. Everything should work now; please review again.

@louis-e
Copy link
Owner

louis-e commented Jan 21, 2025

Thanks a lot for your great work and sorry for catching up with it a bit late!
I've now reviewed and tested everything, this works perfectly! Thank you for your effort :)

@louis-e louis-e merged commit 928f487 into louis-e:main Jan 21, 2025
3 checks passed
@benjamin051000
Copy link
Contributor

Woohoo! cargo build --no-default-features only has 528 deps to build, cargo build --release has 768!

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.

4 participants