Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Huge numbers for dice" #479

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/lint_codeQL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/test_OS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
with:
python-version: '3.x'
- uses: actions/checkout@v3
with:
submodules: true
- name: Install dependencies
run: |
python -m pip install -r reqs/requirements.txt
Expand Down Expand Up @@ -51,8 +49,6 @@ jobs:
python3.10-venv

- uses: actions/checkout@v3
with:
submodules: true
- name: test
shell: wsl-bash {0}
run: |
Expand All @@ -63,8 +59,6 @@ jobs:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build
run: make all
- name: Test
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v3
with:
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/test_language_bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: make
run: |
make cpp
Expand All @@ -51,8 +49,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: prereqs
# https://linuxize.com/post/how-to-install-mono-on-ubuntu-20-04/
run: |
Expand All @@ -72,8 +68,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: go install
run: sudo apt install golang-go
- name: make go
Expand All @@ -86,8 +80,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: dep install
run: |
sudo apt update
Expand All @@ -106,8 +98,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: java dependencies
run: |
sudo apt-get update
Expand All @@ -123,8 +113,6 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
Expand Down Expand Up @@ -161,8 +149,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: julia install
run: |
wget https://julialang-s3.julialang.org/bin/linux/x64/1.8/julia-1.8.2-linux-x86_64.tar.gz
Expand All @@ -172,15 +158,12 @@ jobs:
- name: make julia
run: |
PATH="$PATH:$PWD/julia-1.8.2/bin" make julia

test_lua:
name: "Test: Lua"
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: lua install
run: |
sudo apt install luajit
Expand All @@ -193,8 +176,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: perl install
run: |
sudo apt install perl
Expand All @@ -209,8 +190,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: r-lib/actions/setup-r@v2
- name: make r
run: make r
Expand All @@ -220,8 +199,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: ruby install
run: |
sudo apt install ruby-full
Expand All @@ -233,8 +210,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -251,8 +226,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup Rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/test_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v3
with:
Expand Down Expand Up @@ -52,8 +50,6 @@ jobs:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build
run: make all
- name: Test
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "src/grammar/external/pcg-c"]
path = src/grammar/external/pcg-c
url = https://github.com/imneme/pcg-c.git
34 changes: 13 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
CODEDIRS=./src/grammar ./src/grammar/rolls ./src/grammar/util ./src/grammar/operations ./src/grammar/external
INCDIRS=./src/grammar ./src/grammar/external/pcg-c/include
INCDIRS=./src/grammar

PCG_SRC=./src/grammar/external/pcg-c/src

$(info CC is $(CC))
CC=cc

ifeq ($(CC),g++)
STANDARD= -std=c++11
else ifeq ($(CC),clang++)
STANDARD= -std=c++11
else ifeq ($(filter $(CC),gcc cc),gcc cc)
STANDARD= -std=c99
else
STANDARD= -std=c99
endif
Expand All @@ -29,8 +25,8 @@ ifneq ($(shell uname -s), Darwin)
OPT := $(OPT) -Wl,-z,nodlopen -Wl,-z,noexecstack \
-Wl,-z,relro
endif

# -ffast-math # Problematic for Python
# -ffast-math # Problematic for Python

# YACC/LEX fails for the following, so disabled:
# -Wswitch-default -Wstrict-overflow=5
Expand Down Expand Up @@ -95,16 +91,16 @@ ifeq ($(LEX_FALLBACK), 1)
LEXER:=lex
else
#$(shell echo USING FLEX)
LEXER:=flex -f -Ca -Ce -Cr
LEXER:=flex -f -Ca -Ce -Cr
endif

# add flags and the include paths
DEFS=-DUSE_SECURE_RANDOM=${USE_SECURE_RANDOM} -DJUST_YACC=${YACC_FALLBACK} -DUSE_CLT=${USE_CLT}

CFLAGS=$(foreach D,$(INCDIRS),-I$(D)) $(OPT) $(DEFS)
CFLAGS=$(foreach D,$(INCDIRS),-I$(D)) $(OPT) $(DEFS)

# add flags to build for shared library and add include paths
SHAREDCFLAGS=-fPIC -c $(foreach D,$(INCDIRS),-I$(D)) $(ARC4RANDOM) $(DEFS)
SHAREDCFLAGS=-fPIC -c $(foreach D,$(INCDIRS),-I$(D)) $(ARC4RANDOM) $(DEFS)

# generate list of c files and remove y.tab.c from src/grammar directory
CFILES=$(foreach D,$(CODEDIRS),$(wildcard $(D)/*.c)) build/lex.yy.c build/y.tab.c
Expand All @@ -131,7 +127,7 @@ install: all
yacc:
mkdir -p build
$(foreach BD,$(CFILE_SUBDIRS),mkdir -p build/$(BD))
$(PARSER) -d src/grammar/dice.yacc $(PARSER_DEBUG)
$(PARSER) -d src/grammar/dice.yacc $(PARSER_DEBUG)
mv y.tab.c build/y.tab.c
mv y.tab.h build/y.tab.h
mv y.output build/y.output | true # Only present with verbose
Expand All @@ -140,33 +136,29 @@ lex:
mv lex.yy.c build/lex.yy.c

# Executable
compile: pcg
compile:
# FLEX creates warning when run with -f
# MacOS creates warnings for signs.
$(CC) $(CFLAGS) $(CFILES) $(ARC4RANDOM) \
-Wno-error=implicit-function-declaration \
-Wno-sign-conversion -Wno-sign-compare -lm \
-Wno-implicit-int-conversion -lpcg_random -L$(PCG_SRC) \
-Wno-undef -Wno-conversion # For pcg-c
-Wno-implicit-int-conversion

# PCG Submodule
pcg:
make -C src/grammar/external/pcg-c all

# Shared Lib
shared: $(OBJECTS)
$(CC) -shared -o build/dice.so $^ $(ARC4RANDOM) -lm -lpcg_random -L$(PCG_SRC)
$(CC) -shared -o build/dice.so $^ $(ARC4RANDOM) -lm
cp build/dice.so build/libdice.so
# Linux
mv ./a.out build/dice | true
# Windows
mv ./a.exe build/dice | true

# hardcode for lex and yacc files
build/y.tab.o:
build/y.tab.o:
$(CC) $(SHAREDCFLAGS) -c build/y.tab.c -o $@
build/lex.yy.o:
$(CC) $(SHAREDCFLAGS) -c build/lex.yy.c -o $@
$(CC) $(SHAREDCFLAGS) -c build/lex.yy.c -o $@

# Wildcard everything else
build/*/%.o:src/grammar/*/%.c
Expand Down
2 changes: 1 addition & 1 deletion src/R/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

r: clean yacc lex compile $(OBJECTS)
mkdir -p build/r/
$(CC) -shared -o build/r/dice.so $(OBJECTS) $(ARC4RANDOM) -lR -lpcg_random -L$(PCG_SRC)
$(CC) -shared -o build/r/dice.so $(OBJECTS) $(ARC4RANDOM) -lR
Rscript src/R/main.r
6 changes: 3 additions & 3 deletions src/grammar/constructs/roll_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include "constructs/dice_enums.h"

typedef struct roll_params {
unsigned long long number_of_dice;
unsigned long long die_sides;
unsigned int number_of_dice;
unsigned int die_sides;
EXPLOSION_TYPE explode;
char** symbol_pool;
long long start_value;
int start_value;
DIE_TYPE dtype;
} roll_params;

Expand Down
6 changes: 2 additions & 4 deletions src/grammar/constructs/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

typedef struct vec {
DIE_TYPE dtype;

union { // Vectors can only contain one dice type
long long* content;
int* content;
char** symbols;
} storage;
unsigned long long length;

unsigned int length;
roll_params source;
bool has_source;
} vec;
Expand Down
Loading
Loading