Conversation
Updating GameDLC.md to provide better documentation for the functions included in the directory.
|
Python scripts that use bitcode, specs, or other data in files should refer to them relative to the script's location rather than the current working directory, as a user could try to run the script from different locations. So code like this: base = os.getcwd()
bcname = base + '/build/foo.bc'
cryname = base + '/spec/Foo.cry'
m = llvm_load_module(bcname)
load_cryptol_file(cryname)
...should be refactored to... if __name__ == '__main__':
base = Path(__file__).parents[1] # whichever parent is common to other filenames in the script
bcpath = base/"build/foo.bc"
crypath = base/"spec/Foo.cry"
m = load_module(str(bcpath))
load_cryptol_file(str(crypath))...for portability to multiple platforms and initial working directories. It would be nice if Cryptol/SAW APIs accepted other pathlike filenames, but for now these have to be converted to Afterward, This is better as it restores the initial working directory even if a build error occurs. |
|
Also, a all: build
prove: build
python3 $(PROOF)/ceilLog2.py
build:
mkdir -p $(ARTIFACTS)
clang -c -g -emit-llvm -o $(ARTIFACTS)/ceilLog2.bc $(SRC)/ceilLog2.c
clean:
rm -r $(ARTIFACTS)...should be changed to... all: build
build: $(ARTIFACTS)/ceilLog2.bc
prove: build
python3 $(PROOF)/ceilLog2.py
clean:
rm -rf $(ARTIFACTS)
.PHONY: all build prove clean
$(ARTIFACTS)/ceilLog2.bc: $(SRC)/ceilLog2.c | $(ARTIFACTS)
clang -c -g -emit-llvm -o $@ $<
$(ARTIFACTS):
mkdir -p $(ARTIFACTS) |
|
Excellent points @WeeknightMVP! I added both of your suggestions to #217 for an immediate fix. Always good to make things more portable :) |
Added a new branch for Game/DLC/. This branch serves as a workspace for improving documentation and examples already present in Game/DLC/.
Updates will include: