This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from hunter-packages/pr.resdir
Add GAUZE_RESOUCE_DIR
- Loading branch information
Showing
14 changed files
with
259 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,40 @@ | ||
Directory | ||
--------- | ||
|
||
To copy directory with resources use ``$<GAUZE_RESOURCE_DIR:...>``: | ||
|
||
.. literalinclude:: /../test/gauze/directory/CMakeLists.txt | ||
:language: cmake | ||
:emphasize-lines: 16 | ||
|
||
Read files in directory: | ||
|
||
.. literalinclude:: /../test/gauze/directory/main.cpp | ||
:language: cpp | ||
:emphasize-lines: 28, 39 | ||
|
||
Running this test on Android device: | ||
|
||
.. code-block:: none | ||
:emphasize-lines: 1, 9, 11-16 | ||
> ctest -VV -R gauze_directory | ||
4: Command output (with exit code): | ||
4: *** BEGIN *** | ||
4: argc = 6 | ||
4: argv[0] = /data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon/bin/gauze_directory | ||
4: argv[1] = arg1 | ||
4: argv[2] = arg2 | ||
4: argv[3] = arg3 | ||
4: argv[4] = /data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon/data/resdir | ||
4: argv[5] = /.../gauze/test/gauze/directory/resdir/just_a_string.txt | ||
4: Processing file: "/data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon/data/resdir/file.0" | ||
4: Content: 'Content 0' | ||
4: Processing file: "/data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon/data/resdir/file.1" | ||
4: Content: 'Content 1' | ||
4: Processing file: "/data/local/tmp/gauze/android-ndk-r10e-api-19-armeabi-v7a-neon/data/resdir/file.2" | ||
4: Content: 'Content 2' | ||
4: 0 | ||
4: *** END *** | ||
4: Done | ||
1/1 Test #4: gauze_directory .................. Passed 0.54 sec |
This file contains 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 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 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
add_subdirectory(simple) | ||
add_subdirectory(args) | ||
add_subdirectory(resource) | ||
add_subdirectory(directory) | ||
add_subdirectory(deplib) # before 'deps' | ||
add_subdirectory(deps) | ||
add_subdirectory(gtest) |
This file contains 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,18 @@ | ||
hunter_add_package(Boost COMPONENTS filesystem system) | ||
find_package(Boost REQUIRED COMPONENTS filesystem system) | ||
|
||
add_executable(gauze_directory main.cpp) | ||
target_link_libraries(gauze_directory PRIVATE Boost::filesystem Boost::system) | ||
|
||
set(data_dir "${CMAKE_CURRENT_LIST_DIR}/resdir") | ||
|
||
gauze_add_test( | ||
NAME gauze_directory | ||
COMMAND | ||
gauze_directory | ||
arg1 | ||
arg2 | ||
arg3 | ||
$<GAUZE_RESOURCE_DIR:${data_dir}> | ||
${data_dir}/just_a_string.txt | ||
) |
This file contains 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,43 @@ | ||
#include <cstdlib> // EXIT_SUCCESS | ||
#include <fstream> // std::ifstream | ||
#include <iostream> // std::cout | ||
#include <string> // std::getline | ||
#include <boost/filesystem.hpp> | ||
#include <sstream> // std::ostringstream | ||
|
||
int gauze_main(int argc, char** argv) { | ||
std::cout << "argc = " << argc << std::endl; | ||
for (int i=0; i<argc; ++i) { | ||
std::cout << "argv[" << i << "] = " << argv[i] << std::endl; | ||
} | ||
|
||
if(argc < 6) { | ||
std::cerr << "Unexpected number of arguments: " << argc << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
boost::filesystem::path resdir(argv[4]); | ||
|
||
for (int i=0; i<3; ++i) { | ||
std::ostringstream file_name; | ||
file_name << "file." << i; | ||
|
||
boost::filesystem::path file_path(resdir); | ||
file_path /= file_name.str(); | ||
|
||
std::cout << "Processing file: " << file_path << std::endl; | ||
std::ifstream file(file_path.string()); | ||
|
||
std::string content; | ||
std::getline(file, content); | ||
|
||
if(!file) { | ||
std::cerr << "Can't read file: " << file_path << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
std::cout << "Content: '" << content << "'" << std::endl; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains 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 @@ | ||
Content 0 |
This file contains 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 @@ | ||
Content 1 |
This file contains 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 @@ | ||
Content 2 |