Skip to content

Commit

Permalink
Migrate to flipper openocd fork, windows
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkbatya committed Mar 21, 2024
1 parent 47209e4 commit 6097e18
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 9 deletions.
2 changes: 1 addition & 1 deletion linux/scripts/build-linux-flipper-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function build_hidapi() {
pushd "$LINUX_CONFIGURE_ROOT/hidapi";
cmake \
-S "/toolchain/src/src/hidapi" \
"-DCMAKE_INSTALL_PREFIX=/toolchain/linux-output-root";
"-DCMAKE_INSTALL_PREFIX=$LINUX_OUTPUT_ROOT";
make "-j$CPUS";
make install;
popd;
Expand Down
18 changes: 12 additions & 6 deletions windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ADD scripts/build-windows-gdb.sh /toolchain/src/
RUN bash /toolchain/src/build-windows-gdb.sh

FROM flipperzero-toolchain-windows-build-deps AS flipperzero-toolchain-windows-tools
RUN DEBIAN_FRONTEND=noninteractive apt update && apt -y install rsync git python3 unzip automake autoconf libtool
RUN DEBIAN_FRONTEND=noninteractive apt update && apt -y install rsync git python3 unzip automake autoconf libtool pkg-config
ADD https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-linux-x86_64.tar.gz /toolchain/src/src/archives/
RUN tar -xvf /toolchain/src/src/archives/cmake-3.28.0-linux-x86_64.tar.gz -C /tmp
RUN rsync -azv /tmp/cmake-3.28.0-linux-x86_64/ /usr
Expand All @@ -63,11 +63,17 @@ RUN mv /toolchain/src/src/clang-format/cmake-17.0.6.src /toolchain/src/src/clang
ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/third-party-17.0.6.src.tar.xz /toolchain/src/src/archives/
RUN tar -xvf /toolchain/src/src/archives/third-party-17.0.6.src.tar.xz -C /toolchain/src/src/clang-format/
RUN mv /toolchain/src/src/clang-format/third-party-17.0.6.src /toolchain/src/src/clang-format/third-party
ADD https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.12.0-2/xpack-openocd-0.12.0-2-win32-x64.zip /toolchain/src/src/archives/
RUN unzip /toolchain/src/src/archives/xpack-openocd-0.12.0-2-win32-x64.zip -d /tmp
RUN rm -rf /tmp/xpack-openocd-0.12.0-2/README.md
RUN rm -rf /tmp/xpack-openocd-0.12.0-2/distro-info
RUN rsync -azv /tmp/xpack-openocd-0.12.0-2/ /toolchain/windows-output-root

ADD https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.tar.bz2 /toolchain/src/src/archives/
RUN tar -xvf /toolchain/src/src/archives/libusb-1.0.24.tar.bz2 -C /toolchain/src/src/
RUN mv /toolchain/src/src/libusb-1.0.24 /toolchain/src/src/libusb

ADD https://github.com/libusb/hidapi/archive/refs/tags/hidapi-0.14.0.tar.gz /toolchain/src/src/archives/
RUN tar -xvf /toolchain/src/src/archives/hidapi-0.14.0.tar.gz -C /toolchain/src/src/
RUN mv /toolchain/src/src/hidapi-hidapi-0.14.0 /toolchain/src/src/hidapi

RUN git clone https://github.com/flipperdevices/openocd.git /toolchain/src/src/openocd

ADD scripts/build-windows-flipper-tools.sh /toolchain/src/
RUN bash /toolchain/src/build-windows-flipper-tools.sh

Expand Down
87 changes: 85 additions & 2 deletions windows/scripts/build-windows-flipper-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ WINDOWS_OUTPUT_ROOT=/toolchain/windows-output-root

CPUS="$(grep -c processor /proc/cpuinfo )";

export PKG_CONFIG_PATH="$WINDOWS_OUTPUT_ROOT/lib/pkgconfig";

function build_protobuf() {
pushd /toolchain/src/src/protobuf;
./autogen.sh
Expand Down Expand Up @@ -59,10 +61,91 @@ function build_clang_format() {
--component clang-format;
}

function build_libusb() {
rm -rf "$WINDOWS_CONFIGURE_ROOT/libusb";
mkdir -p "$WINDOWS_CONFIGURE_ROOT/libusb";
pushd "$WINDOWS_CONFIGURE_ROOT/libusb";
LDFLAGS="-Wl,-Bstatic,-lstdc++,-lpthread,-Bdynamic -s" \
/toolchain/src/src/libusb/configure \
"--host=x86_64-w64-mingw32" \
"--target=x86_64-w64-mingw32" \
"--prefix=$WINDOWS_OUTPUT_ROOT";
LDFLAGS="-Wl,-Bstatic,-lstdc++,-lpthread,-Bdynamic -s" \
make "-j$CPUS";
make install;
popd;
}

function build_hidapi() {
rm -rf "$WINDOWS_CONFIGURE_ROOT/hidapi";
mkdir -p "$WINDOWS_CONFIGURE_ROOT/hidapi";
pushd "$WINDOWS_CONFIGURE_ROOT/hidapi";
cmake \
-S "/toolchain/src/src/hidapi" \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
-DCLANG_DEFAULT_RTLIB=compiler-rt \
-DCLANG_DEFAULT_UNWINDLIB=libunwind \
-DCLANG_DEFAULT_CXX_STDLIB=libc++ \
-DCLANG_DEFAULT_LINKER=lld \
-DCMAKE_CXX_FLAGS="-static" \
"-DCMAKE_INSTALL_PREFIX=$WINDOWS_OUTPUT_ROOT";
make "-j$CPUS";
make install;
popd;
}

function build_openocd() {
rm -rf "$WINDOWS_CONFIGURE_ROOT/openocd";
mkdir -p "$WINDOWS_CONFIGURE_ROOT/openocd";
pushd "/toolchain/src/src/openocd";
./bootstrap;
popd;
pushd "$WINDOWS_CONFIGURE_ROOT/openocd";
LDFLAGS="-L$WINDOWS_OUTPUT_ROOT/lib" CPPFLAGS="-I$WINDOWS_OUTPUT_ROOT/include -D__USE_MINGW_ANSI_STDIO=1" LD_LIBRARY_PATH="$WINDOWS_OUTPUT_ROOT/lib" \
/toolchain/src/src/openocd/configure \
"--prefix=$WINDOWS_OUTPUT_ROOT" \
"--host=x86_64-w64-mingw32" \
"--target=x86_64-w64-mingw32" \
"--datarootdir=$WINDOWS_OUTPUT_ROOT" \
"--localedir=$WINDOWS_OUTPUT_ROOT/share/locale" \
"--disable-wextra" \
"--disable-werror" \
"--disable-gccwarnings" \
"--disable-doxygen-html" \
"--disable-doxygen-pdf" \
"--disable-debug" \
"--disable-dependency-tracking" \
"--enable-cmsis-dap" \
"--enable-dummy" \
"--enable-stlink" \
"--disable-zy1000-master" \
"--disable-zy1000" \
"--disable-ioutil" \
"--disable-minidriver-dummy" \
"--disable-parport-ppdev" \
"--enable-amtjtagaccel" \
"--enable-gw16012" \
"--enable-parport" \
"--disable-sysfsgpio" \
"--disable-buspirate" \
"--disable-oocd_trace" \
"--enable-parport-giveio";
LDFLAGS="-L$WINDOWS_OUTPUT_ROOT/lib" CPPFLAGS="-I$WINDOWS_OUTPUT_ROOT/include -D__USE_MINGW_ANSI_STDIO=1" LD_LIBRARY_PATH="$WINDOWS_OUTPUT_ROOT/lib" \
make "-j$CPUS";
make install-strip;
popd;
}

function cleanup() {
find "$WINDOWS_OUTPUT_ROOT" \( -name "*.a" -or -name "*.la" \) -delete;
}

build_protobuf;
build_clang_format;
#build_protobuf;
#build_clang_format;
build_libusb;
build_hidapi;
build_openocd;
cleanup;

0 comments on commit 6097e18

Please sign in to comment.