Skip to content

Commit

Permalink
first draft for app update
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbora committed May 6, 2024
1 parent 3eee94d commit 6b3fcac
Show file tree
Hide file tree
Showing 16 changed files with 4,507 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/update/Dockerfile.linux-x64
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM decenomy/dsw-linux-x64-builder@sha256:49894f78ac27318ed1c018c80e674f99e6b45ac382c9b98a2aa0c94d8bd755a4

# Set up a development tools directory
WORKDIR /home/app

COPY . /home/app

RUN make docker_linux_test

RUN export PATH="/wrapped:$PATH"
10 changes: 10 additions & 0 deletions src/update/Dockerfile.macos-x64
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM decenomy/dsw-macos-x64-builder@sha256:395f7c9cc2ec9767674c0a226ca86855253f8558f94e367d02cfff45fa909f94

# Set up a development tools directory
WORKDIR /home/app

COPY . /home/app

RUN make docker_macos_test

RUN export PATH="/wrapped:$PATH"
10 changes: 10 additions & 0 deletions src/update/Dockerfile.windows-x64
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM decenomy/dsw-windows-x64-builder@sha256:c5102edf92fba810de6596cc9593729b79ab00ca8d88656d4613a3cfa1fecf78

# Set up a development tools directory
WORKDIR /home/app

COPY . /home/app

RUN make docker_windows_test

RUN export PATH="/wrapped:$PATH"
31 changes: 31 additions & 0 deletions src/update/linux-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

TAG=linux-x64-builder

#To compile and build the container execute docker in this way:
docker build \
-f Dockerfile.linux-x64 \
-t $TAG .

# Check if docker build was successful
if [ $? -ne 0 ]; then
echo "Error: Docker build failed."
exit 1
fi

# Create a temporary container from the image
container_id=$(docker create $TAG)

echo "Container ID: $container_id"

# Copy files from the container to the current directory
docker cp "$container_id":home/app/test .

# Remove the temporary container
docker rm "$container_id"


# To run the container use:
#docker run \
# -it \
# -v "$(pwd):/home/app" \
# ${TAG}:latest
34 changes: 34 additions & 0 deletions src/update/logging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef BITCOIN_LOGGING_H
#define BITCOIN_LOGGING_H

#include "tinyformat.h"
#include <cerrno> // For perror
#include <cstring> // For strerror
#include <iostream>
#include <string>

/** Get format string from VA_ARGS for error reporting */
template<typename... Args> std::string FormatStringFromLogArgs(const char *fmt, const Args&... args) { return fmt; }

#define LogPrintf(...) do { \
if(true) { \
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
try { \
_log_msg_ = tfm::format(__VA_ARGS__); \
} catch (tinyformat::format_error &e) { \
/* Original format string will have newline so don't add one here */ \
_log_msg_ = "Error \"" + std::string(e.what()) + \
"\" while formatting log message: " + \
FormatStringFromLogArgs(__VA_ARGS__); \
} \
std::cout << _log_msg_; \
} \
} while(0)

#define LogPrint(category, ...) do { \
if (LogAcceptCategory((category))) { \
LogPrintf(__VA_ARGS__); \
} \
} while(0)

#endif
31 changes: 31 additions & 0 deletions src/update/macos-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

TAG=macos-x64-builder

#To compile and build the container execute docker in this way:
docker build \
-f Dockerfile.macos-x64 \
-t $TAG .

# Check if docker build was successful
if [ $? -ne 0 ]; then
echo "Error: Docker build failed."
exit 1
fi

# Create a temporary container from the image
container_id=$(docker create $TAG)

echo "Container ID: $container_id"

# Copy files from the container to the current directory
docker cp "$container_id":home/app/a.out .

# Remove the temporary container
docker rm "$container_id"


# To run the container use:
#docker run \
# -it \
# -v "$(pwd):/home/app" \
# ${TAG}:latest
68 changes: 68 additions & 0 deletions src/update/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
work_dir := $(shell pwd)
CXX := g++ # Default compiler
CXXFLAGS := -std=c++11 -Wall -Wextra
LDFLAGS :=
arch := x86_64-pc-linux-gnu

ifdef linux_arm64
CXX := aarch64-linux-gnu-g++
arch := aarch64-linux-gnu
endif


all: test

#test is working - .so files had to be deleted !!!!
curl_test:
$(CXX) \
-I$(work_dir)/depends/dist/include \
-L$(work_dir)/depends/dist/lib \
-L$(work_dir)/depends/dist/lib64 \
-o curl_test curl_test.cpp \
-lcurl -lssl -lcrypto -lz

#linux_x86=true make test
test:
$(CXX) -DUPDATETEST \
-I$(work_dir)/../../depends/$(arch)/include \
-L$(work_dir)/../../depends/$(arch)/lib \
-L$(work_dir)/../../depends/$(arch)/lib64 \
-o test test.cpp update.h update.cpp minizip/unzip.h minizip/unzip.c minizip/ioapi.h minizip/ioapi.c \
-lcurl -pthread -lz -lssl -lcrypto -lboost_system-mt-x64 -lboost_filesystem-mt-x64

app:
$(CXX) -DUPDATETEST -DNEWVERSION="$(VERSION)" \
-I$(work_dir)/../../depends/$(arch)/include \
-L$(work_dir)/../../depends/$(arch)/lib \
-L$(work_dir)/../../depends/$(arch)/lib64 \
-o app test.cpp update.h update.cpp minizip/unzip.h minizip/unzip.c minizip/ioapi.h minizip/ioapi.c \
-lcurl -pthread -lz -lssl -lcrypto -lboost_system-mt-x64 -lboost_filesystem-mt-x64


docker_macos_test:
/DSW/depends/x86_64-apple-darwin14/native/bin/clang++ -DUPDATETEST \
-target x86_64-apple-darwin14 -mmacosx-version-min=10.10 --sysroot /DSW/depends/SDKs/MacOSX10.11.sdk -mlinker-version=253.9 -stdlib=libc++ \
-I/DSW/depends/x86_64-apple-darwin14/include \
-L/DSW/depends/x86_64-apple-darwin14/lib \
-L/DSW/depends/x86_64-apple-darwin14/lib64 \
test.cpp logging.h tinyformat.h update.h update.cpp minizip/unzip.h minizip/unzip.c minizip/ioapi.h minizip/ioapi.c \
-lcurl -DCURL_STATICLIB `/DSW/depends/x86_64-apple-darwin14/bin/curl-config --cflags --static-libs` -pthread -lz -lssl -lcrypto -lboost_system-mt-x64 -lboost_filesystem-mt-x64

docker_linux_test:
$(CXX) -DUPDATETEST \
-I/DSW/depends/x86_64-pc-linux-gnu/include \
-L/DSW/depends/x86_64-pc-linux-gnu/lib \
-L/DSW/depends/x86_64-pc-linux-gnu/lib64 \
-o test test.cpp logging.h tinyformat.h update.h update.cpp minizip/unzip.h minizip/unzip.c minizip/ioapi.h minizip/ioapi.c \
-lcurl -pthread -lz -lssl -lcrypto -ldl -lboost_system-mt-x64 -lboost_filesystem-mt-x64

docker_windows_test:
/usr/bin/x86_64-w64-mingw32-g++ -DUPDATETEST -static \
-I/DSW/depends/x86_64-w64-mingw32/include \
-L/DSW/depends/x86_64-w64-mingw32/lib \
-L/DSW/depends/x86_64-w64-mingw32/lib64 \
-o test.exe test.cpp logging.h tinyformat.h update.h update.cpp minizip/unzip.h minizip/unzip.c minizip/ioapi.h minizip/ioapi.c \
-lcurl -DCURL_STATICLIB `/DSW/depends/x86_64-w64-mingw32/bin/curl-config --cflags --static-libs` -pthread -lz -lssl -lcrypto -lboost_system-mt-s-x64 -lboost_filesystem-mt-s-x64

clean:
rm test app test.exe
Loading

2 comments on commit 6b3fcac

@bedri
Copy link
Contributor

@bedri bedri commented on 6b3fcac May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other non-capital letter starting function names in test files. If it's the case it can be accepted in test files but please let us be careful in main function names.

@zimbora
Copy link
Contributor Author

@zimbora zimbora commented on 6b3fcac May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, is stronger than the me, but I will be more careful

Please sign in to comment.