remove deadlock in build system

This commit is contained in:
Sebastian Hugentobler 2023-03-09 10:36:11 +01:00
parent 939201fedb
commit 9c5cd5f4da
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
16 changed files with 84 additions and 102 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
**/target **/target
**/Cargo.lock **/Cargo.lock
woweb/assets/dist_text* woweb/assets/dist_text*
dist/

18
.idea/misc.xml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MakefileSettings">
<option name="linkedExternalProjectsSettings">
<MakefileProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
<option name="version" value="2" />
</MakefileProjectSettings>
</option>
</component>
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/poc.iml" filepath="$PROJECT_DIR$/.idea/poc.iml" />
</modules>
</component>
</project>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/dist_list/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dist_text/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dist_text_js/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/woweb/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
<excludeFolder url="file://$MODULE_DIR$/dist_list/target" />
<excludeFolder url="file://$MODULE_DIR$/woweb/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

16
Cargo.lock generated
View File

@ -121,9 +121,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.10.3" version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [ dependencies = [
"generic-array", "generic-array",
] ]
@ -898,9 +898,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.153" version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a382c72b4ba118526e187430bb4963cd6d55051ebf13d9b25574d379cc98d20" checksum = "8cdd151213925e7f1ab45a9bbfb129316bd00799784b174b7cc7bcd16961c49e"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@ -918,9 +918,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.153" version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ef476a5790f0f6decbc66726b6e5d63680ed518283e64c7df415989d880954f" checksum = "4fc80d722935453bcafdc2c9a73cd6fac4dc1938f0346035d84bf99fa9e33217"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1317,9 +1317,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.10" version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"

View File

@ -5,3 +5,6 @@ members = [
"dist_text_js", "dist_text_js",
"woweb" "woweb"
] ]
[profile.release]
strip = true

View File

@ -4,25 +4,25 @@ ENV RUSTFLAGS="-C target-feature=-crt-static"
RUN apk add --no-cache \ RUN apk add --no-cache \
musl-dev \ musl-dev \
wasm-pack wasm-pack \
make
RUN rustup target add wasm32-unknown-unknown RUN rustup target add wasm32-unknown-unknown
ADD . /src ADD . /src
WORKDIR /src WORKDIR /src
RUN cargo build --release RUN make release
RUN strip target/release/woweb
RUN adduser -D woweb RUN adduser -D woweb
RUN sed -i 's|ws://localhost:3000/ws|wss://woweb.vanwa.ch/ws|' woweb/assets/index.js RUN sed -i 's|ws://localhost:3000/ws|wss://woweb.vanwa.ch/ws|' dist/assets/index.js
FROM scratch FROM scratch
COPY --from=builder /etc/passwd /etc/passwd COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /src/target/release/woweb "/opt/woweb" COPY --from=builder /src/dist/woweb "/opt/woweb"
COPY --from=builder /src/woweb/assets "/opt/assets" COPY --from=builder /src/dist/assets "/opt/assets"
EXPOSE 3000 EXPOSE 3000

38
Makefile Normal file
View File

@ -0,0 +1,38 @@
WASM_PKG_DIR = dist_text_js/pkg
ASSET_DIR = woweb/assets
WASM_JS = dist_text_js.js
WASM_BG = dist_text_js_bg.wasm
WASM_JS_PKG = $(WASM_PKG_DIR)/$(WASM_JS)
WASM_BG_PKG = $(WASM_PKG_DIR)/$(WASM_BG)
WASM_JS_ASSET = $(ASSET_DIR)/$(WASM_JS)
WASM_BG_ASSET = $(ASSET_DIR)/$(WASM_BG)
DIST_DIR = dist
.PHONY: default all wasm serve clean
default: all
all: wasm
wasm: $(WASM_JS_ASSET) $(WASM_BG_ASSET)
$(WASM_JS_ASSET) $(WASM_BG_ASSET): dist_text_js/src/lib.rs
cd dist_text_js; \
wasm-pack build --target web --release --no-typescript
cp $(WASM_JS_PKG) $(WASM_JS_ASSET)
cp $(WASM_BG_PKG) $(WASM_BG_ASSET)
serve: wasm
cargo run --package woweb
release: $(DIST_DIR) wasm
cargo build --package woweb --release
cp target/release/woweb $(DIST_DIR)
cp -r $(ASSET_DIR) $(DIST_DIR)
$(DIST_DIR):
mkdir -p $(DIST_DIR)
clean:
cargo clean
rm -rf $(WASM_PKG_DIR)
rm -f $(ASSET_DIR)/dist_text*

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# Prerequisites
- [make](https://en.wikipedia.org/wiki/Make_(software))
- [wasm-pack](https://github.com/rustwasm/wasm-pack)
- [rustup](https://rustup.rs/)
- [cargo](https://github.com/rust-lang/cargo)
```
rustup target add wasm32-unknown-unknown
```

View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/woweb-poc.iml" filepath="$PROJECT_DIR$/.idea/woweb-poc.iml" />
</modules>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -2,7 +2,6 @@
name = "woweb" name = "woweb"
version = "0.2.0" version = "0.2.0"
edition = "2021" edition = "2021"
build = "build.rs"
[dependencies] [dependencies]
dist_text = { path = "../dist_text" } dist_text = { path = "../dist_text" }

View File

@ -1,29 +0,0 @@
use std::env;
use std::fs;
use std::path::Path;
use std::process::Command;
fn main() {
let woweb_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let woweb_path = Path::new(&woweb_dir);
let woweb_asset_path = woweb_path.join("assets");
let dist_text_path = woweb_path.parent().unwrap().join("dist_text_js");
let dist_text_pkg_path = dist_text_path.join("pkg");
Command::new("wasm-pack")
.args(&["build", "--target", "web", "--release", "--no-typescript"])
.current_dir(dist_text_path)
.status()
.unwrap();
let js_path_src = dist_text_pkg_path.join("dist_text_js.js");
let js_path_dest = woweb_asset_path.join("dist_text_js.js");
let wasm_path_src = dist_text_pkg_path.join("dist_text_js_bg.wasm");
let wasm_path_dest = woweb_asset_path.join("dist_text_js_bg.wasm");
let _ = fs::copy(js_path_src, js_path_dest);
let _ = fs::copy(wasm_path_src, wasm_path_dest);
println!("cargo:rerun-if-changed=../dist_text_js/**/*.rs");
}