17
17
import os
18
18
from typing import Union , Dict
19
19
20
- TAG = '3.4.0.20240907 '
21
- HASH = '48aba179ef50b5efd564535cd549528d06f74d18f7028a06212fccc425b784106b0efb3aa7bf72da6fb80c32a31b410f13a87d4599417cad8dc3af15664fa1b2 '
20
+ TAG = '3.4.0.20250209 '
21
+ HASH = '4acf0fdff680952cd6d6cbf0efaaa9b6347d21049e8c119a2cbd44b2b10d36dd94d3e3b3ef2e8f5c4afe93ff23f9aad5e917d08c52df7ca12d35843a926f1f0c '
22
22
ZIP_URL = f'https://github.com/pongasoft/emscripten-glfw/releases/download/v{ TAG } /emscripten-glfw3-{ TAG } .zip'
23
23
24
24
# contrib port information (required)
27
27
LICENSE = 'Apache 2.0 license'
28
28
29
29
VALID_OPTION_VALUES = {
30
- 'disableWarning' : ['true' , 'false' ],
31
- 'disableJoystick' : ['true' , 'false' ],
32
- 'disableMultiWindow' : ['true' , 'false' ],
33
- 'optimizationLevel' : ['0' , '1' , '2' , '3' , 'g' , 's' , 'z' ] # all -OX possibilities
30
+ 'disableWarning' : ['true' , 'false' ],
31
+ 'disableJoystick' : ['true' , 'false' ],
32
+ 'disableMultiWindow' : ['true' , 'false' ],
33
+ 'disableWebGL2' : ['true' , 'false' ],
34
+ 'optimizationLevel' : ['0' , '1' , '2' , '3' , 'g' , 's' , 'z' ] # all -OX possibilities
34
35
}
35
36
36
37
OPTIONS = {
37
- 'disableWarning' : 'Boolean to disable warnings emitted by the library' ,
38
- 'disableJoystick' : 'Boolean to disable support for joystick entirely' ,
39
- 'disableMultiWindow' : 'Boolean to disable multi window support which makes the code smaller and faster' ,
40
- 'optimizationLevel' : f'Optimization level: { VALID_OPTION_VALUES ["optimizationLevel" ]} (default to 2)' ,
38
+ 'disableWarning' : 'Boolean to disable warnings emitted by the library' ,
39
+ 'disableJoystick' : 'Boolean to disable support for joystick entirely' ,
40
+ 'disableMultiWindow' : 'Boolean to disable multi window support' ,
41
+ 'disableWebGL2' : 'Boolean to disable WebGL2 support' ,
42
+ 'optimizationLevel' : f'Optimization level: { VALID_OPTION_VALUES ["optimizationLevel" ]} (default to 2)' ,
41
43
}
42
44
43
45
# user options (from --use-port)
44
46
opts : Dict [str , Union [str , bool ]] = {
45
- 'disableWarning' : False ,
46
- 'disableJoystick' : False ,
47
- 'disableMultiWindow' : False ,
48
- 'optimizationLevel' : '2'
47
+ 'disableWarning' : False ,
48
+ 'disableJoystick' : False ,
49
+ 'disableMultiWindow' : False ,
50
+ 'disableWebGL2' : False ,
51
+ 'optimizationLevel' : '2'
49
52
}
50
53
51
54
port_name = 'emscripten-glfw3'
52
55
53
56
54
57
def get_lib_name (settings ):
55
- return (f'lib_{ port_name } _{ TAG } -O{ opts ["optimizationLevel" ]} ' +
56
- ('-nw' if opts ['disableWarning' ] else '' ) +
57
- ('-nj' if opts ['disableJoystick' ] else '' ) +
58
- ('-sw' if opts ['disableMultiWindow' ] else '' ) +
59
- '.a' )
58
+ return (f'lib_{ port_name } _{ TAG } -O{ opts ["optimizationLevel" ]} ' +
59
+ ('-nw' if opts ['disableWarning' ] else '' ) +
60
+ ('-nj' if opts ['disableJoystick' ] else '' ) +
61
+ ('-sw' if opts ['disableMultiWindow' ] else '' ) +
62
+ ('-mt' if settings .PTHREADS else '' ) +
63
+ '.a' )
60
64
61
65
62
66
def get (ports , settings , shared ):
63
- # get the port
64
- ports .fetch_project (port_name , ZIP_URL , sha512hash = HASH )
67
+ # get the port
68
+ ports .fetch_project (port_name , ZIP_URL , sha512hash = HASH )
65
69
66
- def create (final ):
67
- root_path = os .path .join (ports .get_dir (), port_name )
68
- source_path = os .path .join (root_path , 'src' , 'cpp' )
69
- source_include_paths = [os .path .join (root_path , 'external' ), os .path .join (root_path , 'include' )]
70
+ def create (final ):
71
+ root_path = os .path .join (ports .get_dir (), port_name )
72
+ source_path = os .path .join (root_path , 'src' , 'cpp' )
73
+ source_include_paths = [os .path .join (root_path , 'external' ), os .path .join (root_path , 'include' )]
74
+
75
+ flags = [f'-O{ opts ["optimizationLevel" ]} ' ]
70
76
71
- flags = [f'-O{ opts ["optimizationLevel" ]} ' ]
77
+ if opts ['disableWarning' ]:
78
+ flags += ['-DEMSCRIPTEN_GLFW3_DISABLE_WARNING' ]
72
79
73
- if opts ['disableWarning ' ]:
74
- flags += ['-DEMSCRIPTEN_GLFW3_DISABLE_WARNING ' ]
80
+ if opts ['disableJoystick ' ]:
81
+ flags += ['-DEMSCRIPTEN_GLFW3_DISABLE_JOYSTICK ' ]
75
82
76
- if opts ['disableJoystick ' ]:
77
- flags += ['-DEMSCRIPTEN_GLFW3_DISABLE_JOYSTICK ' ]
83
+ if opts ['disableMultiWindow ' ]:
84
+ flags += ['-DEMSCRIPTEN_GLFW3_DISABLE_MULTI_WINDOW_SUPPORT ' ]
78
85
79
- if opts [ 'disableMultiWindow' ] :
80
- flags += ['-DEMSCRIPTEN_GLFW3_DISABLE_MULTI_WINDOW_SUPPORT ' ]
86
+ if settings . PTHREADS :
87
+ flags += ['-pthread ' ]
81
88
82
- ports .build_port (source_path , final , port_name , includes = source_include_paths , flags = flags )
89
+ ports .build_port (source_path , final , port_name , includes = source_include_paths , flags = flags )
83
90
91
+ lib = shared .cache .get_lib (get_lib_name (settings ), create , what = 'port' )
92
+ if os .path .getmtime (lib ) < os .path .getmtime (__file__ ):
93
+ clear (ports , settings , shared )
84
94
lib = shared .cache .get_lib (get_lib_name (settings ), create , what = 'port' )
85
- if os .path .getmtime (lib ) < os .path .getmtime (__file__ ):
86
- clear (ports , settings , shared )
87
- lib = shared .cache .get_lib (get_lib_name (settings ), create , what = 'port' )
88
- return [lib ]
95
+ return [lib ]
89
96
90
97
91
98
def clear (ports , settings , shared ):
92
- shared .cache .erase_lib (get_lib_name (settings ))
99
+ shared .cache .erase_lib (get_lib_name (settings ))
93
100
94
101
95
102
def linker_setup (ports , settings ):
96
- root_path = os .path .join (ports .get_dir (), port_name )
97
- source_js_path = os .path .join (root_path , 'src' , 'js' , 'lib_emscripten_glfw3.js' )
98
- settings .JS_LIBRARIES += [source_js_path ]
103
+ root_path = os .path .join (ports .get_dir (), port_name )
104
+ source_js_path = os .path .join (root_path , 'src' , 'js' , 'lib_emscripten_glfw3.js' )
105
+ settings .JS_LIBRARIES += [source_js_path ]
106
+ if not opts ['disableWebGL2' ]:
107
+ settings .MAX_WEBGL_VERSION = 2
99
108
100
109
101
110
# Makes GLFW includes accessible without installing them (ex: #include <GLFW/glfw3.h>)
@@ -110,13 +119,13 @@ def process_args(ports):
110
119
111
120
112
121
def check_option (option , value , error_handler ):
113
- if value not in VALID_OPTION_VALUES [option ]:
114
- error_handler (f'[{ option } ] can be { list (VALID_OPTION_VALUES [option ])} , got [{ value } ]' )
115
- if isinstance (opts [option ], bool ):
116
- value = value == 'true'
117
- return value
122
+ if value not in VALID_OPTION_VALUES [option ]:
123
+ error_handler (f'[{ option } ] can be { list (VALID_OPTION_VALUES [option ])} , got [{ value } ]' )
124
+ if isinstance (opts [option ], bool ):
125
+ value = value == 'true'
126
+ return value
118
127
119
128
120
129
def handle_options (options , error_handler ):
121
- for option , value in options .items ():
122
- opts [option ] = check_option (option , value .lower (), error_handler )
130
+ for option , value in options .items ():
131
+ opts [option ] = check_option (option , value .lower (), error_handler )
0 commit comments