Code Monkey home page Code Monkey logo

flattables's People

Contributors

urban-wombat avatar

Watchers

 avatar  avatar

flattables's Issues

cant find flattables/FlatBuffersSchema.template

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

./flattablesc outout paths are very confusing. See suggestions in the make file

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)


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.