Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wasm-watermarker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
wasm-watermarker
Commits
9b28fa80
Verified
Commit
9b28fa80
authored
Dec 11, 2020
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite embedding script with Ruby
parent
d36d0038
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
54 deletions
+61
-54
.editorconfig
.editorconfig
+4
-0
embed.rb
scripts/embed.rb
+57
-0
embed.sh
scripts/embed.sh
+0
-54
No files found.
.editorconfig
View file @
9b28fa80
...
...
@@ -16,3 +16,7 @@ trim_trailing_whitespace = false
[{Makefile,*.mk}]
indent_style = tab
indent_size = 4
[*.rb]
indent_style = space
indent_size = 2
scripts/embed.rb
0 → 100755
View file @
9b28fa80
#!/usr/bin/env ruby
require
'fileutils'
require
'pathname'
SNPI
=
"./build/bin/snpi"
PISN
=
"./build/bin/pisn"
WASM_BINARIES
=
{
:ammo
=>
"./node_modules/ammo.js/builds/ammo.wasm.wasm"
,
:jq
=>
"./node_modules/jq-web/jq.wasm.wasm"
,
:source_map
=>
"./node_modules/source-map/lib/mappings.wasm"
,
:wasm_flate
=>
"./node_modules/wasm-flate/wasm_flate_bg.wasm"
,
:vim
=>
"./node_modules/vim-wasm/vim.wasm"
,
:vim_small
=>
"./node_modules/vim-wasm/small/vim.wasm"
,
}
OUTPUT_DIRS
=
{
:ammo
=>
"./out/ammo.js"
,
:jq
=>
"./out/jq-web"
,
:source_map
=>
"./out/source-map"
,
:wasm_flate
=>
"./out/wasm-flate"
,
:vim
=>
"./out/vim-wasm"
,
:vim_small
=>
"./out/vim-wasm/small"
,
}
METHODS
=
[
{
:name
=>
"function-reorder"
,
:abbr
=>
"fn"
},
{
:name
=>
"export-reorder"
,
:abbr
=>
"ex"
},
{
:name
=>
"operand-swap"
,
:abbr
=>
"op"
},
]
def
copy
(
file
,
out
)
FileUtils
.
copy
(
file
,
out
,
{
:verbose
=>
true
})
end
def
embed
(
file
,
out
,
method
,
watermark
,
chunk_size
=
20
)
output
=
IO
.
popen
([
SNPI
,
"-o"
,
out
.
to_s
,
"-m"
,
method
,
"-w"
,
watermark
,
"-c"
,
chunk_size
.
to_s
,
file
.
to_s
]).
read
puts
"
#{
file
}
,
#{
out
}
,
#{
method
}
,
#{
watermark
}
,
#{
output
}
"
end
WASM_BINARIES
.
each
do
|
id
,
file
|
dir
=
Pathname
(
OUTPUT_DIRS
[
id
])
FileUtils
.
mkdir_p
(
dir
)
copy
(
file
,
dir
+
Pathname
(
file
).
basename
)
end
METHODS
.
each
do
|
method
|
WASM_BINARIES
.
each
do
|
id
,
file
|
watermark
=
"TEST"
dir
=
Pathname
(
OUTPUT_DIRS
[
id
])
out
=
dir
+
Pathname
(
file
).
basename
.
sub
(
".wasm"
,
"-
#{
method
[
:abbr
]
}
-
#{
watermark
}
.wasm"
)
embed
(
file
,
out
,
method
[
:name
],
watermark
)
end
end
scripts/embed.sh
deleted
100755 → 0
View file @
d36d0038
#!/bin/sh
SNPI
=
"./build/bin/snpi"
PISN
=
"./build/bin/pisn"
OUT_DIR
=
"./out"
WASM_AMMO_JS
=
"./node_modules/ammo.js/builds/ammo.wasm.wasm"
WASM_JQ_WEB
=
"./node_modules/jq-web/jq.wasm.wasm"
WASM_SOURCE_MAP
=
"./node_modules/source-map/lib/mappings.wasm"
WASM_WASM_FLATE
=
"./node_modules/wasm-flate/wasm_flate_bg.wasm"
function
copy
()
{
local
file
=
"
$1
"
local
out
=
"
$2
"
echo
"cp
$file
$out
"
mkdir
-p
"
$(
dirname
"
$out
"
)
"
cp
"
$file
"
"
$out
"
}
function
embed
()
{
local
file
=
"
$1
"
local
out
=
"
$2
"
local
method
=
"
$3
"
local
watermark
=
"
$4
"
local
chunk_size
=
"
${
5
:-
20
}
"
echo
"
$SNPI
-o
$out
-m
$method
-w
$watermark
-c
$chunk_size
$file
"
mkdir
-p
"
$(
dirname
"
$out
"
)
"
local
embedded_size
embedded_size
=
"
$(
"
$SNPI
"
-o
"
$out
"
-m
"
$method
"
-w
"
$watermark
"
-c
"
$chunk_size
"
"
$file
"
)
"
echo
"
$embedded_size
"
}
copy
"
$WASM_AMMO_JS
"
"
$OUT_DIR
/ammo.js/ammo.wasm.wasm"
copy
"
$WASM_JQ_WEB
"
"
$OUT_DIR
/jq-web/jq.wasm.wasm"
copy
"
$WASM_SOURCE_MAP
"
"
$OUT_DIR
/source-map/mappings.wasm"
copy
"
$WASM_WASM_FLATE
"
"
$OUT_DIR
/wasm-flate/wasm_flate_bg.wasm"
embed
"
$WASM_AMMO_JS
"
"
$OUT_DIR
/ammo.js/ammo.wasm-op-TEST.wasm"
"operand-swap"
"TEST"
embed
"
$WASM_JQ_WEB
"
"
$OUT_DIR
/jq-web/jq-op-TEST.wasm.wasm"
"operand-swap"
"TEST"
embed
"
$WASM_SOURCE_MAP
"
"
$OUT_DIR
/source-map/mappings-op-TEST.wasm"
"operand-swap"
"TEST"
embed
"
$WASM_WASM_FLATE
"
"
$OUT_DIR
/wasm-flate/wasm_flate_bg-op-TEST.wasm"
"operand-swap"
"TEST"
embed
"
$WASM_AMMO_JS
"
"
$OUT_DIR
/ammo.js/ammo.wasm-fn-TEST.wasm"
"function-reorder"
"TEST"
embed
"
$WASM_JQ_WEB
"
"
$OUT_DIR
/jq-web/jq-fn-TEST.wasm.wasm"
"function-reorder"
"TEST"
embed
"
$WASM_SOURCE_MAP
"
"
$OUT_DIR
/source-map/mappings-fn-TEST.wasm"
"function-reorder"
"TEST"
embed
"
$WASM_WASM_FLATE
"
"
$OUT_DIR
/wasm-flate/wasm_flate_bg-fn-TEST.wasm"
"function-reorder"
"TEST"
embed
"
$WASM_AMMO_JS
"
"
$OUT_DIR
/ammo.js/ammo.wasm-ex-TEST.wasm"
"export-reorder"
"TEST"
embed
"
$WASM_JQ_WEB
"
"
$OUT_DIR
/jq-web/jq-ex-TEST.wasm.wasm"
"export-reorder"
"TEST"
embed
"
$WASM_SOURCE_MAP
"
"
$OUT_DIR
/source-map/mappings-ex-TEST.wasm"
"export-reorder"
"TEST"
embed
"
$WASM_WASM_FLATE
"
"
$OUT_DIR
/wasm-flate/wasm_flate_bg-ex-TEST.wasm"
"export-reorder"
"TEST"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment