urban-wombat / flattables Goto Github PK
View Code? Open in Web Editor NEWGoogle FlatBuffers low-latency binary data constrained as tables with easy code generation.
License: MIT License
Google FlatBuffers low-latency binary data constrained as tables with easy code generation.
License: MIT License
Problem:
Output paths are ambiguous.
See Case 1 and Case 2 in the MakeFile to see how ambiguous it is currently.
Reproduce:
Everything need to reproduce is in the Makefile. Use any .got table you want as it does not matter.
Suggested Fix:
The suggestion is to make all input and output paths absolute. Its just easier for everyone.
Also, for the output sample, maybe use the convention of "cmd/PACKAGENAME/main.go" also, because everyone gets thats approach with golang and there is no guessing the main file.
I also think that absolute paths and absolute golang namespaces will make it much easier for your inside your code generator - everything is very clear then ?
I did not check if flatc also takes absolutes paths ! If it does then you have absolute paths everywhere and so would make things easy.
It allows the user to have fully control. Eventually best practice approach for where things should be placed in relation to the .got will become apparent but for now full control feels best.
For example best practice is to just take where ever the .got is and make a gen folder under it with a cmd and pkg folder. Sample goes in the cmd. Code goes in the pkg. But still not sure, so just let user control it all for now.
MakeFile
# user walk through of using it.
# tools are in $BIN_FSPATH
BIN_FSPATH=$(realpath $(PWD)/../tools/bin)
NAME=mypackage
NAMESPACE=github.com/gedw99/ci/server/compute/flatbuffers/$(NAME)
# Path to .got files.
INPUT_FSPATH=$(GOPATH)/src/$(NAMESPACE)
# Currently, the generator gives no control about output path.
#OUTPUT_FSPATH=$(realpath $(PWD)/../$(NAME)_main)
# Currently, the generator give no control about sample output path.
# Hard codes to Case 2 location for now :)
SAMPLE_OUTPUT_FSPATH=$(GOPATH)/src/$(NAMESPACE)_main
SAMPLE_OUTPUT_MAIN=$(NAME)_main.go
print:
@echo
@echo BIN_FSPATH : $(BIN_FSPATH)
@echo NAME : $(NAME)
@echo NAMESPACE : $(NAMESPACE)
@echo INPUT_FSPATH : $(INPUT_FSPATH)
@echo OUTPUT_FSPATH : $(OUTPUT_FSPATH)
@echo SAMPLE_OUTPUT_FSPATH : $(SAMPLE_OUTPUT_FSPATH)
@echo SAMPLE_OUTPUT_MAIN : $(SAMPLE_OUTPUT_MAIN)
@echo
check:
$(BIN_FSPATH)/gotsyntax tables.got
gen-help:
cd $(BIN_FSPATH) && ./flattablesc -h
gen:
# BUG:
# Cant control OUTPUT path :) Its also a bit weird the way it chooses where to put the OUTPUT_FSPATH and SAMPLE_OUTPUT_FSPATH.
# Try the two approaches belwo to see what i mean...
# Suggested Fix is to always use absolute path. Its makes everything clearer from the get go for everyone.
# - 1. Make the Output and Sample Output paths absolute ( controlled by user)
# - 2- Make the Input path absolute ( controlled by user currently )
# Case 1:
# In this case it puts the OUTPUT one folder above where the BINPATH is. It disregards the INPUT_FSPATH as context for where the OUTPUT path will be.
#cd $(BIN_FSPATH) && ./flattablesc -v -f $(INPUT_FSPATH)/tables.got -n $(NAME) -p $(NAMESPACE)
# Case 2:
# In this case it puts the OUTPUT in the same folder as the INPUT_FSPATH and then the OUTPUT sample on foler above the OUTPUT. Completely different from Case 1.
$(BIN_FSPATH)/flattablesc -v -f $(INPUT_FSPATH)/tables.got -n $(NAME) -p $(NAMESPACE)
gen-clean:
# delete output (Case 2)
cd $(INPUT_FSPATH) && rm -rf *.go
cd $(INPUT_FSPATH) && rm -rf *.fbs
# delete sample output (Case 2)
rm -rf $(SAMPLE_OUTPUT_FSPATH)
run:
cd $(SAMPLE_OUTPUT_FSPATH) && go run $(SAMPLE_OUTPUT_MAIN)
Hey @urban-wombat
I got time to play around. Geez its fast :)
i think that the reliance on the flattables/FlatBuffersSchema.template at generation time is a problem.
The code currently relies on a certain layout of the code and binary tools.
Can the FlatBuffersSchema.template be embedded inside the schema gen tool called so its all less fragile to folder layout structure ?
If it cant then maybe there is another solution :)
At the moment the when i run:
# Standard example in readme made into a make file.
BIN_FSPATH=$(realpath $(PWD)/../tools/bin)
NAME=mypackage
NAMESPACE=bitbucket.org/gedw99/testing/ci/compute/flatbuffers/$(NAME)
OUTPUT_FSPATH=$(realpath $(PWD)/../$(NAME)_main)
$(BIN_FSPATH)/flattablesc -f ../mypackage/tables.got -n $(NAME) -p $(NAMESPACE)
I get
Adding gotables table 0 to FlatBuffers schema: [MyXyzTable]
Adding gotables table 1 to FlatBuffers schema: [StringsAndThings]
Adding gotables table 2 to FlatBuffers schema: [Wombats]
ERROR: open ../flattables/FlatBuffersSchema.template: no such file or directory
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.