-
Notifications
You must be signed in to change notification settings - Fork 141
Use cmake to build #181
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
Open
WinterMute
wants to merge
5
commits into
master
Choose a base branch
from
cmakeify
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Use cmake to build #181
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3a5be91
use cmake to build
WinterMute dac1dcf
add assets.zip gemeration
WinterMute 1cd6a94
copy headers from libnx rather than add to includes
WinterMute bae83c2
use version from project
WinterMute d880c61
simplify SDL check
WinterMute File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| cmake_minimum_required(VERSION 3.18) | ||
| project(nx_hbmenu VERSION 3.6.0) | ||
|
|
||
| if (NOT NINTENDO_SWITCH) | ||
| find_package(SDL2 REQUIRED) | ||
| find_package(SDL2 CONFIG COMPONENTS SDL2main) | ||
| endif() | ||
|
|
||
| find_package(Freetype REQUIRED) | ||
| find_package(PNG REQUIRED) | ||
| find_package(PhysFS REQUIRED) | ||
| find_package(libjpeg-turbo REQUIRED) | ||
| find_package(libconfig REQUIRED) | ||
|
|
||
| add_compile_options( | ||
| -DVERSION=\"${PROJECT_VERSION}\" | ||
| ) | ||
|
|
||
| add_executable(${PROJECT_NAME}) | ||
|
|
||
| add_custom_command( | ||
| OUTPUT ${CMAKE_SOURCE_DIR}/romfs/assets.zip | ||
| COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/romfs | ||
| COMMAND rm -f ${CMAKE_SOURCE_DIR}/romfs/assets.zip | ||
| COMMAND zip -rj ${CMAKE_SOURCE_DIR}/romfs/assets.zip ${CMAKE_SOURCE_DIR}/assets | ||
| DEPENDS assets | ||
| assets/eth_icon.bin | ||
| assets/airplane_icon.bin | ||
| assets/folder_icon.bin | ||
| assets/battery_icon.bin | ||
| assets/wifi_none_icon.bin | ||
| assets/theme_icon_dark.bin | ||
| assets/hbmenu_logo_light.bin | ||
| assets/wifi2_icon.bin | ||
| assets/wifi3_icon.bin | ||
| assets/theme_icon_light.bin | ||
| assets/invalid_icon.bin | ||
| assets/charging_icon.bin | ||
| assets/wifi1_icon.bin | ||
| assets/hbmenu_logo_dark.bin | ||
| assets/eth_none_icon.bin | ||
| VERBATIM) | ||
|
|
||
| add_custom_target(assets_zip DEPENDS romfs/assets.zip) | ||
|
|
||
| add_dependencies(${PROJECT_NAME} assets_zip) | ||
|
|
||
| target_sources(${PROJECT_NAME} PRIVATE | ||
| common/menu-list.c | ||
| common/worker.c | ||
| common/math.c | ||
| common/menu.c | ||
| common/font.c | ||
| common/launch.c | ||
| common/menu-entry.c | ||
| common/theme.c | ||
| common/message-box.c | ||
| common/text.c | ||
| common/ui.c | ||
| common/status.c | ||
| common/language.c | ||
| common/netloader.c | ||
| common/assets.c | ||
| ) | ||
|
|
||
| if (NINTENDO_SWITCH) | ||
| target_sources(${PROJECT_NAME} PRIVATE | ||
| nx_main/nx_power.c | ||
| nx_main/nx_netstatus.c | ||
| nx_main/nx_audio.c | ||
| nx_main/nx_graphics.c | ||
| nx_main/nx_touch.c | ||
| nx_main/main.c | ||
| nx_main/nx_thermalstatus.c | ||
| nx_main/nx_launch.c | ||
| nx_main/loaders/builtin.c | ||
| ) | ||
|
|
||
|
|
||
|
|
||
| nx_generate_nacp (${PROJECT_NAME}.nacp | ||
| NAME "NX HB Menu" | ||
| AUTHOR "SwitchBrew" | ||
| ) | ||
|
|
||
| nx_create_nro (${PROJECT_NAME} | ||
| NACP ${PROJECT_NAME}.nacp | ||
| ICON ${CMAKE_SOURCE_DIR}/icon.jpg | ||
| ROMFS ${CMAKE_SOURCE_DIR}/romfs | ||
| ) | ||
|
|
||
| else() | ||
| target_sources(${PROJECT_NAME} PRIVATE | ||
| pc_main/main.cpp | ||
| pc_main/pc_launch.c | ||
| pc_main/pc_netstatus.c | ||
| pc_main/pc_thermalstatus.c | ||
| pc_main/pc_power.c | ||
| ) | ||
|
|
||
| endif() | ||
|
|
||
| # SDL2::SDL2main may or may not be available. It is e.g. required by Windows GUI applications | ||
| if(TARGET SDL2::SDL2main) | ||
| # It has an implicit dependency on SDL2 functions, so it MUST be added before SDL2::SDL2 (or SDL2::SDL2-static) | ||
| target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2main) | ||
| endif() | ||
|
|
||
| if (NOT NINTENDO_SWITCH) | ||
| target_link_libraries(${PROJECT_NAME} PRIVATE | ||
| SDL2::SDL2 | ||
| ) | ||
| endif() | ||
WinterMute marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| target_link_libraries(${PROJECT_NAME} PRIVATE | ||
| Freetype::Freetype | ||
| PNG | ||
| PhysFs | ||
| z | ||
| bz2 | ||
| libjpeg-turbo::turbojpeg-static | ||
| config | ||
| ) | ||
|
|
||
| if(NINTENDO_SWITCH) | ||
| target_link_libraries(${PROJECT_NAME} PRIVATE | ||
| deko3d | ||
| ) | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /** | ||
| * @file nacp.h | ||
| * @brief Control.nacp structure / related code for nacp. | ||
| * @copyright libnx Authors | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| /// Language entry. These strings are UTF-8. | ||
| typedef struct { | ||
| char name[0x200]; | ||
| char author[0x100]; | ||
| } NacpLanguageEntry; | ||
|
|
||
| /// ApplicationNeighborDetectionGroupConfiguration | ||
| typedef struct { | ||
| u64 group_id; ///< GroupId | ||
| u8 key[0x10]; | ||
| } NacpApplicationNeighborDetectionGroupConfiguration; | ||
|
|
||
| /// NeighborDetectionClientConfiguration | ||
| typedef struct { | ||
| NacpApplicationNeighborDetectionGroupConfiguration send_group_configuration; ///< SendGroupConfiguration | ||
| NacpApplicationNeighborDetectionGroupConfiguration receivable_group_configurations[0x10]; ///< ReceivableGroupConfigurations | ||
| } NacpNeighborDetectionClientConfiguration; | ||
|
|
||
| /// ApplicationJitConfiguration | ||
| typedef struct { | ||
| u64 flags; ///< Flags | ||
| u64 memory_size; ///< MemorySize | ||
| } NacpApplicationJitConfiguration; | ||
|
|
||
| /// ns ApplicationControlProperty | ||
| typedef struct { | ||
| NacpLanguageEntry lang[16]; ///< \ref NacpLanguageEntry | ||
| u8 isbn[0x25]; ///< Isbn | ||
| u8 startup_user_account; ///< StartupUserAccount | ||
| u8 user_account_switch_lock; ///< UserAccountSwitchLock | ||
| u8 add_on_content_registration_type; ///< AddOnContentRegistrationType | ||
| u32 attribute_flag; ///< AttributeFlag | ||
| u32 supported_language_flag; ///< SupportedLanguageFlag | ||
| u32 parental_control_flag; ///< ParentalControlFlag | ||
| u8 screenshot; ///< Screenshot | ||
| u8 video_capture; ///< VideoCapture | ||
| u8 data_loss_confirmation; ///< DataLossConfirmation | ||
| u8 play_log_policy; ///< PlayLogPolicy | ||
| u64 presence_group_id; ///< PresenceGroupId | ||
| s8 rating_age[0x20]; ///< RatingAge | ||
| char display_version[0x10]; ///< DisplayVersion | ||
| u64 add_on_content_base_id; ///< AddOnContentBaseId | ||
| u64 save_data_owner_id; ///< SaveDataOwnerId | ||
| u64 user_account_save_data_size; ///< UserAccountSaveDataSize | ||
| u64 user_account_save_data_journal_size; ///< UserAccountSaveDataJournalSize | ||
| u64 device_save_data_size; ///< DeviceSaveDataSize | ||
| u64 device_save_data_journal_size; ///< DeviceSaveDataJournalSize | ||
| u64 bcat_delivery_cache_storage_size; ///< BcatDeliveryCacheStorageSize | ||
| u64 application_error_code_category; ///< ApplicationErrorCodeCategory | ||
| u64 local_communication_id[0x8]; ///< LocalCommunicationId | ||
| u8 logo_type; ///< LogoType | ||
| u8 logo_handling; ///< LogoHandling | ||
| u8 runtime_add_on_content_install; ///< RuntimeAddOnContentInstall | ||
| u8 runtime_parameter_delivery; ///< RuntimeParameterDelivery | ||
| u8 reserved_x30f4[0x2]; ///< Reserved | ||
| u8 crash_report; ///< CrashReport | ||
| u8 hdcp; ///< Hdcp | ||
| u64 pseudo_device_id_seed; ///< SeedForPseudoDeviceId | ||
| char bcat_passphrase[0x41]; ///< BcatPassphrase | ||
| u8 startup_user_account_option; ///< StartupUserAccountOption | ||
| u8 reserved_for_user_account_save_data_operation[0x6]; ///< ReservedForUserAccountSaveDataOperation | ||
| u64 user_account_save_data_size_max; ///< UserAccountSaveDataSizeMax | ||
| u64 user_account_save_data_journal_size_max; ///< UserAccountSaveDataJournalSizeMax | ||
| u64 device_save_data_size_max; ///< DeviceSaveDataSizeMax | ||
| u64 device_save_data_journal_size_max; ///< DeviceSaveDataJournalSizeMax | ||
| u64 temporary_storage_size; ///< TemporaryStorageSize | ||
| u64 cache_storage_size; ///< CacheStorageSize | ||
| u64 cache_storage_journal_size; ///< CacheStorageJournalSize | ||
| u64 cache_storage_data_and_journal_size_max; ///< CacheStorageDataAndJournalSizeMax | ||
| u16 cache_storage_index_max; ///< CacheStorageIndexMax | ||
| u8 reserved_x318a[0x6]; ///< Reserved | ||
| u64 play_log_queryable_application_id[0x10]; ///< PlayLogQueryableApplicationId | ||
| u8 play_log_query_capability; ///< PlayLogQueryCapability | ||
| u8 repair_flag; ///< RepairFlag | ||
| u8 program_index; ///< ProgramIndex | ||
| u8 required_network_service_license_on_launch; ///< RequiredNetworkServiceLicenseOnLaunchFlag | ||
| u32 reserved_x3214; ///< Reserved | ||
| NacpNeighborDetectionClientConfiguration neighbor_detection_client_configuration; ///< NeighborDetectionClientConfiguration | ||
| NacpApplicationJitConfiguration jit_configuration; ///< JitConfiguration | ||
| u8 reserved_x33c0[0xc40]; ///< Reserved | ||
| } NacpStruct; | ||
|
|
||
| /// Get the NacpLanguageEntry from the input nacp corresponding to the current system language (this may fallback to other languages when needed). Output langentry is NULL if none found / content of entry is empty. | ||
| /// If you're using ns you may want to use \ref nsGetApplicationDesiredLanguage instead. | ||
| Result nacpGetLanguageEntry(NacpStruct* nacp, NacpLanguageEntry** langentry); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * @file nro.h | ||
| * @brief NRO headers. | ||
| * @copyright libnx Authors | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #define NROHEADER_MAGIC 0x304f524e | ||
|
|
||
| #define NROASSETHEADER_MAGIC 0x54455341 | ||
| #define NROASSETHEADER_VERSION 0 | ||
|
|
||
| /// Entry for each segment in the codebin. | ||
| typedef struct { | ||
| u32 file_off; | ||
| u32 size; | ||
| } NroSegment; | ||
|
|
||
| /// Offset 0x0 in the NRO. | ||
| typedef struct { | ||
| u32 unused; | ||
| u32 mod_offset; | ||
| u8 padding[8]; | ||
| } NroStart; | ||
|
|
||
| /// This follows NroStart, the actual nro-header. | ||
| typedef struct { | ||
| u32 magic; | ||
| u32 unk1; | ||
| u32 size; | ||
| u32 unk2; | ||
| NroSegment segments[3]; | ||
| u32 bss_size; | ||
| u32 unk3; | ||
| u8 build_id[0x20]; | ||
| u8 padding[0x20]; | ||
| } NroHeader; | ||
|
|
||
| /// Custom asset section. | ||
| typedef struct { | ||
| u64 offset; | ||
| u64 size; | ||
| } NroAssetSection; | ||
|
|
||
| /// Custom asset header. | ||
| typedef struct { | ||
| u32 magic; | ||
| u32 version; | ||
| NroAssetSection icon; | ||
| NroAssetSection nacp; | ||
| NroAssetSection romfs; | ||
| } NroAssetHeader; | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be an idea to use cmake in tool mode for compatibility.
${CMAKE_COMMAND} -E, it has rm, make_directory and tar (which can even work on zip files).