-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add contrib ports mechanism (#21244)
- Loading branch information
Showing
13 changed files
with
186 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.. _Contrib-Ports: | ||
|
||
======================== | ||
Emscripten Contrib Ports | ||
======================== | ||
|
||
Contrib ports are contributed by the wider community and | ||
supported on a "best effort" basis. Since they are not run as part | ||
of emscripten CI they are not always guaranteed to build or function. | ||
|
||
The following is the complete list of the contrib ports that are | ||
available in emscripten. In order to use a contrib port you use the | ||
``--use-port=<port_name>`` option (:ref:`emcc <emcc-use-port>`). | ||
|
||
.. _contrib.glfw3: | ||
|
||
contrib.glfw3 | ||
============= | ||
|
||
This project is an emscripten port of glfw written in C++ for the web/webassembly platform | ||
|
||
`Project information <https://github.com/pongasoft/emscripten-glfw>`_ | ||
|
||
License: Apache 2.0 license |
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,25 @@ | ||
/* | ||
* Copyright 2024 The Emscripten Authors. All rights reserved. | ||
* Emscripten is available under two separate licenses, the MIT license and the | ||
* University of Illinois/NCSA Open Source License. Both these licenses can be | ||
* found in the LICENSE file. | ||
*/ | ||
|
||
#include <GLFW/glfw3.h> | ||
#include <GLFW/emscripten_glfw3.h> | ||
#include <assert.h> | ||
|
||
// cpp otherwise it fails to link | ||
int main() { | ||
|
||
assert(glfwInit() == GLFW_TRUE); | ||
|
||
GLFWwindow* window = glfwCreateWindow(320, 200, "test_glfw3_port", 0, 0); | ||
assert(window != 0); | ||
// this call ensures that it uses the right port | ||
assert(emscripten_glfw_is_window_fullscreen(window) == EM_FALSE); | ||
glfwTerminate(); | ||
|
||
|
||
return 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
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,19 @@ | ||
Emscripten "Contrib" Ports | ||
========================== | ||
|
||
Ports in this directory are contributed by the wider community and are | ||
supported on a "best effort" basis. Since they are not run as part of | ||
emscripten CI they are not always guaranteed to build or function. | ||
|
||
If you want to add a contrib port, please use another contrib port as | ||
an example. In particular, each contrib port must provide 3 extra piece | ||
of information: | ||
|
||
* `URL`: the url where the user can find more information about | ||
the project/port | ||
* `DESCRIPTION`: a (short) description of what the project/port | ||
is about | ||
* `LICENSE`: the license used by the project/port | ||
|
||
After adding a contrib port, you should consider modifying the documentation | ||
under `site/source/docs/compiling/Contrib-Ports.rst`. |
Empty file.
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,54 @@ | ||
# Copyright 2024 The Emscripten Authors. All rights reserved. | ||
# Emscripten is available under two separate licenses, the MIT license and the | ||
# University of Illinois/NCSA Open Source License. Both these licenses can be | ||
# found in the LICENSE file. | ||
|
||
import os | ||
|
||
TAG = '1.0.4' | ||
HASH = 'c3c96718e5d2b37df434a46c4a93ddfd9a768330d33f0d6ce2d08c139752894c2421cdd0fefb800fe41fafc2bbe58c8f22b8aa2849dc4fc6dde686037215cfad' | ||
|
||
# contrib port information (required) | ||
URL = 'https://github.com/pongasoft/emscripten-glfw' | ||
DESCRIPTION = 'This project is an emscripten port of glfw written in C++ for the web/webassembly platform' | ||
LICENSE = 'Apache 2.0 license' | ||
|
||
|
||
def get_lib_name(settings): | ||
return 'lib_contrib.glfw3.a' | ||
|
||
|
||
def get(ports, settings, shared): | ||
# get the port | ||
ports.fetch_project('contrib.glfw3', f'https://github.com/pongasoft/emscripten-glfw/releases/download/v{TAG}/emscripten-glfw3-{TAG}.zip', sha512hash=HASH) | ||
|
||
def create(final): | ||
root_path = os.path.join(ports.get_dir(), 'contrib.glfw3') | ||
source_path = os.path.join(root_path, 'src', 'cpp') | ||
source_include_paths = [os.path.join(root_path, 'external', 'GLFW'), os.path.join(root_path, 'include', 'GLFW')] | ||
for source_include_path in source_include_paths: | ||
ports.install_headers(source_include_path, target='GLFW') | ||
|
||
# this should be an option but better to disable for now... | ||
flags = ['-DEMSCRIPTEN_GLFW3_DISABLE_WARNING'] | ||
|
||
ports.build_port(source_path, final, 'contrib.glfw3', includes=source_include_paths, flags=flags) | ||
|
||
return [shared.cache.get_lib(get_lib_name(settings), create, what='port')] | ||
|
||
|
||
def clear(ports, settings, shared): | ||
shared.cache.erase_lib(get_lib_name(settings)) | ||
|
||
|
||
def linker_setup(ports, settings): | ||
root_path = os.path.join(ports.get_dir(), 'contrib.glfw3') | ||
source_js_path = os.path.join(root_path, 'src', 'js', 'lib_emscripten_glfw3.js') | ||
settings.JS_LIBRARIES += [source_js_path] | ||
|
||
|
||
# Using contrib.glfw3 to avoid installing headers into top level include path | ||
# so that we don't conflict with the builtin GLFW headers that emscripten | ||
# includes | ||
def process_args(ports): | ||
return ['-isystem', ports.get_include_dir('contrib.glfw3')] |