diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 0c03bbab14..71f66917a7 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -5,5 +5,5 @@ repositories {
}
}
dependencies {
- implementation "edu.wpi.first:native-utils:2021.0.6"
+ implementation "edu.wpi.first:native-utils:2021.1.0"
}
diff --git a/glass/.styleguide b/glass/.styleguide
new file mode 100644
index 0000000000..70ad49c59b
--- /dev/null
+++ b/glass/.styleguide
@@ -0,0 +1,5 @@
+generatedFileExclude {
+ src/app/native/resources/
+ src/app/native/win/glass.ico
+ src/app/native/mac/glass.icns
+}
diff --git a/glass/CMakeLists.txt b/glass/CMakeLists.txt
index f9ab9fae93..bb9c4fe82a 100644
--- a/glass/CMakeLists.txt
+++ b/glass/CMakeLists.txt
@@ -1,6 +1,7 @@
project(glass)
include(CompileWarnings)
+include(GenResources)
include(LinkMacOSGUI)
#
@@ -49,13 +50,26 @@ install(DIRECTORY src/libnt/native/include/ DESTINATION "${include_dest}/glass")
# glass application
#
+GENERATE_RESOURCES(src/app/native/resources generated/app/cpp GLASS glass glass_resources_src)
+
file(GLOB glass_src src/app/native/cpp/*.cpp)
-add_executable(glass ${glass_src})
+if (WIN32)
+ set(glass_rc src/app/native/win/glass.rc)
+elseif(APPLE)
+ set(MACOSX_BUNDLE_ICON_FILE glass.icns)
+ set(APP_ICON_MACOSX src/app/native/mac/glass.icns)
+ set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
+endif()
+
+add_executable(glass ${glass_src} ${glass_resources_src} ${glass_rc} ${APP_ICON_MACOSX})
wpilib_link_macos_gui(glass)
target_link_libraries(glass libglassnt libglass)
+
if (WIN32)
set_target_properties(glass PROPERTIES WIN32_EXECUTABLE YES)
+elseif(APPLE)
+ set_target_properties(glass PROPERTIES MACOSX_BUNDLE YES OUTPUT_NAME "Glass")
endif()
#if (MSVC OR FLAT_INSTALL_WPILIB)
diff --git a/glass/Info.plist b/glass/Info.plist
index fed0b8f2fe..4a198fcd48 100644
--- a/glass/Info.plist
+++ b/glass/Info.plist
@@ -10,6 +10,8 @@
Glass
CFBundleIdentifier
edu.wpi.first.tools.Glass
+ CFBundleIconFile
+ glass.icns
CFBundlePackageType
APPL
CFBundleSupportedPlatforms
diff --git a/glass/build.gradle b/glass/build.gradle
index a92b93e899..586b152a3e 100644
--- a/glass/build.gradle
+++ b/glass/build.gradle
@@ -1,3 +1,5 @@
+import org.gradle.internal.os.OperatingSystem
+
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
description = "A different kind of dashboard"
@@ -8,13 +10,23 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
+ if (OperatingSystem.current().isWindows()) {
+ apply plugin: 'windows-resources'
+ }
+
ext {
nativeName = 'glass'
}
+ apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
+ def generateTask = createGenerateResourcesTask('app', 'GLASS', 'glass', project)
+
project(':').libraryBuild.dependsOn build
+ tasks.withType(CppCompile) {
+ dependsOn generateTask
+ }
nativeUtils.exportsConfigs {
glass {
@@ -35,7 +47,7 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
sources {
cpp {
source {
- srcDirs = ['src/lib/native/cpp']
+ srcDirs 'src/lib/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
@@ -96,13 +108,20 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
sources {
cpp {
source {
- srcDirs 'src/app/native/cpp'
+ srcDirs 'src/app/native/cpp', "$buildDir/generated/app/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/app/native/include'
}
}
+ if (OperatingSystem.current().isWindows()) {
+ rc {
+ source {
+ srcDirs 'src/app/native/win'
+ }
+ }
+ }
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
diff --git a/glass/publish.gradle b/glass/publish.gradle
index b7df8ac6b1..7f1d005ac6 100644
--- a/glass/publish.gradle
+++ b/glass/publish.gradle
@@ -14,6 +14,7 @@ model {
// We are now in the binary that we want.
// This is the default application path for the ZIP task.
def applicationPath = binary.executable.file
+ def icon = file("$project.projectDir/src/app/native/mac/glass.icns")
// Create the macOS bundle.
def bundleTask = project.tasks.create("bundleGlassOsxApp", Copy) {
@@ -21,6 +22,7 @@ model {
from(file("$project.projectDir/Info.plist"))
into(file("$project.buildDir/outputs/bundles/Glass.app/Contents"))
into("MacOS") { with copySpec { from binary.executable.file } }
+ into("Resources") { with copySpec { from icon } }
doLast {
if (project.hasProperty("developerID")) {
diff --git a/glass/src/app/native/cpp/main.cpp b/glass/src/app/native/cpp/main.cpp
index e7fca2b655..b3d3e2829d 100644
--- a/glass/src/app/native/cpp/main.cpp
+++ b/glass/src/app/native/cpp/main.cpp
@@ -23,6 +23,16 @@
namespace gui = wpi::gui;
+namespace glass {
+wpi::StringRef GetResource_glass_16_png();
+wpi::StringRef GetResource_glass_32_png();
+wpi::StringRef GetResource_glass_48_png();
+wpi::StringRef GetResource_glass_64_png();
+wpi::StringRef GetResource_glass_128_png();
+wpi::StringRef GetResource_glass_256_png();
+wpi::StringRef GetResource_glass_512_png();
+} // namespace glass
+
static std::unique_ptr gPlotProvider;
static std::unique_ptr gNtProvider;
@@ -88,6 +98,14 @@ int main() {
gui::CreateContext();
glass::CreateContext();
+ gui::AddIcon(glass::GetResource_glass_16_png());
+ gui::AddIcon(glass::GetResource_glass_32_png());
+ gui::AddIcon(glass::GetResource_glass_48_png());
+ gui::AddIcon(glass::GetResource_glass_64_png());
+ gui::AddIcon(glass::GetResource_glass_128_png());
+ gui::AddIcon(glass::GetResource_glass_256_png());
+ gui::AddIcon(glass::GetResource_glass_512_png());
+
gPlotProvider = std::make_unique("Plot");
gNtProvider = std::make_unique("NTProvider");
diff --git a/glass/src/app/native/mac/glass.icns b/glass/src/app/native/mac/glass.icns
new file mode 100644
index 0000000000..1204734761
Binary files /dev/null and b/glass/src/app/native/mac/glass.icns differ
diff --git a/glass/src/app/native/resources/glass-128.png b/glass/src/app/native/resources/glass-128.png
new file mode 100644
index 0000000000..f2ea7a1673
Binary files /dev/null and b/glass/src/app/native/resources/glass-128.png differ
diff --git a/glass/src/app/native/resources/glass-16.png b/glass/src/app/native/resources/glass-16.png
new file mode 100644
index 0000000000..dbca52a65d
Binary files /dev/null and b/glass/src/app/native/resources/glass-16.png differ
diff --git a/glass/src/app/native/resources/glass-256.png b/glass/src/app/native/resources/glass-256.png
new file mode 100644
index 0000000000..db9062f939
Binary files /dev/null and b/glass/src/app/native/resources/glass-256.png differ
diff --git a/glass/src/app/native/resources/glass-32.png b/glass/src/app/native/resources/glass-32.png
new file mode 100644
index 0000000000..b6f69d0796
Binary files /dev/null and b/glass/src/app/native/resources/glass-32.png differ
diff --git a/glass/src/app/native/resources/glass-48.png b/glass/src/app/native/resources/glass-48.png
new file mode 100644
index 0000000000..14ee9341ca
Binary files /dev/null and b/glass/src/app/native/resources/glass-48.png differ
diff --git a/glass/src/app/native/resources/glass-512.png b/glass/src/app/native/resources/glass-512.png
new file mode 100644
index 0000000000..b022d1e526
Binary files /dev/null and b/glass/src/app/native/resources/glass-512.png differ
diff --git a/glass/src/app/native/resources/glass-64.png b/glass/src/app/native/resources/glass-64.png
new file mode 100644
index 0000000000..b488115cbc
Binary files /dev/null and b/glass/src/app/native/resources/glass-64.png differ
diff --git a/glass/src/app/native/win/glass.ico b/glass/src/app/native/win/glass.ico
new file mode 100644
index 0000000000..99c54096c8
Binary files /dev/null and b/glass/src/app/native/win/glass.ico differ
diff --git a/glass/src/app/native/win/glass.rc b/glass/src/app/native/win/glass.rc
new file mode 100644
index 0000000000..a9f29516a9
--- /dev/null
+++ b/glass/src/app/native/win/glass.rc
@@ -0,0 +1 @@
+IDI_ICON1 ICON "glass.ico"