Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
58 changes: 0 additions & 58 deletions .github/workflows/release-package.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ cmake-build-*/


# Added by cargo

/target
/lib
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[submodule "dependencies/fmtlib"]
path = dependencies/fmtlib
url = https://github.com/fmtlib/fmt.git
[submodule "dependencies/winflexbison"]
path = dependencies/winflexbison
url = https://github.com/lexxmark/winflexbison.git
[submodule "dependencies/emsdk"]
path = dependencies/emsdk
url = https://github.com/emscripten-core/emsdk.git
3 changes: 0 additions & 3 deletions .npmrc

This file was deleted.

161 changes: 81 additions & 80 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
cmake_minimum_required(VERSION 3.10)
project(gs2test VERSION 1.0)

set(CMAKE_DEBUG_POSTFIX _d)
# Enable verbose makefile for debugging purposes
set(CMAKE_VERBOSE_MAKEFILE ON)

set(BIN_DIR "bin" CACHE STRING "Binary output directory")
# Set debug postfix for binaries
set(CMAKE_DEBUG_POSTFIX _d)

# specify the C++ standard
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Set up output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/${BIN_DIR})

# Second, for multi-config builds (e.g. msvc)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/lib )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/lib )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/${BIN_DIR} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )

link_directories(${PROJECT_SOURCE_DIR}/lib)
# Include necessary directories
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
src
)

# Adjust library prefixes for specific platforms
if(WIN32 OR APPLE)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
endif()

# Handle winflexbison setup on Windows (not MinGW)
if(WIN32 AND NOT MINGW)
execute_process(COMMAND ${CMAKE_COMMAND} -S${CMAKE_CURRENT_SOURCE_DIR}/dependencies/winflexbison -B${CMAKE_CURRENT_SOURCE_DIR}/dependencies/winflexbison/build-winflex-bison -GNinja -DCMAKE_BUILD_TYPE=Release)
execute_process(COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/winflexbison/build-winflex-bison --parallel 8)
Expand All @@ -40,76 +34,83 @@ endif(WIN32 AND NOT MINGW)
find_package(BISON 3.4 REQUIRED)
find_package(FLEX REQUIRED)

# Check for Bison and Flex availability
if(NOT BISON_EXECUTABLE AND (WIN32 AND NOT MINGW))
message(FATAL_ERROR "Bison not found. Please ensure winflexbison is available.")
endif()

if(NOT FLEX_EXECUTABLE AND (WIN32 AND NOT MINGW))
message(FATAL_ERROR "Flex not found. Please ensure winflexbison is available.")
endif()

# Add Flex compatibility flags for Windows
if(WIN32 AND NOT MINGW)
set(FLEX_FLAGS "--wincompat")
endif()

# Generate parser and scanner with Bison/Flex
BISON_TARGET(GS2Parser generator/gs2parser.y ${CMAKE_CURRENT_BINARY_DIR}/gs2parser.tab.cc)
FLEX_TARGET(GS2Scanner generator/gs2scanner.l ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.cc DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.h COMPILE_FLAGS "${FLEX_FLAGS}")
FLEX_TARGET(GS2Scanner generator/gs2scanner.l ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.cc
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.h
COMPILE_FLAGS "${FLEX_FLAGS}")
ADD_FLEX_BISON_DEPENDENCY(GS2Scanner GS2Parser)

include_directories(
${CMAKE_CURRENT_BINARY_DIR}
src
# List source files
set(SOURCES_ALL
src/ast/ast.cpp
src/encoding/buffer.cpp
src/visitors/GS2CompilerVisitor.cpp
src/GS2BuiltInFunctions.cpp
src/GS2Bytecode.cpp
src/GS2Context.cpp
src/Parser.cpp
src/c_interface.cpp

src/ast/ast.h
src/ast/astvisitor.h
src/ast/astnodevisitor.h
src/ast/expressiontypes.h
src/encoding/buffer.h
src/encoding/graalencoding.h
src/utils/EventHandler.h
src/exceptions/GS2CompilerError.h
src/utils/ContextThreadPool.h
src/utils/format_string.h
src/visitors/FunctionInspectVisitor.h
src/visitors/GS2CompilerVisitor.h
src/visitors/GS2SourceVisitor.h
src/CompilerThreadJob.h
src/GS2BuiltInFunctions.h
src/GS2Bytecode.h
src/GS2Context.h
src/opcodes.h
src/Parser.h

${BISON_GS2Parser_INPUT}
${FLEX_GS2Scanner_INPUT}
${BISON_GS2Parser_OUTPUTS}
${FLEX_GS2Scanner_OUTPUTS}
)

set(SOURCES_ALL
src/ast/ast.cpp
src/encoding/buffer.cpp
src/visitors/GS2CompilerVisitor.cpp
src/GS2BuiltInFunctions.cpp
src/GS2Bytecode.cpp
src/GS2Context.cpp
src/Parser.cpp
src/c_interface.cpp

src/ast/ast.h
src/ast/astvisitor.h
src/ast/astnodevisitor.h
src/ast/expressiontypes.h
src/encoding/buffer.h
src/encoding/graalencoding.h
src/utils/EventHandler.h
src/exceptions/GS2CompilerError.h
src/utils/ContextThreadPool.h
src/visitors/FunctionInspectVisitor.h
src/visitors/GS2CompilerVisitor.h
src/visitors/GS2SourceVisitor.h
src/CompilerThreadJob.h
src/GS2BuiltInFunctions.h
src/GS2Bytecode.h
src/GS2Context.h
src/opcodes.h
src/Parser.h

${BISON_GS2Parser_INPUT}
${FLEX_GS2Scanner_INPUT}
${BISON_GS2Parser_OUTPUTS}
${FLEX_GS2Scanner_OUTPUTS})

add_subdirectory(${PROJECT_SOURCE_DIR}/dependencies/fmtlib EXCLUDE_FROM_ALL)

if (DEFINED EMSCRIPTEN)
add_executable(gs2test ${SOURCES_ALL} src/js_interface.cpp)
set_target_properties(gs2test PROPERTIES LINK_FLAGS "--embind-emit-tsd gs2test.d.ts -s ENVIRONMENT=web -s DYNAMIC_EXECUTION=0 -s SINGLE_FILE=1 -s MODULARIZE -s 'EXPORT_NAME=GS2Compiler' --bind")
else()
add_executable(gs2test ${SOURCES_ALL} src/main.cpp)
endif()
# Create executable target
add_executable(gs2test ${SOURCES_ALL} src/main.cpp)

if (STATIC)
add_library(gs2compiler STATIC ${SOURCES_ALL})
# Add library target
if(STATIC)
add_library(gs2compiler STATIC ${SOURCES_ALL})
else()
add_library(gs2compiler SHARED ${SOURCES_ALL})
add_library(gs2compiler SHARED ${SOURCES_ALL})
endif()

# Set special compile options for MinGW
if(WIN32 AND MINGW)
target_compile_options(gs2compiler PRIVATE "-fno-rtti")
target_compile_options(gs2compiler PRIVATE "-fno-rtti")
endif()

set_property(TARGET gs2test PROPERTY CXX_STANDARD 23)
set_property(TARGET gs2compiler PROPERTY CXX_STANDARD 23)

target_link_libraries(gs2test fmt::fmt)
target_link_libraries(gs2compiler fmt::fmt)

# Export include directory for use by other projects
set(GS2COMPILER_INCLUDE_DIRECTORY
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include"
"${PROJECT_SOURCE_DIR}/src"
PARENT_SCOPE)
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include"
"${PROJECT_SOURCE_DIR}/src"
PARENT_SCOPE
)
25 changes: 17 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[package]
name = "gs2compiler"
version = "0.1.0"
version = "0.2.3"
edition = "2021"
build = "build.rs"
description = "Compiles GS2 source code into GS2 bytecode."
license = "GPL-3.0-only"

[dependencies]
libc = "0.2.155"
Expand Down
20 changes: 9 additions & 11 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,18 @@ def buildStep(dockerImage, generator, os, osdir, defines) {

}

sh("rm -rf build");
sh("mkdir -p build/");
sh("mkdir -p lib/");
sh("rm -rfv build/*");
sh("rm -rfv lib/*");

discordSend(description: "", footer: "", link: env.BUILD_URL, result: currentBuild.currentResult, title: "[${split_job_name[0]}] Starting ${os} build target...", webhookURL: env.GS2EMU_WEBHOOK);

dir("build") {
sh("cmake -G\"${generator}\" -DCMAKE_BUILD_TYPE=Release ${defines} -DVER_EXTRA=\"-${fixed_os}-${fixed_job_name}\" .. || true"); // Temporary fix for Windows MingW builds
sh("cmake -G\"${generator}\" -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=bin -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=lib -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=lib -DCMAKE_BUILD_TYPE=Release ${defines} -DVER_EXTRA=\"-${fixed_os}-${fixed_job_name}\" .. || true"); // Temporary fix for Windows MingW builds
sh("cmake --build . --config Release --target all -- -j `nproc`");
}

archiveArtifacts(artifacts: 'lib/*.dylib,lib/*.so,bin/*.dll', allowEmptyArchive: true);
stash(name: osdir, includes: 'lib/*.dylib,lib/*.so,bin/*.dll', allowEmpty: true);
archiveArtifacts(artifacts: 'build/lib/*.dylib,build/lib/*.so,build/bin/*.dll', allowEmptyArchive: true);
stash(name: osdir, includes: 'build/lib/*.dylib,build/lib/*.so,build/bin/*.dll', allowEmpty: true);

discordSend(description: "", footer: "", link: env.BUILD_URL, result: currentBuild.currentResult, title: "[${split_job_name[0]}] Build ${fixed_job_name} #${env.BUILD_NUMBER} Target: ${os} successful!", webhookURL: env.GS2EMU_WEBHOOK);
}
Expand Down Expand Up @@ -256,7 +254,7 @@ killall_jobs();

project.builds.each { v ->
branches["Build ${v.DockerRoot}/${v.DockerImage}:${v.DockerTag}"] = {
node {
node("amd64") {
buildStep(v.DockerImage, v.Generator, v.OS, v.OSDir, v.Defines);
}
}
Expand All @@ -273,12 +271,12 @@ killall_jobs();
dir("bindings/dotnet/cross-compile/${v.OSDir}/") {
unstash(name: v.OSDir);
try {
sh("mv -fv bin/* .");
sh("rm -rf bin")
sh("mv -fv build/bin/* .");
sh("rm -rf build/bin")
} catch(err) { }
try {
sh("mv -fv lib/* .");
sh("rm -rf lib")
sh("mv -fv build/lib/* .");
sh("rm -rf build/lib")
} catch(err) { }
}
}
Expand Down
Loading