Skip to content

Commit

Permalink
Merge pull request #967 from stephengtuggy/boost_program_options_0.9.x
Browse files Browse the repository at this point in the history
Switch Vega Strike 0.9.x over to use boost::program_options
  • Loading branch information
stephengtuggy authored Jan 11, 2025
2 parents a618804 + c13e0c1 commit 27ed843
Show file tree
Hide file tree
Showing 13 changed files with 396 additions and 328 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/macos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
continue-on-error: false
continue-on-error: true

defaults:
run:
Expand All @@ -21,17 +21,26 @@ jobs:
fail-fast: false
matrix:
os:
# x86-64
- macos-13
# - macos-14
# M1 processor
#- macos-14
python-version:
#- 3.12.8
- 3.13.1
compiler:
- clang
- gcc
- AppleClang
#- clang
#- gcc
homebrew-gl:
- true
# - false
#- false
homebrew-al:
- true
- false
#- false
ENABLE_PIE:
- 'ON'
#- 'OFF'

steps:

Expand All @@ -43,12 +52,14 @@ jobs:
# - git
# - jpeg
# - libpng
# - libvorbis
# - ~libvorbis~
# - python
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
id: vega-py-setup
with:
python-version: 3.12.8
python-version: ${{ matrix.python-version }}
update-environment: true # false

- name: Install dependencies using homebrew
run: brew install boost-python3 gtk+3 gtkglext sdl libvorbis
Expand Down Expand Up @@ -83,8 +94,13 @@ jobs:
env:
MY_OS_NAME: macos
COMPILER: ${{ matrix.compiler }}
FLAGS: -DCMAKE_FIND_FRAMEWORK=LAST
FLAGS: "-DCMAKE_FIND_FRAMEWORK=LAST -DENABLE_PIE=${{ matrix.ENABLE_PIE }} -DPython3_ROOT_DIR=${{ matrix.vega-py-setup.outputs.python-path }}"
OPENALDIR: "$(brew --prefix)/opt/openal-soft"
Python3_ROOT_DIR: ${{ matrix.vega-py-setup.outputs.python-path }}
Python_ROOT_DIR: ${{ matrix.vega-py-setup.outputs.python-path }}
pythonLocation: ${{ matrix.vega-py-setup.outputs.python-path }}
PYTHONHOME: ""
PYTHONPATH: ""
run: script/cibuild $FLAGS

- name: Test
Expand Down
33 changes: 24 additions & 9 deletions .github/workflows/macos-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
continue-on-error: false

defaults:
run:
Expand All @@ -23,17 +22,26 @@ jobs:
fail-fast: false
matrix:
os:
# x86-64
- macos-13
# - macos-14
# M1 processor
#- macos-14
python-version:
#- 3.12.8
- 3.13.1
compiler:
# - clang
- gcc
- AppleClang
#- clang
#- gcc
homebrew-gl:
- true
# - false
#- false
homebrew-al:
- true
# - false
#- false
ENABLE_PIE:
- 'ON'
#- 'OFF'

steps:

Expand All @@ -45,12 +53,14 @@ jobs:
# - git
# - jpeg
# - libpng
# - libvorbis
# - ~libvorbis~
# - python
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
id: vega-py-setup
with:
python-version: 3.12.8
python-version: ${{ matrix.python-version }}
update-environment: true # false

- name: Install dependencies using homebrew
run: brew install boost-python3 gtk+3 gtkglext sdl libvorbis
Expand Down Expand Up @@ -90,8 +100,13 @@ jobs:
env:
MY_OS_NAME: macos
COMPILER: ${{ matrix.compiler }}
FLAGS: -DCMAKE_FIND_FRAMEWORK=LAST
FLAGS: "-DCMAKE_FIND_FRAMEWORK=LAST -DENABLE_PIE=${{ matrix.ENABLE_PIE }} -DPython3_ROOT_DIR=${{ matrix.vega-py-setup.outputs.python-path }}"
OPENALDIR: "$(brew --prefix)/opt/openal-soft"
Python3_ROOT_DIR: ${{ matrix.vega-py-setup.outputs.python-path }}
Python_ROOT_DIR: ${{ matrix.vega-py-setup.outputs.python-path }}
pythonLocation: ${{ matrix.vega-py-setup.outputs.python-path }}
PYTHONHOME: ""
PYTHONPATH: ""
IS_RELEASE: 1
run: script/cibuild $FLAGS

Expand Down
134 changes: 48 additions & 86 deletions engine/CMakeLists.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion engine/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@
},
"cacheVariables": {
"CMAKE_PREFIX_PATH": "/opt/local",
"Boost_INCLUDE_DIR": "/opt/local/libexec/boost/1.81/include"
"Boost_INCLUDE_DIR": "/opt/local/libexec/boost/1.81/include",
"CMAKE_FIND_FRAMEWORK": "LAST"
}
},
{
Expand Down
116 changes: 62 additions & 54 deletions engine/setup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,74 +26,82 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.21 FATAL_ERROR)

IF (CMAKE_SYSTEM_NAME STREQUAL BEOS OR CMAKE_SYSTEM_NAME STREQUAL Windows)
MESSAGE ("SKIPPING vegasettings - not supported on this platform at this time")
MESSAGE ("SKIPPING vegasettings - not supported on this platform at this time")
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
#SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "")
SET(VEGASETTINGS_SOURCES
src/c/setup.cpp
src/include/central.cpp
src/include/display_gtk.cpp
src/include/display_dialog.cpp
src/include/file.cpp
src/include/general.cpp
../src/common/common.cpp
)
#SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "")
SET(VEGASETTINGS_SOURCES
src/c/setup.cpp
src/include/central.cpp
src/include/display_gtk.cpp
src/include/display_dialog.cpp
src/include/file.cpp
src/include/general.cpp
../src/common/common.cpp
)

ADD_EXECUTABLE(vegasettings ${VEGASETTINGS_SOURCES})
target_compile_definitions(vegasettings PUBLIC "BOOST_ALL_DYN_LINK" "$<$<CONFIG:Debug>:BOOST_DEBUG_PYTHON>" "$<$<CONFIG:Debug>:Py_DEBUG>")
ADD_EXECUTABLE(vegasettings ${VEGASETTINGS_SOURCES})
TARGET_COMPILE_DEFINITIONS(vegasettings PUBLIC "BOOST_ALL_DYN_LINK")

#find GTK3
FIND_PACKAGE(GTK3 3.0 REQUIRED gtk)
IF(GTK3_FOUND)
SET(GTK_LIBS ${GTK3_LIBRARIES})
SET(GTK_CFLAGS ${GTK3_DEFINITIONS} -DGTK)
ELSE(GTK3_FOUND)
MESSAGE("Did not find GTK3")
ENDIF(GTK3_FOUND)
#find GTK3
FIND_PACKAGE(GTK3 3.0 REQUIRED gtk)
IF(GTK3_FOUND)
SET(GTK_LIBS ${GTK3_LIBRARIES})
SET(GTK_CFLAGS ${GTK3_DEFINITIONS} -DGTK)
ELSE(GTK3_FOUND)
MESSAGE("Did not find GTK3")
ENDIF(GTK3_FOUND)

ADD_DEFINITIONS(${GTK_CFLAGS})
INCLUDE_DIRECTORIES(
ADD_DEFINITIONS(${GTK_CFLAGS})

FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED)

INCLUDE_DIRECTORIES(
${Vega_Strike_SOURCE_DIR}/setup/src/include
${Vega_Strike_SOURCE_DIR}/src/common
${Vega_Strike_BINARY_DIR}
${GTK3_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
TARGET_LINK_LIBRARIES(vegasettings ${GTK_LIBS})
TARGET_LINK_LIBRARIES(vegasettings ${GTK_LIBS} ${Boost_LIBRARIES})

INSTALL(TARGETS vegasettings DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT vegasettings)
INSTALL(TARGETS vegasettings DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT vegasettings)
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Darwin)
SET(VEGASETTINGS_SOURCES
src/c/setup.cpp
src/include/central.cpp
src/include/display_gtk.cpp
src/include/display_dialog.cpp
src/include/file.cpp
src/include/general.cpp
../src/common/common.cpp
)
SET(VEGASETTINGS_SOURCES
src/c/setup.cpp
src/include/central.cpp
src/include/display_gtk.cpp
src/include/display_dialog.cpp
src/include/file.cpp
src/include/general.cpp
../src/common/common.cpp
)

ADD_EXECUTABLE(vegasettings MACOSX_BUNDLE ${VEGASETTINGS_SOURCES})
target_compile_definitions(vegasettings PUBLIC "BOOST_ALL_DYN_LINK" "$<$<CONFIG:Debug>:BOOST_DEBUG_PYTHON>" "$<$<CONFIG:Debug>:Py_DEBUG>")
ADD_EXECUTABLE(vegasettings MACOSX_BUNDLE ${VEGASETTINGS_SOURCES})
TARGET_COMPILE_DEFINITIONS(vegasettings PUBLIC "BOOST_ALL_DYN_LINK")

#find GTK3
FIND_PACKAGE(GTK3 3.0 REQUIRED gtk)
IF(GTK3_FOUND)
SET(GTK_LIBS ${GTK3_LIBRARIES})
SET(GTK_CFLAGS ${GTK3_DEFINITIONS} -DGTK)
ELSE(GTK3_FOUND)
MESSAGE("Did not find GTK3")
ENDIF(GTK3_FOUND)
#find GTK3
FIND_PACKAGE(GTK3 3.0 REQUIRED gtk)
IF(GTK3_FOUND)
SET(GTK_LIBS ${GTK3_LIBRARIES})
SET(GTK_CFLAGS ${GTK3_DEFINITIONS} -DGTK)
ELSE(GTK3_FOUND)
MESSAGE("Did not find GTK3")
ENDIF(GTK3_FOUND)

ADD_DEFINITIONS(${GTK_CFLAGS})
INCLUDE_DIRECTORIES(
${Vega_Strike_SOURCE_DIR}/setup/src/include
${Vega_Strike_SOURCE_DIR}/src/common
${Vega_Strike_BINARY_DIR}
${GTK3_INCLUDE_DIRS}
)
TARGET_LINK_LIBRARIES(vegasettings ${GTK_LIBS})
ADD_DEFINITIONS(${GTK_CFLAGS})

FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED)

INCLUDE_DIRECTORIES(
${Vega_Strike_SOURCE_DIR}/setup/src/include
${Vega_Strike_SOURCE_DIR}/src/common
${Vega_Strike_BINARY_DIR}
${GTK3_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
TARGET_LINK_LIBRARIES(vegasettings ${GTK_LIBS} ${Boost_LIBRARIES})

INSTALL(TARGETS vegasettings DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT vegasettings BUNDLE DESTINATION "/Applications/VegaStrike")
INSTALL(TARGETS vegasettings DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT vegasettings BUNDLE DESTINATION "/Applications/VegaStrike")
ELSE ()
MESSAGE ("SKIPPING vegasettings - not supported on this platform at this time")
MESSAGE ("SKIPPING vegasettings - not supported on this platform at this time")
ENDIF ()
41 changes: 32 additions & 9 deletions engine/setup/src/c/setup.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2001-2022 Daniel Horn, David Ranger, pyramid3d,
* setup.cpp
*
* Copyright (C) 2001-2025 Daniel Horn, David Ranger, pyramid3d,
* Stephen G. Tuggy, and other Vega Strike contributors.
*
* https://github.com/vegastrike/Vega-Strike-Engine-Source
Expand All @@ -13,7 +15,7 @@
*
* Vega Strike is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
Expand All @@ -36,6 +38,8 @@
#endif
#include <vector>
#include <string>
#include <boost/program_options.hpp>

using std::string;
using std::vector;
char origpath[65536];
Expand Down Expand Up @@ -114,16 +118,36 @@ int main(int argc, char *argv[]) {

changeToProgramDirectory(argv[0]);
{
boost::program_options::options_description setup_options("Vega Strike setup utility");
setup_options.add_options()
("target,D", boost::program_options::value<std::string>(), "Specify data directory, full path expected")
("help,h", "Show this help and exit")
;

vector<string> data_paths;

if (argc > 1) {
if (strcmp(argv[1], "--target") == 0 && argc > 2) {
data_paths.push_back(argv[2]);
fprintf(stdout, "Set data directory to %s\n", argv[2]);
try {
auto style = static_cast<boost::program_options::command_line_style::style_t>(boost::program_options::command_line_style::unix_style
| boost::program_options::command_line_style::case_insensitive);
boost::program_options::variables_map vm;
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(setup_options).style(style).run(), vm);
boost::program_options::notify(vm);

if (vm.count("help")) {
std::cout << setup_options << std::endl;
return EXIT_SUCCESS;
}

if (vm.count("target")) {
data_paths.push_back(vm["target"].as<std::string>());
std::cout << "Set data directory to " << vm["target"].as<std::string>() << std::endl;
} else {
fprintf(stderr, "Usage: vegasettings [--target DATADIR]\n");
return 1;
std::cerr << setup_options << std::endl;
return EXIT_FAILURE;
}
} catch (const boost::program_options::error& e) {
std::cerr << setup_options << std::endl;
return EXIT_FAILURE;
}

#ifdef DATA_DIR
Expand Down Expand Up @@ -222,4 +246,3 @@ int main(int argc, char *argv[]) {
Start(&argc, &argv);
return 0;
}

Loading

0 comments on commit 27ed843

Please sign in to comment.