aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-11-16 23:46:25 +0200
committerJukka Jylänki <jujjyl@gmail.com>2013-11-17 22:06:03 +0200
commit1ee42ca288ac5def839833013ae0795b666953f3 (patch)
tree99b2e402033fb08b4f2f21f2e65c2efb05a0e2fb /tests
parentba1d21daa8812d3b5216df538e7c1a0b180bef00 (diff)
Fix browser.test_freealut on Windows by implementing a CMake build path for that library.
Diffstat (limited to 'tests')
-rw-r--r--tests/freealut/CMakeLists.txt55
-rw-r--r--tests/test_browser.py8
2 files changed, 48 insertions, 15 deletions
diff --git a/tests/freealut/CMakeLists.txt b/tests/freealut/CMakeLists.txt
index 640f35bf..c11680cd 100644
--- a/tests/freealut/CMakeLists.txt
+++ b/tests/freealut/CMakeLists.txt
@@ -72,20 +72,39 @@ ADD_DEFINE("__NO_CTYPE 1")
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
ADD_DEFINITIONS(-DNDEBUG)
-FIND_LIBRARY(OPENAL_LIB NAMES openal openal32 PATHS /usr/lib /usr/local/lib ${OPENAL_LIB_DIR})
-IF(OPENAL_LIB MATCHES "NOTFOUND")
- MESSAGE(FATAL_ERROR "OpenAL not installed, cannot build alut - aborting.")
-ENDIF(OPENAL_LIB MATCHES "NOTFOUND")
-
-IF(UNIX)
- SET(ADD_LIBS ${ADD_LIBS} m)
-ENDIF(UNIX)
+if (EMSCRIPTEN)
+ # Emscripten cannot use FIND_LIBRARY, since that seaches for linkable library files, but Emscripten supports
+ # OpenAL in core and there are no library files to link against. Instead, use a custom OpenAL package finder
+ # provided by Emscripten.
+ FIND_PACKAGE(OpenAL)
+
+ # All the include file checks bloew are no-ops for Emscripten, so for that platform, just define the flags we support.
+ SET(HAVE_STDINT_H 1)
+ SET(HAVE_STAT 1)
+ SET(HAVE_NANOSLEEP 1)
+ SET(HAVE_TIME_H 1)
+ ADD_DEFINITIONS(-DHAVE_STDINT_H=1 -DHAVE_STAT=1 -DHAVE_NANOSLEEP=1 -DHAVE_TIME_H=1)
+ SET(CMAKE_EXECUTABLE_SUFFIX ".bc")
+else()
+ FIND_LIBRARY(OPENAL_LIB NAMES openal openal32 PATHS /usr/lib /usr/local/lib ${OPENAL_LIB_DIR})
+
+ IF(OPENAL_LIB MATCHES "NOTFOUND")
+ MESSAGE(FATAL_ERROR "OpenAL not installed, cannot build alut - aborting.")
+ ENDIF(OPENAL_LIB MATCHES "NOTFOUND")
+
+ IF(UNIX)
+ SET(ADD_LIBS ${ADD_LIBS} m)
+ ENDIF(UNIX)
+endif()
SET(CMAKE_REQUIRED_INCLUDES ${OPENAL_INCLUDE_DIR})
-CHECK_INCLUDE_FILES("AL/alc.h;AL/al.h" AL_HEADERS)
-IF(NOT AL_HEADERS)
- MESSAGE(FATAL_ERROR "OpenAL header files not found - aborting.")
-ENDIF(NOT AL_HEADERS)
+
+if (NOT EMSCRIPTEN) # Emscripten is a cross-compiler and cannot verify paths of include files with CHECK_INCLUDE_FILES, since that requires building native executables.
+ CHECK_INCLUDE_FILES("AL/alc.h;AL/al.h" AL_HEADERS)
+ IF(NOT AL_HEADERS)
+ MESSAGE(FATAL_ERROR "OpenAL header files not found - aborting.")
+ ENDIF(NOT AL_HEADERS)
+endif()
IF(DEFINED OPENAL_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
@@ -178,10 +197,18 @@ INSTALL_FILES(/lib/pkgconfig FILES admin/pkgconfig/freealut.pc)
IF(BUILD_TESTS)
# examples
ADD_EXECUTABLE(hello_world examples/hello_world.c)
- TARGET_LINK_LIBRARIES(hello_world ${OPENAL_LIB} ${ADD_LIBS} alut)
+ if (EMSCRIPTEN)
+ TARGET_LINK_LIBRARIES(hello_world ${OPENAL_LIB} ${ADD_LIBS} alut_static)
+ else()
+ TARGET_LINK_LIBRARIES(hello_world ${OPENAL_LIB} ${ADD_LIBS} alut)
+ endif()
ADD_EXECUTABLE(playfile examples/playfile.c)
- TARGET_LINK_LIBRARIES(playfile ${OPENAL_LIB} ${ADD_LIBS} alut)
+ if (EMSCRIPTEN)
+ TARGET_LINK_LIBRARIES(playfile ${OPENAL_LIB} ${ADD_LIBS} alut_static)
+ else()
+ TARGET_LINK_LIBRARIES(playfile ${OPENAL_LIB} ${ADD_LIBS} alut)
+ endif()
SET(TESTS errorstuff
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 3ad2087e..12a08fe3 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -1162,8 +1162,14 @@ keydown(100);keyup(100); // trigger the end
Popen([PYTHON, EMCC, '-O2', os.path.join(self.get_dir(), 'test_egl_width_height.c'), '-o', 'page.html']).communicate()
self.run_browser('page.html', 'Should print "(300, 150)" -- the size of the canvas in pixels', '/report_result?1')
+ def get_freealut_library(self):
+ if WINDOWS and Building.which('cmake'):
+ return self.get_library('freealut', os.path.join('hello_world.bc'), configure=['cmake', '.'], configure_args=['-DBUILD_TESTS=ON'])
+ else:
+ return self.get_library('freealut', os.path.join('examples', '.libs', 'hello_world.bc'), make_args=['EXEEXT=.bc'])
+
def test_freealut(self):
- programs = self.get_library('freealut', os.path.join('examples', '.libs', 'hello_world.bc'), make_args=['EXEEXT=.bc'])
+ programs = self.get_freealut_library()
for program in programs:
assert os.path.exists(program)
Popen([PYTHON, EMCC, '-O2', program, '-o', 'page.html']).communicate()