Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emscripten wasm side module library #548

Open
wants to merge 1 commit into
base: libpng16
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,24 @@ if(PNG_SHARED AND PNG_TOOLS)
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
endif()

if(EMSCRIPTEN)
set(LIBPNG_WASM_SOURCES
${pngfix_sources}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an actual review comment, but rather, a question:

Is pngfix needed for the Emscripten build?

I just pushed a new commit, see aa95dee. I'm still building the third-party contributed tools for now, if only not to break the downstream package maintainers' workflows. However, I want to decouple those tools from the main library build, including pngfix, eventually. They should be built independently from libpng, in a manner that allows us to verify the correctness of a libpng installation.

One thing that you may or may not want to consider is adding EMSCRIPTEN besides ANDROID and IOS at line 72:

if (ANDROID OR IOS)

)
add_executable(libpng_wasm
${LIBPNG_WASM_SOURCES}
)
target_include_directories(libpng_wasm PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(libpng_wasm ${ZLIB_LIBRARIES} ${M_LIBRARY})
set_target_properties(libpng_wasm PROPERTIES COMPILE_FLAGS "-Os -fPIC -s SIDE_MODULE=1 ")
set_target_properties(libpng_wasm PROPERTIES LINK_FLAGS "-Os -fPIC -s WASM=1 -s SIDE_MODULE=1 -s STANDALONE_WASM --no-entry")
set(CMAKE_EXECUTABLE_SUFFIX ".wasm")
list(APPEND PNG_BIN_TARGETS libpng_wasm)
endif()


# Create a symlink from src to dest (if possible), or, alternatively,
# copy src to dest if different.
function(create_symlink DEST_FILE)
Expand Down