Skip to content

Commit

Permalink
Merge branch 'task10frontend' into Install-cmake-on-startup
Browse files Browse the repository at this point in the history
  • Loading branch information
maxarfvidssonnilsson committed Nov 30, 2021
2 parents 0760414 + a54aa4c commit 6ac20aa
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 35 deletions.
1 change: 1 addition & 0 deletions CMake/Modules/SetupGodotCpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
if(NOT GDCPP_ROOT OR NOT EXISTS GDCPP_ROOT)
set (GDCPP_USER_ROOT "${GDCPP_ROOT}")

include (FetchContent)
FetchContent_Declare (fc-godot-cpp
GIT_REPOSITORY https://github.com/godotengine/godot-cpp.git
GIT_TAG 3.x
Expand Down
75 changes: 75 additions & 0 deletions CMake/Modules/SetupSMCE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# SetupSMCE.cmake
# Copyright 2021 ItJustWorksTM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include_guard ()

set (SMCEGD_SMCE_LINKING "SOURCE")

if (SMCEGD_SMCE_LINKING STREQUAL "AUTO")
find_package (SMCE 1.4)
if (SMCE_FOUND)
if (TARGET SMCE::SMCE)
set (SMCEGD_SMCE_LINKING "SHARED")
elseif (TARGET SMCE::SMCE_static)
set (SMCEGD_SMCE_LINKING "STATIC")
endif ()
else ()
set (SMCEGD_SMCE_LINKING "SOURCE")
endif ()
message (STATUS "Resolved SMCEGD_SMCE_LINKING: AUTO -> ${SMCEGD_SMCE_LINKING}")
endif ()

if (SMCEGD_SMCE_LINKING STREQUAL "SHARED")
find_package (SMCE 1.4 REQUIRED)
if (NOT TARGET SMCE::SMCE)
message (FATAL_ERROR "Shared link requested but libSMCE shared library not installed")
endif ()
add_library (smcegd_SMCE ALIAS SMCE::SMCE)
elseif (SMCEGD_SMCE_LINKING STREQUAL "STATIC")
find_package (SMCE 1.4 REQUIRED)
if (NOT TARGET SMCE::SMCE_static)
message (FATAL_ERROR "Static link requested but libSMCE static library not installed")
endif ()
add_library (smcegd_SMCE ALIAS SMCE::SMCE_static)
elseif (SMCEGD_SMCE_LINKING STREQUAL "SOURCE")
include (FetchContent)
FetchContent_Declare (libsmce
#GIT_REPOSITORY "https://github.com/ItJustWorksTM/libSMCE"
#GIT_TAG master
GIT_REPOSITORY "https://github.com/Team-3-Software-Evolution-Project/libSMCE"
GIT_TAG task10
GIT_SHALLOW On
)
FetchContent_GetProperties (libsmce)
if (NOT libsmce_POPULATED)
FetchContent_Populate (libsmce)

file (READ "${libsmce_SOURCE_DIR}/CMakeLists.txt" libsmce_cmakelists)
string (REPLACE "add_dependencies (SMCE ArdRtRes)" "add_dependencies (SMCE_static ArdRtRes)" libsmce_cmakelists "${libsmce_cmakelists}")
file (WRITE "${libsmce_SOURCE_DIR}/CMakeLists.txt" "${libsmce_cmakelists}")
file (APPEND "${libsmce_SOURCE_DIR}/CMakeLists.txt" "set (SMCE_RESOURCES_ARK \"\${SMCE_RESOURCES_ARK}\" CACHE INTERNAL \"\")\n")

set (SMCE_BUILD_SHARED Off CACHE INTERNAL "")
set (SMCE_BUILD_STATIC On CACHE INTERNAL "")
set (SMCE_CXXRT_LINKING "${SMCEGD_CXXRT_LINKING}" CACHE INTERNAL "" FORCE)
set (SMCE_BOOST_LINKING "SOURCE" CACHE INTERNAL "")
add_subdirectory ("${libsmce_SOURCE_DIR}" "${libsmce_BINARY_DIR}" EXCLUDE_FROM_ALL)
endif ()
add_library (smcegd_SMCE ALIAS SMCE_static)
else ()
message (FATAL_ERROR "SMCEGD_SMCE_LINKING: Unknown final link mode ${SMCEGD_SMCE_LINKING}")
endif ()
7 changes: 2 additions & 5 deletions CMake/Modules/UserConfigVars.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ if (NOT "${SMCEGD_CXXRT_LINKING}" IN_LIST SMCEGD_LIBRARY_TYPES)
message (FATAL_ERROR "SMCEGD_CXXRT_LINKING must be SHARED or STATIC")
endif ()

set (SMCEGD_SMCE_LINKING "SHARED" CACHE STRING "SHARED to dynamically link against libSMCE, STATIC to link statically, AUTO to pick the simplest available option, or SOURCE to build from source")
set (SMCEGD_SMCE_LINKING "AUTO" CACHE STRING "SHARED to dynamically link against libSMCE, STATIC to link statically, AUTO to pick the simplest available option, or SOURCE to build from source")
if (NOT "${SMCEGD_SMCE_LINKING}" IN_LIST SMCEGD_EXTENDED_LIBRARY_TYPES)
message (FATAL_ERROR "SMCEGD_SMCE_LINKING must be SHARED or STATIC")
message (FATAL_ERROR "SMCEGD_SMCE_LINKING must AUTO, SHARED, STATIC, or SOURCE")
endif ()

option (SMCEGD_BUNDLE_DEPS False "Set to True to bundle during packaging shared libs required at runtime")
if (SMCEGD_BUNDLE_DEPS AND NOT SMCEGD_SMCE_LINKING STREQUAL "SHARED")
message (FATAL_ERROR "SMCEGD_BUNDLE_DEPS may only be set to True when SMCEGD_SMCE_LINKING is explicitly \"SHARED\"")
endif ()
34 changes: 14 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

cmake_minimum_required (VERSION 3.17)

set (SMCEGD_SMCE_LINKING "SOURCE")

project (godot-smce VERSION 1.3.2 LANGUAGES CXX)
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake/Modules")
include (UserConfigVars)
Expand All @@ -35,18 +37,6 @@ set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package (Threads REQUIRED)
find_package (SMCE 1.4 REQUIRED)

set (SMCE_TARGET SMCE::SMCE)
if (SMCEGD_SMCE_LINKING STREQUAL "STATIC")
if (NOT TARGET SMCE::SMCE_static)
message (FATAL_ERROR "Static link requested but libSMCE static library not installed")
endif ()
set (SMCE_TARGET SMCE::SMCE_static)
message (STATUS "libSMCE statically linked")
endif ()

if (APPLE)
set (CMAKE_BUILD_RPATH "@loader_path/../Frameworks;${CMAKE_BUILD_RPATH}")
set (CMAKE_INSTALL_RPATH "@loader_path/../Frameworks;${CMAKE_INSTALL_RPATH}")
Expand All @@ -56,7 +46,12 @@ include (CheckIPOSupported)
check_ipo_supported (RESULT CMAKE_IPO_SUPPORTED LANGUAGES CXX)
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION ${CMAKE_IPO_SUPPORTED})

include (FetchContent)
find_package (Threads REQUIRED)
include (SetupSMCE)
if (SMCEGD_BUNDLE_DEPS AND NOT SMCEGD_SMCE_LINKING STREQUAL "SHARED")
message (FATAL_ERROR "SMCEGD_BUNDLE_DEPS may only be set to True when SMCEGD_SMCE_LINKING resolves to \"SHARED\"")
endif ()

list (APPEND GDCPP_NEEDED_CLASSES Reference Node Resource _ResourceLoader)
include (SetupGodotCpp)

Expand All @@ -73,7 +68,7 @@ target_sources (godot-smce PRIVATE
)

target_include_directories (godot-smce PUBLIC include)
target_link_libraries (godot-smce PUBLIC godot-cpp ${SMCE_TARGET})
target_link_libraries (godot-smce PUBLIC godot-cpp smcegd_SMCE)

if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_target_properties (godot-smce PROPERTIES LINK_FLAGS_RELEASE -s)
Expand All @@ -82,19 +77,18 @@ if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif ()
endif ()

get_target_property (SMCE_RT_RES SMCE::SMCE RESOURCES_ARCHIVE)

file (MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/project/gdnative/lib/RtResources")
add_custom_command (TARGET godot-smce POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:godot-smce>" "${PROJECT_SOURCE_DIR}/project/gdnative/lib/"
COMMAND "${CMAKE_COMMAND}" -E tar xf "${SMCE_RT_RES}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:SMCE::SMCE>" "${PROJECT_SOURCE_DIR}/project/gdnative/lib/"

COMMAND "${CMAKE_COMMAND}" -E tar xf "${SMCE_RESOURCES_ARK}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:smcegd_SMCE>" "${PROJECT_SOURCE_DIR}/project/gdnative/lib/"
COMMAND "${CMAKE_COMMAND}" -E copy_directory "./RtResources" "${PROJECT_SOURCE_DIR}/project/share/RtResources"
COMMAND "${CMAKE_COMMAND}" -E rm -rf "./RtResources"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
)

include(GNUInstallDirs)
include (GNUInstallDirs)

if (NOT GODOT_DEBUG)
set (GODOT_BUILD_TYPE "GodotRelease")
Expand All @@ -118,7 +112,7 @@ endif ()
file (REMOVE_RECURSE "${PROJECT_BINARY_DIR}/export")
file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/export")

if (SMCEGD_BUNDLE_DEPS)
if (SMCEGD_BUNDLE_DEPS AND SMCEGD_SMCE_LINKING STREQUAL "SHARED")
if (UNIX AND NOT APPLE)
set (SMCE_DYLIB_VER_SUFFIX ".1")
elseif (APPLE)
Expand Down
14 changes: 14 additions & 0 deletions include/bind/Toolchain.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ class Toolchain : public Node {
static void _register_methods();
void _init();

class CompilerInformation : public Reference {
GODOT_CLASS(CompilerInformation, Reference);
public:
String name;
String path;
String version;

static void _register_methods();

void _init() {}
};

smce::Toolchain& native() { return *tc; }

Ref<GDResult> init(String resource_dir);
Expand All @@ -59,6 +71,8 @@ class Toolchain : public Node {
bool compile(Ref<Sketch> sketch);

void set_free();

Array find_compilers();
};

} // namespace godot
Expand Down
10 changes: 5 additions & 5 deletions project/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _global_script_classes=[ {
"language": "NativeScript",
"path": "res://src/bind/AnyTask.gdns"
}, {
"base": "Reference",
"base": "ButtonGroup",
"class": "BButtonGroup",
"language": "GDScript",
"path": "res://src/utilities/toggleable_bgroup/BButtonGroup.gd"
Expand All @@ -29,12 +29,12 @@ _global_script_classes=[ {
"language": "NativeScript",
"path": "res://src/bind/Board.gdns"
}, {
"base": "",
"base": "Reference",
"class": "BoardConfig",
"language": "NativeScript",
"path": "res://src/bind/BoardConfig.gdns"
}, {
"base": "",
"base": "Node",
"class": "BoardView",
"language": "NativeScript",
"path": "res://src/bind/BoardView.gdns"
Expand Down Expand Up @@ -154,7 +154,7 @@ _global_script_classes=[ {
"language": "NativeScript",
"path": "res://src/bind/UartChannelConfig.gdns"
}, {
"base": "",
"base": "Node",
"class": "UartSlurper",
"language": "NativeScript",
"path": "res://src/bind/UartSlurper.gdns"
Expand Down Expand Up @@ -329,7 +329,6 @@ file_logging/enable_file_logging=true
[rendering]

threads/thread_model=2
quality/filters/anisotropic_filter_level=2
quality/directional_shadow/size=2048
quality/shadow_atlas/size=2048
quality/shadow_atlas/quadrant_3_subdiv=3
Expand All @@ -338,6 +337,7 @@ quality/reflections/texture_array_reflections=false
quality/reflections/high_quality_ggx=false
quality/reflections/irradiance_max_size=32
quality/shading/force_blinn_over_ggx=true
quality/filters/anisotropic_filter_level=2
quality/subsurface_scattering/quality=0
quality/reflections/atlas_size=0
quality/reflections/atlas_subdiv=16
Expand Down
17 changes: 15 additions & 2 deletions project/src/ui/hud/SettingPane.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ onready var save_btn: Button = $VBoxContainer/MarginContainer/VBoxContainer/HBox
onready var world_list: OptionButton = $VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer2/Worlds
onready var sketches_label: Label = $VBoxContainer/MarginContainer/VBoxContainer/Sketches
onready var boards_label: Label = $VBoxContainer/MarginContainer/VBoxContainer/Boards
onready var compiler_list: OptionButton = $VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer3/Compilers

onready var version_label: Label = $VBoxContainer/MarginContainer/Version

Expand All @@ -42,6 +43,7 @@ func set_master_manager(mngr) -> void:

var unique_sketches: int = 0
var boards: Array = []
var compilers: Array = []

func _ready():
toggle_btn.connect("pressed", self, "emit_signal", ["toggled"])
Expand All @@ -50,9 +52,11 @@ func _ready():
save_btn.connect("pressed", self, "_save_profile")
profile_name_input.connect("text_changed", self, "_change_profile_name")
world_list.connect("item_selected", self, "_on_world_selected")
compiler_list.connect("item_selected", self, "_on_compiler_selected")
version_label.text = "SMCE-gd: %s" % Global.version

_update_envs()
_update_compilers()


func _reflect_profile() -> void:
Expand All @@ -73,15 +77,22 @@ func _reflect_profile() -> void:
map[slot.path] = null

sketches_label.text = "Sketches: %d" % map.size()

world_list.select(Global.environments.keys().find(profile.environment))
compiler_list.select(master_manager.active_profile.compiler)


func _update_envs():
for env in Global.environments.keys():
world_list.add_item(env)


func _update_compilers():
compilers = Toolchain.new().find_compilers()
for compiler in compilers:
compiler_list.add_item(compiler.name + " (" + compiler.version + ")")


func _switch_profile() -> void:
master_manager.show_profile_select()

Expand Down Expand Up @@ -109,7 +120,9 @@ func _change_profile_name(text: String) -> void:
func _on_world_selected(index: int) -> void:
master_manager.active_profile.environment = world_list.get_item_text(index)
master_manager.load_profile(master_manager.active_profile)


func _on_compiler_selected(index: int) -> void:
master_manager.active_profile.compiler = index

func _process(_delta) -> void:
_reflect_profile()
Expand Down
20 changes: 20 additions & 0 deletions project/src/ui/hud/SettingPane.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,23 @@ margin_top = 98.0
margin_right = 288.0
margin_bottom = 118.0
text = "Boards: 4"

[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer"]
margin_top = 126.0
margin_right = 288.0
margin_bottom = 146.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer3"]
margin_right = 65.0
margin_bottom = 20.0
text = "Compiler:"

[node name="Compilers" type="OptionButton" parent="VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer3"]
margin_left = 69.0
margin_right = 288.0
margin_bottom = 20.0
size_flags_horizontal = 3
theme = SubResource( 11 )
4 changes: 4 additions & 0 deletions project/src/ui/master_control/ProfileConfig.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class_name ProfileConfig

var profile_name: String = "No Name"
var environment: String = "playground/Playground"
var compiler: int = 0
var slots: Array = []

func type_info() -> Dictionary:
Expand All @@ -36,6 +37,9 @@ func is_equal(other) -> bool:

if other.environment != environment:
return false

if other.compiler != compiler:
return false

for i in range(slots.size()):
if !slots[i].is_equal(other.slots[i]):
Expand Down
Loading

0 comments on commit 6ac20aa

Please sign in to comment.