From a4be8dfd75e8a3143189f41226b236a5046ad5ce Mon Sep 17 00:00:00 2001 From: Sinem Akinci <99284450+sinemakinci1@users.noreply.github.com> Date: Wed, 31 Aug 2022 18:10:15 +0000 Subject: [PATCH 1/2] added dockerfiles and devcontainer for codespaces development --- .devcontainer/Dockerfile | 29 ++++++++++++++++ .devcontainer/devcontainer.json | 33 ++++++++++++++++++ .devcontainer/packages | 10 ++++++ .devcontainer/reinstall-cmake.sh | 58 ++++++++++++++++++++++++++++++++ src/aircraft_cmd.cpp | 2 +- 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/packages create mode 100644 .devcontainer/reinstall-cmake.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000000..9666970609733 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,29 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp/.devcontainer/base.Dockerfile + +# [Choice] Debian / Ubuntu version (use Debian 11, Ubuntu 18.04/22.04 on local arm64/Apple Silicon): debian-11, debian-10, ubuntu-22.04, ubuntu-20.04, ubuntu-18.04 +ARG VARIANT="bullseye" +FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT} + +# [Optional] Install CMake version different from what base image has already installed. +# CMake reinstall choices: none, 3.21.5, 3.22.2, or versions from https://cmake.org/download/ +ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none" + +# Optionally install the cmake for vcpkg +COPY ./reinstall-cmake.sh /tmp/ +RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ + chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \ + fi \ + && rm -f /tmp/reinstall-cmake.sh + +# [Optional] Uncomment this section to install additional vcpkg ports. +# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install " + +# [Optional] Uncomment this section to install additional packages. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends libpng-dev \ + zlib1g-dev \ + liblzma-dev \ + libsdl2-dev \ + libfreetype-dev \ + libfontconfig1-dev \ + libicu-dev diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000000..9ee64692155fc --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp +{ + "name": "C++", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-11, debian-10, ubuntu-22.04, ubuntu-20.04, ubuntu-18.04 + // Use Debian 11, Ubuntu 18.04 or Ubuntu 22.04 on local arm64/Apple Silicon + "args": { "VARIANT": "ubuntu-22.04" } + }, + "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vscode.cpptools", + "ms-vscode.cmake-tools" + ] + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "gcc -v", + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.devcontainer/packages b/.devcontainer/packages new file mode 100644 index 0000000000000..b143de48adafc --- /dev/null +++ b/.devcontainer/packages @@ -0,0 +1,10 @@ +(encouraged) zlib: (de)compressing of old (0.3.0-1.0.5) savegames, content downloads, heightmaps -> zlib1g-dev +(encouraged) liblzma: (de)compressing of savegames (1.1.0 and later) -> liblzma-dev +(encouraged) libpng: making screenshots and loading heightmaps -> libpng-dev +(optional) liblzo2: (de)compressing of old (pre 0.3.0) savegames -> +For Linux, the following additional libraries are used (for non-dedicated only): + +libSDL2: hardware access (video, sound, mouse) -> libsdl2-dev +libfreetype: loading generic fonts and rendering them -> libfreetype-dev +libfontconfig: searching for fonts, resolving font names to actual fonts -> libfontconfig1-dev +libicu: handling of right-to-left scripts (e.g. Arabic and Persian) and natural sorting of strings -> libicu-dev \ No newline at end of file diff --git a/.devcontainer/reinstall-cmake.sh b/.devcontainer/reinstall-cmake.sh new file mode 100644 index 0000000000000..c833253832dd8 --- /dev/null +++ b/.devcontainer/reinstall-cmake.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +set -e + +CMAKE_VERSION=${1:-"none"} + +if [ "${CMAKE_VERSION}" = "none" ]; then + echo "No CMake version specified, skipping CMake reinstallation" + exit 0 +fi + +# Cleanup temporary directory and associated files when exiting the script. +cleanup() { + EXIT_CODE=$? + set +e + if [[ -n "${TMP_DIR}" ]]; then + echo "Executing cleanup of tmp files" + rm -Rf "${TMP_DIR}" + fi + exit $EXIT_CODE +} +trap cleanup EXIT + + +echo "Installing CMake..." +apt-get -y purge --auto-remove cmake +mkdir -p /opt/cmake + +architecture=$(dpkg --print-architecture) +case "${architecture}" in + arm64) + ARCH=aarch64 ;; + amd64) + ARCH=x86_64 ;; + *) + echo "Unsupported architecture ${architecture}." + exit 1 + ;; +esac + +CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" +CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt" +TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX) + +echo "${TMP_DIR}" +cd "${TMP_DIR}" + +curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O +curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O + +sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}" +sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license + +ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index d67969c0067bf..450a4df0d21a4 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -126,7 +126,7 @@ static StationID FindNearestHangar(const Aircraft *v) TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos); const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type); uint max_range = v->acache.cached_max_range_sqr; - + /* Determine destinations where it's coming from and where it's heading to */ const Station *last_dest = nullptr; const Station *next_dest = nullptr; From 6d0e2b9cafbc8c8deda4098fab4f44c3582c863c Mon Sep 17 00:00:00 2001 From: Sinem Akinci <99284450+sinemakinci1@users.noreply.github.com> Date: Wed, 31 Aug 2022 20:03:06 +0000 Subject: [PATCH 2/2] added bison to packages --- .devcontainer/Dockerfile | 7 +++++-- .gitmodules | 4 ++-- .vcpkgbootstrap-vcpkg.bat | 0 git | 0 vcpkg | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .vcpkgbootstrap-vcpkg.bat create mode 100644 git create mode 160000 vcpkg diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9666970609733..496aa8c5ed734 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -20,10 +20,13 @@ RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ # [Optional] Uncomment this section to install additional packages. RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends libpng-dev \ + && apt-get -y install --no-install-recommends \ + liblzo2-dev \ + libpng-dev \ zlib1g-dev \ liblzma-dev \ libsdl2-dev \ libfreetype-dev \ libfontconfig1-dev \ - libicu-dev + libicu-dev \ + bison diff --git a/.gitmodules b/.gitmodules index 061f088850659..fe07c999afc11 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "vcpkg"] -path=vcpkg -url=https://github.com/microsoft/vcpkg \ No newline at end of file + path = vcpkg + url = https://github.com/microsoft/vcpkg diff --git a/.vcpkgbootstrap-vcpkg.bat b/.vcpkgbootstrap-vcpkg.bat new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/git b/git new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/vcpkg b/vcpkg new file mode 160000 index 0000000000000..f688b2e29676b --- /dev/null +++ b/vcpkg @@ -0,0 +1 @@ +Subproject commit f688b2e29676bfa3a02ead4b7096c589f8af8180