Skip to content

Commit

Permalink
turn into a .a lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerboa-app committed Oct 18, 2023
1 parent 516e000 commit fe451e1
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 40 deletions.
40 changes: 27 additions & 13 deletions .github/workflows/ci-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:

- name: linux-linux
run: |
./build.sh -t -r
./build.sh -t -r -e
mkdir linux-x86_64
chmod +x build/Particles
cp build/Particles linux-x86_64/Particles-linux-x86_64
cp -r build/Examples linux-x86_64-examples
cp build/libjGL.a linux-x86_64/libjGL-linux-x86_64.a
cp LICENSE linux-x86_64-examples/
cp LICENSE linux-x86_64/
cp -r resource linux-x86_64/
- name: Tests
working-directory: ${{github.workspace}}/build
Expand All @@ -44,6 +44,13 @@ jobs:
with:
name: linux-x86_64
path: linux-x86_64

- name: buildArtifact
uses: actions/upload-artifact@v3
with:
name: linux-x86_64-examples
path: linux-x86_64-examples


linuxXwindows:
runs-on: ubuntu-22.04
Expand All @@ -56,18 +63,24 @@ jobs:

- name: linux-X-windows
run: |
./build.sh -t -w -r
./build.sh -t -w -r -e
mkdir windows
chmod +x build/Particles.exe
cp build/Particles.exe windows/
cp -r build/Examples windows-examples
cp build/libjGL.a windows/libjGL-windows.a
cp LICENSE windows-examples/
cp LICENSE windows/
cp -r resource windows/
- name: buildArtifact
uses: actions/upload-artifact@v3
with:
name: windows
path: windows

- name: buildArtifact
uses: actions/upload-artifact@v3
with:
name: windows-examples
path: windows-examples

linuxRun:
needs: linuxXlinux
Expand All @@ -80,16 +93,17 @@ jobs:
- name: get linux build
uses: actions/download-artifact@v3
with:
name: linux-x86_64
name: linux-x86_64-examples

- name: launch and screenshot
run: |
ls
chmod +x Particles-linux-x86_64
cd Particles
chmod +x Particles
export DISPLAY=:99
sudo Xvfb :99 -screen 0 800x600x24 &
sleep 5
MESA_GL_VERSION_OVERRIDE=3.3 ./Particles-linux-x86_64 &
MESA_GL_VERSION_OVERRIDE=3.3 ./Particles &
export PID=$!
sleep 10
xwd -root -silent | convert xwd:- png:screenshot.png
Expand Down Expand Up @@ -125,8 +139,8 @@ jobs:
name: "release-${{ github.ref_name }}"
tag_name: ${{ github.ref }}
files: |
Particles-linux-x86_64
Particles.exe
libjGL-linux-x86_64.a
libjGL-windows.a
# - name: create release
# id: createRelease
# uses: actions/create-release@v1
Expand Down
28 changes: 10 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,17 @@ include_directories(include include/vendored ${OPENGL_INCLUDE_DIRS} ${GLEW_INCLU

include_directories(src)

file(GLOB SRC
"src/*.cpp"
"src/Display/*.cpp"
"src/Util/*.cpp"
)

file(GLOB_RECURSE jGL_SRC
"src/jGL/*.cpp"
"src/*.cpp"
"src/Util/*.cpp"
)

if (WINDOWS)
add_compile_definitions(WINDOWS)

set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")

if (RELEASE)
# launch as windows, not console app - so cmd does not open as well
add_link_options(-mwindows)
endif ()
link_directories(include/vendored/VulkanSDK/Windows/Lib)
else()
# so nautilus etc recognise target as executable rather than .so
add_link_options(-no-pie)
link_directories(include/vendored/VulkanSDK/Linux/Lib)
endif()

Expand All @@ -91,15 +79,19 @@ if (VALIDATION)
endif()
endif()

add_library(jGL STATIC ${jGL_SRC})

target_compile_definitions(jGL PUBLIC GLSL_VERSION="330")
target_link_libraries(jGL glew freetype glm ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES} ${Vulkan_LIBRARIES} glfw shaderc_combined)

add_executable(Particles ${SRC} ${jGL_SRC})

target_compile_definitions(Particles PUBLIC GLSL_VERSION="330")
target_link_libraries(Particles glew freetype glm ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES} ${Vulkan_LIBRARIES} glfw shaderc_combined)
If (EXAMPLES)
add_subdirectory(examples)
endif()

IF (TEST_SUITE)

file(COPY "tests/resource" DESTINATION "${CMAKE_BINARY_DIR}/")

IF (WINDOWS)
## ask nicely for big objs (gnu assembler flag)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")
Expand Down
21 changes: 12 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,27 @@ VALIDATION=0
VERBOSE=0
VK_SDK="include/vendored/VulkanSDK"
BENCHMARK=0
EXAMPLES=0

while [[ $# -gt 0 ]]; do
case $1 in
-w|--windows)
WINDOWS=0
shift # past argument
;;
-e|--examples)
EXAMPLES=1
shift
;;
-v|--validation)
VALIDATION=1
shift
;;
-vv|--verbose-validation)
VALIDATION=1
VERBOSE=1
shift
;;
VALIDATION=1
VERBOSE=1
shift
;;
--vk)
VK_SDK=$2
shift
Expand Down Expand Up @@ -89,7 +94,7 @@ then
export VULKAN_SDK=$VK_SDK/Windows
export VULKAN_LIBRARY="$VK_SDK/Windows/Lib"
export VULKAN_INCLUDE_DIR="$VK_SDK/Windows/Include"
cmake -E chdir build cmake .. -D WINDOWS=ON -D VERBOSE=$VERBOSE -D VALIDATION=$VALIDATION -D RELEASE=$RELEASE -D TEST_SUITE=$TEST -D CMAKE_TOOLCHAIN_FILE=./windows.cmake && make -j 4 -C build
cmake -E chdir build cmake .. -D WINDOWS=ON -D VERBOSE=$VERBOSE -D EXAMPLES=$EXAMPLES -D VALIDATION=$VALIDATION -D RELEASE=$RELEASE -D TEST_SUITE=$TEST -D CMAKE_TOOLCHAIN_FILE=./windows.cmake && make -j 4 -C build
# now copy dlls
PREFIX="x86_64-w64-mingw32"

Expand Down Expand Up @@ -120,10 +125,8 @@ then
elif [[ $OSX -eq 0 ]];
then
cmake -E make_directory build
cmake -E chdir build cmake .. -D OSX=ON -D RELEASE=$RELEASE -D TEST_SUITE=$TEST -D CMAKE_TOOLCHAIN_FILE=./osx.cmake && make -j 4 -C build
cmake -E chdir build cmake .. -D OSX=ON -D RELEASE=$RELEASE -D TEST_SUITE=$TEST -D EXAMPLES=$EXAMPLES -D CMAKE_TOOLCHAIN_FILE=./osx.cmake && make -j 4 -C build
else
cmake -E make_directory build
cmake -E chdir build cmake -D BENCHMARK=$BENCHMARK -D VERBOSE=$VERBOSE -D VALIDATION=$VALIDATION -D RELEASE=$RELEASE -D TEST_SUITE=$TEST .. && make -j 4 -C build
cmake -E chdir build cmake -D BENCHMARK=$BENCHMARK -D VERBOSE=$VERBOSE -D VALIDATION=$VALIDATION -D RELEASE=$RELEASE -D TEST_SUITE=$TEST -D EXAMPLES=$EXAMPLES .. && make -j 4 -C build
fi

cp -r resource build
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(Particles)
23 changes: 23 additions & 0 deletions examples/Particles/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
file(GLOB_RECURSE SRC
"*.cpp"
)

if (WINDOWS)
if (RELEASE)
# launch as windows, not console app - so cmd does not open as well
add_link_options(-mwindows)
endif ()
else()
# so nautilus etc recognise target as executable rather than .so
add_link_options(-no-pie)
endif()

include_directories(.)

add_executable(Particles ${SRC})

target_link_libraries(Particles jGL)

set_target_properties(Particles PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Examples/Particles")

file(COPY resource DESTINATION "${CMAKE_BINARY_DIR}/Examples/Particles/")
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file added tests/resource/texture/saturn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fe451e1

Please sign in to comment.