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

misc improvements #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

misc improvements #1

wants to merge 7 commits into from

Conversation

mochaaP
Copy link

@mochaaP mochaaP commented Nov 14, 2024

  • deps: bump deps
  • shims/linux: perform dlopen exactly once
  • build: make cosmos relocatable
  • main: declare ImGui backend names
  • build: autodetect cosmocc in path
  • build: optimize binary
  • build: support building with makefile

Copy link
Owner

@bullno1 bullno1 left a comment

Choose a reason for hiding this comment

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

Thanks, the GL and sokol stuff are cool but the rest are a bit of a personal preference.

.clangd Outdated
@@ -8,3 +8,7 @@ CompileFlags:
- -std=c11
- -Ideps/sokol
- -Ideps/cimgui
- -Invapi
- -D_COSMO_SOURCE
- -I/opt/cosmos/include
Copy link
Owner

Choose a reason for hiding this comment

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

My sokol is not in /opt

Copy link
Author

Choose a reason for hiding this comment

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

it's for the cosmocc toolchain, not sokol.
there won't be errors if this is not present on the system.

.clangd Outdated
- -Invapi
- -D_COSMO_SOURCE
- -I/opt/cosmos/include
- -include libc/integral/normalize.inc
Copy link
Owner

Choose a reason for hiding this comment

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

Is this relative to the project?

Copy link
Author

Choose a reason for hiding this comment

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

without this <cosmo.h> and friends won't work. (missing a few internal macros and typedefs)

clean:
rm -rf $(BUILD_DIR) $(BIN_DIR)

-include $(DEPS)
Copy link
Owner

Choose a reason for hiding this comment

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

This is a demo so I just use shell script and no build system.

Normally, I don't even use make.

Copy link
Author

Choose a reason for hiding this comment

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

I added this because I have to use gcc's dependency tracking (so targets get rebuilt when I make change in deps/ or header files). it's just here for convenience :)

@@ -1,24 +1,29 @@
#!/bin/sh -e

if ! command -v cosmocc > /dev/null
COSMOS="${COSMOS:-/opt/cosmos}"
Copy link
Owner

Choose a reason for hiding this comment

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

I don't have COSMOS set and only add cosmo bin to PATH when needed.


FLAGS="-I deps/sokol \
-I deps/cimgui \
-mcosmo \
-mtiny \
-Wall \
-Werror"
Copy link
Owner

Choose a reason for hiding this comment

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

Please keep this.

case SG_BACKEND_DUMMY:
io->BackendRendererName = "sokol_gfx_dummy";
break;
}
Copy link
Owner

Choose a reason for hiding this comment

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

Is this necessary? main.c is just copied from sokol actual example.

.clangd Outdated
@@ -8,3 +8,7 @@ CompileFlags:
- -std=c11
- -Ideps/sokol
- -Ideps/cimgui
- -Invapi
- -D_COSMO_SOURCE
Copy link
Owner

Choose a reason for hiding this comment

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

This is manually defined per file, only for cosmo related source.

Copy link
Author

Choose a reason for hiding this comment

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

I will remove this.

@mochaaP
Copy link
Author

mochaaP commented Nov 19, 2024

i have some ideas on macos support:

since cross compiling and linking with cocoa is very annoying 1, we could consider building the sokol_app dylib at runtime, provided that we already need cc to dlopen libraries.

to start, we can include a (partially) preprocessed source file of sokol_app in the binary, and copy the compiling logic from dlopen_helper.

Footnotes

  1. normally needs a copy of osx sdk packaged with osxcross. also the sdk doesn't really work well on arbitrary platforms. due to how objective-c works, it's theoretically possible to only link depend on objc_* symbols and get the job done, but it's a pain in the ass and we'd like to leave that to the compiler.

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