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

Add DEFAULT_ADDITIONAL_DIRS CMake option #659

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jayman2000
Copy link
Contributor

Pull Request Type

  • GitHub Workflow changes
  • Documentation or Wiki changes
  • Build and Dependency changes
  • Runtime changes
    • Render changes
    • Audio changes
    • Input changes
    • Network changes
    • Other changes

Description

This pull request adds a DEFAULT_ADDITIONAL_DIRS CMake option. This new CMake option can be used by packagers in order to help ensure that Descent 3 automatically finds game files that were installed by one or more packages. See the commit message for details.

Related Issues

In the pull request description for #471, I had promised that I would open three additional pull requests if #471 got merged. This is one of those pull requests.

Checklist

  • I have tested my changes locally and verified that they work as intended.
  • I have documented any new or modified functionality.
  • I have reviewed the changes to ensure they do not introduce any unnecessary complexity or duplicate code.
  • I understand that by submitting this pull request, I am agreeing to license my contributions under the project's license.

Additional Comments

USAGE.md Outdated Show resolved Hide resolved
USAGE.md Outdated Show resolved Hide resolved
BUILD.md Outdated
| `CMAKE_BUILD_TYPE` | `Debug` builds are generally larger, slower and contain extra correctness checks that will validate game data and interrupt gameplay when problems are detected.<br>`Release` builds are optimized for size and speed and do not include debugging information, which makes it harder to find problems. | `Debug` |
| `BUILD_EDITOR` | _(Windows-only)_ Build internal editor. | `OFF` |
| `BUILD_TESTING` | Enable testing. Requires GTest. | `OFF` |
| `DEFAULT_ADDITIONAL_DIRS` | A list of directories that Descent 3 will use as read-only base directories unless `-nodefaultadditionaldirs` is used (see [USAGE.md’s Base directories section](./USAGE.md#base-directories)). This value gets interpreted as a C++ expression, so you’ll need to use C++’s syntax. Here’s an example of a valid value: <pre lang=cpp>`{"C:\\Games\\Descent3\\", "D:\\"}`</pre> | `{}` |
Copy link
Member

Choose a reason for hiding this comment

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

it would be more idiomatic to provide a list in the CMake sense and then bracket it and quote it automatically

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried turning that variable into a list, but I ran into a problem. Consider this list:

  • C:\Directory 1\
  • C:\Directory 2\

At the moment, it’s not possible to store that list as a CMake list. It’s also not possible to store this next list as a CMake list (although this next list is not a realistic example):

  • /home/user/[
  • /home/user/\;

What do think I should do about this problem?

Copy link
Member

Choose a reason for hiding this comment

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

that's annoying indeed. We could forbid trailing backslashes at the end of paths, or have a function to remove them. I could also ask Brad about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems like a lot of work to make this value a CMake list instead of a C++ expression, and it might result in a situations where some paths can be used with -additionaldir and cannot be used with DEFAULT_ADDITIONAL_DIRS. Is it worth it?

Copy link
Member

Choose a reason for hiding this comment

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

I was just thinking, as a packager, is there any situation where you would put static game assets in more than one given directory? Doing so would be confusing and very non-standard. DEFAULT_ADDITIONAL_DIR could simply be a single path value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just thinking, as a packager, is there any situation where you would put static game assets in more than one given directory?

Yes, I outlined one of those situations in this PR’s commit message. Also, Nixpkgs has packages named descent1-assets and descent2-assets. If a descent3-assets package was added to Nixpkgs, then it would be convenient to have Descent3 executables that load some on the game data from the descent3-unwrapped package and some of the game data from the descent3-assets package.

Doing so would be confusing and very non-standard.

If that’s the case, then you should probably go and respond to the comment that I linked to in this PR’s commit message.

@Jayman2000 Jayman2000 force-pushed the default-additional-dirs branch from feb6085 to c3a45bd Compare January 1, 2025 15:19
The main motivation behind this change is to make it easier to package
Descent 3 for Linux. For example, let’s say that you’re packaging
Descent 3 for Debian and you want to make the package work well with
Debian’s game-data-packager. The package for the Descent 3 engine will
put d3-linux.hog in one directory, and the package for the proprietary
Descent 3 game data will put d3.hog into a different directory [1]. The
Descent 3 engine package can use the DEFAULT_ADDITIONAL_DIRS CMake
option in order to make sure that both d3-linux.hog and d3.hog are
located automatically.

For the example value in USAGE.md, I decided to use Windows paths in
order to showcase the fact that you have to escape backslashes.

[1]: <DescentDevelopers#373 (comment)>
@Jayman2000 Jayman2000 force-pushed the default-additional-dirs branch from c3a45bd to a2dc357 Compare January 3, 2025 16:21
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.

2 participants