Work on the Windows build. Edge binary can now be embedded into the application.
This commit is contained in:
parent
78ee5662fc
commit
f16608815f
17 changed files with 350 additions and 23 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
|||
*~
|
||||
output.log
|
||||
bin/
|
||||
modules/embedded/embeds/
|
||||
hamncheese/export_presets.cfg
|
||||
temp/
|
||||
scp.sh
|
||||
|
|
|
@ -1,9 +1,74 @@
|
|||
#!/bin/bash
|
||||
|
||||
function createEmbeddedBinary() {
|
||||
local BINFILE=$1
|
||||
local SOURCEFILE=$2
|
||||
local BLOCKER=$3
|
||||
|
||||
outputLicense > ${SOURCEFILE}
|
||||
outputHeader ${BLOCKER} >> ${SOURCEFILE}
|
||||
printf "\n#ifdef EMBED_HERE\n\n" >> ${SOURCEFILE}
|
||||
xxd -i ${BINFILE} >> ${SOURCEFILE}
|
||||
printf "\n#else // EMBED_HERE\n\n" >> ${SOURCEFILE}
|
||||
printf "extern unsigned char ${BINFILE/\./_}[];\n" >> ${SOURCEFILE}
|
||||
printf "extern unsigned int ${BINFILE/\./_}_len;\n" >> ${SOURCEFILE}
|
||||
printf "\n#endif // EMBED_HERE\n\n" >> ${SOURCEFILE}
|
||||
outputFooter ${BLOCKER} >> ${SOURCEFILE}
|
||||
}
|
||||
|
||||
|
||||
function outputFooter() {
|
||||
local BLOCKER=$1
|
||||
|
||||
printf "\n#pragma GCC diagnostic pop\n\n\n#endif // ${BLOCKER}\n"
|
||||
}
|
||||
|
||||
|
||||
function outputHeader() {
|
||||
local BLOCKER=$1
|
||||
|
||||
printf "\n\n#ifndef ${BLOCKER}\n#define ${BLOCKER}\n\n\n"
|
||||
printf "// ===== THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT =====\n\n\n"
|
||||
printf "#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wunused-variable\"\n"
|
||||
}
|
||||
|
||||
|
||||
function outputLicense() {
|
||||
cat <<-LICENSE
|
||||
/*
|
||||
*
|
||||
* Ham'n'Cheese
|
||||
* Copyright (C) 2006-2020 Scott Duensing <scott@kangaroopunch.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
LICENSE
|
||||
}
|
||||
|
||||
|
||||
# Eventually provide a build_profile file to reduce file size.
|
||||
TEMPLATE="disable_3d=yes svg=no"
|
||||
LTO="lto=none" # Use "lto=full" for releases.
|
||||
|
||||
# Embed edge binaries.
|
||||
pushd bin
|
||||
mkdir -p ../modules/embedded/embeds
|
||||
createEmbeddedBinary x86_64-linux-gnu-edge ../modules/embedded/embeds/linux_x86_64.h EDGE_H
|
||||
popd
|
||||
|
||||
pushd godot
|
||||
|
||||
# Use Our Custom Settings.
|
||||
|
|
67
build-n2n.sh
67
build-n2n.sh
|
@ -1,28 +1,53 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Build n2n for current platform.
|
||||
# Build n2n.
|
||||
|
||||
|
||||
BUILDROOT=${PWD}
|
||||
|
||||
mkdir -p bin
|
||||
|
||||
mkdir -p n2n/thirdparty/libnatpmp/build
|
||||
pushd n2n/thirdparty/libnatpmp/build
|
||||
cmake ..
|
||||
make
|
||||
popd
|
||||
|
||||
mkdir -p n2n/thirdparty/miniupnp/miniupnpc/build
|
||||
pushd n2n/thirdparty/miniupnp/miniupnpc/build
|
||||
cmake ..
|
||||
make
|
||||
popd
|
||||
function buildn2n() {
|
||||
TRIPLE=$1
|
||||
TOOLCHAIN=${BUILDROOT}/cmake/${TRIPLE}.cmake
|
||||
|
||||
pushd n2n
|
||||
./autogen.sh
|
||||
CFLAGS="-I thirdparty/libnatpmp -I thirdparty/miniupnp/miniupnpc/include" \
|
||||
LDFLAGS="-L thirdparty/libnatpmp/build -L thirdparty/miniupnp/miniupnpc/build" \
|
||||
./configure --enable-pthread --enable-natpmp --enable-miniupnp
|
||||
make edge
|
||||
make supernode
|
||||
mv edge ../bin/.
|
||||
mv supernode ../bin/.
|
||||
popd
|
||||
pushd n2n/thirdparty/libnatpmp
|
||||
sed -i 's/Iphlpapi/iphlpapi/g' CMakeLists.txt
|
||||
[[ -d build ]] && rm -rf build
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN} ..
|
||||
make
|
||||
popd
|
||||
|
||||
pushd n2n/thirdparty/miniupnp/miniupnpc
|
||||
[[ -d build ]] && rm -rf build
|
||||
mkdir -p build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN} ..
|
||||
make
|
||||
popd
|
||||
|
||||
pushd n2n
|
||||
./autogen.sh
|
||||
CFLAGS="-I ${BUILDROOT}/n2n/thirdparty/libnatpmp -I ${BUILDROOT}/n2n/thirdparty/miniupnp/miniupnpc/include" \
|
||||
LDFLAGS="-L ${BUILDROOT}/n2n/thirdparty/libnatpmp/build -L ${BUILDROOT}/n2n/thirdparty/miniupnp/miniupnpc/build" \
|
||||
./configure \
|
||||
--target=${TRIPLE} \
|
||||
--host=${TRIPLE} \
|
||||
--build=x86_64-linux \
|
||||
--enable-pthread \
|
||||
--enable-natpmp \
|
||||
--enable-miniupnp
|
||||
make edge
|
||||
make supernode
|
||||
upx -9 edge
|
||||
upx -9 supernode
|
||||
mv edge ../bin/${TRIPLE}-edge
|
||||
mv supernode ../bin/${TRIPLE}-supernode
|
||||
popd
|
||||
}
|
||||
|
||||
|
||||
buildn2n "x86_64-linux-gnu"
|
||||
buildn2n "x86_64-w64-mingw32"
|
||||
|
|
1
cmake/x86_64-linux-gnu.cmake
Normal file
1
cmake/x86_64-linux-gnu.cmake
Normal file
|
@ -0,0 +1 @@
|
|||
# Nothing to do on the native platform.
|
9
cmake/x86_64-w64-mingw32.cmake
Normal file
9
cmake/x86_64-w64-mingw32.cmake
Normal file
|
@ -0,0 +1,9 @@
|
|||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
set(triple x86_64-w64-mingw32)
|
||||
|
||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-10-posix)
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-c++-posix)
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
|
@ -40,4 +40,4 @@ module_visual_script_enabled = "no"
|
|||
module_vorbis_enabled = "no"
|
||||
module_websocket_enabled = "no"
|
||||
module_webxr_enabled = "no"
|
||||
#custom_modules = "../modules"
|
||||
custom_modules = "../modules"
|
||||
|
|
|
@ -51,6 +51,18 @@ func _process(_delta):
|
|||
_data_buffer[received["_tag"]].append(received)
|
||||
|
||||
|
||||
func _ready():
|
||||
# Extract the edge binary.
|
||||
var binary = OS.get_user_data_dir() + "/edge"
|
||||
if OS.get_name() == "Windows":
|
||||
binary = binary + ".exe"
|
||||
if !FileAccess.file_exists(binary):
|
||||
var extract = Embedded.new()
|
||||
extract.save_edge(binary)
|
||||
if OS.get_name() != "Windows":
|
||||
OS.execute("chmod", ["+x", binary])
|
||||
|
||||
|
||||
func _send(what: String, mode: String = MODE_READ):
|
||||
if _udp.is_socket_connected():
|
||||
var packet = mode + " " + str(_sequence) + ":1:" + _password + " " + what
|
||||
|
|
3
modules/.gitignore
vendored
Normal file
3
modules/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
__pycache__/
|
||||
*.o
|
||||
*~
|
12
modules/embedded/SCsub
Normal file
12
modules/embedded/SCsub
Normal file
|
@ -0,0 +1,12 @@
|
|||
Import('env')
|
||||
|
||||
env_embedded = env.Clone()
|
||||
|
||||
# Bindings.
|
||||
env_embedded.add_source_files(env.modules_sources, "*.cpp")
|
||||
|
||||
# Append CCFLAGS flags for both C and C++ code.
|
||||
# If you need to, you can:
|
||||
# - Append CFLAGS for C code only.
|
||||
# - Append CXXFLAGS for C++ code only.
|
||||
env_embedded.Append(CCFLAGS=['-g', '-O2'])
|
6
modules/embedded/config.py
Normal file
6
modules/embedded/config.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
def can_build(env, platform):
|
||||
return True
|
||||
|
||||
|
||||
def configure(env):
|
||||
pass
|
51
modules/embedded/embedded.cpp
Normal file
51
modules/embedded/embedded.cpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include "embedded.h"
|
||||
|
||||
#define EMBED_HERE
|
||||
|
||||
extern "C" {
|
||||
#include <stdio.h>
|
||||
#include "stddclmr.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#ifdef __arm__
|
||||
#include "embeds/linux_arm64.h"
|
||||
#else
|
||||
#include "embeds/linux_x86_64.h"
|
||||
unsigned char *data = x86_64_linux_gnu_edge;
|
||||
size_t length = (size_t)x86_64_linux_gnu_edge_len;
|
||||
#endif
|
||||
#elif _WIN32
|
||||
#include "embeds/windows_x86_64.h"
|
||||
unsigned char *data = x86_64_w64_mingw32_edge;
|
||||
size_t length = (size_t)x86_64_w64_mingw32_edge_len;
|
||||
#elif __APPLE__
|
||||
#ifdef __arm__
|
||||
#include "embeds/macos_arm64.h"
|
||||
#else
|
||||
#include "embeds/macos_x86_64.h"
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Embedded::Embedded() {
|
||||
}
|
||||
|
||||
|
||||
void Embedded::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("save_edge", "filename"), &Embedded::save_edge);
|
||||
}
|
||||
|
||||
|
||||
bool Embedded::save_edge(String filename) {
|
||||
FILE *out;
|
||||
|
||||
out = fopen(filename.ascii().get_data(), "wb");
|
||||
if (out) {
|
||||
fwrite(data, length, 1, out);
|
||||
fclose(out);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
22
modules/embedded/embedded.h
Normal file
22
modules/embedded/embedded.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef GODOT_EMBEDDED_H
|
||||
#define GODOT_EMBEDDED_H
|
||||
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/variant/variant.h"
|
||||
|
||||
|
||||
class Embedded : public RefCounted {
|
||||
GDCLASS(Embedded, RefCounted);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
Embedded();
|
||||
|
||||
bool save_edge(String filename);
|
||||
};
|
||||
|
||||
|
||||
#endif // GODOT_EMBEDDED_H
|
19
modules/embedded/register_types.cpp
Normal file
19
modules/embedded/register_types.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "register_types.h"
|
||||
#include "core/object/class_db.h"
|
||||
#include "embedded.h"
|
||||
|
||||
|
||||
void initialize_embedded_module(ModuleInitializationLevel p_level) {
|
||||
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
return;
|
||||
}
|
||||
ClassDB::register_class<Embedded>();
|
||||
}
|
||||
|
||||
|
||||
void uninitialize_embedded_module(ModuleInitializationLevel p_level) {
|
||||
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
return;
|
||||
}
|
||||
// Nothing to do here.
|
||||
}
|
4
modules/embedded/register_types.h
Normal file
4
modules/embedded/register_types.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include "modules/register_module_types.h"
|
||||
|
||||
void initialize_embedded_module(ModuleInitializationLevel p_level);
|
||||
void uninitialize_embedded_module(ModuleInitializationLevel p_level);
|
95
modules/embedded/stddclmr.h
Normal file
95
modules/embedded/stddclmr.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
#ifndef STDDCLMR_H
|
||||
#define STDDCLMR_H
|
||||
|
||||
/*
|
||||
Action figures sold separately. Add toner. All models over 18 years of age.
|
||||
All rights reserved. Allow four to six weeks for delivery. An equal
|
||||
opportunity employer. Any resemblance to actual persons, living or dead, is
|
||||
unintentional and purely coincidental. Apply only to affected area. Approved
|
||||
for veterans. As seen on TV. At participating locations only. Avoid contact
|
||||
with mucous membranes. Avoid contact with skin. Avoid extreme temperatures
|
||||
and store in a cool dry place. Batteries not included. Be sure each item is
|
||||
properly endorsed. Beware of dog. Booths for two or more. Breaking seal
|
||||
constitutes acceptance of agreement. Call toll free number before digging.
|
||||
Caveat emptor. Check here if tax deductible. Close cover before striking
|
||||
Colors may fade. Contains a substantial amount of non-tobacco ingredients.
|
||||
Contents may settle during shipment. Contestants have been briefed on some
|
||||
questions before the show. Copyright 1995 Joker's Wild. Disclaimer does
|
||||
not cover hurricane, lightning, tornado, tsunami, volcanic eruption,
|
||||
earthquake, flood, and other Acts of God, misuse, neglect, unauthorized
|
||||
repair, damage from improper installation, broken antenna or marred cabinet,
|
||||
incorrect line voltage, missing or altered serial numbers, sonic boom
|
||||
vibrations, electromagnetic radiation from nuclear blasts, customer
|
||||
adjustments that are not covered in the joke list, and incidents owing to
|
||||
airplane crash, ship sinking, motor vehicle accidents, leaky roof, broken
|
||||
glass, falling rocks, mud slides, forest fire, flying projectiles, or
|
||||
dropping the item. Do not bend, fold, mutilate, or spindle. Do not place
|
||||
near flammable or magnetic source. Do not puncture, incinerate, or store
|
||||
above 120 degrees Fahrenheit. Do not stamp. Use other side for additional
|
||||
listings. Do not use while operating a motor vehicle or heavy equipment. Do
|
||||
not write below this line. Documents are provided "as is" without any
|
||||
warranties expressed or implied. Don't quote me on anything. Don't quote me
|
||||
on that. Driver does not carry cash. Drop in any mailbox. Edited for
|
||||
television. Employees and their families are not eligible. Falling rock.
|
||||
First pull up, then pull down. Flames redirected to /dev/null. For a
|
||||
limited time only. For external use only. For off-road use only. For office
|
||||
use only. For recreational use only. Do not disturb. Freshest if eaten
|
||||
before date on carton. Hand wash only, tumble dry on low heat. If a rash,
|
||||
redness, irritation, or swelling develops, discontinue use. If condition
|
||||
persists, consult your physician. If defects are discovered, do not attempt
|
||||
to fix them yourself, but return to an authorized service center. If
|
||||
ingested, do not induce vomiting, if symptoms persist, consult a doctor.
|
||||
Keep away from open flames and avoid inhaling fumes. Keep away from
|
||||
sunlight, pets, and small children. Keep cool; process promptly. Limit
|
||||
one-per-family please. Limited time offer, call now to ensure prompt
|
||||
delivery. List at least two alternate dates. List each check separately by
|
||||
bank number. List was current at time of printing. Lost ticket pays maximum
|
||||
rate. May be too intense for some viewers. Must be 18 to enter. No Canadian
|
||||
coins. No alcohol, dogs or horses. No anchovies unless otherwise specified.
|
||||
No animals were harmed in the production of these documents. No money down.
|
||||
No other warranty expressed or implied. No passes accepted for this
|
||||
engagement. No postage necessary if mailed in the United States. No
|
||||
preservatives added. No purchase necessary. No salt, MSG, artificial color
|
||||
or flavor added. No shoes, no shirt, no service, no kidding. No solicitors.
|
||||
No substitutions allowed. No transfers issued until the bus comes to a
|
||||
complete stop. No user-serviceable parts inside. Not affiliated with the
|
||||
American Red Cross. Not liable for damages due to use or misuse. Not
|
||||
recommended for children. Not responsible for direct, indirect, incidental
|
||||
or consequential damages resulting from any defect, error or failure to
|
||||
perform. Not the Beatles. Objects in mirror may be closer than they appear.
|
||||
One size fits all. Many suitcases look alike. Other copyright laws for
|
||||
specific entries apply wherever noted. Other restrictions may apply. Package
|
||||
sold by weight, not volume. Parental advisory - explicit lyrics. Penalty for
|
||||
private use. Place stamp here. Please remain seated until the ride has come
|
||||
to a complete stop. Possible penalties for early withdrawal. Post office will
|
||||
not deliver without postage. Postage will be paid by addressee. Prerecorded
|
||||
for this time zone. Price does not include taxes. Processed at location
|
||||
stamped in code at top of carton. Quantities are limited while supplies last.
|
||||
Read at your own risk. Record additional transactions on back of previous
|
||||
stub. Replace with same type. Reproduction strictly prohibited. Restaurant
|
||||
package, not for resale. Return to sender, no forwarding order on file,
|
||||
unable to forward. Safety goggles may be required during use. Sanitized for
|
||||
your protection. Sealed for your protection, do not use if the safety seal is
|
||||
broken. See label for sequence. Shading within a garment may occur. Sign here
|
||||
without admitting guilt. Simulated picture. Slightly enlarged to show detail.
|
||||
Slightly higher west of the Rockies. Slippery when wet. Smoking these may be
|
||||
hazardous to your health. Some assembly required. Some equipment shown is
|
||||
optional. Some of the trademarks mentioned in this product appear for
|
||||
identification purposes only. Subject to FCC approval. Subject to change
|
||||
without notice. Substantial penalty for early withdrawal. Text may contain
|
||||
material some readers may find objectionable, parental guidance is advised.
|
||||
Text used in these documents is made from 100% recycled electrons and magnetic
|
||||
particles. These documents do not reflect the thoughts or opinions of either
|
||||
myself, my company, my friends, or my rabbit. This is not an offer to sell
|
||||
securities. This offer is void where prohibited, taxed, or otherwise
|
||||
restricted. This product is meant for educational purposes only. Times
|
||||
approximate. Unix is a registered trademark of AT&T. Use only as directed. Use
|
||||
only in a well-ventilated are. User assumes full liabilities. Void where
|
||||
prohibited. We have sent the forms which seem right for you. You must be
|
||||
present to win. You need not be present to win. Your canceled check is your
|
||||
receipt. Your mileage may vary. I didn't do it. You can't prove anything.
|
||||
|
||||
This supersedes all previous notices.
|
||||
*/
|
||||
|
||||
#endif // STDDCLMR_H
|
2
n2n/thirdparty/libnatpmp/CMakeLists.txt
vendored
2
n2n/thirdparty/libnatpmp/CMakeLists.txt
vendored
|
@ -21,7 +21,7 @@ target_include_directories(natpmp PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
|||
target_compile_definitions(natpmp PRIVATE -DENABLE_STRNATPMPERR)
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(natpmp PUBLIC ws2_32 Iphlpapi)
|
||||
target_link_libraries(natpmp PUBLIC ws2_32 iphlpapi)
|
||||
target_compile_definitions(natpmp PUBLIC -DNATPMP_STATICLIB)
|
||||
endif (WIN32)
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ apt-get -y install \
|
|||
build-essential \
|
||||
scons \
|
||||
pkg-config \
|
||||
xxd \
|
||||
upx-ucl \
|
||||
libx11-dev \
|
||||
libxcursor-dev \
|
||||
libxinerama-dev \
|
||||
|
|
Loading…
Add table
Reference in a new issue