Skip to content

Commit

Permalink
Update to foobar2000 SDK 2022-01-04 and use vcpkg manifest mode
Browse files Browse the repository at this point in the history
This updates submodules to bring in changes from foobar2000 SDK 2022-01-04.

Some bits of code were tidied up as part of this and `fmt` was added as a dependency (`std::format()` isn't used as it's not currently available in VS 2022 with the /std:c++20 compiler option).

Finally, vcpkg is now used in manifest mode to simplify handling of dependencies. Currently, only a single manifest in the root directory is used rather than having manifests for each project (I'm not sure how exactly the latter would behave, particularly if the manifests conflicted with each other).
  • Loading branch information
reupen committed Jan 9, 2022
1 parent 4b8e867 commit c750743
Show file tree
Hide file tree
Showing 21 changed files with 126 additions and 96 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,4 @@ Release.Win32
.vs

/foo_ui_columns/version.h
vcpkg_installed/
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

* The component is now compiled using Visual Studio 2022 17.0 and the /std:c++20 compiler option. [[#408](https://github.com/reupen/columns_ui/pull/408), [#409](https://github.com/reupen/columns_ui/pull/409)]

* The component is now compiled using foobar2000 SDK 2022-01-04. [[#419](https://github.com/reupen/columns_ui/pull/419)]

## 1.7.0

* There were no changes from version 1.7.0-beta.2.
Expand Down
41 changes: 19 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,34 @@ The latest development version can be downloaded by clicking on the Azure Pipeli

To clone the repo and dependencies, [download and install Git](https://git-scm.com/downloads), and then run:

`git clone --recursive https://github.com/reupen/columns_ui.git`
```powershell
git clone --recursive https://github.com/reupen/columns_ui.git
```

This repo makes use of Git submodules. If you're not familiar with them, [check out the guide here](https://git-scm.com/book/en/v2/Git-Tools-Submodules).

### Build instructions

Visual Studio 2022 is required to build Columns UI. You can use the [free community edition](https://www.visualstudio.com/downloads/) (select the Desktop development with C++ workload during installation).

#### Installing external dependencies

The following libraries are required to build Columns UI:

- Microsoft Guideline Support Library (GSL)
- Microsoft Windows Implementation Library (WIL)
- range-v3
#### Installing vcpkg

The recommended way to install them is using [vcpkg](https://github.com/Microsoft/vcpkg).
Some dependencies are managed using [vcpkg](https://github.com/Microsoft/vcpkg) and it must be installed to build Columns UI.

You can set up vcpkg, and install Microsoft GSL, using the following commands (run outside of the Columns UI source tree):
You can install and set up vcpkg by running the following commands (in a directory of your choice outside the Columns UI source tree):

```
```powershell
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
.\vcpkg install ms-gsl wil range-v3 --overlay-ports=..\columns_ui\ports
vcpkg\bootstrap-vcpkg.bat
vcpkg\vcpkg integrate install
```

(Note: Change the `..\columns_ui\ports` path in the `.\vcpkg install` command as necessary.)
Dependencies should then be automatically installed when Columns UI is built.

(You’ll need to occasionally run `git pull` in the vcpkg directory to fetch updated package metatdata.)

#### Building using the Visual Studio IDE

Open `vc17/columns_ui-public.sln` in Visual Studio 2022.

Select the Release configuration and the Win32 platform, and build the solution.
Expand All @@ -55,16 +52,16 @@ If the build is successful, `foo_ui_columns.dll` will be output in `vc17\Release

You can use MSBuild if you prefer. In a Developer Command Prompt for VS 2022 (in the start menu), run:

```
msbuild /m /p:Platform=Win32 /p:Configuration=Release vc17\columns_ui-public.sln
```powershell
msbuild /m "/p:Platform=Win32;Configuration=Release" vc17\columns_ui-public.sln
```

If the build is successful, `foo_ui_columns.dll` will be output in `vc17\Release`.

For a clean build, run:

```
msbuild /m /p:Platform=Win32 /p:Configuration=Release /t:Rebuild vc17\columns_ui-public.sln
```powershell
msbuild /m "/p:Platform=Win32;Configuration=Release" "/t:Rebuild" vc17\columns_ui-public.sln
```

#### Using the Clang compiler (experimental)
Expand All @@ -77,6 +74,6 @@ Columns UI can be also compiled using the version of Clang distributed with Visu

With these installed, open a Developer Command Prompt for VS 2022 from the start menu, switch to the Columns UI source directory and run:

```
msbuild /m /p:PlatformToolset=ClangCL;UseLldLink=True;VcpkgAutoLink=False;WholeProgramOptimization=False;Platform=Win32;Configuration=Release /t:Rebuild vc17\columns_ui-public.sln
```powershell
msbuild /m "/p:PlatformToolset=ClangCL;UseLldLink=True;VcpkgAutoLink=False;WholeProgramOptimization=False;Platform=Win32;Configuration=Release" "/t:Rebuild" vc17\columns_ui-public.sln
```
7 changes: 2 additions & 5 deletions azure/job-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ parameters:
msBuildArgs: ''
platform: ''
solution: ''
vcpkgInstallArgs: ''
vmImage: ''
jobs:
- job: ${{ parameters.name }}
Expand All @@ -16,7 +15,6 @@ jobs:
msBuildArgs: ${{ parameters.msBuildArgs }}
platform: ${{ parameters.platform }}
solution: ${{ parameters.solution }}
vcpkgInstallArgs: ${{ parameters.vcpkgInstallArgs }}
strategy:
matrix:
${{ insert }}: ${{ parameters.matrix }}
Expand All @@ -25,11 +23,10 @@ jobs:
submodules: recursive
- powershell: |
Set-PSDebug -Trace 1
git -C "$Env:VCPKG_INSTALLATION_ROOT" pull
vcpkg version
vcpkg integrate install
vcpkg install $(vcpkgInstallArgs)
condition: variables.vcpkgInstallArgs
displayName: Install dependencies
displayName: Set up vcpkg
- task: VSBuild@1
displayName: Build
inputs:
Expand Down
3 changes: 0 additions & 3 deletions azure/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ variables:
solution: vc17/columns_ui-public.sln
llvmMsBuildArgs: /p:PlatformToolset=ClangCL;UseLldLink=True;VcpkgAutoLink=False;WholeProgramOptimization=False;SpectreMitigation=
vc142MsBuildArgs:
vcpkgInstallArgs: 'ms-gsl range-v3 wil --overlay-ports=$(System.DefaultWorkingDirectory)\ports'
jobs:
- template: job-build.yml
parameters:
Expand All @@ -16,7 +15,6 @@ jobs:
name: vs2022_llvm
platform: Win32
solution: ${{ variables.solution }}
vcpkgInstallArgs: ${{ variables.vcpkgInstallArgs }}
vmImage: windows-2022
- template: job-build.yml
parameters:
Expand All @@ -31,5 +29,4 @@ jobs:
name: vs2022_v143
platform: Win32
solution: ${{ variables.solution }}
vcpkgInstallArgs: ${{ variables.vcpkgInstallArgs }}
vmImage: windows-2022
2 changes: 1 addition & 1 deletion columns_ui-sdk
2 changes: 1 addition & 1 deletion fbh
Submodule fbh updated 1 files
+15 −0 fbh.vcxproj
82 changes: 36 additions & 46 deletions foo_ui_columns/buttons_custom_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,38 +105,33 @@ void ButtonsToolbar::Button::CustomImage::read_from_file(ConfigVersion p_version
}
}
{
pfc::string_printf dir1("%s\\images", p_base);
pfc::string_printf dir2("%s\\images\\%s", p_base, p_name);
if (!filesystem::g_exists(dir1, p_abort))
filesystem::g_create_directory(dir1, p_abort);
if (!filesystem::g_exists(dir2, p_abort))
filesystem::g_create_directory(dir2, p_abort);
const auto dir1 = fmt::format(R"({}\images)", p_base);
const auto dir2 = fmt::format(R"({}\images\{})", p_base, p_name);
if (!filesystem::g_exists(dir1.c_str(), p_abort))
filesystem::g_create_directory(dir1.c_str(), p_abort);
if (!filesystem::g_exists(dir2.c_str(), p_abort))
filesystem::g_create_directory(dir2.c_str(), p_abort);

service_ptr_t<file> p_image;

pfc::string8 curdir = pfc::string_printf("%s\\images", p_base);
const auto curdir = fmt::format(R"({}\images)", p_base);
auto wname
= fmt::format(R"({}\{}\{})", curdir, p_name, std::string_view(name.get_ptr(), name.get_size()));

pfc::string8 wname = curdir;
wname.add_byte('\\');

wname.add_string(p_name);
wname.add_byte('\\');

wname.add_string(name.get_ptr(), name.get_size());
pfc::string8 name_only = pfc::string_filename(wname);
pfc::string8 ext = pfc::string_extension(wname).get_ptr();
const auto name_only = pfc::string_filename(wname.c_str());
const auto ext = pfc::string_extension(wname.c_str());
unsigned n = 0;

bool b_write = true;
{
bool b_continue = false;
do {
bool b_exists = filesystem::g_exists(wname, p_abort);
bool b_exists = filesystem::g_exists(wname.c_str(), p_abort);
if (b_exists) {
b_continue = true;
service_ptr_t<file> p_temp;
try {
filesystem::g_open(p_temp, wname, filesystem::open_mode_read, p_abort);
filesystem::g_open(p_temp, wname.c_str(), filesystem::open_mode_read, p_abort);
{
bool b_same = false;
g_compare_file_with_bytes(p_temp, data, b_same, p_abort);
Expand All @@ -151,18 +146,18 @@ void ButtonsToolbar::Button::CustomImage::read_from_file(ConfigVersion p_version
b_continue = false;

if (b_continue && n < 100)
wname = pfc::string_printf(
"%s\\%s\\%s %02u.%s", curdir.get_ptr(), p_name, name_only.get_ptr(), n, ext.get_ptr());
wname = fmt::format(
R"({}\{}\{} {:02}.{})", curdir.c_str(), p_name, name_only.get_ptr(), n, ext.get_ptr());
n++;

} while (b_continue && n < 100);
}

if (b_write) {
filesystem::g_open(p_image, wname, filesystem::open_mode_write_new, p_abort);
filesystem::g_open(p_image, wname.c_str(), filesystem::open_mode_write_new, p_abort);
p_image->write(data.get_ptr(), data.get_size(), p_abort);
}
m_path = wname;
m_path = wname.c_str();
}
} break;
case I_BUTTON_CUSTOM_IMAGE_MASK_DATA: {
Expand Down Expand Up @@ -194,37 +189,32 @@ void ButtonsToolbar::Button::CustomImage::read_from_file(ConfigVersion p_version
}
}
{
pfc::string_printf dir1("%s\\images", p_base);
pfc::string_printf dir2("%s\\images\\%s", p_base, p_name);
if (!filesystem::g_exists(dir1, p_abort))
filesystem::g_create_directory(dir1, p_abort);
if (!filesystem::g_exists(dir2, p_abort))
filesystem::g_create_directory(dir2, p_abort);
const auto dir1 = fmt::format(R"({}\images)", p_base);
const auto dir2 = fmt::format(R"({}\images\{})", p_base, p_name);
if (!filesystem::g_exists(dir1.c_str(), p_abort))
filesystem::g_create_directory(dir1.c_str(), p_abort);
if (!filesystem::g_exists(dir2.c_str(), p_abort))
filesystem::g_create_directory(dir2.c_str(), p_abort);
service_ptr_t<file> p_image;

pfc::string8 curdir = pfc::string_printf("%s\\images", p_base);

pfc::string8 wname = curdir;
wname.add_byte('\\');

wname.add_string(p_name);
wname.add_byte('\\');
const auto curdir = fmt::format(R"({}\images)", p_base);

wname.add_string(name.get_ptr(), name.get_size());
auto wname
= fmt::format(R"({}\{}\{})", curdir, p_name, std::string_view(name.get_ptr(), name.get_size()));

pfc::string8 name_only = pfc::string_filename(wname);
pfc::string8 ext = pfc::string_extension(wname).get_ptr();
const auto name_only = pfc::string_filename(wname.c_str());
const auto ext = pfc::string_extension(wname.c_str());
unsigned n = 0;
bool b_write = true;
{
bool b_continue = false;
do {
bool b_exists = filesystem::g_exists(wname, p_abort);
bool b_exists = filesystem::g_exists(wname.c_str(), p_abort);
if (b_exists) {
b_continue = true;
service_ptr_t<file> p_temp;
try {
filesystem::g_open(p_temp, wname, filesystem::open_mode_read, p_abort);
filesystem::g_open(p_temp, wname.c_str(), filesystem::open_mode_read, p_abort);
{
bool b_same = false;
g_compare_file_with_bytes(p_temp, data, b_same, p_abort);
Expand All @@ -239,18 +229,18 @@ void ButtonsToolbar::Button::CustomImage::read_from_file(ConfigVersion p_version
b_continue = false;

if (b_continue && n < 100)
wname = pfc::string_printf(
"%s\\%s\\%s %02u.%s", curdir.get_ptr(), p_name, name_only.get_ptr(), n, ext.get_ptr());
wname = fmt::format(
R"({}\{}\{} {:02}.{})", curdir.c_str(), p_name, name_only.get_ptr(), n, ext.get_ptr());
n++;

} while (b_continue && n < 100);
}

if (b_write) {
filesystem::g_open(p_image, wname, filesystem::open_mode_write_new, p_abort);
filesystem::g_open(p_image, wname.c_str(), filesystem::open_mode_write_new, p_abort);
p_image->write(data.get_ptr(), data.get_size(), p_abort);
}
m_mask_path = wname;
m_mask_path = wname.c_str();
}
} break;
default:
Expand Down Expand Up @@ -283,7 +273,7 @@ void ButtonsToolbar::Button::CustomImage::write_to_file(stream_writer& p_file, b
filesystem::g_get_canonical_path(realPath, canPath);
filesystem::g_open(p_image, canPath, filesystem::open_mode_read, p_abort);

pfc::string_filename_ext name(m_path);
const auto name = pfc::string_filename_ext(m_path);

t_filesize imagesize = p_image->get_size(p_abort);

Expand Down Expand Up @@ -321,7 +311,7 @@ void ButtonsToolbar::Button::CustomImage::write_to_file(stream_writer& p_file, b
service_ptr_t<file> p_image;
filesystem::g_open(p_image, m_mask_path, filesystem::open_mode_read, p_abort);

pfc::string_filename_ext name(m_mask_path);
const auto name = pfc::string_filename_ext(m_mask_path);

t_filesize imagesize = p_image->get_size(p_abort);

Expand Down
10 changes: 5 additions & 5 deletions foo_ui_columns/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void FilterPanel::notify_update_item_data(t_size index)
auto& subitems = get_item_subitems(index);
subitems.resize(1);

subitems[0] = pfc::stringcvt::string_utf8_from_wide(m_nodes[index].m_value);
subitems[0] = pfc::stringcvt::string_utf8_from_wide(m_nodes[index].m_value.c_str());
}

t_size FilterPanel::get_highlight_item()
Expand Down Expand Up @@ -565,7 +565,7 @@ void FilterPanel::do_items_action(const pfc::bit_array& p_nodes, Action action)
if (p_nodes[i]) {
if (playlist_name.get_length())
playlist_name << ", ";
playlist_name << pfc::stringcvt::string_utf8_from_wide(m_nodes[i].m_value);
playlist_name << pfc::stringcvt::string_utf8_from_wide(m_nodes[i].m_value.c_str());
}
}
}
Expand Down Expand Up @@ -677,7 +677,7 @@ void FilterPanel::update_first_node_text(bool b_update)
temp << "s";
temp << ")";
}
m_nodes[0].m_value.set_string(pfc::stringcvt::string_wide_from_utf8(temp));
m_nodes[0].m_value = pfc::stringcvt::string_wide_from_utf8(temp).get_ptr();
if (b_update)
update_items(0, 1);
}
Expand Down Expand Up @@ -723,12 +723,12 @@ void Node::remove_handles(metadb_handle_list_cref to_remove)

int Node::g_compare(const Node& i1, const WCHAR* i2)
{
return StrCmpLogicalW(i1.m_value, i2);
return StrCmpLogicalW(i1.m_value.c_str(), i2);
}

int Node::g_compare_ptr_with_node(const Node& i1, const Node& i2)
{
return StrCmpLogicalW(i1.m_value, i2.m_value);
return StrCmpLogicalW(i1.m_value.c_str(), i2.m_value.c_str());
}

void FilterPanel::refresh_stream()
Expand Down
2 changes: 1 addition & 1 deletion foo_ui_columns/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Field {
class Node {
public:
metadb_handle_list_t<pfc::alloc_fast_aggressive> m_handles;
pfc::string_simple_t<WCHAR> m_value;
std::wstring m_value;
bool m_handles_sorted{false};

void ensure_handles_sorted();
Expand Down
2 changes: 1 addition & 1 deletion foo_ui_columns/filter_inline_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bool FilterPanel::notify_create_inline_edit(const pfc::list_base_const_t<t_size>

m_edit_fields = m_field_data.m_fields;

p_text = (m_edit_previous_value = pfc::stringcvt::string_utf8_from_wide(m_nodes[indices[0]].m_value));
p_text = (m_edit_previous_value = pfc::stringcvt::string_utf8_from_wide(m_nodes[indices[0]].m_value.c_str()));

return true;
}
Expand Down
Loading

0 comments on commit c750743

Please sign in to comment.