diff options
| -rw-r--r-- | Project_Export.toml | 4 | ||||
| -rw-r--r-- | core/bindings/lang/clang/Generate.toml | 11 | ||||
| -rw-r--r-- | core/bindings/lang/clang/build.rs | 67 | ||||
| -rw-r--r-- | core/bindings/lang/clang/configures/nogamepads_data.toml | 17 | ||||
| -rw-r--r-- | core/bindings/lang/clang/headers/nogamepads_data.h (renamed from core/bindings/lang/clang/headers/nogamepads.h) | 34 | ||||
| -rw-r--r-- | export/dev/bin/completeion/install_completion_powershell.ps1 | 39 |
6 files changed, 83 insertions, 89 deletions
diff --git a/Project_Export.toml b/Project_Export.toml index 5d09f89..9b1e7bd 100644 --- a/Project_Export.toml +++ b/Project_Export.toml @@ -5,7 +5,7 @@ # It will search starting from the project directory and copy to the specified location in the target directory. [release.root] -# License files, third-party licenses +# License files license = { raw = "./", target = "./", files = [ "LICENSE-MIT" ] } @@ -17,7 +17,7 @@ powershell_complete = { raw = "./.cargo/resources/scripts/", target = "./bin/com # Headers headers = { raw = "./core/bindings/lang/clang/headers/", target = "./lib", files = [ - "nogamepads.h" + "nogamepads_data.h" ] } # Items defined in [release.deps] diff --git a/core/bindings/lang/clang/Generate.toml b/core/bindings/lang/clang/Generate.toml deleted file mode 100644 index 08d8b00..0000000 --- a/core/bindings/lang/clang/Generate.toml +++ /dev/null @@ -1,11 +0,0 @@ -language = "C" -include_guard = "NOGAMEPADS_H" -header = "// Auto generated by cbindgen 0.29.0" -cpp_compat = true - -[parse] -parse_deps = true -include = ["*"] - -[fn] -prefix = "ngp_"
\ No newline at end of file diff --git a/core/bindings/lang/clang/build.rs b/core/bindings/lang/clang/build.rs index c43ee7f..190501e 100644 --- a/core/bindings/lang/clang/build.rs +++ b/core/bindings/lang/clang/build.rs @@ -1,34 +1,61 @@ fn main() { - // Get the project root directory let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); let root_path = std::path::Path::new(&manifest_dir); - // Input configuration file path - let config_path = root_path.join("Generate.toml"); + // Input configuration directory path + let config_dir = root_path.join("configures"); // Output directory path (headers folder in the crate directory) let headers_dir = root_path.join("headers"); - // Create the headers directory (if it does not exist) - std::fs::create_dir_all(&headers_dir).expect("Failed to create headers directory"); - - // Output file path - let output_file = headers_dir.join("nogamepads.h"); + // Clear existing headers directory (if it exists) + if headers_dir.exists() { + std::fs::remove_dir_all(&headers_dir).expect("Failed to remove headers directory"); + } - // Load configuration from Generate.toml - let config = cbindgen::Config::from_file(&config_path) - .expect("Failed to parse Generate.toml configuration"); - - // Generate header file - cbindgen::Builder::new() - .with_crate(manifest_dir) - .with_config(config) - .generate() - .expect("Failed to generate C header file") - .write_to_file(&output_file); + // Create a new headers directory + std::fs::create_dir_all(&headers_dir).expect("Failed to create headers directory"); - println!("cargo:rerun-if-changed={}", config_path.display()); + // Find all TOML files in configures directory + let config_files = std::fs::read_dir(&config_dir) + .expect("Failed to read configures directory") + .filter_map(|entry| { + let entry = entry.expect("Failed to read directory entry"); + let path = entry.path(); + if path.is_file() && path.extension().map_or(false, |ext| ext == "toml") { + Some(path) + } else { + None + } + }); + + // Process each configuration file + for config_path in config_files { + // Extract filename without extension + let file_stem = config_path.file_stem() + .and_then(|s| s.to_str()) + .expect("Invalid filename") + .to_string(); + + // Set output file path + let output_file = headers_dir.join(format!("{}.h", file_stem)); + + // Load configuration from current TOML file + let config = cbindgen::Config::from_file(&config_path) + .expect(&format!("Failed to parse configuration: {}", config_path.display())); + + // Generate header file + cbindgen::Builder::new() + .with_crate(&manifest_dir) + .with_config(config) + .generate() + .expect(&format!("Failed to generate header for: {}", config_path.display())) + .write_to_file(&output_file); + } + + // Print rerun instructions + println!("cargo:rerun-if-changed={}", config_dir.display()); println!("cargo:rerun-if-changed=src/mycode.rs"); println!("cargo:rerun-if-changed=build.rs"); }
\ No newline at end of file diff --git a/core/bindings/lang/clang/configures/nogamepads_data.toml b/core/bindings/lang/clang/configures/nogamepads_data.toml new file mode 100644 index 0000000..56d645d --- /dev/null +++ b/core/bindings/lang/clang/configures/nogamepads_data.toml @@ -0,0 +1,17 @@ +language = "C" +include_guard = "NOGAMEPADS_DATA_H" +header = "// Auto generated by cbindgen 0.29.0" +cpp_compat = true + +[parse] +parse_deps = true +include = [ + "string_converter", + + "ngpd_game_info", + "ngpd_message", + "ngpd_player" +] + +[fn] +prefix = "ngpd_data_"
\ No newline at end of file diff --git a/core/bindings/lang/clang/headers/nogamepads.h b/core/bindings/lang/clang/headers/nogamepads_data.h index 3242a44..6d9f1ad 100644 --- a/core/bindings/lang/clang/headers/nogamepads.h +++ b/core/bindings/lang/clang/headers/nogamepads_data.h @@ -1,7 +1,7 @@ // Auto generated by cbindgen 0.29.0 -#ifndef NOGAMEPADS_H -#define NOGAMEPADS_H +#ifndef NOGAMEPADS_DATA_H +#define NOGAMEPADS_DATA_H #include <stdarg.h> #include <stdbool.h> @@ -146,36 +146,36 @@ typedef struct FfiConnectionResponseMessage { extern "C" { #endif // __cplusplus -ngp_ void free_c_string(char *ptr); +ngpd_data_ void free_c_string(char *ptr); -ngp_ struct FfiPlayer *player_register(const char *id, const char *password); +ngpd_data_ struct FfiPlayer *player_register(const char *id, const char *password); -ngp_ bool player_check(const struct FfiPlayer *player, const char *password); +ngpd_data_ bool player_check(const struct FfiPlayer *player, const char *password); -ngp_ void player_set_nickname(struct FfiPlayer *player, const char *nickname); +ngpd_data_ void player_set_nickname(struct FfiPlayer *player, const char *nickname); -ngp_ void player_set_hue(struct FfiPlayer *player, int hue); +ngpd_data_ void player_set_hue(struct FfiPlayer *player, int hue); -ngp_ void player_set_hsv(struct FfiPlayer *player, int hue, double saturation, double value); +ngpd_data_ void player_set_hsv(struct FfiPlayer *player, int hue, double saturation, double value); -ngp_ void player_free(struct FfiPlayer *player); +ngpd_data_ void player_free(struct FfiPlayer *player); -ngp_ void free_control_message(struct FfiControlMessage msg); +ngpd_data_ void free_control_message(struct FfiControlMessage msg); -ngp_ void free_game_message(struct FfiGameMessage msg); +ngpd_data_ void free_game_message(struct FfiGameMessage msg); -ngp_ void free_exit_reason(enum FfiExitReason msg); +ngpd_data_ void free_exit_reason(enum FfiExitReason msg); -ngp_ void free_connection_message(struct FfiConnectionMessage msg); +ngpd_data_ void free_connection_message(struct FfiConnectionMessage msg); -ngp_ void free_connection_response_message(struct FfiConnectionResponseMessage msg); +ngpd_data_ void free_connection_response_message(struct FfiConnectionResponseMessage msg); -ngp_ void free_join_failed_message(enum FfiJoinFailedMessage msg); +ngpd_data_ void free_join_failed_message(enum FfiJoinFailedMessage msg); -ngp_ void free_game_info(struct FfiGameInfo map); +ngpd_data_ void free_game_info(struct FfiGameInfo map); #ifdef __cplusplus } // extern "C" #endif // __cplusplus -#endif /* NOGAMEPADS_H */ +#endif /* NOGAMEPADS_DATA_H */ diff --git a/export/dev/bin/completeion/install_completion_powershell.ps1 b/export/dev/bin/completeion/install_completion_powershell.ps1 deleted file mode 100644 index 8707870..0000000 --- a/export/dev/bin/completeion/install_completion_powershell.ps1 +++ /dev/null @@ -1,39 +0,0 @@ -$ErrorActionPreference = "Stop" - -try { - # Check if padc.exe exists in the current directory - if (-not (Test-Path -Path ".\..\padc.exe" -PathType Leaf)) { - throw "Error: padc.exe program not found in the current directory" - } - - # Generate completion script - Write-Host "Generating padc.ps1 file..." - .\..\padc.exe generate-completion powershell | Out-File padc.ps1 -Encoding utf8 -Force - - # Get target profile file path - $targetProfile = $PROFILE.CurrentUserAllHosts - - # Ensure the profile directory exists - $profileDir = Split-Path $targetProfile -Parent - if (-not (Test-Path $profileDir)) { - New-Item -ItemType Directory -Path $profileDir -Force | Out-Null - } - - # Copy the generated script to the profile file - Write-Host "Installing to user profile file..." - Copy-Item padc.ps1 $targetProfile -Force - - # Clean up temporary files (optional) - # Remove-Item padc.ps1 -Force - - Write-Host "`nComplete! Auto-completion has been successfully installed to $targetProfile" -ForegroundColor Green - Write-Host "Effective in new terminal sessions (restart PowerShell to use)" -} -catch { - Write-Host "`nError: $_" -ForegroundColor Red - exit 1 -} - -# Pause the script -Write-Host "`nPress any key to continue..." -$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
\ No newline at end of file |
