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
abb8beaa
Verified
Commit
abb8beaa
authored
Dec 11, 2020
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add wasm-stat command
parent
9b28fa80
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
+80
-0
CMakeLists.txt
src/CMakeLists.txt
+10
-0
wasm-stat.cpp
src/wasm-stat.cpp
+70
-0
No files found.
src/CMakeLists.txt
View file @
abb8beaa
...
...
@@ -15,3 +15,13 @@ target_link_libraries(pisn
kyut
cmdline::cmdline
)
add_executable
(
wasm-stat
wasm-stat.cpp
)
target_link_libraries
(
wasm-stat
binaryen::binaryen
cmdline::cmdline
fmtlib::fmt
)
src/wasm-stat.cpp
0 → 100644
View file @
abb8beaa
#include <fmt/printf.h>
#include "cmdline.h"
#include "wasm-io.h"
namespace
{
const
std
::
string
program_name
=
"wasm-stat"
;
const
std
::
string
version
=
"0.1.0"
;
}
// namespace
int
main
(
int
argc
,
char
*
argv
[])
{
cmdline
::
parser
options
{};
options
.
add
(
"help"
,
'h'
,
"Print help message"
);
options
.
add
(
"version"
,
'v'
,
"Print version"
);
options
.
add
(
"quiet"
,
'q'
,
"Only display numbers"
);
options
.
set_program_name
(
program_name
);
options
.
footer
(
"filename"
);
// Parse command line arguments.
// Exit the program if help flag is specified or arguments are invalid.
options
.
parse_check
(
argc
,
argv
);
if
(
options
.
exist
(
"version"
))
{
// Show the program version.
fmt
::
print
(
"{} v{}
\n
"
,
program_name
,
version
);
std
::
exit
(
EXIT_SUCCESS
);
}
if
(
options
.
rest
().
size
()
==
0
)
{
// No input file specified.
fmt
::
print
(
std
::
cerr
,
"no input file
\n
"
);
fmt
::
print
(
std
::
cerr
,
"{}"
,
options
.
usage
());
std
::
exit
(
EXIT_FAILURE
);
}
if
(
options
.
rest
().
size
()
>
1
)
{
// Too many input files.
fmt
::
print
(
std
::
cerr
,
"too many input files
\n
"
);
fmt
::
print
(
std
::
cerr
,
"{}"
,
options
.
usage
());
std
::
exit
(
EXIT_FAILURE
);
}
const
auto
input
=
options
.
rest
()[
0
];
const
bool
quiet
=
options
.
exist
(
"quiet"
);
try
{
wasm
::
Module
module
{};
wasm
::
ModuleReader
{}.
read
(
input
,
module
);
if
(
!
quiet
)
{
fmt
::
print
(
"functions: {}
\n
"
"exports: {}
\n
"
,
module
.
functions
.
size
(),
module
.
exports
.
size
());
}
else
{
fmt
::
print
(
"{}
\t
{}
\n
"
,
module
.
functions
.
size
(),
module
.
exports
.
size
());
}
}
catch
(
const
std
::
exception
&
e
)
{
fmt
::
print
(
std
::
cerr
,
"error: {}
\n
"
,
e
.
what
());
std
::
exit
(
EXIT_FAILURE
);
}
catch
(
const
wasm
::
ParseException
&
e
)
{
e
.
dump
(
std
::
cerr
);
std
::
exit
(
EXIT_FAILURE
);
}
}
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