Skip to content

Commit

Permalink
Merge branch 'json-sewage-treatment' of https://github.com/chaisawlaj…
Browse files Browse the repository at this point in the history
…atang/Cataclysm-DDA into json-sewage-treatment
  • Loading branch information
chaisawlajatang committed Aug 17, 2019
2 parents c461dbe + 551d482 commit 3c5bcc2
Show file tree
Hide file tree
Showing 689 changed files with 80,630 additions and 42,995 deletions.
25 changes: 1 addition & 24 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Checks: "\
bugprone-*,\
cata-*,\
cert-*,\
-cert-dcl21-cpp,\
-cert-err58-cpp,\
clang-diagnostic-*,\
cppcoreguidelines-slicing,\
Expand All @@ -16,74 +17,50 @@ misc-*,\
modernize-*,\
performance-*,\
readability-*,\
-bugprone-incorrect-roundings,\
-bugprone-integer-division,\
-bugprone-macro-parentheses,\
-bugprone-misplaced-widening-cast,\
-bugprone-narrowing-conversions,\
-bugprone-string-integer-assignment,\
-bugprone-too-small-loop-variable,\
-bugprone-undefined-memory-manipulation,\
-bugprone-unused-return-value,\
-bugprone-use-after-move,\
-cert-dcl21-cpp,\
-cert-dcl50-cpp,\
-cert-dcl58-cpp,\
-cert-dcl59-cpp,\
-cert-env33-c,\
-cert-err34-c,\
-cert-flp30-c,\
-cert-msc30-c,\
-cert-msc32-c,\
-cert-msc50-cpp,\
-cert-msc51-cpp,\
-misc-definitions-in-headers,\
-misc-non-private-member-variables-in-classes,\
-misc-redundant-expression,\
-misc-unconventional-assign-operator,\
-modernize-avoid-c-arrays,\
-modernize-deprecated-headers,\
-modernize-make-unique,\
-modernize-pass-by-value,\
-modernize-raw-string-literal,\
-modernize-return-braced-init-list,\
-modernize-use-auto,\
-modernize-use-default-member-init,\
-modernize-use-emplace,\
-modernize-use-equals-default,\
-modernize-use-equals-delete,\
-modernize-use-nullptr,\
-modernize-use-override,\
-modernize-use-transparent-functors,\
-performance-for-range-copy,\
-performance-inefficient-vector-operation,\
-performance-move-const-arg,\
-performance-noexcept-move-constructor,\
-performance-implicit-conversion-in-loop,\
-performance-inefficient-algorithm,\
-performance-inefficient-string-concatenation,\
-performance-type-promotion-in-math-fn,\
-performance-unnecessary-copy-initialization,\
-performance-unnecessary-value-param,\
-readability-avoid-const-params-in-decls,\
-readability-braces-around-statements,\
-readability-const-return-type,\
-readability-else-after-return,\
-readability-function-size,\
-readability-implicit-bool-conversion,\
-readability-inconsistent-declaration-parameter-name,\
-readability-isolate-declaration,\
-readability-magic-numbers,\
-readability-named-parameter,\
-readability-non-const-parameter,\
-readability-container-size-empty,\
-readability-redundant-control-flow,\
-readability-redundant-declaration,\
-readability-redundant-member-init,\
-readability-redundant-preprocessor,\
-readability-redundant-string-init,\
-readability-simplify-boolean-expr,\
-readability-static-accessed-through-instance,\
"
WarningsAsErrors: '*'
HeaderFilterRegex: '(src|test).*'
Expand Down
4 changes: 3 additions & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ staleLabel: stale
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
for your contributions. Please do not \'bump\' or comment on this issue
unless you are actively working on it. Stale issues, and stale issues that
are closed are still considered.
# Comment to post when removing the stale label.
# unmarkComment: >
Expand Down
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ jobs:
apt:
packages: ["wine"]

- env: NATIVE=android COMPILER=gcc
name: "Android build"
language: android
android:
components:
- build-tools-28.0.1
- android-26
cache:
# The ccache feature in Travis doesn't work for language: android, so
# do it ourselves.
directories:
- $HOME/.ccache

- env: CLANG=clang++ NATIVE=osx OSX_MIN=10.13 TILES=1 SOUND=1
name: "Xcode 10.1 Make build with Tiles and sound (macOS)"
os: osx
Expand Down
2 changes: 1 addition & 1 deletion COMPILING-MSYS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pacman -Su
4. Install packages required for compilation with:

```bash
pacman -S git git-extras-git make mingw-w64-x86_64-{astyle,ccache,gcc,libmad,libwebp,ncurses,pkg-config,SDL2} mingw-w64-x86_64-SDL2_{image,mixer,ttf}
pacman -S git git-extras make mingw-w64-x86_64-{astyle,ccache,gcc,libmad,libwebp,ncurses,pkg-config,SDL2} mingw-w64-x86_64-SDL2_{image,mixer,ttf}
```

5. Update paths in system-wide profile file (e.g. `C:\msys64\etc\profile`) as following:
Expand Down
16 changes: 14 additions & 2 deletions COMPILING-VS-VCPKG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,20 @@ git clone https://github.com/CleverRaven/Cataclysm-DDA.git
cd Cataclysm-DDA
```

2. Open one of provided solutions (`msvc-full-features\Cataclysm-vcpkg.sln` for dynamically linked executable or `msvc-full-features\Cataclysm-vcpkg-static.sln` for statically linked executable) in `Visual Studio`, select configuration (`Release` or `Debug`) an platform (`x64` or `x86`) and build it.
2. Open one of provided solutions (`msvc-full-features\Cataclysm-vcpkg.sln` for dynamically linked executable or `msvc-full-features\Cataclysm-vcpkg-static.sln` for statically linked executable) in `Visual Studio`, select configuration (`Release` or `Debug`) and platform (`x64` or `x86`) and build it.

**Note**: This will compile release version with Sound, Tiles and Localization support (language files won't be automatically compiled).

3. See [COMPILING.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING.md#visual-studio-guide) for detail about building and debugging.
3. Building Cataclysm with Visual Studio is very simple. Just build it like a normal Visual C++ project. The process may takes a long period of time, so you'd better prepare a cup of coffee and some books in front of your computer :)

4. If you need localization support, execute the bash script `lang/compile_mo.sh` inside Git Bash GUI just like on a UNIX-like system. This will compile the language files that were not automatically compiled in step 2 above.

### Debugging

After building Cataclysm, you may discover that after pressing the debug button in Visual Studio, Cataclysm just exits after launch with return code 1. That is because of the wrong working directory. You need to configure the working directory to `$(ProjectDir)..`.

When debugging, it is not strictly necessary to use a `Debug` build; `Release` builds run significantly faster, can still be run in the debugger, and most of the time will have most of the information you need.

### Make a distribution

There is a batch script in `msvc-full-features` folder `distribute.bat`. It will create a sub folder `distribution` and copy all required files(eg. `data/`, `Cataclysm.exe` and dlls) into that folder. Then you can zip it and share the archive on the Internet.
162 changes: 12 additions & 150 deletions COMPILING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* [Advanced info for Developers](#advanced-info-for-developers)
* [Troubleshooting](#mac-troubleshooting)
* [Windows](#windows)
* [Visual Studio Guide](#visual-studio-guide)
* [MinGW Guide](#mingw-guide)
* [Rough guide to building with only MSYS2](#rough-guide-to-building-with-only-msys2)
* [Building with Visual Studio](#building-with-visual-studio)
* [Building with MSYS2](#building-with-msys2)
* [Building with CYGWIN](#building-with-cygwin)
* [BSDs](#bsds)

# General Linux Guide
Expand Down Expand Up @@ -436,7 +436,6 @@ ncurses (with wide character support enabled) and gettext are needed if you want

For Homebrew:

brew tap homebrew/dupes
brew install gettext ncurses
brew link --force gettext ncurses

Expand Down Expand Up @@ -573,160 +572,23 @@ Open Terminal's preferences, turn on "Use bright colors for bold text" in "Prefe

# Windows

## Visual Studio Guide
## Building with Visual Studio

Visual Studio 2017 (or later) is required to build Cataclysm: Dark Days Ahead. Solutions and project files are located in directory `msvc-full-features`. Because of the complexity and how troublesome defining every combination of build feature options are, Visual Studio projects have all build features enabled, including tiles, sound and localization.
See [COMPILING-VS-VCPKG.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING-VS-VCPKG.md) for instructions on how to set up and use a build environment using Visual Studio on windows.

### Dependencies

We've prepared an archive containing all the headers and libraries required to build Cataclysm: [http://dev.narc.ro/cataclysm/WinDepend-MSVC.zip](http://dev.narc.ro/cataclysm/WinDepend-MSVC.zip) or [http://dev.narc.ro/cataclysm/WinDepend-MSVC.7z](http://dev.narc.ro/cataclysm/WinDepend-MSVC.7z). The latter is smaller, but if you don't have a 7-zip archive extracter, the former one is easier to deal with.

Extract the 'WinDepend' folder from the zip and put the 'WinDepend' folder in the root folder of Cataclysm project. Your folder structure should look like this: `.../Cataclysm-DDA/WinDepend/...`

Run the "copy_dll_to_bin" batch file and then move the dll files from the bin folder inside 'WinDepend' into the root folder the Cataclysm project. You'll probably want to use the dlls that are in `WinDepend/bin/x64/`.

### Building

Building Cataclysm with Visual Studio is very simple. Just build it like a normal Visual C++ project. The process may takes a long period of time, so you'd better prepare a cup of coffee and some books in front of your computer :)

If you need localization support, execute the bash script `lang/compile_mo.sh` inside Git Bash GUI just like on a UNIX-like system.

### Debugging

After building Cataclysm, you may discover that after pressing the debug button in Visual Studio, Cataclysm just exits after launch with return code 1. That is because of the wrong working directory. You need to configure the working directory to `$(ProjectDir)..`.

### Make a distribution

There is a batch script in `msvc-full-features` folder `distribute.bat`. It will create a sub folder `distribution` and copy all required files(eg. `data/`, `Cataclysm.exe` and dlls) into that folder. Then you can zip it and share the archive on the Internet.

## MinGW Guide
To compile under windows MinGW you first need to download mingw. An automated GUI installer assistant called mingw-get-setup.exe will make everything a lot easier. I recommend installing it to `C:\MinGW`
https://sourceforge.net/projects/mingw/files/latest/download

### MinGW setup
once installed we need to get the right packages. In "Basic Setup", mark `mingw-developer-toolkit`, `mingw32-base` and `mingw32-gcc-g++`

Then install these components using `Installation -> Apply Changes`.

#### Localization
If we want to compile with localization, we will need gettext and libintl. In "All Packages -> MinGW -> MinGW Autotools" ensure that `mingw32-gettext` and `mingw32-libintl` are installed.

### Required Tiles(SDL) Libraries
If we want to compile with Tiles (SDL) we have to download a few libraries.
* `SDL2` http://www.libsdl.org/download-2.0.php chose `SDL2-devel-2.0.X-mingw.tar.gz`.
* `SDL_ttf` https://www.libsdl.org/projects/SDL_ttf/ chose `SDL2_ttf-devel-2.0.12-mingw.tar.gz`.
* `SDL_image` https://www.libsdl.org/projects/SDL_image/ chose ` SDL2_image-devel-2.0.0-mingw.tar.gz`
* `freetype` http://gnuwin32.sourceforge.net/packages/freetype.htm chose `Binaries` and `Developer files`

#### Bundled Libraries
The following archives were pre-bundled for convenience and reduction of head-aches, simply download and extract directly to the root directory of the CDDA source:
* `64-bit SDL \ Tiles \ Sound \ Localization` http://dev.narc.ro/cataclysm/cdda-win64-codeblocks.7z

#### Installing Tiles(SDL) libraries.
For the first 3 (`SDL2`, `SDL_ttf` and `SDL_image`) you want to extract the include and lib folders from the `i686-w64-mingw32` folders into your MinGW installation folder. (Recommended `C:\MinGW`). And the `SDL2_image.dll` and `SDL2_ttf.dll` into your cataclysm root folder.

For freetype you want to grab the include and lib folders from the `freetype-2.X.X-X-lib.zip` and move them into your your MinGW installation folder. Then you want to get the freetype6.dll from the `freetype-2.X.X-X-bin.zip` and move it into your cataclysm root folder.

#### ISSUE - "winapifamily.h" no such file or directoyr
There seems to be at the moment of writing that a file in SDL is broken and needs to be replaced.
https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h
Replace SDL_platform.h in the MinGW/include/SDL2 folder and it should be fine.

### Makefile changes
This probably not the best way to do it. But it seems that you need to remove a few dependencies from the makefile or it will not build.
change the line `LDFLAGS += -lfreetype -lpng -lz -ljpeg -lbz2` to `LDFLAGS += -lfreetype`

### Compiling
Navigate to `MinGW\msys\1.0` and run `msys.bat`. This will start a cmd-like shell where the following entries will be made.

Add the MinGW toolchain to your PATH with `export PATH=$PATH:/c/MinGW/bin`. Replace /c/MinGW/ with the directory into which you installed MinGW (/c/ stands for drive C:, so if it's in F:/foo/bar, you'd use /f/foo/bar).

Navigate to the CDDA source code directory.

Compile using `make TILES=1 NATIVE=win32 LOCALIZE=1` and unless there are problems, it should produce a CDDA binary for you.
This is probably the easiest solution for someone used to working with Visual Studio and similar IDEs.

If you dont want tiles you can change `TILES` to 0.
## Building with MSYS2

If you dont want localization you can change `LOCALIZE` to 0.
See [COMPILING-MSYS.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING-MSYS.md) for instructions on how to set up and use a build environment using MSYS2 on windows.

## Rough guide to building with only MSYS2
MSYS2 strikes a balance between a native Windows application and a UNIX-like environment. There's some command-line tools that our project uses (notably our JSON linter) that are harder to use without a command-line environment such as what MSYS2 or CYGWIN provide.

This is a tentative step-by-step guide to building your own CDDA with Tiles and Localization using only MSYS2. You may want to follow it if the MinGW guide above doesn't work for you or you just feel adventurous. Feedback is very much welcome in terms of issues and/or pull-requests.
## Building with CYGWIN

This guide assumes you're building on a x86_64 build of Windows. If not adjust the invocations appropriately. It has been tested and proven to work on Windows XP, Windows 7 and Windows 10. Your mileage may vary.

#### 1. Go to https://msys2.github.io/ and download appropriate MSYS (top of the page).

#### 2. Install MSYS2 and leave the Run ticker on. You should end up with a MSYS2 terminal.

#### 3. In the open terminal:

```bash
pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime
```

Note: You may close the terminal now and reopen it from the Start menu (MSYS2 Shell, just to be on the safe-er side).

Note: You may need to bash the close button repeatedly. Or use the task manager to kill it.

#### 4. Open an editor that preserves line-endings

Note: Wordpad should do. Or Notepad++.

#### 5. Open `C:\msys64\etc\pacman.conf` and change:

```bash
# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
#SigLevel = Never
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required
```

To:

```bash
# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel = Never
#SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required
```

(Exchange the # on SigLevel). This disables signature checking as it is currently borked.

#### 6. Save the file

#### 7. Run in MSYS2 terminal:

```bash
update-core
pacman -Su
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_ttf
pacman -S mingw-w64-x86_64-ncurses
pacman -S mingw-w64-x86_64-pkg-config mingw-w64-x86_64-libwebp
pacman -S git make
```

#### 8. Close MSYS2 terminal and open MinGW-w64 Win64 Shell from Start menu and run:

Note: This will download whole CDDA repository. If you're just testing you should probably add `--depth=1`.

```bash
git clone https://github.com/CleverRaven/Cataclysm-DDA.git
cd Cataclysm-DDA
```

#### 9. Compile your CDDA by running:

```bash
make MSYS2=1 RELEASE=1 TILES=1 LOCALIZE=1 SOUND=1 NATIVE=win64
```
See [COMPILING-CYGWIN.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING-CYGWIN.md) for instructions on how to set up and use a build environment using CYGWIN on windows.

That's it. You should get a `cataclysm-tiles.exe` binary in the same folder you've found the `Makefile` in. The make flags are the same as the ones described above. For instance, if you do not want to build with sound support, you can remove `SOUND=1`.
CYGWIN attempts to more fully emulate a POSIX environment, to be "more unix" than MSYS2. It is a little less modern in some respects, and lacks the convenience of the MSYS2 package manager.

# BSDs

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ We also have the following build guides:

## Contribute

Cataclysm:Dark Days Ahead is the result of contributions from over 800 volunteers under the Creative Commons Attribution ShareAlike 3.0 license. The code and content of the game is free to use, modify, and redistribute for any purpose whatsoever. See http://creativecommons.org/licenses/by-sa/3.0/ for details.
Cataclysm:Dark Days Ahead is the result of contributions from over 900 volunteers under the Creative Commons Attribution ShareAlike 3.0 license. The code and content of the game is free to use, modify, and redistribute for any purpose whatsoever. See http://creativecommons.org/licenses/by-sa/3.0/ for details.
Some code distributed with the project is not part of the project and is released under different software licenses, the files covered by different software licenses have their own license notices.

[![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=146201)](https://www.bountysource.com/trackers/146201-clever-raven-cataclysm-dda?utm_source=146201&utm_medium=shield&utm_campaign=TRACKER_BADGE)
Expand Down
19 changes: 18 additions & 1 deletion build-scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function run_tests

date +%s > build-start-time

export CCACHE_MAXSIZE=1G
if [ -n "$TEST_STAGE" ]
then
build-scripts/lint-json.sh
Expand All @@ -30,6 +29,10 @@ then
fi

ccache --zero-stats
# Increase cache size because debug builds generate large object files
ccache -M 2G
ccache --show-stats

if [ -n "$CMAKE" ]
then
bin_path="./"
Expand Down Expand Up @@ -128,6 +131,20 @@ then
[ -f "${bin_path}cata_test" ] && run_tests "${bin_path}cata_test"
[ -f "${bin_path}cata_test-tiles" ] && run_tests "${bin_path}cata_test-tiles"
fi
elif [ "$NATIVE" == "android" ]
then
export USE_CCACHE=1
export NDK_CCACHE="$(which ccache)"

# Tweak the ccache compiler analysis. We're using the compiler from the
# Android NDK which has an unpredictable mtime, so we need to hash the
# content rather than the size+mtime (which is ccache's default behaviour).
export CCACHE_COMPILERCHECK=content

cd android
# Specify dumb terminal to suppress gradle's constatnt output of time spent building, which
# fills the log with nonsense.
TERM=dumb ./gradlew assembleDebug -Pj=3
else
make -j "$num_jobs" RELEASE=1 CCACHE=1 BACKTRACE=1 CROSS="$CROSS_COMPILATION" LINTJSON=0

Expand Down
6 changes: 6 additions & 0 deletions build-scripts/requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gettext ncurses ccache
brew link --force gettext ncurses
fi

if [[ "$NATIVE" == "android" ]]; then
yes | sdkmanager "ndk-bundle"
fi

set +x
Loading

0 comments on commit 3c5bcc2

Please sign in to comment.