Skip to content
Open
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
82 changes: 71 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/cache@v4
with:
path: test/gamescripts
key: rpu-and-modderpack-gamescripts-v1004
key: rpu-and-modderpack-gamescripts-v1006

- name: Download RPU scripts & modderspack
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check')
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
uses: actions/cache@v4
with:
path: test/gamescripts
key: rpu-and-modderpack-gamescripts-v1004
key: rpu-and-modderpack-gamescripts-v1006
- name: Download RPU scripts & modderspack
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check')
shell: bash
Expand Down Expand Up @@ -234,7 +234,7 @@ jobs:
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check')
with:
path: test/gamescripts
key: rpu-and-modderpack-gamescripts-v1004
key: rpu-and-modderpack-gamescripts-v1006
fail-on-cache-miss: true
- name: Test on Fallout RPU
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check')
Expand All @@ -249,9 +249,18 @@ jobs:
path: build/bin/**

build_linux:
name: Linux build
name: Linux build (${{ matrix.arch }})
runs-on: ubuntu-22.04
needs: [setup_rpu_tests]
needs: [setup_rpu_tests]
strategy:
matrix:
include:
- arch: x86
cmake_flags: ""
artifact_name: linux-x86
- arch: x64
cmake_flags: "-DFORCE_32BIT=OFF"
artifact_name: linux-x64
defaults:
run:
shell: bash
Expand All @@ -260,6 +269,7 @@ jobs:
uses: actions/checkout@v4

- name: Dependencies (x86)
if: matrix.arch == 'x86'
run: |
sudo dpkg --add-architecture i386
sudo apt update
Expand All @@ -269,7 +279,51 @@ jobs:
run: |
mkdir out
cd out
cmake ..
cmake ${{ matrix.cmake_flags }} ..
make

- name: Test
shell: bash
run: |
export SSLC=../out/bin/sslc
(cd test && bash ./tests.bash)

- name: Get cache RPU & modderspack
uses: actions/cache@v4
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check')
with:
path: test/gamescripts
key: rpu-and-modderpack-gamescripts-v1006
fail-on-cache-miss: true
- name: Test on Fallout RPU
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check')
run: |
export SSLC=../out/bin/sslc
(cd test && bash ./test_on_fallout2_rpu_run.bash)

- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: out/bin/**
retention-days: 7

build_macos:
name: macOS build (x64)
runs-on: macos-latest
needs: [setup_rpu_tests]
defaults:
run:
shell: bash
steps:
- name: Clone
uses: actions/checkout@v4

- name: Configure & build
run: |
mkdir out
cd out
cmake -DFORCE_32BIT=OFF ..
make

- name: Test
Expand All @@ -283,7 +337,7 @@ jobs:
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check')
with:
path: test/gamescripts
key: rpu-and-modderpack-gamescripts-v1004
key: rpu-and-modderpack-gamescripts-v1006
fail-on-cache-miss: true
- name: Test on Fallout RPU
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check')
Expand All @@ -294,14 +348,14 @@ jobs:
- name: Upload
uses: actions/upload-artifact@v4
with:
name: linux
name: macos-x64
path: out/bin/**
retention-days: 7

release:
if: github.event_name == 'push'
runs-on: ubuntu-22.04
needs: [build_windows, build_linux, build_emscripten]
needs: [build_windows, build_linux, build_macos, build_emscripten]
permissions: write-all
steps:
- name: Download all artifacts
Expand Down Expand Up @@ -330,8 +384,14 @@ jobs:
mv windows-release-dll/Build/parser.dll parser.dll
rm -rf windows-release-dll

mv linux/sslc sslc-linux
rm -rf linux
mv linux-x86/sslc sslc-linux-x86
rm -rf linux-x86

mv linux-x64/sslc sslc-linux-x64
rm -rf linux-x64

mv macos-x64/sslc sslc-macos-x64
rm -rf macos-x64

ls -laR

Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ set(EXECUTABLE_NAME sslc)

project(${EXECUTABLE_NAME})

# Set 32-bit flag for all targets because it segfaults on 64-bit
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
option(FORCE_32BIT "Force 32-bit build" ON)

if(FORCE_32BIT AND APPLE)
message(FATAL_ERROR "Unable to compile 32-bit on Apple")
endif()

if(FORCE_32BIT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

Expand Down
2 changes: 1 addition & 1 deletion compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int strcat_s(char *dest, size_t destsz, const char *src);
#define _stat stat


#if !defined(__EMSCRIPTEN__)
#if defined(__linux__) && !defined(__EMSCRIPTEN__)
typedef __time_t time_t;
#endif

Expand Down
2 changes: 1 addition & 1 deletion compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ FILE *parseroutput;
#define FINDFIRST(x, y) _findfirst(x, y)
#define FINDNEXT(x, y) _findnext(x, y)
#define FINDCLOSE(x, y) _findclose(x)
#define FINDHANDLE long
#define FINDHANDLE intptr_t
//#define BAD_HANDLE -1

#if defined(_MSC_VER)
Expand Down
13 changes: 7 additions & 6 deletions gencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string.h>
#include <stdarg.h>
#include <setjmp.h>
#include <stdint.h>

#include "parse.h"
#include "parselib.h"
Expand Down Expand Up @@ -53,22 +54,22 @@ static void writeWord(unsigned short a, FILE *f) {
writeByte((unsigned char)(a & 0x00ff), f);
}

static void writeLong(unsigned long a, FILE *f) {
static void writeLong(uint32_t a, FILE *f) {
writeWord((unsigned short)(a >> 16), f);
writeWord((unsigned short)(a & 0x0000ffff), f);
}

void writeInt(unsigned long a, FILE *f) {
void writeInt(uint32_t a, FILE *f) {
writeWord(O_INTOP, f);
writeLong(a, f);
}

void writeFloat(float a, FILE *f) {
writeWord(O_FLOATOP, f);
writeLong(*(unsigned long *)&a, f);
writeLong(*(uint32_t *)&a, f);
}

void writeString(unsigned long a, FILE *f) {
void writeString(uint32_t a, FILE *f) {
writeWord(O_STRINGOP, f);
writeLong(a, f);
}
Expand All @@ -84,7 +85,7 @@ static void writeMemory(unsigned char *p, int len, FILE *f) {
static void writenamelist(FILE *f, char *namelist) {
if (namelist) {
int len;
writeLong(*(unsigned long *)namelist, f);
writeLong(*(unsigned int *)namelist, f);
namelist += 4;
while((len = *(unsigned short *)namelist) != 0xffff) {
writeWord((unsigned short)len, f);
Expand Down Expand Up @@ -696,7 +697,7 @@ static int writeStatement(NodeList *n, int i, FILE *f) {
patchOffset(trueAddr+OPCODE_SIZE, outputTell(f), f);
}
else {
unsigned long a = outputTell(f);
int a = outputTell(f);
patchOffset(falseAddr+OPCODE_SIZE, a, f);
}

Expand Down
8 changes: 5 additions & 3 deletions gencode.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#ifndef _GENCODE_H_
#define _GENCODE_H_

#include <stdint.h>

extern void generateCode(Program *, const char *);

extern int writeNumExpression(NodeList *n, int i, int num, FILE *f);
extern int writeExpression(NodeList *n, int i, FILE *f);
extern int writeExpressionProc(NodeList *n, int i, FILE *f);
extern int writeNumExpressionProc(NodeList *n, int i, int num, FILE *f);
extern void writeOp(unsigned short op, FILE *f);
extern void writeInt(unsigned long a, FILE *f);
extern void writeInt(uint32_t a, FILE *f);
extern void writeFloat(float a, FILE *f);
extern void writeString(unsigned long a, FILE *f);
extern void writeString(uint32_t a, FILE *f);
extern int writeBlock(NodeList *n, int i, FILE *f);

#endif
#endif
4 changes: 2 additions & 2 deletions lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ static int fileNameSize=0;
static char **fileNames=0;
const char *AddFileName(const char *c) {
if(fileNameSize==0) {
fileNames=(char**)malloc(8*4);
fileNames=(char**)malloc(8*sizeof(char*));
fileNameSize=8;
} else if(numFileNames==fileNameSize-1) {
fileNameSize+=8;
fileNames=(char**)realloc(fileNames, fileNameSize*4);
fileNames=(char**)realloc(fileNames, fileNameSize*sizeof(char*));
}
fileNames[numFileNames]=(char*)malloc(strlen(c)+1);
strcpy(fileNames[numFileNames], c);
Expand Down
4 changes: 2 additions & 2 deletions mcpp_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ int get_ch( void)
* Always return the value representable by unsigned char.
*/
{
int len;
size_t len;
int c;
FILEINFO * file;

Expand Down Expand Up @@ -1186,7 +1186,7 @@ int get_ch( void)
infile->fp = fopen( cur_fullname, "r");
fseek( infile->fp, infile->pos, SEEK_SET);
} /* Re-open the includer and restore the file-position */
len = (int) (infile->bptr - infile->buffer);
len = infile->bptr - infile->buffer;
infile->buffer = (char*)realloc( infile->buffer, NBUFF);
/* Restore full size buffer to get the next line */
infile->bptr = infile->buffer + len;
Expand Down
4 changes: 2 additions & 2 deletions mcpp_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ static int open_file(
{
char dir_fname[ PATHMAX] = { EOS, };
static int max_open;
int len;
size_t len;
FILEINFO * file = infile;
FILE * fp;
char * fullname;
Expand Down Expand Up @@ -1088,7 +1088,7 @@ static int open_file(
} else if (fp == NULL) /* No read permission */
goto _false;
/* Truncate buffer of the includer to save memory */
len = (int) (file->bptr - file->buffer);
len = file->bptr - file->buffer;
if (len) {
file->buffer = xrealloc( file->buffer, len + 1);
file->bptr = file->buffer + len;
Expand Down
4 changes: 4 additions & 0 deletions noconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@
#endif

#ifndef HOST_HAVE_STPCPY
#if defined(__APPLE__)
#define HOST_HAVE_STPCPY TRUE
#else
#define HOST_HAVE_STPCPY FALSE
#endif
#endif

/*
* Declaration of standard library functions and macros.
Expand Down
14 changes: 7 additions & 7 deletions optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static int ConstantPropagateExpression(Node* nodes, Variable* vars, Value* value
}

static int* FindAssignmentsInBlock(const Node* nodes, const Variable* vars, int varCount) {
int* results = (int*)calloc(1, varCount * 4);
int* results = (int*)calloc(1, varCount * sizeof(int));
int statementdepth = 1, var;
assert(nodes->token == T_START_STATEMENT);
while (statementdepth) {
Expand Down Expand Up @@ -719,7 +719,7 @@ static void VariableReuse(NodeList* _nodes, VariableList* vars, int numArgs, Var
static void DeadVariableRemoval(NodeList* _nodes, VariableList* vars, int numArgs) {
int i, var, j;
Node* nodes = _nodes->nodes;
int *uses = (int*)calloc(1, vars->numVariables * 4);
int *uses = (int*)calloc(1, vars->numVariables * sizeof(int));
for (i = 0; i < vars->numVariables; i++) uses[i] = 0;
for (i = 0; i < _nodes->numNodes; i++) {
if (nodes[i].token == T_SYMBOL && (var = LookupVariable(&nodes[i])) != -1) {
Expand Down Expand Up @@ -1114,16 +1114,16 @@ static void GetNamelistData(char* namelist, int* outEntries, char** outEndptr, i
list += *(unsigned short*)list + 2;
}
endptr = list + 2;
refs = (int*)calloc(1, entries * 4);
offsets = (int*)malloc(entries * 4);
transforms = (int*)malloc(entries * 4);
refs = (int*)calloc(1, entries * sizeof(int));
offsets = (int*)malloc(entries * sizeof(int));
transforms = (int*)malloc(entries * sizeof(int));
//first find the offsets
list = namelist + 4;
for (i = 0; i < entries; i++) {
offsets[i] = 2 + (unsigned int)list - (unsigned int)namelist;
offsets[i] = 2 + (int)(list - namelist);
list += *(unsigned short*)list + 2;
}
memcpy(transforms, offsets, entries * 4);
memcpy(transforms, offsets, entries * sizeof(int));

*outEntries = entries;
*outEndptr = endptr;
Expand Down
Loading