Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
vbam-libretro
Commits
c3fc4e7e
Commit
c3fc4e7e
authored
Oct 21, 2017
by
Zach Bacon
Browse files
Added basic windows script
parent
21926d62
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/win/builder
0 → 100644
View file @
c3fc4e7e
#!/bin/sh
set
-e
BUILD_ROOT
=
$HOME
/vbam-build
# build env
export
HOST_SYSTEM
=
x86_64-w64-mingw32
export
CFLAGS
=
"-I
$BUILD_ROOT
/root/include"
export
CPPFLAGS
=
"-I
$BUILD_ROOT
/root/include"
export
CXXFLAGS
=
"-I
$BUILD_ROOT
/root/include -std=gnu++11"
export
OBJCXXFLAGS
=
"-I
$BUILD_ROOT
/root/include -std=gnu++11"
export
LDFLAGS
=
"-L
$BUILD_ROOT
/root/lib"
export
CMAKE_PREFIX_PATH
=
"
$BUILD_ROOT
/root"
export
PKG_CONFIG_PATH
=
"
$BUILD_ROOT
/root/lib/pkgconfig"
export
PATH
=
"
$BUILD_ROOT
/root/bin:
$PATH
"
DISTS
=
'
gettext http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz lib/libintl.a
openssl https://www.openssl.org/source/openssl-1.0.2l.tar.gz lib/libssl.a
libpng https://download.sourceforge.net/libpng/libpng-1.6.32.tar.xz lib/libpng.a
libjpeg-turbo https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.5.2.tar.gz lib/libjpeg.a
libtiff http://dl.maptools.org/dl/libtiff/tiff-3.8.2.tar.gz lib/libtiff.a
sdl2 https://www.libsdl.org/release/SDL2-2.0.6.tar.gz lib/libSDL2.a
sfml https://www.sfml-dev.org/files/SFML-2.4.2-sources.zip lib/libsfml-system-s.a
wxwidgets https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3/wxWidgets-3.0.3.tar.bz2 lib/libwx_baseu-3.0.a
ffmpeg http://ffmpeg.org/releases/ffmpeg-3.3.4.tar.xz lib/libavformat.a
xz https://tukaani.org/xz/xz-5.2.3.tar.xz lib/liblzma.a
'
CONFIGURE_ARGS
=
"--disable-shared --enable-static --prefix=
$BUILD_ROOT
/root --host=
$HOST_SYSTEM
--build=
$HOST_SYSTEM
--target=
$HOST_SYSTEM
"
CMAKE_ARGS
=
"-DCMAKE_PREFIX_PATH=
$BUILD_ROOT
/root -DCMAKE_INSTALL_PREFIX=
$BUILD_ROOT
/root"
DIST_OVERRIDES
=
"
openssl mingw64 no-shared --prefix=
$BUILD_ROOT
/root
"
DIST_ARGS
=
"
sfml -DBUILD_SHARED_LIBS=NO
wxwidgets --enable-stl
"
main
()
{
setup
delete_outdated_dists
download_dists
build_dists
build_project
}
setup
()
{
mkdir
-p
"
$BUILD_ROOT
"
DIST_NAMES
=
$(
table_column 0 3
"
$DISTS
"
)
DIST_URLS
=
$(
table_column 1 3
"
$DISTS
"
)
DIST_TARGETS
=
$(
table_column 2 3
"
$DISTS
"
)
DISTS_NUM
=
$(
table_rows
"
$DISTS
"
)
NUM_CPUS
=
$(
nproc
)
CHECKOUT
=
$(
find_checkout
)
}
delete_outdated_dists
()
{
files
=
i
=
0
for
dist
in
$DIST_NAMES
;
do
dist_url
=
$(
list_get
$i
$DIST_URLS
)
dist_file
=
"
$BUILD_ROOT
/dists/
${
dist_url
##*/
}
"
files
=
"
$files
$dist_file
"
i
=
$((
i
+
1
))
done
for
file
in
$BUILD_ROOT
/dists/
*
;
do
if
!
list_contains
"
$file
"
$files
;
then
echo
"
\n
[32mDeleting outdated dist: [1;34m
$file
[0m
\n
"
rm
-f
"
$file
"
fi
done
}
download_dists
()
{
mkdir
-p
"
$BUILD_ROOT
/dists"
i
=
0
while
[
$i
-lt
$DISTS_NUM
]
;
do
dist_name
=
$(
list_get
$i
$DIST_NAMES
)
dist_url
=
$(
list_get
$i
$DIST_URLS
)
dist_file
=
"
$BUILD_ROOT
/dists/
${
dist_url
##*/
}
"
cd
"
$BUILD_ROOT
/dists"
if
[
!
-e
"
$dist_file
"
]
;
then
echo
"
\n
[32mFetching [1;35m
$dist_name
[0m: [1;34m
$dist_url
[0m
\n
"
curl
-LO
"
$dist_url
"
# force rebuild for new dist file
rm
-f
"
$BUILD_ROOT
/root/
$(
list_get
$i
$DIST_TARGETS
)
"
rm
-rf
"
$BUILD_ROOT
/libs/
$dist_name
"
fi
dist_dir
=
"
$BUILD_ROOT
/libs/
$dist_name
"
if
[
!
-d
"
$dist_dir
"
]
;
then
mkdir
-p
"
$dist_dir
"
tmp_dir
=
"
$BUILD_ROOT
/libs/tmp"
mkdir
-p
"
$tmp_dir
"
cd
"
$tmp_dir
"
case
"
$dist_file
"
in
*
.tar.gz
)
tar
zxf
"
$dist_file
"
;;
*
.tar.xz
)
xzcat
"
$dist_file
"
|
tar
xf -
;;
*
.tar.bz2
)
bzcat
"
$dist_file
"
|
tar
xf -
;;
*
.zip
)
unzip
-q
"
$dist_file
"
;;
esac
mv
*
/
*
"
$dist_dir
"
rm
-rf
"
$tmp_dir
"
fi
i
=
$((
i
+
1
))
done
}
build_dists
()
{
cd
"
$BUILD_ROOT
/libs"
i
=
0
for
dist
in
$DIST_NAMES
;
do
target_lib
=
"
$BUILD_ROOT
/root/
$(
list_get
$i
$DIST_TARGETS
)
"
if
[
!
-e
"
$target_lib
"
]
;
then
cd
"
$dist
"
if
[
-e
configure
-o
-e
configure.ac
-o
-e
configure.in
-o
-e
Makefile.am
]
;
then
echo
"
\n
[32mBuilding [1;35m
$dist
[0m
\n
"
if
[
!
-e
configure
]
;
then
aclocal
if
command
-v
glibtoolize
>
/dev/null
;
then
glibtoolize
else
libtoolize
fi
autoheader
autoconf
[
-e
Makefile.am
]
&&
automake
--add-missing
fi
./configure
$(
dist_args
"
$dist
"
autoconf
)
make
-j
$NUM_CPUS
make
install
prefix
=
$BUILD_ROOT
/root
echo
"
\n
[32mDone!!![0m
\n
"
elif
[
-e
CMakeLists.txt
]
;
then
echo
"
\n
[32mBuilding [1;35m
$dist
[0m
\n
"
mkdir
-p
build
cd
build
cmake ..
$(
dist_args
"
$dist
"
cmake
)
make
-j
$NUM_CPUS
rm
-rf
destdir
mkdir
destdir
make
install
DESTDIR
=
"
$PWD
/destdir"
cd
"
$PWD
/destdir/
$BUILD_ROOT
/root"
find
.
!
-type
d |
(
cd
"
$BUILD_ROOT
/root"
;
IFS
=
'
'
;
while
read
f
;
do
mkdir
-p
"
${
f
%/*
}
"
cp
-a
"
$BUILD_ROOT
/libs/
$dist
/build/destdir/
$BUILD_ROOT
/root/
$f
"
"
$f
"
done
)
cd
"
$BUILD_ROOT
/libs/
$dist
"
echo
"
\n
[32mDone!!![0m
\n
"
fi
cd
..
fi
i
=
$((
i
+
1
))
done
}
list_get
()
{
i
=
0
n
=
${
1
:
=0
}
shift
for
item
;
do
if
[
$i
-eq
$n
]
;
then
echo
"
$item
"
return
0
fi
i
=
$((
i
+
1
))
done
}
dist_args
()
{
dist
=
$1
[
-n
"
$dist
"
]
||
error
'dist name required'
buildsys
=
$2
[
"
$buildsys
"
=
autoconf
-o
"
$buildsys
"
=
cmake
]
||
\
error
"buildsystem type required, must be 'autoconf' or 'cmake'"
args
=
$(
table_line
"
$dist
"
"
$DIST_OVERRIDES
"
)
if
[
-z
"
$args
"
]
;
then
case
"
$buildsys
"
in
autoconf
)
args
=
"
$CONFIGURE_ARGS
$(
table_line
"
$dist
"
"
$DIST_ARGS
"
)
"
;;
cmake
)
args
=
"
$CMAKE_ARGS
$(
table_line
"
$dist
"
"
$DIST_ARGS
"
)
"
;;
esac
fi
echo
"
$args
"
return
0
}
table_line
()
{
name
=
$1
[
-n
"
$name
"
]
||
error
'item name required'
table
=
$2
[
-n
"
$table
"
]
||
error
'table string required'
OLDIFS
=
$IFS
IFS
=
'
'
for
line
in
$table
;
do
IFS
=
$OLDIFS
set
--
$line
if
[
"
$1
"
=
"
$name
"
]
;
then
shift
echo
"
$@
"
return
0
fi
done
IFS
=
$OLDIFS
}
find_checkout
()
{
(
cd
"
$(
dirname
"
$0
"
)
"
while
[
"
$PWD
"
!=
/
]
;
do
if
[
-e
src/version.h.in
]
;
then
echo
"
$PWD
"
exit
0
fi
cd
..
done
exit
1
)
||
error
'cannot find project checkout'
}
error
()
{
printf
>
&2
'\n[31mERROR[0m: %s.\n\n'
"
$1
"
[
-z
"
$2
"
]
&&
exit
1
}
build_project
()
{
echo
"
\n
[32mBuilding project: [1;34m
$CHECKOUT
[0m
\n
"
mkdir
-p
"
$BUILD_ROOT
/project"
cd
"
$BUILD_ROOT
/project"
cmake
"
$CHECKOUT
"
-DCMAKE_PREFIX_PATH
=
"
$BUILD_ROOT
/root"
-DENABLE_FFMPEG
=
OFF
-DSFML_STATIC_LIBRARIES
=
TRUE
make
-j
$NUM_CPUS
echo
"
\n
[32mBuild Successful!!![0m
\n\n
Build results can be found in: [1;34m
$BUILD_ROOT
/project[0m
\n
"
}
table_column
()
{
col
=
$1
[
-n
"
$col
"
]
||
error
'table_column: column required'
row_size
=
$2
[
-n
"
$row_size
"
]
||
error
'table_column: row_size required'
table
=
$3
[
-n
"
$table
"
]
||
error
'table_column: table required'
i
=
0
res
=
for
item
in
$table
;
do
if
[
$((
i
%
row_size
))
-eq
"
$col
"
]
;
then
res
=
"
$res
$item
"
fi
i
=
$((
i
+
1
))
done
echo
$res
return
0
}
table_rows
()
{
table
=
$1
[
-n
"
$table
"
]
||
error
'table_rows: table required'
i
=
0
OLDIFS
=
$IFS
IFS
=
'
'
;
for
line
in
$table
;
do
i
=
$((
i
+
1
))
done
IFS
=
$OLDIFS
echo
$i
return
0
}
list_contains
()
{
_item
=
$1
[
-n
"
$_item
"
]
||
error
'list_contains: item required'
shift
for
_pos
;
do
[
"
$_item
"
=
"
$_pos
"
]
&&
return
0
done
return
1
}
main
"
$@
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment