mirror of
https://github.com/mhx/dwarfs.git
synced 2025-08-04 02:06:22 -04:00
Symbolic links for the universal binary also work on Windows
This commit is contained in:
parent
b978b954e0
commit
89571de0f3
23
README.md
23
README.md
@ -128,24 +128,33 @@ FUSE driver) in a single executable. These executables are compressed
|
||||
using [upx](https://github.com/upx/upx), so they are much smaller than
|
||||
the individual tools combined.
|
||||
|
||||
The universal binaries can be run either through symbolic links named
|
||||
after the proper tool. e.g.:
|
||||
The universal binaries can be run through symbolic links named after
|
||||
the proper tool. e.g.:
|
||||
|
||||
```
|
||||
$ ln -s dwarfs-universal-0.7.0-RC5-Linux-aarch64 mkdwarfs
|
||||
$ ln -s dwarfs-universal-0.7.0-Linux-aarch64 mkdwarfs
|
||||
$ ./mkdwarfs --help
|
||||
```
|
||||
|
||||
Or you can select the tool by passing `--tool=<name>` as the first
|
||||
argument on the command line:
|
||||
This also works on Windows ift the file system supports symbolic links:
|
||||
|
||||
```
|
||||
$ .\dwarfs-universal-0.7.0-RC5-Windows-AMD64.exe --tool=mkdwarfs --help
|
||||
> mklink mkdwarfs.exe dwarfs-universal-0.7.0-Windows-AMD64.exe
|
||||
> .\mkdwarfs.exe --help
|
||||
```
|
||||
|
||||
Alternatively, you can select the tool by passing `--tool=<name>` as
|
||||
the first argument on the command line:
|
||||
|
||||
```
|
||||
> .\dwarfs-universal-0.7.0-Windows-AMD64.exe --tool=mkdwarfs --help
|
||||
```
|
||||
|
||||
Note that just like the `dwarfs.exe` Windows binary, the universal
|
||||
Windows binary depends on the `winfsp-x64.dll` from the
|
||||
[WinFsp](https://github.com/winfsp/winfsp) project.
|
||||
[WinFsp](https://github.com/winfsp/winfsp) project. However, for the
|
||||
universal binary, the DLL is loaded lazily, so you can still use all
|
||||
other tools without the DLL.
|
||||
See the [Windows Support](#windows-support) section for more details.
|
||||
|
||||
### Dependencies
|
||||
|
@ -87,6 +87,12 @@ int dwarfs_main_helper(int argc, sys_char** argv) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define EXE_EXT ".exe"
|
||||
#else
|
||||
#define EXE_EXT ""
|
||||
#endif
|
||||
|
||||
std::map<std::string_view, int (*)(int, sys_char**)> const functions{
|
||||
#ifdef _WIN32
|
||||
{"dwarfs", &dwarfs_main_helper},
|
||||
@ -120,14 +126,13 @@ int SYS_MAIN(int argc, sys_char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
auto path = std::filesystem::path(argv[0]);
|
||||
|
||||
if (auto it = functions.find(path.filename().string());
|
||||
it != functions.end()) {
|
||||
if (path.extension().string() == EXE_EXT) {
|
||||
if (auto it = functions.find(path.stem().string()); it != functions.end()) {
|
||||
return safe_main([&] { return it->second(argc, argv); });
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
using namespace folly::gen;
|
||||
|
||||
|
@ -589,9 +589,7 @@ enum class binary_mode {
|
||||
std::vector<binary_mode> tools_test_modes{
|
||||
binary_mode::standalone,
|
||||
binary_mode::universal_tool,
|
||||
#ifndef _WIN32
|
||||
binary_mode::universal_symlink,
|
||||
#endif
|
||||
};
|
||||
|
||||
class tools_test : public ::testing::TestWithParam<binary_mode> {};
|
||||
@ -608,10 +606,10 @@ TEST_P(tools_test, end_to_end) {
|
||||
auto image_hdr = td / "test_hdr.dwarfs";
|
||||
auto fsdata_dir = td / "fsdata";
|
||||
auto header_data = fsdata_dir / "format.sh";
|
||||
auto universal_symlink_dwarfs_bin = td / "dwarfs";
|
||||
auto universal_symlink_mkdwarfs_bin = td / "mkdwarfs";
|
||||
auto universal_symlink_dwarfsck_bin = td / "dwarfsck";
|
||||
auto universal_symlink_dwarfsextract_bin = td / "dwarfsextract";
|
||||
auto universal_symlink_dwarfs_bin = td / "dwarfs" EXE_EXT;
|
||||
auto universal_symlink_mkdwarfs_bin = td / "mkdwarfs" EXE_EXT;
|
||||
auto universal_symlink_dwarfsck_bin = td / "dwarfsck" EXE_EXT;
|
||||
auto universal_symlink_dwarfsextract_bin = td / "dwarfsextract" EXE_EXT;
|
||||
std::vector<std::string> mkdwarfs_tool_arg;
|
||||
std::vector<std::string> dwarfsck_tool_arg;
|
||||
std::vector<std::string> dwarfsextract_tool_arg;
|
||||
@ -897,7 +895,7 @@ TEST_P(tools_test, mutating_ops) {
|
||||
auto non_empty_dir = mountpoint / "foo";
|
||||
auto name_inside_fs = mountpoint / "some_random_name";
|
||||
auto name_outside_fs = td / "some_random_name";
|
||||
auto universal_symlink_dwarfs_bin = td / "dwarfs";
|
||||
auto universal_symlink_dwarfs_bin = td / "dwarfs" EXE_EXT;
|
||||
|
||||
if (mode == binary_mode::universal_symlink) {
|
||||
fs::create_symlink(universal_bin, universal_symlink_dwarfs_bin);
|
||||
|
Loading…
x
Reference in New Issue
Block a user