Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement rest args behavior in vinoc, fixes vino-core/#1
Browse files Browse the repository at this point in the history
jsoverson committed Nov 15, 2021
1 parent 34c4164 commit de37517
Showing 40 changed files with 891 additions and 1,356 deletions.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -182,6 +182,7 @@ jobs:
environment:
AZURE_STORAGE_ACCOUNT: $AZURE_STORAGE_ACCOUNT
steps:
- checkout
- restore_cache:
keys:
- artifacts-x86_64-unknown-linux-gnu-{{ .Environment.CIRCLE_SHA1 }}
@@ -206,7 +207,9 @@ jobs:
make-tarball vino ./build/aarch64-unknown-linux-gnu linux.aarch64 build/artifacts
make-tarball vino ./build/x86_64-apple-darwin darwin.x86_64 build/artifacts
make-tarball vino ./build/aarch64-apple-darwin darwin.aarch64 build/artifacts
make-zip ./build/x86_64-pc-windows-gnu win64 build/artifacts
make-zip ./build/x86_64-pc-windows-gnu vino.win64 build/artifacts
cp /home/vino/project/crates/vino-rpc/proto/vino.proto build/artifacts/vino.proto
echo << pipeline.git.tag >> > build/artifacts/RELEASE
echo << pipeline.git.tag >> > build/RELEASE
- run:
name: Upload to Azure
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 21 additions & 24 deletions crates/integration/test-vino-provider/interface.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
{
"name": "test-vino-provider",
"components": [
{
"types": {},
"components": {
"error": {
"name": "error",
"inputs": [
{
"name": "input",
"type_string": "string"
"inputs": {
"input": {
"type": "string"
}
],
"outputs": [
{
"name": "output",
"type_string": "string"
},
"outputs": {
"output": {
"type": "string"
}
]
}
},
{
"test-component": {
"name": "test-component",
"inputs": [
{
"name": "input",
"type_string": "string"
"inputs": {
"input": {
"type": "string"
}
],
"outputs": [
{
"name": "output",
"type_string": "string"
},
"outputs": {
"output": {
"type": "string"
}
]
}
}
]
}
}
27 changes: 2 additions & 25 deletions crates/integration/test-vino-provider/src/components.rs
Original file line number Diff line number Diff line change
@@ -47,31 +47,8 @@ pub fn get_signature() -> ProviderSignature {
);

ProviderSignature {
name: None,
types: std::collections::HashMap::from([
(
"name".to_owned(),
StructSignature {
name: "".to_owned(),
fields: std::collections::HashMap::from([]).into(),
},
),
(
"types".to_owned(),
StructSignature {
name: "".to_owned(),
fields: std::collections::HashMap::from([]).into(),
},
),
(
"components".to_owned(),
StructSignature {
name: "".to_owned(),
fields: std::collections::HashMap::from([]).into(),
},
),
])
.into(),
name: Some("test-vino-provider".to_owned()),
types: std::collections::HashMap::from([]).into(),
components: components.into(),
}
}
16 changes: 8 additions & 8 deletions crates/integration/test-wapc-component/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 23 additions & 26 deletions crates/integration/test-wapc-component/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.DEFAULT_GOAL:=all

.PHONY: all codegen build clean doc test help list

ifdef OS
_OS := $(OS)
else
@@ -32,9 +30,6 @@ GENERATED_MODULE := ./src/components.rs
# Get list of WIDL files in SCHEMA_DIR
SCHEMAS=$(wildcard ${SCHEMA_DIR}/*.widl)

# Translate a list of WIDL files to COMPONENTS_DIR/file.rs (transposing hyphens to underscores)
GENERATED_COMPONENTS := $(patsubst %.widl,%.rs,$(patsubst ${SCHEMA_DIR}%,${COMPONENTS_DIR}%,$(subst -,_,$(SCHEMAS))))

# Name of the package from Cargo.toml
CRATE_NAME:=$(shell tomlq -f Cargo.toml package.name)
# Name with hyphens substituted with underscores
@@ -51,34 +46,25 @@ BUILD_ARTIFACT:=$(ARTIFACT_DIR)/$(CRATE_FS_NAME).wasm
SIGNED_ARTIFACT:=$(ARTIFACT_DIR)/$(CRATE_FS_NAME)_s.wasm
# Path to the interface JSON
INTERFACE:=./interface.json
# All *.rs files in src/
RUST_SOURCES:=$(wildcard src/*.rs) $(wildcard src/*/*.rs)

TARGET=wasm32-unknown-unknown

VINOC=cargo run --manifest-path ../../../Cargo.toml -p vinoc
VINOC=vinoc
CODEGEN:=vino-codegen

# Files to clean on make clean
CLEAN_FILES := $(GENERATED_MODULE) $(BUILD_ARTIFACT) $(SIGNED_ARTIFACT) ./src/components/mod.rs $(INTERFACE)

$(SIGNED_ARTIFACT): $(BUILD_ARTIFACT) $(INTERFACE)
@echo Signing $(BUILD_ARTIFACT)
@$(VINOC) -- sign $(BUILD_ARTIFACT) $(INTERFACE) --ver=$(CRATE_VERSION) --rev=0
@$(VINOC) sign $(BUILD_ARTIFACT) $(INTERFACE) --ver=$(CRATE_VERSION) --rev=0
@echo Created $(SIGNED_ARTIFACT)

# Defines rules like the following for each schema found :
# src/components/my_components.rs: schemas/my-component.widl
define WIDL_CODEGEN
$(patsubst %.widl,%.rs,$(patsubst ${SCHEMA_DIR}%,${COMPONENTS_DIR}%,$(subst -,_,$(1)))): $1
@$$(shell $$(MKDIR) $$(dir $$@))
@echo Generating $$@
@$(CODEGEN) rust wapc-component $(notdir $(basename $(subst -,_,$(1)))) -o $$@
@rustfmt $$@
endef

# Call the above rule generator for each schema file
$(foreach schema,$(SCHEMAS),$(eval $(call WIDL_CODEGEN,$(schema))))

$(GENERATED_MODULE): $(SCHEMAS)
$(GENERATED_MODULE): $(INTERFACE)
@echo Generating $@
@$(CODEGEN) rust wapc-integration $(SCHEMA_DIR) -f -o $@
@$(CODEGEN) rust wapc-integration $(INTERFACE) -f -o $@
@rustfmt $@

$(COMPONENTS_DIR):
@@ -89,35 +75,46 @@ $(ARTIFACT_DIR):
@echo Making directory \"$@\"
$(shell $(MKDIR) $@)

$(BUILD_ARTIFACT): $(wildcard src/*.rs) ./src/lib.rs $(ARTIFACT_DIR) $(GENERATED_MODULE) $(GENERATED_COMPONENTS)
components: $(INTERFACE) $(COMPONENTS_DIR)
@echo Generating component stubs
@$(CODEGEN) rust wapc-components $(INTERFACE) -o $(COMPONENTS_DIR)

$(BUILD_ARTIFACT): $(ARTIFACT_DIR) components $(GENERATED_MODULE) $(RUST_SOURCES)
@echo Building artifact
cargo build --target wasm32-unknown-unknown --release
cargo build --target $(TARGET) --release
@echo Copying binary to $(BUILD_ARTIFACT)
@cp $(WORKSPACE_ROOT)/target/wasm32-unknown-unknown/release/$(CRATE_FS_NAME).wasm build/
@cp $(WORKSPACE_ROOT)/target/$(TARGET)/release/$(CRATE_FS_NAME).wasm build/

##@ Targets

$(INTERFACE): $(SCHEMAS) ## Create an interface.json from the project's schemas
@echo Building $@ from schemas in $(SCHEMA_DIR)
@$(CODEGEN) json interface "$(CRATE_NAME)" $(SCHEMA_DIR) -o $@ -f

.PHONY: all
all: $(SIGNED_ARTIFACT) ## Make and sign the wasm binary

.PHONY: clean
clean: ## Clean the generated files
@rm -f $(CLEAN_FILES)

codegen: $(INTERFACE) $(GENERATED_COMPONENTS) $(GENERATED_MODULE) ./src/lib.rs ## Generate code from schemas
.PHONY: codegen
codegen: $(INTERFACE) components $(GENERATED_MODULE) ./src/lib.rs ## Generate code from schemas

.PHONY: doc
doc: ## Generate documentation
@echo Unimplemented

.PHONY: test
test: build ## Run tests
cargo test

##@ Helpers

.PHONY: list
list: ## Print schemas
@echo $(SCHEMAS)

.PHONY: help
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_\-.*]+:.*?##/ { printf " \033[36m%-32s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
Loading

0 comments on commit de37517

Please sign in to comment.