Skip to content

Commit

Permalink
Merge pull request #474 from DarkWanderer/revert-to-fetch
Browse files Browse the repository at this point in the history
Revert Orbiter to use Fetch mechanism instead of submodules
  • Loading branch information
jarmonik authored Sep 6, 2024
2 parents c630b2d + 7001240 commit 2fec70a
Show file tree
Hide file tree
Showing 32 changed files with 151 additions and 126 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
required: true
type: string
default: 2024.1.0
description: Release tag. Recommended format year.month.version

run-name: Release ${{ inputs.version }}

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Problem Matcher
uses: ammaraskar/msvc-problem-matcher@master
Expand Down
9 changes: 0 additions & 9 deletions .gitmodules

This file was deleted.

5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ set(HTMLHELP_LIB_DIR ${HTMLHELP_DIR}/lib-${ARCH})
set(HTMLHELP_LIB ${HTMLHELP_LIB_DIR}/Htmlhelp.lib)

set(ORBITER_TOOL_MESHC "$<TARGET_FILE:meshc>")
set(ldoc $<TARGET_FILE:lua_bin> ${ORBITER_BINARY_ROOT_DIR}/packages/LDoc/ldoc.lua -v --multimodule)
set(ldoc $<TARGET_FILE:lua::exe> ${ORBITER_BINARY_ROOT_DIR}/packages/LDoc/ldoc.lua -v --multimodule)

find_package(OpenGL QUIET)
find_package(HTMLHelp)
Expand Down Expand Up @@ -390,9 +390,6 @@ endfunction()
install(DIRECTORY Scenarios Textures Meshes Config GravityModels Script Flights BinAssets/
DESTINATION ${ORBITER_INSTALL_ROOT_DIR}
)
#install(FILES ${LUA_DLL_DIR}/lua5.1.lib
# DESTINATION ${ORBITER_INSTALL_SDK_DIR}/lib/Lua
#)

set(CMAKE_MODULE_PATH
${ORBITER_BINARY_ROOT_DIR}
Expand Down
87 changes: 14 additions & 73 deletions Extern/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,22 @@
project(Extern)
Include(FetchContent)

##########################################
## Lua
if(NOT DEFINED ORBITER_BINARY_ROOT_DIR)
message(FATAL_ERROR "ORBITER_BINARY_ROOT_DIR is not set")
endif(NOT DEFINED ORBITER_BINARY_ROOT_DIR)

file(GLOB LUA_FILES "Lua/*.c" "Lua/*.h")
list(REMOVE_ITEM LUA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Lua/lua.c)
list(REMOVE_ITEM LUA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Lua/luac.c)
list(REMOVE_ITEM LUA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Lua/print.c)
add_library(lua SHARED ${LUA_FILES})
target_compile_definitions(lua PUBLIC LUA_BUILD_AS_DLL)

# for tests and running Orbiter from inside the build dir
set_target_properties(lua PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
)

install(TARGETS lua RUNTIME DESTINATION ${ORBITER_INSTALL_ROOT_DIR})
install(TARGETS lua DESTINATION ${ORBITER_INSTALL_SDK_DIR}/lib/Lua)
install(TARGETS lua DESTINATION ${ORBITER_INSTALL_SDK_DIR}/Utils/)


add_executable(lua_bin
${LUA_FILES} "Lua/lua.c"
)
set_target_properties(lua_bin
PROPERTIES
OUTPUT_NAME lua
)
set_target_properties(lua_bin PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
)

install(TARGETS lua_bin
DESTINATION ${ORBITER_BINARY_ROOT_DIR}
)
install(TARGETS lua_bin DESTINATION ${ORBITER_INSTALL_SDK_DIR}/Utils/)
add_subdirectory(lua)
add_subdirectory(zlib)

## LFS
add_library(lfs SHARED luafilesystem/src/lfs.c)
install(TARGETS lfs DESTINATION ${ORBITER_BINARY_ROOT_DIR})
install(TARGETS lfs DESTINATION ${ORBITER_INSTALL_SDK_DIR}/Utils/)
target_include_directories(lfs PUBLIC Lua)
target_link_libraries(lfs lua)
SET_TARGET_PROPERTIES(lfs PROPERTIES LINK_FLAGS "/DEF:\"${CMAKE_CURRENT_SOURCE_DIR}/luafilesystem/src/lfs.def\""
)
install(TARGETS lfs
DESTINATION ${ORBITER_BINARY_ROOT_DIR}
)
install(TARGETS lfs DESTINATION ${ORBITER_BINARY_ROOT_DIR})
install(TARGETS lfs DESTINATION ${ORBITER_INSTALL_SDK_DIR}/Utils/)
target_include_directories(lfs PUBLIC Lua)
target_link_libraries(lfs lua)
SET_TARGET_PROPERTIES(lfs PROPERTIES LINK_FLAGS "/DEF:\"${CMAKE_CURRENT_SOURCE_DIR}/luafilesystem/src/lfs.def\"")

install(TARGETS lfs DESTINATION ${ORBITER_BINARY_ROOT_DIR})

set_target_properties(lfs PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
Expand All @@ -61,28 +27,3 @@ add_custom_target(CopyLDoc ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ldoc/ ${ORBITER_BINARY_ROOT_DIR}/packages/ldoc
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Penlight/lua/ ${ORBITER_BINARY_ROOT_DIR}/
)

##########################################
## zlib

set(SKIP_INSTALL_ALL ON)
add_subdirectory(zlib)

target_include_directories(zlib INTERFACE ${zlib_SOURCE_DIR})
target_include_directories(zlib INTERFACE ${zlib_BINARY_DIR}) # for zconf.h

# for tests and running Orbiter from inside the build dir
set_target_properties(zlib PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
)

install(TARGETS zlib RUNTIME DESTINATION ${ORBITER_INSTALL_ROOT_DIR})

##########################################
## Catch2

if(ORBITER_MAKE_TESTS)
add_subdirectory(Catch2)
endif()
1 change: 0 additions & 1 deletion Extern/Catch2
Submodule Catch2 deleted from 3f0283
1 change: 0 additions & 1 deletion Extern/Lua
Submodule Lua deleted from 69ea08
50 changes: 50 additions & 0 deletions Extern/Lua/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
project(lua)

Include(FetchContent)

FetchContent_Declare(
lua
GIT_REPOSITORY https://github.com/lua/lua.git
GIT_TAG v5.1
)
FetchContent_MakeAvailable(lua)

file(GLOB LUA_SRC_FILES "${lua_SOURCE_DIR}/*.c")
file(GLOB LUA_HDR_FILES "${lua_SOURCE_DIR}/*.h")

list(REMOVE_ITEM LUA_SRC_FILES "${lua_SOURCE_DIR}/lua.c")
list(REMOVE_ITEM LUA_SRC_FILES "${lua_SOURCE_DIR}/luac.c")
list(REMOVE_ITEM LUA_SRC_FILES "${lua_SOURCE_DIR}/print.c")

# Executable - lua.exe
add_executable(lua-exe ${LUA_SRC_FILES} "${lua_SOURCE_DIR}/lua.c")
set_target_properties(lua-exe PROPERTIES OUTPUT_NAME lua)

set_target_properties(lua-exe PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
)

install(TARGETS lua-exe RUNTIME DESTINATION ${ORBITER_INSTALL_ROOT_DIR})
install(TARGETS lua-exe DESTINATION ${ORBITER_INSTALL_SDK_DIR}/lib/Lua)
install(TARGETS lua-exe DESTINATION ${ORBITER_INSTALL_SDK_DIR}/Utils/)

# Library - lua.dll
add_library(lua SHARED ${LUA_SRC_FILES})
target_compile_definitions(lua PUBLIC LUA_BUILD_AS_DLL)

set_target_properties(lua PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
)
install(TARGETS lua DESTINATION ${ORBITER_INSTALL_ROOT_DIR})

set(LUA_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
file(COPY ${LUA_HDR_FILES} DESTINATION ${LUA_INCLUDE_DIR})
target_include_directories(lua INTERFACE ${LUA_INCLUDE_DIR})

# Aliases for easier reference
add_executable(lua::exe ALIAS lua-exe)
add_library(lua::lib ALIAS lua)
19 changes: 19 additions & 0 deletions Extern/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# How to add new dependency

If you want to add new dependency, the way to add it will depend on the type

## lunarmodule dependency

Use `add_lunarmodule` function in Extern/CMakeLists.txt with appropriate tag:

```
add_lunarmodule(ldoc v1.5.0)
```

## C++ dependency

1. Create a new directory (e.g. `mylib`)
1. Add a line to Extern/CMakeLists.txt: `add_subdirectory(mylib)`
1. Copy `Extern/zlib/CMakeLists.txt` to new directory
1. Edit the file replacing `zlib` with `mylib` and adding new repository URL
1. Add other tweaks to `CMakeLists.txt` as necessary
1 change: 0 additions & 1 deletion Extern/zlib
Submodule zlib deleted from 04f42c
21 changes: 21 additions & 0 deletions Extern/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project(zlib)

Include(FetchContent)

set(SKIP_INSTALL_ALL ON)

FetchContent_Declare(
zlib
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG v1.2.11
)
FetchContent_MakeAvailable(zlib)
target_include_directories(zlib INTERFACE ${zlib_SOURCE_DIR})
target_include_directories(zlib INTERFACE ${zlib_BINARY_DIR})

set_target_properties(zlib PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${ORBITER_BINARY_ROOT_DIR}
)
install(TARGETS zlib RUNTIME DESTINATION ${ORBITER_INSTALL_ROOT_DIR})
2 changes: 1 addition & 1 deletion Orbitersdk/include/OrbiterAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

extern "C" {
#include "Lua/lua.h"
#include <lua/lua.h>
}

// Assumes MS VC++ compiler. Modify these statements for other compilers
Expand Down
2 changes: 1 addition & 1 deletion Src/Module/LuaScript/LuaInline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target_link_libraries(LuaInline
${ORBITER_LIB}
${ORBITER_SDK_LIB}
LuaInterpreter
lua
lua::lib
)

add_dependencies(LuaInline
Expand Down
2 changes: 1 addition & 1 deletion Src/Module/LuaScript/LuaInterpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ target_include_directories(LuaInterpreter
target_link_libraries(LuaInterpreter
${ORBITER_LIB}
${ORBITER_SDK_LIB}
lua
lua::lib
XRSound_lib
)

Expand Down
6 changes: 3 additions & 3 deletions Src/Module/LuaScript/LuaInterpreter/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#define __INTERPRETER_H

extern "C" {
#include "Lua/lua.h"
#include "Lua/lualib.h"
#include "Lua/lauxlib.h"
#include <lua/lua.h>
#include <lua/lualib.h>
#include <lua/lauxlib.h>
}

#include "OrbiterAPI.h"
Expand Down
2 changes: 1 addition & 1 deletion Src/Orbiter/OrbiterAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "resource.h"
#include "Mesh.h"
#include "MenuInfoBar.h"
#include "zlib.h"
#include <zlib.h>
#include "DrawAPI.h"

#ifdef INLINEGRAPHICS // should be temporary
Expand Down
2 changes: 1 addition & 1 deletion Src/Plugin/LuaConsole/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target_include_directories(LuaConsole
target_link_libraries(LuaConsole
${ORBITER_LIB}
${ORBITER_SDK_LIB}
lua
lua::lib
${LUAINTERPRETER_LIB}
)

Expand Down
2 changes: 1 addition & 1 deletion Src/Plugin/LuaMFD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ target_include_directories(LuaMFD
target_link_libraries(LuaMFD
${ORBITER_LIB}
${ORBITER_SDK_LIB}
lua
lua::lib
${LUAINTERPRETER_LIB}
)

Expand Down
2 changes: 1 addition & 1 deletion Src/Plugin/ScriptMFD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ target_include_directories(ScriptMFD
target_link_libraries(ScriptMFD
${ORBITER_LIB}
${ORBITER_SDK_LIB}
lua
lua::lib
${LUAINTERPRETER_LIB}
)

Expand Down
2 changes: 1 addition & 1 deletion Src/Vessel/DeltaGlider/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ target_link_libraries(DeltaGlider
${ORBITER_LIB}
${ORBITER_SDK_LIB}
${ORBITER_DLGCTRL_LIB}
lua
lua::lib
)

# scan mesh files for labels and output to header file
Expand Down
6 changes: 3 additions & 3 deletions Src/Vessel/DeltaGlider/DGLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include <stdio.h>

extern "C" {
#include "Lua/lua.h"
#include "Lua/lualib.h"
#include "Lua/lauxlib.h"
#include <lua/lua.h>
#include <lua/lualib.h>
#include <lua/lauxlib.h>
}

// ==========================================================================
Expand Down
2 changes: 1 addition & 1 deletion Src/Vessel/HST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ add_dependencies(HST

if(ADD_SCRIPT_SUPPORT)
add_definitions(-DSCRIPTSUPPORT)
target_link_libraries(HST lua)
target_link_libraries(HST lua::lib)
endif()

add_custom_command(
Expand Down
6 changes: 3 additions & 3 deletions Src/Vessel/HST/HST_Lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#ifdef SCRIPTSUPPORT

extern "C" {
#include "Lua/lua.h"
#include "Lua/lualib.h"
#include "Lua/lauxlib.h"
#include <lua/lua.h>
#include <lua/lualib.h>
#include <lua/lauxlib.h>
}

// ==========================================================================
Expand Down
2 changes: 1 addition & 1 deletion Src/Vessel/Quadcopter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ target_include_directories(Quadcopter
target_link_libraries(Quadcopter
${ORBITER_LIB}
${ORBITER_SDK_LIB}
lua
lua::lib
)

add_dependencies(Quadcopter
Expand Down
6 changes: 3 additions & 3 deletions Src/Vessel/Quadcopter/QuadcopterLua.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#define __QUADCOPTERLUA_H

extern "C" {
#include "Lua/lua.h"
#include "Lua/lualib.h"
#include "Lua/lauxlib.h"
#include <lua/lua.h>
#include <lua/lualib.h>
#include <lua/lauxlib.h>
}
class Quadcopter;

Expand Down
2 changes: 1 addition & 1 deletion Src/Vessel/ScriptVessel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target_include_directories(ScriptVessel
target_link_libraries(ScriptVessel
${ORBITER_LIB}
${ORBITER_SDK_LIB}
lua
lua::lib
)

add_dependencies(ScriptVessel
Expand Down
Loading

0 comments on commit 2fec70a

Please sign in to comment.