mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2024-12-21 10:31:54 +01:00
Add github actions and update Dockerfile
This commit is contained in:
parent
8da299cc73
commit
d854510aa1
@ -7,9 +7,7 @@ AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignOperands: true
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 0
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
|
59
.github/workflows/ci.yml
vendored
Normal file
59
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
name: CI-Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source ./include
|
||||
build-binary:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "$GITHUB_SHA")
|
||||
cat <<EOF > ./source/wiiu/version.h
|
||||
#pragma once
|
||||
#define VERSION_EXTRA " (nightly-$git_hash)"
|
||||
EOF
|
||||
- name: build binary
|
||||
run: |
|
||||
docker build . -t builder
|
||||
docker run --rm -v ${PWD}:/project builder make
|
||||
- uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: binary
|
||||
path: "*.wps"
|
||||
deploy-binary:
|
||||
needs: build-binary
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Get environment variables
|
||||
id: get_repository_name
|
||||
run: |
|
||||
echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") >> $GITHUB_ENV
|
||||
echo DATETIME=$(echo $(date '+%Y%m%d-%H%M%S')) >> $GITHUB_ENV
|
||||
- uses: actions/download-artifact@master
|
||||
with:
|
||||
name: binary
|
||||
- name: zip artifact
|
||||
run: zip -r ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip *.wps
|
||||
- name: Create Release
|
||||
uses: "softprops/action-gh-release@v1"
|
||||
with:
|
||||
tag_name: ${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
generate_release_notes: true
|
||||
name: Nightly-${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
files: |
|
||||
./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
43
.github/workflows/pr.yml
vendored
Normal file
43
.github/workflows/pr.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: CI-PR
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source ./include
|
||||
check-build-with-logging:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary with logging
|
||||
run: |
|
||||
docker build . -t builder
|
||||
docker run --rm -v ${PWD}:/project builder make DEBUG=VERBOSE
|
||||
docker run --rm -v ${PWD}:/project builder make clean
|
||||
docker run --rm -v ${PWD}:/project builder make DEBUG=1
|
||||
build-binary:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")
|
||||
cat <<EOF > ./source/wiiu/version.h
|
||||
#pragma once
|
||||
#define VERSION_EXTRA " (nightly-$git_hash)"
|
||||
EOF
|
||||
- name: build binary
|
||||
run: |
|
||||
docker build . -t builder
|
||||
docker run --rm -v ${PWD}:/project builder make
|
||||
- uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: binary
|
||||
path: "*.wps"
|
@ -1,6 +1,6 @@
|
||||
FROM ghcr.io/wiiu-env/devkitppc:20231112
|
||||
|
||||
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230719 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libmocha:20230621 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:0.8.0-dev-20240302-3b5cc2f /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libmocha:20231127 /artifacts $DEVKITPRO
|
||||
|
||||
WORKDIR project
|
@ -53,7 +53,7 @@ docker run -it --rm -v ${PWD}:/project ftpiiuplugin-builder make clean
|
||||
|
||||
## Format the code via docker
|
||||
|
||||
`docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./src -i`
|
||||
`docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source ./include -i`
|
||||
|
||||
## Credits
|
||||
|
||||
|
@ -124,7 +124,7 @@ void drawLog ()
|
||||
#ifdef __WIIU__
|
||||
for (auto &cur : s_messages)
|
||||
{
|
||||
OSReport ("%s %s\x1b[0m", s_colors[cur.level], cur.message.c_str ());
|
||||
OSReport ("ftpiiu plugin: %s %s\x1b[0m", s_colors[cur.level], cur.message.c_str ());
|
||||
}
|
||||
#else
|
||||
auto it = std::begin (s_messages);
|
||||
|
@ -19,6 +19,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "platform.h"
|
||||
#include "version.h"
|
||||
|
||||
#include "IOAbstraction.h"
|
||||
#include "ftpServer.h"
|
||||
@ -39,16 +40,20 @@
|
||||
#ifndef CLASSIC
|
||||
#error "Wii U must be built in classic mode"
|
||||
#endif
|
||||
#define VERSION_FULL "0.1"
|
||||
#define VERSION "v0.4.1"
|
||||
#define VERSION_FULL VERSION VERSION_EXTRA
|
||||
|
||||
WUPS_PLUGIN_NAME ("ftpd");
|
||||
WUPS_PLUGIN_DESCRIPTION ("FTP Server");
|
||||
WUPS_PLUGIN_NAME ("ftpiiu");
|
||||
WUPS_PLUGIN_DESCRIPTION ("FTP Server based on ftpd");
|
||||
WUPS_PLUGIN_VERSION (VERSION_FULL);
|
||||
WUPS_PLUGIN_AUTHOR ("mtheall, Maschell");
|
||||
WUPS_PLUGIN_LICENSE ("GPL");
|
||||
WUPS_PLUGIN_LICENSE ("GPL3");
|
||||
|
||||
WUPS_USE_WUT_DEVOPTAB ();
|
||||
WUPS_USE_STORAGE ("ftpd"); // Unqiue id for the storage api
|
||||
WUPS_USE_STORAGE ("ftpiiu"); // Unique id for the storage api
|
||||
|
||||
#define DEFAULT_FTPIIU_ENABLED_VALUE true
|
||||
#define DEFAULT_SYSTEM_FILES_ALLOWED_VALUE false
|
||||
|
||||
#define FTPIIU_ENABLED_STRING "enabled"
|
||||
#define SYSTEM_FILES_ALLOWED_STRING "systemFilesAllowed"
|
||||
@ -60,8 +65,8 @@ bool platform::networkVisible ()
|
||||
|
||||
bool platform::networkAddress (SockAddr &addr_)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
addr.sin_family = AF_INET;
|
||||
struct sockaddr_in addr = {};
|
||||
addr.sin_family = AF_INET;
|
||||
nn::ac::GetAssignedAddress (&addr.sin_addr.s_addr);
|
||||
addr_ = addr;
|
||||
return true;
|
||||
@ -86,10 +91,10 @@ MochaUtilsStatus MountWrapper (const char *mount, const char *dev, const char *m
|
||||
return res;
|
||||
}
|
||||
|
||||
UniqueFtpServer server = nullptr;
|
||||
bool sSystemFilesAllowed = false;
|
||||
bool sMochaPathsWereMounted = false;
|
||||
bool sFTPServerEnabled = true;
|
||||
UniqueFtpServer server = nullptr;
|
||||
static bool sSystemFilesAllowed = DEFAULT_SYSTEM_FILES_ALLOWED_VALUE;
|
||||
static bool sMochaPathsWereMounted = false;
|
||||
static bool sFTPServerEnabled = DEFAULT_FTPIIU_ENABLED_VALUE;
|
||||
|
||||
void start_server ()
|
||||
{
|
||||
@ -189,7 +194,7 @@ void stop_server ()
|
||||
IOAbstraction::clear ();
|
||||
}
|
||||
|
||||
void gFTPServerRunningChanged (ConfigItemBoolean *item, bool newValue)
|
||||
static void gFTPServerRunningChanged (ConfigItemBoolean *item, bool newValue)
|
||||
{
|
||||
sFTPServerEnabled = newValue;
|
||||
if (!sFTPServerEnabled)
|
||||
@ -210,7 +215,7 @@ void gFTPServerRunningChanged (ConfigItemBoolean *item, bool newValue)
|
||||
}
|
||||
}
|
||||
|
||||
void gSystemFilesAllowedChanged (ConfigItemBoolean *item, bool newValue)
|
||||
static void gSystemFilesAllowedChanged (ConfigItemBoolean *item, bool newValue)
|
||||
{
|
||||
// DEBUG_FUNCTION_LINE("New value in gFTPServerEnabled: %d", newValue);
|
||||
if (server != nullptr)
|
||||
@ -264,7 +269,7 @@ WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback (WUPSConfigCategoryHandle r
|
||||
(hostIpAddress >> 16) & 0xFF,
|
||||
(hostIpAddress >> 8) & 0xFF,
|
||||
(hostIpAddress >> 0) & 0xFF,
|
||||
5000);
|
||||
21);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -277,7 +282,7 @@ WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback (WUPSConfigCategoryHandle r
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
OSReport ("Exception T_T : %s\n", e.what ());
|
||||
OSReport ("fptiiu plugin: Exception: %s\n", e.what ());
|
||||
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR;
|
||||
}
|
||||
|
||||
@ -286,32 +291,43 @@ WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback (WUPSConfigCategoryHandle r
|
||||
|
||||
void ConfigMenuClosedCallback ()
|
||||
{
|
||||
OSReport ("ConfigMenuClosedCallback\n");
|
||||
WUPSStorageAPI::SaveStorage ();
|
||||
}
|
||||
|
||||
INITIALIZE_PLUGIN ()
|
||||
{
|
||||
WUPSConfigAPIOptionsV1 configOptions = {.name = "ftpd"};
|
||||
WUPSConfigAPIOptionsV1 configOptions = {.name = "ftpiiu"};
|
||||
if (WUPSConfigAPI_Init (configOptions, ConfigMenuOpenedCallback, ConfigMenuClosedCallback) !=
|
||||
WUPSCONFIG_API_RESULT_SUCCESS)
|
||||
{
|
||||
OSFatal ("Failed to init config api");
|
||||
OSFatal ("ftpiiu plugin: Failed to init config api");
|
||||
}
|
||||
|
||||
if (WUPSStorageAPI::GetOrStoreDefault (FTPIIU_ENABLED_STRING, sFTPServerEnabled, true) !=
|
||||
WUPSStorageError err;
|
||||
if ((err = WUPSStorageAPI::GetOrStoreDefault (
|
||||
FTPIIU_ENABLED_STRING, sFTPServerEnabled, DEFAULT_FTPIIU_ENABLED_VALUE)) !=
|
||||
WUPS_STORAGE_ERROR_SUCCESS)
|
||||
{
|
||||
OSReport ("Failed\n");
|
||||
OSReport ("ftpiiu plugin: Failed to get or create item \"%s\": %s (%d)\n",
|
||||
FTPIIU_ENABLED_STRING,
|
||||
WUPSStorageAPI_GetStatusStr (err),
|
||||
err);
|
||||
}
|
||||
if (WUPSStorageAPI::GetOrStoreDefault (
|
||||
SYSTEM_FILES_ALLOWED_STRING, sSystemFilesAllowed, false) != WUPS_STORAGE_ERROR_SUCCESS)
|
||||
if ((err = WUPSStorageAPI::GetOrStoreDefault (SYSTEM_FILES_ALLOWED_STRING,
|
||||
sSystemFilesAllowed,
|
||||
DEFAULT_SYSTEM_FILES_ALLOWED_VALUE)) != WUPS_STORAGE_ERROR_SUCCESS)
|
||||
{
|
||||
OSReport ("Failed\n");
|
||||
OSReport ("ftpiiu plugin: Failed to get or create item \"%s\": %s (%d)\n",
|
||||
SYSTEM_FILES_ALLOWED_STRING,
|
||||
WUPSStorageAPI_GetStatusStr (err),
|
||||
err);
|
||||
}
|
||||
if (WUPSStorageAPI::SaveStorage () != WUPS_STORAGE_ERROR_SUCCESS)
|
||||
|
||||
if ((err = WUPSStorageAPI::SaveStorage ()) != WUPS_STORAGE_ERROR_SUCCESS)
|
||||
{
|
||||
OSReport ("Failed\n");
|
||||
OSReport ("ftpiiu plugin: Failed to save storage: %s (%d)\n",
|
||||
WUPSStorageAPI_GetStatusStr (err),
|
||||
err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,7 +388,7 @@ public:
|
||||
explicit privateData_t (std::function<void ()> &&func_) : thread (std::move (func_))
|
||||
{
|
||||
auto nativeHandle = (OSThread *)thread.native_handle ();
|
||||
OSSetThreadName (nativeHandle, "ftpd");
|
||||
OSSetThreadName (nativeHandle, "ftpiiu");
|
||||
while (!OSSetThreadAffinity (nativeHandle, OS_THREAD_ATTRIB_AFFINITY_CPU2))
|
||||
{
|
||||
OSSleepTicks (OSMillisecondsToTicks (16));
|
||||
|
2
source/wiiu/version.h
Normal file
2
source/wiiu/version.h
Normal file
@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#define VERSION_EXTRA ""
|
Loading…
Reference in New Issue
Block a user