Skip to content

Commit 5d66a3b

Browse files
committed
Impoving UTF-8 BOM handling for collection info in lib2inpx
Moving to go 1.20, droppng deprecated packages (pkg/errors, ioutils) and updating all dependencies. Dropping support for 32 bit Windows build
1 parent 8979e9b commit 5d66a3b

File tree

27 files changed

+119
-827
lines changed

27 files changed

+119
-827
lines changed

.gitignore

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,22 @@
1111
*.log
1212
*.svg
1313

14-
*.[568vq]
15-
[568vq].out
16-
17-
.undodir/
18-
.glide/
19-
.idea/
20-
.vscode/
21-
build/
22-
bin/
23-
_obj/
24-
_test/
25-
2614
# build specific
2715
src/*/misc/version.go
2816

29-
pkg/
30-
!src/**/pkg/
31-
32-
*.cgo1.go
33-
*.cgo2.c
34-
_cgo_defun.c
35-
_cgo_gotypes.go
36-
_cgo_export.*
37-
_testmain.go
38-
.session.vim
39-
.set-project-env
40-
conf/mmb_*
17+
lib2inpx-*.7z
18+
lib2inpx-*.zip
19+
lib2inpx-*.xz
20+
lib2inpx-*.gz
4121

42-
# Our staff
43-
44-
lib2inpx-win32.7z
45-
lib2inpx-win64.7z
46-
lib2inpx-linux_i686-glibc_*.tar.xz
47-
lib2inpx-linux_x86_64-glibc_*.tar.xz
22+
bin/
23+
build/
24+
[Bb]in_*/
25+
[Dd]ebug*/
26+
[Rr]elease*/
4827

49-
[Bb]in_win32
50-
[Bb]in_win64
51-
[Bb]in_linux_i686
52-
[Bb]in_linux_x86_64
28+
mariadb-??.?.*-linux-glibc_*-x86_64.tar.gz
29+
lib2inpx-*.tar.xz
5330

5431
mariadb-??.?.*-linux-glibc_*-x86_64.tar.gz
5532
mariadb-??.?.*-linux-glibc_*-x86_64/**
@@ -68,16 +45,3 @@ mysql-?.?.*-win32.zip
6845
mysql-?.?.*-win32/**
6946
mysql-?.?.*-winx64.zip
7047
mysql-?.?.*-winx64/**
71-
72-
[Dd]ebug32/
73-
[Dd]ebug64/
74-
[Dd]ebug_win32/
75-
[Dd]ebug_win64/
76-
[Rr]elease32/
77-
[Rr]elease64/
78-
[Rr]elease_win32/
79-
[Rr]elease_win64/
80-
[Dd]ebug_linux_i686/
81-
[Dd]ebug_linux_x86_64/
82-
[Rr]elease_linux_i686/
83-
[Rr]elease_linux_x86_64/

CMakeLists.txt

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
1313

1414
# Project version number
1515
set(PRJ_VERSION_MAJOR 9)
16-
set(PRJ_VERSION_MINOR 45)
16+
set(PRJ_VERSION_MINOR 46)
1717

1818
if(WIN32 AND NOT DEFINED ENV{MSYSTEM})
1919
message(FATAL_ERROR "Currently unsuppored environment. Use MINGW for Windows builds. CMake willl exit now.")
@@ -49,6 +49,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
4949
message(STATUS "** Debug mode")
5050
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -D_XML_DEBUG")
5151
set(TEST_RUN_ARGS "-v")
52+
set(GO_MOD_ARGS "-mod=mod")
5253
else()
5354
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
5455
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
@@ -84,7 +85,8 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/inpx
8485
configure_file("${PROJECT_SOURCE_DIR}/cmake/version.h.in" "${PROJECT_BINARY_DIR}/version.h")
8586

8687
set(Boost_USE_STATIC_LIBS ON)
87-
set(Boost_USE_STATIC_RUNTIME ON)
88+
# set(Boost_USE_STATIC_RUNTIME ON)
89+
8890
find_package(Boost 1.58.0 REQUIRED COMPONENTS "date_time" "program_options" "filesystem")
8991
find_package(Threads)
9092
if(DEFINED ENV{MYSQL_PROPER})
@@ -152,7 +154,7 @@ install(FILES ${MYSQL_LIB_DIR}/../share/english/errmsg.sys DESTINATION ${PROJECT
152154
# go targets are always out of date, "go build" will figure it out
153155
########################################################################################################
154156

155-
find_package(Go 1.13 REQUIRED)
157+
find_package(Go 1.20 REQUIRED)
156158

157159
if(CMAKE_CROSSCOMPILING)
158160
# Set Go target environments
@@ -165,11 +167,20 @@ if(CMAKE_CROSSCOMPILING)
165167
endif()
166168
endif()
167169

170+
# Make sure we setup go properly
171+
if (DEFINED ENV{GOPATH})
172+
set(GO_PATH "$ENV{GOPATH}")
173+
else()
174+
set(GO_PATH "/tmp/gopkg_${CMAKE_PROJECT_NAME}")
175+
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${GO_PATH})
176+
endif()
177+
message(STATUS "Using go modules with GOPATH=${GO_PATH}")
178+
168179
configure_file("${PROJECT_SOURCE_DIR}/cmake/version.go.in" "${PROJECT_SOURCE_DIR}/src/inpxcreator/misc/version.go")
169180

170181
add_custom_target(bin_libget2 ALL
171182
DEPENDS gen_git_ver
172-
COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on GOOS=${CROSS_GOOS} GOARCH=${CROSS_GOARCH}
183+
COMMAND GOPATH=${GO_PATH} GOOS=${CROSS_GOOS} GOARCH=${CROSS_GOARCH} CGO_ENABLED=0
173184
${GO_EXECUTABLE} build -o ${PROJECT_BINARY_DIR}/libget2${CMAKE_EXECUTABLE_SUFFIX}
174185
-ldflags='-X main.LastGitCommit=\$\(shell cat ${PROJECT_BINARY_DIR}/inpxc_git_ver\)'
175186
${GO_MOD_ARGS}
@@ -180,7 +191,7 @@ install(PROGRAMS ${PROJECT_BINARY_DIR}/libget2${CMAKE_EXECUTABLE_SUFFIX} DESTINA
180191

181192
add_custom_target(bin_libmerge ALL
182193
DEPENDS gen_git_ver
183-
COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on GOOS=${CROSS_GOOS} GOARCH=${CROSS_GOARCH}
194+
COMMAND GOPATH=${GO_PATH} GOOS=${CROSS_GOOS} GOARCH=${CROSS_GOARCH} CGO_ENABLED=0
184195
${GO_EXECUTABLE} build -o ${PROJECT_BINARY_DIR}/libmerge${CMAKE_EXECUTABLE_SUFFIX}
185196
-ldflags='-X main.LastGitCommit=\$\(shell cat ${PROJECT_BINARY_DIR}/inpxc_git_ver\)'
186197
${GO_MOD_ARGS}
@@ -193,30 +204,16 @@ install(PROGRAMS ${PROJECT_BINARY_DIR}/libmerge${CMAKE_EXECUTABLE_SUFFIX} DESTIN
193204
# Go dependency management
194205
########################################################################################################
195206

196-
add_custom_target(deps_print
197-
SOURCES ${PROJECT_SOURCE_DIR}/src/inpxcreator/go.mod
198-
COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on ${GO_EXECUTABLE} mod graph
199-
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator"
200-
COMMENT "Printing dependencies (go mod graph)"
201-
VERBATIM)
202-
203207
add_custom_target(deps_tidy
204208
SOURCES ${PROJECT_SOURCE_DIR}/src/inpxcreator/go.mod
205-
COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on ${GO_EXECUTABLE} mod tidy
209+
COMMAND GOPATH=${GO_PATH} ${GO_EXECUTABLE} mod tidy -go=${GO_LANG_VERSION}
206210
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator"
207211
COMMENT "Cleaning dependencies (go mod tidy)"
208212
VERBATIM)
209213

210-
add_custom_target(deps_verify
211-
SOURCES ${PROJECT_SOURCE_DIR}/src/inpxcreator/go.mod
212-
COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on ${GO_EXECUTABLE} mod verify
213-
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator"
214-
COMMENT "Verifying dependencies (go mod verify)"
215-
VERBATIM)
216-
217214
add_custom_target(deps_vendor
218215
SOURCES ${PROJECT_SOURCE_DIR}/src/inpxcreator/go.mod
219-
COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on ${GO_EXECUTABLE} mod vendor
216+
COMMAND GOPATH=${GO_PATH} ${GO_EXECUTABLE} mod vendor
220217
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator"
221218
COMMENT "Creating vendor directory (go mod vendor)"
222219
VERBATIM)

build-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RED=''
3333
YELLOW=''
3434

3535
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
36-
ARCH_INSTALLS="${ARCH_INSTALLS:-win32 win64 linux}"
36+
ARCH_INSTALLS="${ARCH_INSTALLS:-win64 linux}"
3737

3838
if [ ! -d ${HOME}/result ]; then
3939
print_error "directory for the result is not available. Exiting..."

cmake/FindGlide.cmake

Lines changed: 0 additions & 23 deletions
This file was deleted.

cmake/FindGo.cmake

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,33 @@
55
# The module defines the following variables:
66
# GO_FOUND - true if the Go was found
77
# GO_EXECUTABLE - path to the executable
8+
# GOFMT_EXECUTABLE - path to gofmt executable
89
# GO_VERSION - Go version number
10+
# GO_LANG_VERSION - Go version number without patch, only major and minor versions. Used with "go mod tidy"
911
# GO_PLATFORM - i.e. linux
1012
# GO_ARCH - i.e. amd64
1113
# Example usage:
1214
# find_package(Go 1.2 REQUIRED)
1315

14-
find_program(GO_EXECUTABLE go PATHS $ENV{HOME}/go ENV GOROOT GOPATH PATH_SUFFIXES bin)
16+
find_program(GO_EXECUTABLE go PATHS ENV GOROOT GOPATH PATH_SUFFIXES bin)
1517
if(GO_EXECUTABLE)
16-
if(NOT CMAKE_CROSSCOMPILING AND WIN32 AND DEFINED ENV{MSYSTEM})
17-
if(NOT GO_ROOT)
18-
if($ENV{MSYSTEM} STREQUAL "MINGW32")
19-
set(GO_ROOT "/mingw32/lib/go")
20-
elseif($ENV{MSYSTEM} STREQUAL "MINGW64")
21-
set(GO_ROOT "/mingw64/lib/go")
22-
else()
23-
message(FATAL_ERROR "Currently unsuppored environment. CMake willl exit now.")
24-
endif()
25-
endif()
26-
else()
27-
if (DEFINED ENV{GOROOT})
28-
set(GO_ROOT "$ENV{GOROOT}")
29-
else()
30-
set(GO_ROOT "/usr/lib/go")
31-
endif()
32-
endif()
33-
execute_process(COMMAND sh -c "${GO_EXECUTABLE} version" OUTPUT_VARIABLE GO_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
34-
if(GO_VERSION_OUTPUT MATCHES "go([0-9]+\\.[0-9]+\\.?[0-9]*)[a-zA-Z0-9]* ([^/]+)/(.*)")
18+
execute_process(COMMAND ${GO_EXECUTABLE} version OUTPUT_VARIABLE GO_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
19+
if(GO_VERSION_OUTPUT MATCHES "go version go([0-9]+\\.[0-9]+\\.?[0-9]*)[a-zA-Z0-9]* ([^/]+)/(.*)")
3520
set(GO_VERSION ${CMAKE_MATCH_1})
3621
set(GO_PLATFORM ${CMAKE_MATCH_2})
3722
set(GO_ARCH ${CMAKE_MATCH_3})
23+
string(REGEX MATCH "([0-9]+\\.[0-9]+)" GO_LANG_VERSION ${GO_VERSION})
3824
elseif(GO_VERSION_OUTPUT MATCHES "go version devel .* ([^/]+)/(.*)$")
3925
set(GO_VERSION "99-devel")
26+
set(GO_LANG_VERSION, "99-devel")
4027
set(GO_PLATFORM ${CMAKE_MATCH_1})
4128
set(GO_ARCH ${CMAKE_MATCH_2})
4229
message("WARNING: Development version of Go being used, can't determine compatibility.")
4330
endif()
31+
get_filename_component(path ${GO_EXECUTABLE} DIRECTORY)
32+
set(GOFMT_EXECUTABLE ${path}/gofmt${CMAKE_EXECUTABLE_SUFFIX})
4433
endif()
4534
mark_as_advanced(GO_EXECUTABLE)
4635

4736
include(FindPackageHandleStandardArgs)
48-
find_package_handle_standard_args(Go REQUIRED_VARS GO_EXECUTABLE GO_VERSION GO_PLATFORM GO_ARCH VERSION_VAR GO_VERSION)
37+
find_package_handle_standard_args(Go REQUIRED_VARS GO_EXECUTABLE GOFMT_EXECUTABLE GO_PLATFORM GO_ARCH GO_VERSION GO_LANG_VERSION VERSION_VAR GO_VERSION)

cmake/FindGodep.cmake

Lines changed: 0 additions & 25 deletions
This file was deleted.

docker/Dockerfile.build

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,41 @@
11
FROM ubuntu:16.04
22

3+
# Synology is still running very old glibc - 2.5 as of v7. So I have to use old verion of Ubuntu for linux build...
4+
35
RUN apt-get -qqy update &&\
46
apt-get -qqy install tzdata wget curl build-essential git git-extras automake pkg-config libcurl4-openssl-dev zlib1g-dev libaio-dev libboost-all-dev p7zip-full gdb mingw-w64 binutils-mingw-w64 mingw-w64-tools libz-mingw-w64-dev
57

68
WORKDIR /root/
79

810
# ---------- We either patch cmake to support up to date boost (/usr/share/cmake-3.5/Modules/FindBoost.cmake) or build fresh one
9-
RUN curl -LO https://cmake.org/files/v3.15/cmake-3.15.4.tar.gz \
10-
&& tar -xvf cmake-3.15.4.tar.gz \
11-
&& cd cmake-3.15.4 \
11+
RUN curl -LO https://cmake.org/files/v3.25/cmake-3.25.3.tar.gz \
12+
&& tar -xvf cmake-3.25.3.tar.gz \
13+
&& cd cmake-3.25.3 \
1214
&& ./bootstrap --system-curl \
1315
&& make install \
1416
&& cd .. \
15-
&& rm -rf cmake-3.15.4.tar.gz cmake-3.15.4
17+
&& rm -rf cmake-3.25.3.tar.gz cmake-3.25.3
1618

1719
# ---------- mingw does not have expat
1820
RUN git clone https://github.com/libexpat/libexpat.git \
1921
&& cd libexpat \
20-
&& git checkout R_2_2_6 \
22+
&& git checkout R_2_5_0 \
2123
&& cd expat \
2224
&& ./buildconf.sh \
23-
&& ./configure --host=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32 --without-xmlwf --without-docbook \
24-
&& make install \
25-
&& make clean \
2625
&& ./configure --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32 --without-xmlwf --without-docbook \
2726
&& make install \
2827
&& cd ../.. \
2928
&& rm -rf libexpat \
30-
&& rm /usr/i686-w64-mingw32/lib/*.la \
3129
&& rm /usr/x86_64-w64-mingw32/lib/*.la
3230

3331
# ---------- mingw does not have static iconv
34-
RUN curl -LO https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz \
35-
&& tar -xvf libiconv-1.15.tar.gz \
36-
&& cd libiconv-1.15 \
37-
&& ./configure --host=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32 --enable-static \
38-
&& make install \
39-
&& make clean \
32+
RUN curl -LO https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz \
33+
&& tar -xvf libiconv-1.17.tar.gz \
34+
&& cd libiconv-1.17 \
4035
&& ./configure --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32 --enable-static \
4136
&& make install \
4237
&& cd .. \
43-
&& rm -rf libiconv-1.15.tar.gz libiconv-1.15 \
44-
&& rm /usr/i686-w64-mingw32/lib/*.la \
38+
&& rm -rf libiconv-1.17.tar.gz libiconv-1.17 \
4539
&& rm /usr/x86_64-w64-mingw32/lib/*.la
4640

4741
# ---------- mingw does not have boost (and we cannot cross build anything older than 1.63)
@@ -64,9 +58,6 @@ RUN ln -s /usr/bin/x86_64-w64-mingw32-windres /usr/bin/windres \
6458
&& ./b2 --without-python --without-serialization --user-config=user-config.jam --debug-configuration toolset=gcc-5.3.1 link=shared,static target-os=windows address-model=64 pch=off threading=multi threadapi=win32 variant=release --prefix=/usr/x86_64-w64-mingw32 --layout=tagged --without-python --without-mpi -sICONV_PATH=/usr/x86_64-w64-mingw32 -sICONV_LINK="-L/usr/x86_64-w64-mingw32/lib -liconv" install \
6559
&& ./b2 --without-python --without-serialization --user-config=user-config.jam --debug-configuration toolset=gcc-5.3.1 link=shared,static target-os=windows address-model=64 pch=off threading=multi threadapi=win32 variant=release --prefix=/usr/x86_64-w64-mingw32 --layout=tagged --without-python --without-mpi -sICONV_PATH=/usr/x86_64-w64-mingw32 -sICONV_LINK="-L/usr/x86_64-w64-mingw32/lib -liconv" clean \
6660
&& rm -rf bin.v2 stage \
67-
&& echo "using gcc : 5.3.1 : i686-w64-mingw32-g++ ;" > user-config.jam \
68-
&& ./b2 --user-config=user-config.jam --debug-configuration toolset=gcc-5.3.1 link=shared,static target-os=windows address-model=32 pch=off threading=multi threadapi=win32 variant=release --prefix=/usr/i686-w64-mingw32 --layout=tagged --without-python --without-mpi --without-serialization -sICONV_PATH=/usr/i686-w64-mingw32 -sICONV_LINK="-L/usr/i686-w64-mingw32/lib -liconv" install \
69-
&& ./b2 --user-config=user-config.jam --debug-configuration toolset=gcc-5.3.1 link=shared,static target-os=windows address-model=32 pch=off threading=multi threadapi=win32 variant=release --prefix=/usr/i686-w64-mingw32 --layout=tagged --without-python --without-mpi --without-serialization -sICONV_PATH=/usr/i686-w64-mingw32 -sICONV_LINK="-L/usr/i686-w64-mingw32/lib -liconv" clean \
7061
&& cd .. \
7162
&& rm -rf boost_1_63_0.tar.gz boost_1_63_0
7263

@@ -76,9 +67,9 @@ RUN ./get-maria.sh
7667

7768
# ---------- download golang
7869

79-
RUN curl -LO https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz \
80-
&& tar -xvf go1.14.2.linux-amd64.tar.gz \
81-
&& rm go1.14.2.linux-amd64.tar.gz \
70+
RUN curl -LO https://go.dev/dl/go1.20.2.linux-amd64.tar.gz \
71+
&& tar -xvf go1.20.2.linux-amd64.tar.gz \
72+
&& rm go1.20.2.linux-amd64.tar.gz \
8273
&& sed -i -e '$a export PATH=$PATH:/root/go/bin' .bashrc \
8374
&& sed -i -e '$a export GOROOT=/root/go' .bashrc
8475

docker/container.txt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
docker build --squash -t inpxc:latest . -f ./Dockerfile.build
2-
3-
docker save -o ../../inpxc.tar inpxc
4-
docker load -i ../../inpxc.tar
5-
6-
docker run --name inpxcreator -v E:/projects/books/InpxCreator:/root/result -it inpxc:latest
7-
docker run -e TZ=America/New_York --name inpxcreator -v E:/projects/books/InpxCreator:/root/result -it inpxc:latest /bin/bash
8-
9-
--------------------------------------
10-
111
podman build -t inpxc:latest . -f ./Dockerfile.build
122

13-
podman run -it --name inpxcreator -v /mnt/e/projects/books/InpxCreator:/root/result --rm inpxc:latest
14-
podman run -it -e TZ=America/New_York --name inpxcreator -v /mnt/e/projects/books/InpxCreator:/root/result inpxc:latest /bin/bash
3+
podman run -it --network host -v ~/projects/github.com/rupor-github:/root/result --rm inpxc:latest
4+
podman run -it --network host -e TZ=America/New_York -v ~/projects/github.com/rupor-github/InpxCreator:/root/result inpxc:latest /bin/bash

docker/get-maria.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ver_minor=26
88
declare -A checkmap
99
from_url="https://downloads.mariadb.com/MariaDB"
1010

11-
ARCH_INSTALLS="${ARCH_INSTALLS:-win32 win64 linux}"
11+
ARCH_INSTALLS="${ARCH_INSTALLS:-win64 linux}"
1212

1313
for _mingw in ${ARCH_INSTALLS}; do
1414
case ${_mingw} in

0 commit comments

Comments
 (0)