aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource')
-rw-r--r--vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/portfile.cmake4
-rw-r--r--vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/project/CMakeLists.txt45
-rw-r--r--vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/project/main.cpp58
-rw-r--r--vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/vcpkg.json13
4 files changed, 120 insertions, 0 deletions
diff --git a/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/portfile.cmake b/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/portfile.cmake
new file mode 100644
index 0000000..bc78596
--- /dev/null
+++ b/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/portfile.cmake
@@ -0,0 +1,4 @@
+set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
+
+vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}/project")
+vcpkg_cmake_build()
diff --git a/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/project/CMakeLists.txt b/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/project/CMakeLists.txt
new file mode 100644
index 0000000..8bbcf70
--- /dev/null
+++ b/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/project/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.12)
+
+project(embedresource-test VERSION 0.0.1)
+
+set(CMAKE_CXX_STANDARD 17)
+
+find_package(EmbedResource REQUIRED)
+
+file(SIZE "${CMAKE_CURRENT_LIST_DIR}/main.cpp" MAIN_CPP_FILE_SIZE)
+file(SIZE "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" CMAKELISTS_TXT_FILE_SIZE)
+
+add_resource_library(sample_test_resources OBJECT RESOURCE_COLLECTION_NAME testdata1 RESOURCES main.cpp GENERATOR_COMMAND echo "CMakeLists.txt" GENERATOR_DEPEND CMakeLists.txt)
+add_resource_library(testdata3 OBJECT RESOURCES main.cpp)
+
+macro(setup_target target)
+ target_add_resource(${target} RESOURCE_COLLECTION_NAME testdata2 RESOURCES main.cpp)
+ get_target_property(type ${target} TYPE)
+ if ("${type}" STREQUAL "STATIC_LIBRARY")
+ target_link_libraries(${target} PRIVATE $<BUILD_INTERFACE:sample_test_resources> $<BUILD_INTERFACE:testdata3>)
+ else()
+ target_link_libraries(${target} PRIVATE sample_test_resources testdata3)
+ endif()
+
+ target_compile_definitions(${target} PRIVATE MAIN_CPP_FILE_SIZE=${MAIN_CPP_FILE_SIZE})
+ target_compile_definitions(${target} PRIVATE CMAKELISTS_TXT_FILE_SIZE=${CMAKELISTS_TXT_FILE_SIZE})
+endmacro()
+
+add_executable(sample_test_exe main.cpp)
+setup_target(sample_test_exe)
+
+add_library(sample_test_shlib SHARED main.cpp)
+target_compile_features(sample_test_shlib PRIVATE cxx_std_20)
+setup_target(sample_test_shlib)
+
+add_library(sample_test_lib STATIC main.cpp)
+setup_target(sample_test_lib)
+
+install(TARGETS sample_test_shlib EXPORT sample_test_shlib)
+install(EXPORT sample_test_shlib FILE sampleTargets.cmake DESTINATION cmake)
+
+install(TARGETS sample_test_lib EXPORT sample_test_lib)
+install(EXPORT sample_test_lib FILE sampleTargets.cmake DESTINATION cmake)
+
+enable_testing()
+add_test(NAME sample_test_exe COMMAND sample_test_exe)
diff --git a/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/project/main.cpp b/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/project/main.cpp
new file mode 100644
index 0000000..39d7a83
--- /dev/null
+++ b/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/project/main.cpp
@@ -0,0 +1,58 @@
+#include <EmbeddedResource.h>
+#include <exception>
+#include <iostream>
+#include <stdexcept>
+#include <string_view>
+
+DECLARE_RESOURCE_COLLECTION(testdata1);
+DECLARE_RESOURCE_COLLECTION(testdata2);
+DECLARE_RESOURCE_COLLECTION(testdata3);
+DECLARE_RESOURCE(testdata3, main_cpp);
+
+void verify_resource(ResourceLoader const& r)
+{
+ if (r.name() == L"main.cpp")
+ {
+#ifdef __cpp_lib_span
+ if (r.template data<uint8_t>().size() != MAIN_CPP_FILE_SIZE) { throw std::runtime_error("r.data.len() != MAIN_CPP_FILE_SIZE"); }
+#endif
+#ifdef __cpp_lib_string_view
+ if (r.string().size() != MAIN_CPP_FILE_SIZE) { throw std::runtime_error("r.string().size() != MAIN_CPP_FILE_SIZE"); }
+#endif
+ }
+ else if (r.name() == L"CMakeLists.txt")
+ {
+#ifdef __cpp_lib_span
+ if (r.template data<uint8_t>().size() != CMAKELISTS_TXT_FILE_SIZE)
+ {
+ throw std::runtime_error("r.data.len() != CMAKELISTS_TXT_FILE_SIZE");
+ }
+#endif
+#ifdef __cpp_lib_string_view
+ if (r.string().size() != CMAKELISTS_TXT_FILE_SIZE) { throw std::runtime_error("r.string().size() != CMAKELISTS_TXT_FILE_SIZE"); }
+#endif
+ }
+ else { throw std::runtime_error("Unknown resource name"); }
+}
+
+int main(int argc, char* argv[])
+try
+{
+ std::string_view res = LOAD_RESOURCE(testdata3, main_cpp).data;
+ if (res.size() != MAIN_CPP_FILE_SIZE) { throw std::runtime_error("r.data.len() != MAIN_CPP_FILE_SIZE"); }
+
+ auto resourceCollection1 = LOAD_RESOURCE_COLLECTION(testdata1);
+ for (auto const r : resourceCollection1) { verify_resource(r); }
+
+ auto resourceCollection2 = LOAD_RESOURCE_COLLECTION(testdata2);
+ for (auto const r : resourceCollection2) { verify_resource(r); }
+
+ auto resourceCollection3 = LOAD_RESOURCE_COLLECTION(testdata3);
+ for (auto const r : resourceCollection2) { verify_resource(r); }
+
+ return 0;
+} catch (const std::exception& ex)
+{
+ std::cerr << "Failed: " << ex.what() << std::endl;
+ return -1;
+} \ No newline at end of file
diff --git a/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/vcpkg.json b/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/vcpkg.json
new file mode 100644
index 0000000..a8267bb
--- /dev/null
+++ b/vcpkg/scripts/test_ports/vcpkg-ci-ankurvdev-embedresource/vcpkg.json
@@ -0,0 +1,13 @@
+{
+ "name": "vcpkg-ci-ankurvdev-embedresource",
+ "version-string": "ci",
+ "description": "Validates ankurvdev-embedresource",
+ "license": "BSD-3-Clause",
+ "dependencies": [
+ "ankurvdev-embedresource",
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ }
+ ]
+}