Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Olm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
Olm
Commits
602c00a8
Commit
602c00a8
authored
6 years ago
by
David Baker
Browse files
Options
Downloads
Patches
Plain Diff
Dual-build wasm and asm.js olm
parent
00384ba8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+23
-5
23 additions, 5 deletions
Makefile
javascript/olm_post.js
+0
-9
0 additions, 9 deletions
javascript/olm_post.js
javascript/olm_pre.js
+9
-0
9 additions, 0 deletions
javascript/olm_pre.js
javascript/olm_suffix.js
+6
-4
6 additions, 4 deletions
javascript/olm_suffix.js
with
38 additions
and
18 deletions
Makefile
+
23
−
5
View file @
602c00a8
...
...
@@ -17,7 +17,8 @@ AR = ar
RELEASE_TARGET
:=
$(
BUILD_DIR
)
/libolm.so.
$(
VERSION
)
STATIC_RELEASE_TARGET
:=
$(
BUILD_DIR
)
/libolm.a
DEBUG_TARGET
:=
$(
BUILD_DIR
)
/libolm_debug.so.
$(
VERSION
)
JS_TARGET
:=
javascript/olm.js
JS_WASM_TARGET
:=
javascript/olm.js
JS_ASMJS_TARGET
:=
javascript/olm_legacy.js
JS_EXPORTED_FUNCTIONS
:=
javascript/exported_functions.json
JS_EXTRA_EXPORTED_RUNTIME_METHODS
:=
ALLOC_STACK
...
...
@@ -84,8 +85,11 @@ EMCCFLAGS += -s NO_BROWSER=1
# mind that the plaintext can only be 48K because base64). We also have about
# 36K of statics. So let's have 256K of memory.
# (This can't be changed by the app with wasm since it's baked into the wasm).
EMCCFLAGS
+=
-s
TOTAL_STACK
=
65536
-s
TOTAL_MEMORY
=
262144
# (emscripten also mandates at least 16MB of memory for asm.js now, so
# we don't use this for the legacy build.)
EMCCFLAGS_WASM
+=
-s
TOTAL_STACK
=
65536
-s
TOTAL_MEMORY
=
262144
EMCCFLAGS_ASMJS
+=
-s
WASM
=
0
EMCC.c
=
$(
EMCC
)
$(
CFLAGS
)
$(
CPPFLAGS
)
-c
EMCC.cc
=
$(
EMCC
)
$(
CXXFLAGS
)
$(
CPPFLAGS
)
-c
...
...
@@ -121,7 +125,8 @@ $(FUZZER_DEBUG_BINARIES): LDFLAGS += $(DEBUG_OPTIMIZE_FLAGS)
$(JS_OBJECTS)
:
CFLAGS += $(JS_OPTIMIZE_FLAGS)
$(JS_OBJECTS)
:
CXXFLAGS += $(JS_OPTIMIZE_FLAGS)
$(JS_TARGET)
:
LDFLAGS += $(JS_OPTIMIZE_FLAGS)
$(JS_WASM_TARGET)
:
LDFLAGS += $(JS_OPTIMIZE_FLAGS)
$(JS_ASMJS_TARGET)
:
LDFLAGS += $(JS_OPTIMIZE_FLAGS)
### Fix to make mkdir work on windows and linux
ifeq
($(shell echo "check_quotes"),"check_quotes")
...
...
@@ -164,14 +169,27 @@ static: $(STATIC_RELEASE_TARGET)
$(STATIC_RELEASE_TARGET)
:
$(RELEASE_OBJECTS)
$(
AR
)
rcs
$@
$^
js
:
$(JS_TARGET)
js
:
$(JS_
WASM_TARGET) $(JS_ASMJS_
TARGET)
.PHONY
:
js
# Note that the output file we give to emcc determines the name of the
# wasm file baked into the js, hence messing around outputting to olm.js
# and then renaming it.
$(JS_TARGET)
:
$(JS_OBJECTS) $(JS_PRE) $(JS_POST) $(JS_EXPORTED_FUNCTIONS) $(JS_PREFIX) $(JS_SUFFIX)
$(JS_
WASM_
TARGET)
:
$(JS_OBJECTS) $(JS_PRE) $(JS_POST) $(JS_EXPORTED_FUNCTIONS) $(JS_PREFIX) $(JS_SUFFIX)
EMCC_CLOSURE_ARGS
=
"--externs
$(
JS_EXTERNS
)
"
$(
EMCC_LINK
)
\
$(
EMCCFLAGS_WASM
)
\
$(
foreach f,
$(
JS_PRE
)
,--pre-js
$(
f
))
\
$(
foreach f,
$(
JS_POST
)
,--post-js
$(
f
))
\
-s
"EXPORTED_FUNCTIONS=@
$(
JS_EXPORTED_FUNCTIONS
)
"
\
-s
"EXTRA_EXPORTED_RUNTIME_METHODS=
$(
JS_EXTRA_EXPORTED_RUNTIME_METHODS
)
"
\
$(
JS_OBJECTS
)
-o
$@
mv
$@
javascript/olmtmp.js
cat
$(
JS_PREFIX
)
javascript/olmtmp.js
$(
JS_SUFFIX
)
>
$@
rm
javascript/olmtmp.js
$(JS_ASMJS_TARGET)
:
$(JS_OBJECTS) $(JS_PRE) $(JS_POST) $(JS_EXPORTED_FUNCTIONS) $(JS_PREFIX) $(JS_SUFFIX)
EMCC_CLOSURE_ARGS
=
"--externs
$(
JS_EXTERNS
)
"
$(
EMCC_LINK
)
\
$(
EMCCFLAGS_ASMJS
)
\
$(
foreach f,
$(
JS_PRE
)
,--pre-js
$(
f
))
\
$(
foreach f,
$(
JS_POST
)
,--post-js
$(
f
))
\
-s
"EXPORTED_FUNCTIONS=@
$(
JS_EXPORTED_FUNCTIONS
)
"
\
...
...
This diff is collapsed.
Click to expand it.
javascript/olm_post.js
+
0
−
9
View file @
602c00a8
...
...
@@ -463,12 +463,3 @@ olm_exports["get_library_version"] = restore_stack(function() {
getValue
(
buf
+
2
,
'
i8
'
),
];
});
Module
[
'
onRuntimeInitialized
'
]
=
function
()
{
OLM_ERROR
=
Module
[
'
_olm_error
'
]();
if
(
onInitSuccess
)
onInitSuccess
();
};
Module
[
'
onAbort
'
]
=
function
(
err
)
{
if
(
onInitFail
)
onInitFail
(
err
);
};
This diff is collapsed.
Click to expand it.
javascript/olm_pre.js
+
9
−
0
View file @
602c00a8
...
...
@@ -37,3 +37,12 @@ if (typeof(OLM_OPTIONS) !== 'undefined') {
* use UTF8ToString.
*/
var
NULL_BYTE_PADDING_LENGTH
=
1
;
Module
[
'
onRuntimeInitialized
'
]
=
function
()
{
OLM_ERROR
=
Module
[
'
_olm_error
'
]();
if
(
onInitSuccess
)
onInitSuccess
();
};
Module
[
'
onAbort
'
]
=
function
(
err
)
{
if
(
onInitFail
)
onInitFail
(
err
);
};
This diff is collapsed.
Click to expand it.
javascript/olm_suffix.js
+
6
−
4
View file @
602c00a8
...
...
@@ -24,7 +24,9 @@ if (typeof(window) !== 'undefined') {
window
[
"
Olm
"
]
=
olm_exports
;
}
// Emscripten sets the module exports to be its module
// with wrapped c functions. Clobber it with our higher
// level wrapper class.
module
.
exports
=
olm_exports
;
if
(
typeof
module
===
'
object
'
)
{
// Emscripten sets the module exports to be its module
// with wrapped c functions. Clobber it with our higher
// level wrapper class.
module
.
exports
=
olm_exports
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment