Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SharedModel] Basic cmake support #5751

Merged
merged 6 commits into from
May 4, 2021
Merged

Conversation

paulcam206
Copy link
Member

@paulcam206 paulcam206 commented Apr 29, 2021

Description

This change introduces cmake build support for the Shared Model. This allows us to independently build the Shared Model in a cross-platform way. As part of this, there were a number of code issues found that are fixed here (primarily from clang, which seems stricter than MSVC).

Tested configurations

  • cmake/VS (Visual Studio 16 2019 / Windows SDK version 10.0.19041.0 / MSVC 19.28.29914.0 - Windows)
  • cmake/gcc (GNU 10.3.0 - WSL)
  • cmake/clang (Clang 9.0.1 - Windows and WSL)
  • cmake/emscripten (emcc 2.0.18 - Windows and WSL)

Benefits

  • Easy access to real clang tooling (e.g. clang-tidy)
  • Different compilers catch different types of issues
  • Necessary prerequisite to broader emscripten investigation

How do I build this thing?

  • Windows + VS
    1. Install prerequisites
      • Install VS 2019
      • winget install cmake
    2. Run Developer Command Prompt for VS 2019 from start menu
    3. cd <ac root>\source\shared\cpp\ObjectModel
    4. cmake .
    5. cmake --build .
  • Windows + clang
    1. Install prerequisites
      • winget install cmake
      • winget install llvm
    2. cd <ac root>\source\shared\cpp\ObjectModel
    3. cmake .
    4. cmake --build .
  • Windows + emscripten
    1. Install prerequisites
      • winget install python
      • winget install cmake
      • winget install git
    2. Install emscripten
      1. git clone https://github.com/emscripten-core/emsdk.git <location to place emscripten SDK>
      2. cd <emsdk directory>
      3. git pull
      4. emsdk install latest
      5. emsdk activate latest
    3. cd <ac root>\source\shared\cpp\ObjectModel
    4. <emsdk directory>\emsdk_env.bat <- might not be needed depending on your environment
    5. emcmake cmake .
    6. cmake --build .
  • WSL (Ubuntu) + gcc
    1. Install prerequisites: sudo apt update && sudo apt install cmake gcc
    2. cd <ac root>/source/shared/cpp/ObjectModel
    3. cmake .
    4. cmake --build .
  • WSL (Ubuntu) + clang
    1. Install prerequisites: sudo apt update && sudo apt install cmake clang
      • You might need to change your compilers:
        • Environment vars:
          • export CC=/usr/bin/clang
          • export CXX=/usr/bin/clang++
        • Choose clang as your default C/C++ compiler:
          • sudo update-alternatives --config cc (choose clang)
          • sudo update-alternatives --config c++ (choose clang)
    2. cd <ac root>/source/shared/cpp/ObjectModel
    3. cmake .
    4. cmake --build .
  • WSL (Ubuntu) + emscripten
    1. Install prerequisites: sudo apt update && sudo apt install cmake python3 git
    2. Install emscripten
      1. git clone https://github.com/emscripten-core/emsdk.git <location to place emscripten SDK>
      2. cd <emsdk directory>
      3. git pull
      4. emsdk install latest
      5. emsdk activate latest
    3. cd <ac root>/source/shared/cpp/ObjectModel
    4. source <emsdk directory>/emsdk_env.sh <- might not be needed depending on your environment
    5. emcmake cmake .
    6. cmake --build .
Microsoft Reviewers: Open in CodeFlow

@paulcam206
Copy link
Member Author

ooh -- build errors, that's exciting :)

@paulcam206
Copy link
Member Author

UWP break is interesting -- complaining because existing max() macro def. Can force it not to be defined, but we're using min() macro def in XamlHelpers.cpp. Will fix tomorrow.

Copy link
Contributor

@jonmill jonmill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions but LGTM otherwise!

source/shared/cpp/ObjectModel/HostConfig.cpp Show resolved Hide resolved
source/shared/cpp/ObjectModel/ParseUtil.h Outdated Show resolved Hide resolved
@paulcam206
Copy link
Member Author

UWP break is interesting -- complaining because existing max() macro def. Can force it not to be defined, but we're using min() macro def in XamlHelpers.cpp. Will fix tomorrow.

fixed in 297566c

@paulcam206 paulcam206 enabled auto-merge (squash) April 30, 2021 17:58
@paulcam206
Copy link
Member Author

@jwoo-msft - could you fix up the iOS project for me? InternalID was moved into its own header file, InternalID.h, which needs to be referenced by the iOS project :)

Thanks!

@paulcam206
Copy link
Member Author

@jwoo-msft - gentle ping :)

@jwoo-msft
Copy link
Member

jwoo-msft commented May 4, 2021

@jwoo-msft - gentle ping :)

@paulcam206
sorry!

@jwoo-msft
Copy link
Member

@paulcam206,
Done

@paulcam206 paulcam206 merged commit 79ecfe9 into main May 4, 2021
@paulcam206 paulcam206 deleted the paulcam/cmake-objectmodel branch May 4, 2021 20:11
RebeccaAnne pushed a commit that referenced this pull request May 6, 2021
* [SharedModel] Build clean VS, cmake/clang, cmake/VS, and cmake/emscripten

* clang-format ParseUtil.h

* Fix UWP build breaks
michaelfarnsworth pushed a commit to michaelfarnsworth/AdaptiveCards that referenced this pull request Nov 10, 2022
* [SharedModel] Build clean VS, cmake/clang, cmake/VS, and cmake/emscripten

* clang-format ParseUtil.h

* Fix UWP build breaks
rankush pushed a commit to rankush/AdaptiveCards that referenced this pull request May 8, 2024
* [SharedModel] Build clean VS, cmake/clang, cmake/VS, and cmake/emscripten

* clang-format ParseUtil.h

* Fix UWP build breaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants