Skip to content

Commit 02f949b

Browse files
Merge remote-tracking branch 'upstream' into GEN-202/fixup-deploy
2 parents 8173491 + e12d29e commit 02f949b

File tree

223 files changed

+6275
-1446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+6275
-1446
lines changed

.ci/travis/bootstrap.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/usr/bin/env bash
2+
3+
# Sets some Bash options to encourage well formed code.
4+
# For example, some of the options here will cause the script to terminate as
5+
# soon as a command fails. Another option will cause an error if an undefined
6+
# variable is used.
7+
# See: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
8+
9+
# Any trap on ERR is inherited by shell functions, command substitutions, and
10+
# commands executed in a subshell environment. The ERR trap is normally not
11+
# inherited in such cases.
12+
set -o errtrace
13+
14+
# Any trap on DEBUG and RETURN are inherited by shell functions, command
15+
# substitutions, and commands executed in a subshell environment. The DEBUG and
16+
# RETURN traps are normally not inherited in such cases.
17+
set -o functrace
18+
19+
# Exit if any command exits with a non-zero exit status.
20+
set -o errexit
21+
22+
# Exit if script uses undefined variables.
23+
set -o nounset
24+
25+
# Prevent masking an error in a pipeline.
26+
# Look at the end of the 'Use set -e' section for an excellent explanation.
27+
# see: https://www.davidpashley.com/articles/writing-robust-shell-scripts/
28+
set -o pipefail
29+
30+
# Make debugging easier when you use `set -x`
31+
# See: http://wiki.bash-hackers.org/scripting/debuggingtips#making_xtrace_more_useful
32+
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
33+
34+
# If using Travis, output is 0, else 1
35+
function using_travis {
36+
if [[ "${TRAVIS:-}" == "true" ]]; then
37+
echo 0
38+
else
39+
echo 1
40+
fi
41+
}
42+
43+
# If using Linux, output is 'linux'
44+
# If using OSX, output is 'osx'
45+
function get_os {
46+
local -i on_travis
47+
local os
48+
on_travis=$(using_travis)
49+
50+
if [[ $on_travis -eq 0 ]]; then
51+
printf "%s" "$TRAVIS_OS_NAME"
52+
else
53+
os="$(uname)"
54+
case "$os" in
55+
Darwin)
56+
printf "osx"
57+
;;
58+
59+
Linux)
60+
printf "linux"
61+
;;
62+
63+
*)
64+
echo "ERROR: Unsupported platform '$os'"
65+
set -x && exit 1
66+
;;
67+
esac
68+
fi
69+
}
70+
71+
function get_merge_release_filename {
72+
shopt -s nocasematch
73+
local pattern
74+
pattern="(gen[^0-9]+[0-9]+)[^0-9]*"
75+
if [[ "${TRAVIS_COMMIT_MESSAGE:-}" =~ $pattern ]]; then
76+
local jira_ticket_id
77+
# convert to upper case.
78+
# NOTE: don't use anything fancy here since osx on Travis uses Bash 3.x so
79+
# version 4.x's way of doing this won't work here.
80+
jira_ticket_id=$(echo "${BASH_REMATCH[1]}" | tr '[:lower:]' '[:upper:]')
81+
jira_ticket_id="${jira_ticket_id}.app"
82+
echo "${jira_ticket_id// /-}" # replace spaces with hyphens
83+
else
84+
echo "ERROR: Unable to get JIRA branch name from the merge to master."
85+
set -x && exit 1
86+
fi
87+
}
88+
89+
function get_release_filename {
90+
if [[ "${TRAVIS_BRANCH:-}" == "master" ]]; then
91+
# On merge to 'master', generate [jira_ticket_id].app.tgz release.
92+
# Ticket name can safely be assumed based on the regexp /(gen[^0-9]+[0-9]+)/i.
93+
printf "%s" "$(get_merge_release_filename)"
94+
elif [[ -n "${TRAVIS_TAG:-}" ]]; then
95+
# On tag, generate [GIT_TAG].tgz release
96+
printf "%s" "${TRAVIS_TAG}"
97+
fi
98+
}

.ci/travis/create_release.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
# This script should be used to make preparations to run the 'script' lifecycle.
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
# shellcheck source=./.ci/travis/bootstrap.sh
7+
source "$DIR"/bootstrap.sh
8+
9+
if [[ "${TRAVIS_BRANCH:-}" != "master" ]] && [[ -z "${TRAVIS_TAG:-}" ]]; then
10+
echo "ERROR: This is not being merged into master and no tag is present."
11+
exit 1
12+
fi
13+
14+
declare release_filename
15+
release_filename=$(get_release_filename)
16+
17+
mv "${TRAVIS_BUILD_DIR}/build/release.tgz" "${TRAVIS_BUILD_DIR}/build/${release_filename}.tgz"

.ci/travis/install_deps.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
# This script should be used to install build dependencies.
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
# shellcheck source=./.ci/travis/bootstrap.sh
7+
source "$DIR"/bootstrap.sh
8+
9+
declare os
10+
os="$(get_os)"
11+
12+
case "$os" in
13+
osx)
14+
brew install shellcheck
15+
;;
16+
17+
*)
18+
echo "ERROR: Unsupported platform '$os'"
19+
set -x && exit 1
20+
;;
21+
esac
22+
23+
# If you have a highly customized ~/.ssh/config file, you might find setting
24+
# this variable very useful if you want to run this script locally.
25+
#
26+
# For example:
27+
# $ cat ~/.ssh/config
28+
#
29+
# Host github.com
30+
# HostName github.com
31+
# User git
32+
# IdentityFile ~/.ssh/id_rsa.pub
33+
#
34+
# Host github.com-alternative
35+
# HostName github.com
36+
# User git
37+
# IdentityFile ~/.ssh/id_rsa-alternative.pub
38+
#
39+
# You can now do:
40+
# $ GEN_GITHUB_HOSTNAME=github.com-alternative ./before_install.sh
41+
# That will cause Git to use the '~/.ssh/id_rsa-alternative.pub' key.
42+
if [[ -z "${GEN_GITHUB_HOSTNAME:-}" ]]; then
43+
GEN_GITHUB_HOSTNAME="github.com"
44+
fi
45+
git clone git@"$GEN_GITHUB_HOSTNAME":ModusCreateOrg/creative-engine.git

.ci/travis/lint.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# This script should be used to make preparations to run the 'script' lifecycle.
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
# shellcheck source=./.ci/travis/bootstrap.sh
7+
source "$DIR"/bootstrap.sh
8+
9+
shellcheck --version
10+
11+
# Running in a subshell to avoid cd'ing back and forth.
12+
(
13+
pushd "$DIR/../../" > /dev/null
14+
# Look for all files with a '.sh' extension, excluding the 'creative-engine'
15+
# dir. Run shellcheck against those files
16+
find \
17+
. \
18+
-path ./creative-engine \
19+
-prune -o \
20+
-name '*.sh' \
21+
-exec \
22+
bash -c \
23+
'shellcheck --external-sources "$1"' \
24+
-- {} \;
25+
)

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
.*
33
~*
44

5-
# Include the Travis build config
5+
# Include the Travis build config and its scripts
66
!.travis.yml
7+
!.ci
78

89
# ignore node/grunt dependency directories
910
node_modules/
@@ -93,3 +94,4 @@ src/Resources.h
9394
sdkconfig
9495
sdkconfig.old
9596
*.store
97+
*.tmp

.travis.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
sudo: enabled
1+
---
22
os: osx
33
language: cpp
4-
before_install: git clone git@github.com:ModusCreateOrg/creative-engine.git
5-
script: "./scripts/build.sh"
4+
sudo: enabled
5+
git:
6+
depth: 1
7+
install: ./.ci/travis/install_deps.sh
8+
before_script: ./.ci/travis/lint.sh
9+
script: ./scripts/build.sh
10+
before_deploy: ./.ci/create_release.sh
611
deploy:
712
provider: releases
813
skip_cleanup: true
@@ -12,3 +17,13 @@ deploy:
1217
on:
1318
tags: true
1419
repo: ModusCreateOrg/genus
20+
file_glob: true
21+
file: build/*.tgz
22+
skip_cleanup: true
23+
overwrite: true
24+
on:
25+
tags: true
26+
repo: ModusCreateOrg/genus
27+
# create release on merge to 'master' and on a tag.
28+
condition: $TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG
29+
# TODO: Post to Slack

CMakeLists.txt

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,51 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
77

88
# creative-engine path
99
if (EXISTS $ENV{CREATIVE_ENGINE_PATH})
10-
# set ENV variable in CLion project settings
11-
set(CREATIVE_ENGINE_PATH $ENV{CREATIVE_ENGINE_PATH})
12-
message(STATUS "Using user-defined creative-engine path: ${CREATIVE_ENGINE_PATH}")
13-
else()
10+
# set ENV variable in CLion project settings
11+
set(CREATIVE_ENGINE_PATH $ENV{CREATIVE_ENGINE_PATH})
12+
# message(STATUS "********************************* Using user-defined creative-engine path: ${CREATIVE_ENGINE_PATH}")
13+
else ()
1414
set(CREATIVE_ENGINE_PATH "${CMAKE_SOURCE_DIR}/../creative-engine")
15-
message(STATUS "Falling back to default creative-engine path: ${CREATIVE_ENGINE_PATH}")
16-
endif()
15+
# message(STATUS "<<<<<<<<<<<<<<<<<<<<<<<<<< Falling back to default creative-engine path: ${CREATIVE_ENGINE_PATH}")
16+
endif ()
1717

1818
# resource compiler
1919
set(RCOMP "${CREATIVE_ENGINE_PATH}/tools/rcomp")
2020

2121
INCLUDE_DIRECTORIES(
22-
${SDL2_INCLUDE_DIRS}
23-
${SDL2IMAGE_INCLUDE_DIRS}
24-
${CMAKE_SOURCE_DIR}/src
25-
${CMAKE_CURRENT_SOURCE_DIR}/src
26-
${CMAKE_BINARY_DIR} /usr/local/include
27-
${CREATIVE_ENGINE_PATH}/src
28-
${CREATIVE_ENGINE_PATH}/src/Widgets
29-
${CREATIVE_ENGINE_PATH}/src/libxmp
30-
${CREATIVE_ENGINE_PATH}/src/libxmp/loaders
31-
${CREATIVE_ENGINE_PATH}/src/libxmp/loaders/prowizarde
22+
${SDL2_INCLUDE_DIRS}
23+
${SDL2IMAGE_INCLUDE_DIRS}
24+
${CMAKE_SOURCE_DIR}/src
25+
${CMAKE_SOURCE_DIR}/src/GameState
26+
${CMAKE_SOURCE_DIR}/src/GameState/Playfields
27+
${CMAKE_SOURCE_DIR}/src/GameState/Powerups
28+
${CMAKE_SOURCE_DIR}/src/GameOverState
29+
${CMAKE_SOURCE_DIR}/src/HighScoresState
30+
${CMAKE_SOURCE_DIR}/src/MainMenuState
31+
${CMAKE_SOURCE_DIR}/src/MainOptionsState
32+
${CMAKE_SOURCE_DIR}/src/SplashState
33+
${CMAKE_SOURCE_DIR}/src/RulesState
34+
${CMAKE_BINARY_DIR} /usr/local/include
35+
${CREATIVE_ENGINE_PATH}/src
36+
${CREATIVE_ENGINE_PATH}/src/Widgets
37+
${CREATIVE_ENGINE_PATH}/src/libxmp
38+
${CREATIVE_ENGINE_PATH}/src/libxmp/loaders
39+
${CREATIVE_ENGINE_PATH}/src/libxmp/loaders/prowizarde
3240
)
3341

3442
# external libraries
3543
INCLUDE(FindPkgConfig)
3644
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
3745
PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
3846

47+
# include creative-engine sources
48+
# when using out-of-tree source paths add_subdirectory's build_dir argument is required
49+
# use the project's current build directory
50+
# https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_BINARY_DIR.html
51+
# https://cmake.org/cmake/help/latest/command/add_subdirectory.html
52+
# https://stackoverflow.com/questions/35260552/how-do-i-explicitly-specify-an-out-of-tree-source-in-cmake
53+
add_subdirectory(${CREATIVE_ENGINE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/creative-engine)
54+
3955
# build rcomp
4056
add_custom_command(
4157
OUTPUT rcomp
@@ -58,25 +74,23 @@ file(GLOB_RECURSE CREATIVE_ENGINE ${CREATIVE_ENGINE_PATH}/src/*.cpp)
5874

5975
# gather LibXMP sources
6076
add_compile_definitions(LIBXMP_CORE_PLAYER=true)
61-
add_compile_definitions(LIBXMP_CORE_DISABLE_IT=true)
77+
6278
file(
6379
GLOB LIBXMP_SRC
64-
${CREATIVE_ENGINE_PATH}/src/libxmp/loaders/*.h
6580
${CREATIVE_ENGINE_PATH}/src/libxmp/loaders/*.c
66-
${CREATIVE_ENGINE_PATH}/src/libxmp/*.h
6781
${CREATIVE_ENGINE_PATH}/src/libxmp/*.c
6882
)
6983

7084
# gather Genus sources
7185
file(GLOB_RECURSE GENUS_SRC RELATIVE ${CMAKE_SOURCE_DIR} "src/*.cpp")
7286

7387
add_executable(
74-
genus
75-
Resources.bin
76-
${LIBXMP_SRC}
77-
${CREATIVE_ENGINE}
78-
${GENUS_SRC}
79-
)
88+
genus
89+
Resources.bin
90+
${LIBXMP_SRC}
91+
${CREATIVE_ENGINE}
92+
${GENUS_SRC}
93+
)
8094

8195
# make genus.app
8296
if (APPLE)

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ GENUS_STATES=$(GENUS_SRC_PATH)/GameState
1111
GENUS_STATES+=$(GENUS_SRC_PATH)/HighScoreState
1212
GENUS_STATES+=$(GENUS_SRC_PATH)/MainOptionsState
1313
GENUS_STATES+=$(GENUS_SRC_PATH)/SplashState
14+
GENUS_STATES+=$(GENUS_SRC_PATH)/CreditsState
1415

15-
EXTRA_COMPONENT_DIRS=${CREATIVE_ENGINE_PATH} ${PROJECT_PATH}/src $(GENUS_STATES)
16+
GENUS_POWERUPS=$(GENUS_SRC_PATH)/GameState/Powerups
17+
18+
EXTRA_COMPONENT_DIRS=${CREATIVE_ENGINE_PATH} ${PROJECT_PATH}/src $(GENUS_STATES) $(GENUS_POWERUPS)
1619

1720
include $(IDF_PATH)/make/project.mk
1821

@@ -38,6 +41,10 @@ resources: rcomp FORCE
3841
echo "Compiling resources"
3942
cd src && ${CREATIVE_ENGINE_PATH}/tools/rcomp Resources.r
4043

44+
reset: FORCE
45+
echo "Resetting high score table (and options)"
46+
rm -f cmake-build-debug/genus.app/Contents/MacOS/*.store
47+
4148
FORCE:
4249

4350

doc/genus-game-doc2x2.pdf

-360 KB
Binary file not shown.

doc/genus-game-stg1-test.bmp

-76.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)