Skip to content

Commit

Permalink
(#7410) [corrade] Build using emsdk
Browse files Browse the repository at this point in the history
  • Loading branch information
jgsogo authored Sep 28, 2021
1 parent 2139780 commit a2bb060
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
7 changes: 7 additions & 0 deletions recipes/corrade/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ sources:
"2019.10":
sha256: 19dbf3c0b28a06a7017d627ee7b84c23b994c469198c1134a8aeba9cfbff7ec3
url: https://github.com/mosra/corrade/archive/v2019.10.tar.gz
patches:
"2020.06":
- base_path: "source_subfolder"
patch_file: "patches/2020.06/0001-emscripten-toolchain.patch"
# patch_type: "portability"
# description: "Remove unnecessary dependency on UseEmscripten"
# source: "https://github.com/mosra/corrade/issues/104"
5 changes: 4 additions & 1 deletion recipes/corrade/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CorradeConan(ConanFile):
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://magnum.graphics/corrade"
license = "MIT"
exports_sources = ["CMakeLists.txt", "cmake/*"]
exports_sources = ["CMakeLists.txt", "cmake/*", "patches/*"]
generators = "cmake"
short_paths = True
_cmake = None
Expand Down Expand Up @@ -92,6 +92,9 @@ def _configure_cmake(self):
return self._cmake

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)

cmake = self._configure_cmake()
cmake.build()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0cc288..81e919e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -223,9 +223,6 @@ if(TESTSUITE_TARGET_XCTEST)
endif()

include(UseCorrade)
-if(CORRADE_TARGET_EMSCRIPTEN)
- include(UseEmscripten)
-endif()

# Installation paths
include(CorradeLibSuffix)
diff --git a/modules/UseCorrade.cmake b/modules/UseCorrade.cmake
index 8276c71..d0800a0 100644
--- a/modules/UseCorrade.cmake
+++ b/modules/UseCorrade.cmake
@@ -319,11 +319,6 @@ if(CORRADE_TESTSUITE_TARGET_XCTEST)
endif()
endif()

-if(CORRADE_TARGET_EMSCRIPTEN)
- # For bundling files to the tests
- include(UseEmscripten)
-endif()
-
if(CORRADE_TARGET_IOS AND NOT CORRADE_TESTSUITE_TARGET_XCTEST)
set(CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX ${PROJECT_NAME} CACHE STRING
"Bundle identifier prefix for tests ran on iOS device")
@@ -434,7 +429,17 @@ function(corrade_add_test test_name)
string(REGEX REPLACE ${_corrade_file_pair_match} "${_corrade_file_pair_replace}" file_pair ${file})
list(GET file_pair 0 input_filename)
list(GET file_pair 1 output_filename)
- emscripten_embed_file(${test_name} ${input_filename} "/${output_filename}")
+
+ # This is a verbatim copy of emscripten_embed_file() from
+ # UseEmscripten inside the toolchains submodule. It's not
+ # included in order to avoid a dependency on the toolchains and
+ # thus allow 3rd party toolchains to be used instead.
+ get_filename_component(absolute_file ${input_filename} ABSOLUTE)
+ get_target_property(${test_name}_LINK_FLAGS ${test_name} LINK_FLAGS)
+ if(NOT ${test_name}_LINK_FLAGS)
+ set(${test_name}_LINK_FLAGS )
+ endif()
+ set_target_properties(${test_name} PROPERTIES LINK_FLAGS "${${test_name}_LINK_FLAGS} --embed-file ${absolute_file}@/${output_filename}")
endforeach()

# Generate the runner file, first replacing ${test_name} with
4 changes: 4 additions & 0 deletions recipes/corrade/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ def test(self):
if self.options["corrade"].with_utility:
# Run corrade-rc
self.run("corrade-rc --help", run_environment=True)

if self.settings.os == "Emscripten":
bin_path = os.path.join("bin", "test_package.js")
self.run("node {}".format(bin_path), run_environment=True)

0 comments on commit a2bb060

Please sign in to comment.