Skip to content

Commit

Permalink
Remove wabt dependency (#156)
Browse files Browse the repository at this point in the history
* Use WasmTransformer.stripCustomSections

* Remove wabt dependency
  • Loading branch information
kateinoigakukun authored Nov 6, 2020
1 parent 501274a commit b9702ea
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ brew "pre-commit"
brew "swiftformat"
brew "swiftlint"
brew "binaryen"
brew "wabt"
brew "wasmer"
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@
"repositoryURL": "https://github.com/swiftwasm/WasmTransformer",
"state": {
"branch": null,
"revision": "c7cb17309372e57c9f75f7abd5c7323d667eaddc",
"version": "0.0.1"
"revision": "74bd6559322b43390eb6da5a134f5af7f117bd01",
"version": "0.0.2"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let package = Package(
.package(url: "https://github.com/vapor/vapor.git", from: "4.29.3"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "1.1.0"),
.package(url: "https://github.com/JohnSundell/Splash.git", from: "0.14.0"),
.package(url: "https://github.com/swiftwasm/WasmTransformer", .upToNextMinor(from: "0.0.1")),
.package(url: "https://github.com/swiftwasm/WasmTransformer", .upToNextMinor(from: "0.0.2")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module
Expand Down
1 change: 0 additions & 1 deletion Sources/carton-release/Formula.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ struct Formula: ParsableCommand {
depends_on :xcode => "11.4"
depends_on "wasmer"
depends_on "binaryen"
depends_on "wabt"
stable do
version "\#(version)"
Expand Down
12 changes: 10 additions & 2 deletions Sources/carton/Commands/Bundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CartonHelpers
import Crypto
import SwiftToolchain
import TSCBasic
import WasmTransformer

private let dependency = Dependency(
fileName: "bundle.js",
Expand Down Expand Up @@ -57,7 +58,8 @@ struct Bundle: ParsableCommand {
newline: true
)

try ProcessRunner(["wasm-strip", mainWasmPath.pathString], terminal).waitUntilFinished()
try strip(mainWasmPath)

try terminal.logLookup(
"After applying `wasm-strip` the main binary size is ",
localFileSystem.humanReadableFileSize(mainWasmPath),
Expand All @@ -73,7 +75,7 @@ struct Bundle: ParsableCommand {
terminal
).waitUntilFinished()
try terminal.logLookup(
"After applying `wasm-opt` the main binary size is ",
"After stripping debug info the main binary size is ",
localFileSystem.humanReadableFileSize(optimizedPath),
newline: true
)
Expand All @@ -89,6 +91,12 @@ struct Bundle: ParsableCommand {
terminal.write("Bundle generation finished successfully\n", inColor: .green, bold: true)
}

func strip(_ wasmPath: AbsolutePath) throws {
let binary = try localFileSystem.readFileContents(wasmPath)
let strippedBinary = try stripCustomSections(binary.contents)
try localFileSystem.writeFileContents(wasmPath, bytes: .init(strippedBinary))
}

func copyToBundle(
terminal: InteractiveWriter,
optimizedPath: AbsolutePath,
Expand Down
4 changes: 0 additions & 4 deletions install_ubuntu_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set -ex

curl -L -v -o wabt.tar.gz https://github.com/WebAssembly/wabt/releases/download/1.0.19/wabt-1.0.19-ubuntu.tar.gz
tar xzvf wabt.tar.gz
cp wabt-1.0.19/bin/* /usr/local/bin

curl -L -v -o binaryen.tar.gz https://github.com/WebAssembly/binaryen/releases/download/version_97/binaryen-version_97-x86_64-linux.tar.gz
tar xzvf binaryen.tar.gz
cp binaryen-version_97/bin/* /usr/local/bin

0 comments on commit b9702ea

Please sign in to comment.