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

Provide definitions for macros in rootless.h when !TARGET_OS_IPHONE #97

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

Conversation

leptos-null
Copy link
Member

What does this implement/fix? Explain your changes.

Theos only links libroot when targeting iphone:
https://github.com/theos/theos/blob/351fbe83ee6058bdb64e90884c3bb047c31ab6c1/makefiles/instance/rules.mk#L139-L142

This is currently required because libroot is currently only compiled for iOS.

This PR seeks to match this linking behavior on the headers side:
Only include libroot if the target is iOS.

When libroot is not available, this PR uses the definitions that were previously used in a2a4086

I opted for this approach so that projects that target both iOS and macOS, in particular, can use macros from rootless.h without needing to shim these macros or provide separate code for each target.

Checklist

  • New code follows the code rules
  • I've added modulemaps for any new libraries (e.g. see libactivator/module.modulemap): it should be possible to @import MyLibrary; in ObjC, or import MyLibrary in Swift.
  • My contribution is code written by myself from reverse-engineered headers, licensed into the Public Domain as per LICENSE.md; or, code written by myself / taken from an existing project, released under an OSI-approved license, and I've added relevant licensing credit to LICENSE.md

Does this close any currently open issues?

No

Any relevant logs, error output, etc?

Some tests:

main.m:

#import <Foundation/Foundation.h>
#import <rootless.h>

int main(int argc, const char *argv[]) {
	printf("ROOT_PATH: %s\n", ROOT_PATH("/bin/"));
	printf("ROOT_PATH_VAR: %s\n", ROOT_PATH_VAR(argv[0]));

	printf("ROOT_PATH_NS: %s\n", ROOT_PATH_NS(@"/bin/").UTF8String);
	printf("ROOT_PATH_NS_VAR: %s\n", ROOT_PATH_NS_VAR(@(argv[0])).UTF8String);

	return 0;
}
  • Compiled for TARGET="macosx:clang:latest:11.0"
  • Compiled for TARGET="iphone:clang:latest:14.0"

Any other comments?

No

Where has this been tested?

Operating System: macOS

Platform: Darwin

Target Platform: iOS, macOS

Toolchain Version: Apple clang version 15.0.0 (clang-1500.3.9.4)

SDK Version: MacOSX14.5.sdk, iPhoneOS17.5.sdk

These definitions should not rely on libroot which is currently
only available for iOS. This uses the definitions that were
previously used in a2a4086
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.

1 participant