diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..af376d8a --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.'cfg(target_os = "macos")'] +rustflags = "-C link-arg=-fapple-link-rtlib" diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2b8f7da8..63baddb9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -78,3 +78,24 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose + + build-mac-vendored: + runs-on: macOS-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + # - name: Install Prerequisites + # run: brew install wxwidgets + - name: Build + run: cargo build --verbose --features vendored + - name: Run tests + run: cargo test --verbose --features vendored diff --git a/Cargo.lock b/Cargo.lock index 4073fff8..a5d3ceae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,6 +46,9 @@ version = "0.1.0" dependencies = [ "cc", "wx-base", + "wx-universal-apple-darwin", + "wx-x86_64-pc-windows-gnu", + "wx-x86_64-pc-windows-msvc", "wxrust-config", ] @@ -54,9 +57,27 @@ name = "wx-base" version = "0.1.0" dependencies = [ "cc", + "wx-universal-apple-darwin", + "wx-x86_64-pc-windows-gnu", + "wx-x86_64-pc-windows-msvc", "wxrust-config", ] +[[package]] +name = "wx-universal-apple-darwin" +version = "3.1.6" +source = "git+https://github.com/ancwrd1/wx-universal-apple-darwin#4e512d2c125436007a7ee1331a48d8b5de430fb4" + +[[package]] +name = "wx-x86_64-pc-windows-gnu" +version = "3.1.6" +source = "git+https://github.com/ancwrd1/wx-x86_64-pc-windows-gnu#b41af996f766692e2d08926dbd2660091a654916" + +[[package]] +name = "wx-x86_64-pc-windows-msvc" +version = "3.1.7" +source = "git+https://github.com/kenz-gelsoft/wx-x86_64-pc-windows-msvc#baac6119a393ab49c25edc3926747d5ce2644d56" + [[package]] name = "wxrust-config" version = "0.1.0" diff --git a/doxybindgen.toml b/doxybindgen.toml index 482d0a2d..aba6ce54 100644 --- a/doxybindgen.toml +++ b/doxybindgen.toml @@ -71,6 +71,9 @@ cxx = "#ifndef __WXGTK__" [conditions.wx31] cxx = "#if wxCHECK_VERSION(3, 1, 0)" +[conditions.wx317] +cxx = "#if wxCHECK_VERSION(3, 1, 7)" + [types] [types.wxAnyButton] library = 'core' @@ -78,6 +81,10 @@ library = 'core' blocklist = [ 'Insert', ] +wx317 = [ + # Doc isn't up-to-date in wx3.1.6 + 'GetSizeHint', +] [types.wxBitmapButton] wx31 = [ 'CreateCloseButton', @@ -89,6 +96,12 @@ blocklist = [ # doesn't support returning wxList 'GetHandlers', ] +wx317 = [ + # Doc isn't up-to-date in wx3.1.6 + 'SetDepth', + 'SetHeight', + 'SetWidth', +] wx31 = [ 'wxBitmap8', ] @@ -188,6 +201,12 @@ blocklist = [ blocklist = [ 'operator=', ] +wx317 = [ + # Doc isn't up-to-date in wx3.1.6 + 'SetDepth', + 'SetHeight', + 'SetWidth', +] [types.wxItemContainer] blocklist = [ # std::vector is not supported @@ -293,6 +312,11 @@ blocklist = [ 'operator/=', 'operator*=', ] +[types.wxRadioBox] +wx317 = [ + # Doc isn't up-to-date in wx3.1.6 + 'GetItemHelpText', +] [types.wxRect] blocklist = [ 'operator==', @@ -411,6 +435,10 @@ blocklist = [ 'GetCursor', 'GetUpdateRegion', ] +wx317 = [ + # Doc isn't up-to-date in wx3.1.6 + 'GetHelpText', +] not_gtk = [ 'RegisterHotKey', 'UnregisterHotKey', diff --git a/doxybindgen/binding.py b/doxybindgen/binding.py index 4c8a2779..b9a5cbfe 100644 --- a/doxybindgen/binding.py +++ b/doxybindgen/binding.py @@ -581,11 +581,12 @@ def lines(self, is_cc): self.__model.name(without_index=True), new_params_or_expr, ) - if (self.__model.maybe_returns_self() or - self.__model.returns.is_ref_to_binding()): - yield ' return &(%s);' % (new_params_or_expr,) - elif wrapped: + if (wrapped or + self.__model.returns.is_const_ref_to_binding()): yield ' return new %s(%s);' % (wrapped.in_cxx(), new_params_or_expr) + elif (self.__model.maybe_returns_self() or + self.__model.returns.is_ref_to_binding()): + yield ' return &(%s);' % (new_params_or_expr,) else: yield ' return %s;' % (new_params_or_expr,) yield '}' diff --git a/doxybindgen/model.py b/doxybindgen/model.py index 3aa41af5..6a5edc93 100644 --- a/doxybindgen/model.py +++ b/doxybindgen/model.py @@ -181,7 +181,8 @@ def overload_indexed(self, name): def wrap_return_type(self, allows_ptr): if (self.is_ctor or - self.returns_new() or + self.returns_new() or + self.returns.is_const_ref_to_binding() or allows_ptr and (self.returns.is_ptr_to_binding() or self.returns.is_ref_to_binding())): return ReturnTypeWrapper(self) diff --git a/samples/hello/Cargo.toml b/samples/hello/Cargo.toml index feafaaf3..727c849c 100644 --- a/samples/hello/Cargo.toml +++ b/samples/hello/Cargo.toml @@ -8,4 +8,3 @@ edition = "2021" [dependencies] wx-base = { path = "../../wx-base" } wx = { path = "../../wx-core" } - diff --git a/samples/minimal/Cargo.toml b/samples/minimal/Cargo.toml index 1279a053..fda9dcfa 100644 --- a/samples/minimal/Cargo.toml +++ b/samples/minimal/Cargo.toml @@ -8,4 +8,3 @@ edition = "2021" [dependencies] wx-base = { path = "../../wx-base" } wx = { path = "../../wx-core" } - diff --git a/samples/widgets/Cargo.toml b/samples/widgets/Cargo.toml index 7985d845..939bdc3a 100644 --- a/samples/widgets/Cargo.toml +++ b/samples/widgets/Cargo.toml @@ -8,4 +8,3 @@ edition = "2021" [dependencies] wx-base = { path = "../../wx-base" } wx = { path = "../../wx-core" } - diff --git a/samples/wrapsizer/Cargo.toml b/samples/wrapsizer/Cargo.toml index b3fbd503..2dcc63c8 100644 --- a/samples/wrapsizer/Cargo.toml +++ b/samples/wrapsizer/Cargo.toml @@ -8,4 +8,3 @@ edition = "2021" [dependencies] wx-base = { path = "../../wx-base" } wx = { path = "../../wx-core" } - diff --git a/wx-base/Cargo.toml b/wx-base/Cargo.toml index 7d6143b2..caa9e360 100644 --- a/wx-base/Cargo.toml +++ b/wx-base/Cargo.toml @@ -5,6 +5,23 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +vendored = [ + "wxrust-config/vendored", + "dep:wx-universal-apple-darwin", + "dep:wx-x86_64-pc-windows-gnu", + "dep:wx-x86_64-pc-windows-msvc", +] + +[target.'cfg(target_os = "macos")'.dependencies] +wx-universal-apple-darwin = { git = "https://github.com/ancwrd1/wx-universal-apple-darwin", optional = true } + +[target.x86_64-pc-windows-gnu.dependencies] +wx-x86_64-pc-windows-gnu = { git = "https://github.com/ancwrd1/wx-x86_64-pc-windows-gnu", optional = true } + +[target.x86_64-pc-windows-msvc.dependencies] +wx-x86_64-pc-windows-msvc = { git = "https://github.com/kenz-gelsoft/wx-x86_64-pc-windows-msvc", optional = true } + [build-dependencies] cc = "1.0.72" wxrust-config = { path = "../wxrust-config" } diff --git a/wx-core/Cargo.toml b/wx-core/Cargo.toml index 5c300b7d..70b6a86c 100644 --- a/wx-core/Cargo.toml +++ b/wx-core/Cargo.toml @@ -5,9 +5,26 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +vendored = [ + "wxrust-config/vendored", + "dep:wx-universal-apple-darwin", + "dep:wx-x86_64-pc-windows-gnu", + "dep:wx-x86_64-pc-windows-msvc", +] + [dependencies] wx-base = { path = "../wx-base" } +[target.'cfg(target_os = "macos")'.dependencies] +wx-universal-apple-darwin = { git = "https://github.com/ancwrd1/wx-universal-apple-darwin", optional = true } + +[target.x86_64-pc-windows-gnu.dependencies] +wx-x86_64-pc-windows-gnu = { git = "https://github.com/ancwrd1/wx-x86_64-pc-windows-gnu", optional = true } + +[target.x86_64-pc-windows-msvc.dependencies] +wx-x86_64-pc-windows-msvc = { git = "https://github.com/kenz-gelsoft/wx-x86_64-pc-windows-msvc", optional = true } + [build-dependencies] cc = "1.0.72" wxrust-config = { path = "../wxrust-config" } diff --git a/wx-core/include/generated.h b/wx-core/include/generated.h index 0047aa44..f0fe04fe 100644 --- a/wx-core/include/generated.h +++ b/wx-core/include/generated.h @@ -33,7 +33,9 @@ bool wxArtProvider_Delete(wxArtProvider * provider); wxBitmap *wxArtProvider_GetBitmap(const wxArtID * id, const wxArtClient * client, const wxSize * size); wxIcon *wxArtProvider_GetIcon(const wxArtID * id, const wxArtClient * client, const wxSize * size); wxSize *wxArtProvider_GetNativeSizeHint(const wxArtClient * client); +#if wxCHECK_VERSION(3, 1, 7) wxSize *wxArtProvider_GetSizeHint(const wxArtClient * client, bool platform_default); +#endif bool wxArtProvider_HasNativeProvider(); bool wxArtProvider_Pop(); void wxArtProvider_Push(wxArtProvider * provider); @@ -65,11 +67,15 @@ wxBitmap *wxBitmap_GetSubBitmap(const wxBitmap * self, const wxRect * rect); wxSize *wxBitmap_GetSize(const wxBitmap * self); int wxBitmap_GetWidth(const wxBitmap * self); bool wxBitmap_IsOk(const wxBitmap * self); +#if wxCHECK_VERSION(3, 1, 7) void wxBitmap_SetDepth(wxBitmap * self, int depth); void wxBitmap_SetHeight(wxBitmap * self, int height); +#endif void wxBitmap_SetMask(wxBitmap * self, wxMask * mask); void wxBitmap_SetPalette(wxBitmap * self, const wxPalette * palette); +#if wxCHECK_VERSION(3, 1, 7) void wxBitmap_SetWidth(wxBitmap * self, int width); +#endif void wxBitmap_AddHandler(wxBitmapHandler * handler); void wxBitmap_CleanUpHandlers(); #ifndef __WXMSW__ @@ -278,9 +284,11 @@ int wxIcon_GetDepth(const wxIcon * self); int wxIcon_GetHeight(const wxIcon * self); int wxIcon_GetWidth(const wxIcon * self); bool wxIcon_IsOk(const wxIcon * self); +#if wxCHECK_VERSION(3, 1, 7) void wxIcon_SetDepth(wxIcon * self, int depth); void wxIcon_SetHeight(wxIcon * self, int height); void wxIcon_SetWidth(wxIcon * self, int width); +#endif // CLASS: wxItemContainer void wxItemContainer_delete(wxItemContainer *self); @@ -450,7 +458,7 @@ wxMenuBar * wxMenuBar_MacGetCommonMenuBar(); // CLASS: wxMenuItem #ifdef __WXMSW__ -const wxBitmap * wxMenuItem_GetDisabledBitmap(const wxMenuItem * self); +wxBitmap *wxMenuItem_GetDisabledBitmap(const wxMenuItem * self); #endif wxString *wxMenuItem_GetHelp(const wxMenuItem * self); int wxMenuItem_GetId(const wxMenuItem * self); @@ -550,7 +558,9 @@ bool wxRadioBox_Create1(wxRadioBox * self, wxWindow * parent, wxWindowID id, con bool wxRadioBox_Enable(wxRadioBox * self, unsigned int n, bool enable); unsigned int wxRadioBox_GetColumnCount(const wxRadioBox * self); int wxRadioBox_GetItemFromPoint(const wxRadioBox * self, const wxPoint * pt); +#if wxCHECK_VERSION(3, 1, 7) wxString *wxRadioBox_GetItemHelpText(const wxRadioBox * self, unsigned int item); +#endif wxToolTip * wxRadioBox_GetItemToolTip(const wxRadioBox * self, unsigned int item); unsigned int wxRadioBox_GetRowCount(const wxRadioBox * self); bool wxRadioBox_IsItemEnabled(const wxRadioBox * self, unsigned int n); @@ -770,7 +780,7 @@ void wxStaticText_Wrap(wxStaticText * self, int width); // CLASS: wxTextAttr void wxTextAttr_delete(wxTextAttr *self); -const wxColour * wxTextAttr_GetBackgroundColour(const wxTextAttr * self); +wxColour *wxTextAttr_GetBackgroundColour(const wxTextAttr * self); wxString *wxTextAttr_GetBulletFont(const wxTextAttr * self); wxString *wxTextAttr_GetBulletName(const wxTextAttr * self); int wxTextAttr_GetBulletNumber(const wxTextAttr * self); @@ -783,7 +793,7 @@ wxString *wxTextAttr_GetFontFaceName(const wxTextAttr * self); int wxTextAttr_GetFontSize(const wxTextAttr * self); bool wxTextAttr_GetFontUnderlined(const wxTextAttr * self); #if wxCHECK_VERSION(3, 1, 0) -const wxColour * wxTextAttr_GetUnderlineColour(const wxTextAttr * self); +wxColour *wxTextAttr_GetUnderlineColour(const wxTextAttr * self); #endif long wxTextAttr_GetLeftIndent(const wxTextAttr * self); long wxTextAttr_GetLeftSubIndent(const wxTextAttr * self); @@ -794,7 +804,7 @@ int wxTextAttr_GetParagraphSpacingAfter(const wxTextAttr * self); int wxTextAttr_GetParagraphSpacingBefore(const wxTextAttr * self); wxString *wxTextAttr_GetParagraphStyleName(const wxTextAttr * self); long wxTextAttr_GetRightIndent(const wxTextAttr * self); -const wxColour * wxTextAttr_GetTextColour(const wxTextAttr * self); +wxColour *wxTextAttr_GetTextColour(const wxTextAttr * self); int wxTextAttr_GetTextEffectFlags(const wxTextAttr * self); int wxTextAttr_GetTextEffects(const wxTextAttr * self); wxString *wxTextAttr_GetURL(const wxTextAttr * self); @@ -873,7 +883,7 @@ wxTextCtrl *wxTextCtrl_new1(wxWindow * parent, wxWindowID id, const wxString * v bool wxTextCtrl_Create(wxTextCtrl * self, wxWindow * parent, wxWindowID id, const wxString * value, const wxPoint * pos, const wxSize * size, long style, const wxValidator * validator, const wxString * name); void wxTextCtrl_DiscardEdits(wxTextCtrl * self); bool wxTextCtrl_EmulateKeyPress(wxTextCtrl * self, const wxKeyEvent * event); -const wxTextAttr * wxTextCtrl_GetDefaultStyle(const wxTextCtrl * self); +wxTextAttr *wxTextCtrl_GetDefaultStyle(const wxTextCtrl * self); int wxTextCtrl_GetLineLength(const wxTextCtrl * self, long line_no); wxString *wxTextCtrl_GetLineText(const wxTextCtrl * self, long line_no); int wxTextCtrl_GetNumberOfLines(const wxTextCtrl * self); @@ -1072,7 +1082,7 @@ void wxWindow_AddChild(wxWindow * self, wxWindow * child); bool wxWindow_DestroyChildren(wxWindow * self); wxWindow * wxWindow_FindWindow(const wxWindow * self, long id); wxWindow * wxWindow_FindWindow1(const wxWindow * self, const wxString * name); -const wxWindowList * wxWindow_GetChildren1(const wxWindow * self); +wxWindowList *wxWindow_GetChildren1(const wxWindow * self); void wxWindow_RemoveChild(wxWindow * self, wxWindow * child); wxWindow * wxWindow_GetGrandParent(const wxWindow * self); wxWindow * wxWindow_GetNextSibling(const wxWindow * self); @@ -1264,7 +1274,9 @@ bool wxWindow_IsShownOnScreen(const wxWindow * self); bool wxWindow_Disable(wxWindow * self); bool wxWindow_Enable(wxWindow * self, bool enable); bool wxWindow_Show(wxWindow * self, bool show); +#if wxCHECK_VERSION(3, 1, 7) wxString *wxWindow_GetHelpText(const wxWindow * self); +#endif void wxWindow_SetHelpText(wxWindow * self, const wxString * help_text); wxToolTip * wxWindow_GetToolTip(const wxWindow * self); wxString *wxWindow_GetToolTipText(const wxWindow * self); diff --git a/wx-core/src/generated.cpp b/wx-core/src/generated.cpp index a2e60dd2..d10c1f83 100644 --- a/wx-core/src/generated.cpp +++ b/wx-core/src/generated.cpp @@ -68,9 +68,11 @@ wxIcon *wxArtProvider_GetIcon(const wxArtID * id, const wxArtClient * client, co wxSize *wxArtProvider_GetNativeSizeHint(const wxArtClient * client) { return new wxSize(wxArtProvider::GetNativeSizeHint(*client)); } +#if wxCHECK_VERSION(3, 1, 7) wxSize *wxArtProvider_GetSizeHint(const wxArtClient * client, bool platform_default) { return new wxSize(wxArtProvider::GetSizeHint(*client, platform_default)); } +#endif bool wxArtProvider_HasNativeProvider() { return wxArtProvider::HasNativeProvider(); } @@ -156,21 +158,25 @@ int wxBitmap_GetWidth(const wxBitmap * self) { bool wxBitmap_IsOk(const wxBitmap * self) { return self->IsOk(); } +#if wxCHECK_VERSION(3, 1, 7) void wxBitmap_SetDepth(wxBitmap * self, int depth) { return self->SetDepth(depth); } void wxBitmap_SetHeight(wxBitmap * self, int height) { return self->SetHeight(height); } +#endif void wxBitmap_SetMask(wxBitmap * self, wxMask * mask) { return self->SetMask(mask); } void wxBitmap_SetPalette(wxBitmap * self, const wxPalette * palette) { return self->SetPalette(*palette); } +#if wxCHECK_VERSION(3, 1, 7) void wxBitmap_SetWidth(wxBitmap * self, int width) { return self->SetWidth(width); } +#endif void wxBitmap_AddHandler(wxBitmapHandler * handler) { return wxBitmap::AddHandler(handler); } @@ -695,6 +701,7 @@ int wxIcon_GetWidth(const wxIcon * self) { bool wxIcon_IsOk(const wxIcon * self) { return self->IsOk(); } +#if wxCHECK_VERSION(3, 1, 7) void wxIcon_SetDepth(wxIcon * self, int depth) { return self->SetDepth(depth); } @@ -704,6 +711,7 @@ void wxIcon_SetHeight(wxIcon * self, int height) { void wxIcon_SetWidth(wxIcon * self, int width) { return self->SetWidth(width); } +#endif // CLASS: wxItemContainer void wxItemContainer_delete(wxItemContainer *self) { @@ -1171,8 +1179,8 @@ wxMenuBar * wxMenuBar_MacGetCommonMenuBar() { // CLASS: wxMenuItem #ifdef __WXMSW__ -const wxBitmap * wxMenuItem_GetDisabledBitmap(const wxMenuItem * self) { - return &(self->GetDisabledBitmap()); +wxBitmap *wxMenuItem_GetDisabledBitmap(const wxMenuItem * self) { + return new wxBitmap(self->GetDisabledBitmap()); } #endif wxString *wxMenuItem_GetHelp(const wxMenuItem * self) { @@ -1425,9 +1433,11 @@ unsigned int wxRadioBox_GetColumnCount(const wxRadioBox * self) { int wxRadioBox_GetItemFromPoint(const wxRadioBox * self, const wxPoint * pt) { return self->GetItemFromPoint(*pt); } +#if wxCHECK_VERSION(3, 1, 7) wxString *wxRadioBox_GetItemHelpText(const wxRadioBox * self, unsigned int item) { return new wxString(self->GetItemHelpText(item)); } +#endif wxToolTip * wxRadioBox_GetItemToolTip(const wxRadioBox * self, unsigned int item) { return self->GetItemToolTip(item); } @@ -2039,8 +2049,8 @@ void wxStaticText_Wrap(wxStaticText * self, int width) { void wxTextAttr_delete(wxTextAttr *self) { delete self; } -const wxColour * wxTextAttr_GetBackgroundColour(const wxTextAttr * self) { - return &(self->GetBackgroundColour()); +wxColour *wxTextAttr_GetBackgroundColour(const wxTextAttr * self) { + return new wxColour(self->GetBackgroundColour()); } wxString *wxTextAttr_GetBulletFont(const wxTextAttr * self) { return new wxString(self->GetBulletFont()); @@ -2076,8 +2086,8 @@ bool wxTextAttr_GetFontUnderlined(const wxTextAttr * self) { return self->GetFontUnderlined(); } #if wxCHECK_VERSION(3, 1, 0) -const wxColour * wxTextAttr_GetUnderlineColour(const wxTextAttr * self) { - return &(self->GetUnderlineColour()); +wxColour *wxTextAttr_GetUnderlineColour(const wxTextAttr * self) { + return new wxColour(self->GetUnderlineColour()); } #endif long wxTextAttr_GetLeftIndent(const wxTextAttr * self) { @@ -2107,8 +2117,8 @@ wxString *wxTextAttr_GetParagraphStyleName(const wxTextAttr * self) { long wxTextAttr_GetRightIndent(const wxTextAttr * self) { return self->GetRightIndent(); } -const wxColour * wxTextAttr_GetTextColour(const wxTextAttr * self) { - return &(self->GetTextColour()); +wxColour *wxTextAttr_GetTextColour(const wxTextAttr * self) { + return new wxColour(self->GetTextColour()); } int wxTextAttr_GetTextEffectFlags(const wxTextAttr * self) { return self->GetTextEffectFlags(); @@ -2340,8 +2350,8 @@ void wxTextCtrl_DiscardEdits(wxTextCtrl * self) { bool wxTextCtrl_EmulateKeyPress(wxTextCtrl * self, const wxKeyEvent * event) { return self->EmulateKeyPress(*event); } -const wxTextAttr * wxTextCtrl_GetDefaultStyle(const wxTextCtrl * self) { - return &(self->GetDefaultStyle()); +wxTextAttr *wxTextCtrl_GetDefaultStyle(const wxTextCtrl * self) { + return new wxTextAttr(self->GetDefaultStyle()); } int wxTextCtrl_GetLineLength(const wxTextCtrl * self, long line_no) { return self->GetLineLength(line_no); @@ -2891,8 +2901,8 @@ wxWindow * wxWindow_FindWindow(const wxWindow * self, long id) { wxWindow * wxWindow_FindWindow1(const wxWindow * self, const wxString * name) { return self->FindWindow(*name); } -const wxWindowList * wxWindow_GetChildren1(const wxWindow * self) { - return &(self->GetChildren()); +wxWindowList *wxWindow_GetChildren1(const wxWindow * self) { + return new wxWindowList(self->GetChildren()); } void wxWindow_RemoveChild(wxWindow * self, wxWindow * child) { return self->RemoveChild(child); @@ -3443,9 +3453,11 @@ bool wxWindow_Enable(wxWindow * self, bool enable) { bool wxWindow_Show(wxWindow * self, bool show) { return self->Show(show); } +#if wxCHECK_VERSION(3, 1, 7) wxString *wxWindow_GetHelpText(const wxWindow * self) { return new wxString(self->GetHelpText()); } +#endif void wxWindow_SetHelpText(wxWindow * self, const wxString * help_text) { return self->SetHelpText(*help_text); } diff --git a/wxrust-config/Cargo.toml b/wxrust-config/Cargo.toml index 3cb478f4..0b3dc6c6 100644 --- a/wxrust-config/Cargo.toml +++ b/wxrust-config/Cargo.toml @@ -5,5 +5,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +vendored = [] + [dependencies] cc = "1.0.72" diff --git a/wxrust-config/src/lib.rs b/wxrust-config/src/lib.rs index 0a82008e..5d6d634d 100644 --- a/wxrust-config/src/lib.rs +++ b/wxrust-config/src/lib.rs @@ -21,7 +21,7 @@ pub fn wx_config_cflags(cc_build: &mut cc::Build) -> &mut cc::Build { panic!("unsupported argument '{}'. please file a bug.", arg) } } - if cfg!(windows) { + if cfg!(target_env = "msvc") { cc_build.flag("/EHsc"); } cc_build @@ -49,7 +49,32 @@ pub fn print_wx_config_libs_for_cargo() { } } +fn dep_links() -> String { + let target = env::var("TARGET").unwrap().replace('-', "_").to_uppercase(); + if target.contains("APPLE") { + "UNIVERSAL_APPLE_DARWIN".to_owned() + } else { + target + } +} + fn wx_config(args: &[&str]) -> String { + if cfg!(feature = "vendored") { + let flags: Vec<_> = env::var(format!("DEP_WX_{}_CFLAGS", dep_links())) + .unwrap() + .split_whitespace() + .map(ToOwned::to_owned) + .collect(); + let (ldflags, cflags): (Vec<_>, Vec<_>) = flags + .into_iter() + .partition(|f| f.starts_with("-l") || f.starts_with("-L")); + return if args.contains(&"--cflags") { + cflags.join(" ") + } else { + ldflags.join(" ") + }; + } + if cfg!(windows) { wx_config_win(args) } else {