Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ message(STATUS "--------------------------------")

message(STATUS "CMake version: ${CMAKE_VERSION}")

# specify that this binary is to be built with C++14
set(CMAKE_CXX_STANDARD 14)

if(NOT ${CMAKE_CXX_STANDARD})
# if not otherwise set, specify that this binary is to be built with C++14
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
21 changes: 14 additions & 7 deletions cmake/msix_resources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ if ((XML_PARSER MATCHES msxml6) OR (XML_PARSER MATCHES xerces))
# Used by namespace manager
if (XML_PARSER MATCHES msxml6)
set(CHAR_TYPE "wchar_t")
set(STR_COMP "wcscmp")
set(STR_PREFIX "L")
else() # xerces
set(CHAR_TYPE "char")
set(STR_COMP "strcmp")
set(STR_PREFIX "u8")
# Previously, this was set to use u8 prefixes. However, with c++20 u8 means that
# we start getting char8_t and its ilk. While this does generally mean that it's
# not consistent what encoding we use here, wiring up everything to convert back
# and forth in a standard manner is exceedingly difficult.
#
# If you want to go down that rabbit hole, change STR_PREFIX to "u8"; CHAR_TYPE,
# as defined below, will then be 'char' on c++14/17, and 'char8_t' on c++20.
set(STR_PREFIX "")
set(CHAR_TYPE "std::remove_const<std::remove_reference<decltype(${STR_PREFIX}\"\"[0])>::type>::type")
endif()

if(USE_VALIDATION_PARSER)
Expand Down Expand Up @@ -317,7 +322,7 @@ if ((XML_PARSER MATCHES msxml6) OR (XML_PARSER MATCHES xerces))
list(GET ${TRIPLET} 0 NAMESPACE)
list(GET ${TRIPLET} 1 ALIAS)
list(GET ${TRIPLET} 2 FILE)
string(APPEND RESULT "SchemaEntry(" "${STR_PREFIX}" \" "${NAMESPACE}" \", "${STR_PREFIX}" \" "${ALIAS}" \" , u8\" "${FILE}" \" "),\n\t\t")
string(APPEND RESULT "SchemaEntry(" "${STR_PREFIX}" \" "${NAMESPACE}" \", "${STR_PREFIX}" \" "${ALIAS}" \" , \" "${FILE}" \" "),\n\t\t")
endforeach()
set(${OUTPUT} ${RESULT} PARENT_SCOPE)
endfunction()
Expand All @@ -335,11 +340,13 @@ if ((XML_PARSER MATCHES msxml6) OR (XML_PARSER MATCHES xerces))
const ${CHAR_TYPE}* uri;
const ${CHAR_TYPE}* alias;
const char* schema;
const size_t len;

SchemaEntry(const ${CHAR_TYPE}* u, const ${CHAR_TYPE}* a, const char* s) : uri(u), alias(a), schema(s) {}
template<size_t new_len>
SchemaEntry(const ${CHAR_TYPE} (&u)[new_len], const ${CHAR_TYPE}* a, const char* s) : uri(u), alias(a), schema(s), len(new_len) {}

inline bool operator==(const ${CHAR_TYPE}* otherUri) const {
return 0 == ${STR_COMP}(uri, otherUri);
return 0 == std::char_traits<${CHAR_TYPE}>::compare(uri, otherUri, len);
}
};

Expand Down
9 changes: 8 additions & 1 deletion makelinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ usage()
echo $'\t' "--pack Include packaging features. Sets validation parser on."
echo $'\t' "--skip-samples Skip building samples."
echo $'\t' "--skip-tests Skip building tests."
echo $'\t' "--cxxstd (14|17|20) c++ standard to use (default 14)."
}

printsetup()
Expand All @@ -28,6 +29,8 @@ printsetup()
echo "Build tests:" $tests
}

cxxstd="14"

while [ "$1" != "" ]; do
case $1 in
-b ) shift
Expand All @@ -49,6 +52,9 @@ while [ "$1" != "" ]; do
;;
--skip-tests ) tests=off
;;
--cxxstd ) shift
cxxstd=$1
;;
* ) usage
exit 1
esac
Expand All @@ -71,5 +77,6 @@ cmake -DCMAKE_BUILD_TYPE=$build \
-DMSIX_PACK=$pack \
-DMSIX_SAMPLES=$samples \
-DMSIX_TESTS=$tests \
-DLINUX=on ..
-DLINUX=on .. \
-DCMAKE_CXX_STANDARD=$cxxstd
make
2 changes: 2 additions & 0 deletions pipelines/templates/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
debug_pack:
_arguments: -b Debug --pack
_artifact: LINUXchk-pack
debug_pack_cxx20:
_arguments: -b Debug --pack --extra -DCMAKE_CXX_STANDARD=20

steps:
- task: Bash@3
Expand Down
100 changes: 54 additions & 46 deletions src/msix/common/AppxManifestObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,69 +11,77 @@
#include "AppxPackageInfo.hpp"

#include <array>
#include <type_traits>
#include <string>

namespace MSIX {

template<typename T>
struct Entry
{
const char* tdf;
// Change the string constant type here to match that of the Entry constants
// in targetDeviceFamilyList and capabilitiesList - that is, u8"" if those
// strings regain the u8 prefix.
typedef std::remove_const<std::remove_reference<decltype(""[0])>::type>::type u8char;
const u8char* tdf;
const size_t len;
const T value;

Entry(const char* t, const T p) : tdf(t), value(p) {}
template<size_t new_len>
Entry(const u8char (&t)[new_len], const T p) : tdf(t), len(new_len), value(p) {}

inline bool operator==(const char* otherTdf) const {
return 0 == strcmp(tdf, otherTdf);
inline bool operator==(const u8char *otherTdf) const {
return 0 == std::char_traits<u8char>::compare(tdf, otherTdf, len);
}
};

// ALL THE TargetDeviceFamily ENTRIES MUST BE LOWER-CASE
static const Entry<MSIX_PLATFORMS> targetDeviceFamilyList[] = {
Entry<MSIX_PLATFORMS>(u8"windows.universal", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>(u8"windows.mobile", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>(u8"windows.desktop", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>(u8"windows.xbox", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>(u8"windows.team", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>(u8"windows.holographic", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>(u8"windows.iot", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>(u8"windows.server", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>(u8"apple.ios.all", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>(u8"apple.ios.phone", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>(u8"apple.ios.tablet", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>(u8"apple.ios.tv", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>(u8"apple.ios.watch", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>(u8"apple.macos.all", MSIX_PLATFORM_MACOS),
Entry<MSIX_PLATFORMS>(u8"google.android.all", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>(u8"google.android.phone", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>(u8"google.android.tablet", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>(u8"google.android.desktop", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>(u8"google.android.tv", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>(u8"google.android.watch", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>(u8"msixcore.desktop", MSIX_PLATFORM_CORE),
Entry<MSIX_PLATFORMS>(u8"msixcore.server", MSIX_PLATFORM_CORE),
Entry<MSIX_PLATFORMS>(u8"linux.all", MSIX_PLATFORM_LINUX),
Entry<MSIX_PLATFORMS>(u8"web.edge.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>(u8"web.blink.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>(u8"web.chromium.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>(u8"web.webkit.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>(u8"web.safari.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>(u8"web.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>(u8"platform.all", static_cast<MSIX_PLATFORMS>(MSIX_PLATFORM_ALL)),
Entry<MSIX_PLATFORMS>("windows.universal", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>("windows.mobile", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>("windows.desktop", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>("windows.xbox", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>("windows.team", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>("windows.holographic", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>("windows.iot", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>("windows.server", MSIX_PLATFORM_WINDOWS10),
Entry<MSIX_PLATFORMS>("apple.ios.all", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>("apple.ios.phone", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>("apple.ios.tablet", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>("apple.ios.tv", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>("apple.ios.watch", MSIX_PLATFORM_IOS),
Entry<MSIX_PLATFORMS>("apple.macos.all", MSIX_PLATFORM_MACOS),
Entry<MSIX_PLATFORMS>("google.android.all", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>("google.android.phone", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>("google.android.tablet", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>("google.android.desktop", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>("google.android.tv", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>("google.android.watch", MSIX_PLATFORM_AOSP),
Entry<MSIX_PLATFORMS>("msixcore.desktop", MSIX_PLATFORM_CORE),
Entry<MSIX_PLATFORMS>("msixcore.server", MSIX_PLATFORM_CORE),
Entry<MSIX_PLATFORMS>("linux.all", MSIX_PLATFORM_LINUX),
Entry<MSIX_PLATFORMS>("web.edge.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>("web.blink.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>("web.chromium.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>("web.webkit.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>("web.safari.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>("web.all", MSIX_PLATFORM_WEB),
Entry<MSIX_PLATFORMS>("platform.all", static_cast<MSIX_PLATFORMS>(MSIX_PLATFORM_ALL)),
};

static const Entry<APPX_CAPABILITIES> capabilitiesList[] = {
Entry<APPX_CAPABILITIES>(u8"internetClient", APPX_CAPABILITY_INTERNET_CLIENT),
Entry<APPX_CAPABILITIES>(u8"internetClientServer", APPX_CAPABILITY_INTERNET_CLIENT_SERVER),
Entry<APPX_CAPABILITIES>(u8"privateNetworkClientServer", APPX_CAPABILITY_PRIVATE_NETWORK_CLIENT_SERVER),
Entry<APPX_CAPABILITIES>(u8"documentsLibrary", APPX_CAPABILITY_DOCUMENTS_LIBRARY),
Entry<APPX_CAPABILITIES>(u8"picturesLibrary", APPX_CAPABILITY_PICTURES_LIBRARY),
Entry<APPX_CAPABILITIES>(u8"videosLibrary", APPX_CAPABILITY_VIDEOS_LIBRARY),
Entry<APPX_CAPABILITIES>(u8"musicLibrary", APPX_CAPABILITY_MUSIC_LIBRARY),
Entry<APPX_CAPABILITIES>(u8"enterpriseAuthentication", APPX_CAPABILITY_ENTERPRISE_AUTHENTICATION),
Entry<APPX_CAPABILITIES>(u8"sharedUserCertificates", APPX_CAPABILITY_SHARED_USER_CERTIFICATES),
Entry<APPX_CAPABILITIES>(u8"removableStorage", APPX_CAPABILITY_REMOVABLE_STORAGE),
Entry<APPX_CAPABILITIES>(u8"appointments", APPX_CAPABILITY_APPOINTMENTS),
Entry<APPX_CAPABILITIES>(u8"contacts", APPX_CAPABILITY_CONTACTS),
Entry<APPX_CAPABILITIES>("internetClient", APPX_CAPABILITY_INTERNET_CLIENT),
Entry<APPX_CAPABILITIES>("internetClientServer", APPX_CAPABILITY_INTERNET_CLIENT_SERVER),
Entry<APPX_CAPABILITIES>("privateNetworkClientServer", APPX_CAPABILITY_PRIVATE_NETWORK_CLIENT_SERVER),
Entry<APPX_CAPABILITIES>("documentsLibrary", APPX_CAPABILITY_DOCUMENTS_LIBRARY),
Entry<APPX_CAPABILITIES>("picturesLibrary", APPX_CAPABILITY_PICTURES_LIBRARY),
Entry<APPX_CAPABILITIES>("videosLibrary", APPX_CAPABILITY_VIDEOS_LIBRARY),
Entry<APPX_CAPABILITIES>("musicLibrary", APPX_CAPABILITY_MUSIC_LIBRARY),
Entry<APPX_CAPABILITIES>("enterpriseAuthentication", APPX_CAPABILITY_ENTERPRISE_AUTHENTICATION),
Entry<APPX_CAPABILITIES>("sharedUserCertificates", APPX_CAPABILITY_SHARED_USER_CERTIFICATES),
Entry<APPX_CAPABILITIES>("removableStorage", APPX_CAPABILITY_REMOVABLE_STORAGE),
Entry<APPX_CAPABILITIES>("appointments", APPX_CAPABILITY_APPOINTMENTS),
Entry<APPX_CAPABILITIES>("contacts", APPX_CAPABILITY_CONTACTS),
};

AppxManifestObject::AppxManifestObject(IMsixFactory* factory, const ComPtr<IStream>& stream) : m_factory(factory), m_stream(stream)
Expand Down
4 changes: 2 additions & 2 deletions src/msix/pack/BundleValidationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ namespace MSIX {
std::string packageFullName = packageIdInternal->GetPackageFullName();
std::ostringstream errorBuilder;
errorBuilder << "The package with file name " << fileName << " and package full name " << packageFullName << " is not valid in the bundle because its manifest declares a value for "
<< ElementsToTest[i] << " which is not supported in bundles. The minimum supported value is " << MinimumAllowedOSVersion << ".";
<< wstring_to_utf8(ElementsToTest[i]) << " which is not supported in bundles. The minimum supported value is " << MinimumAllowedOSVersion << ".";
ThrowErrorAndLog(Error::AppxManifestSemanticError, errorBuilder.str().c_str());
}
}
Expand Down Expand Up @@ -246,4 +246,4 @@ namespace MSIX {
}
}
}
}
}
23 changes: 15 additions & 8 deletions src/msix/unpack/ApplicabilityCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>
#include <algorithm>
#include <string>
#include <type_traits>
#include <vector>

#include "AppxBundleManifest.hpp"
Expand All @@ -14,22 +16,27 @@ namespace MSIX {

struct Bcp47Entry
{
const char* icu;
const char* bcp47;
// Change the string constant type here to match that of the Bcp47Entry constants
// in bcp47List - that is, u8"" if those strings regain the u8 prefix.
typedef std::remove_const<std::remove_reference<decltype(""[0])>::type>::type u8char;
const u8char* icu;
const size_t len;
const u8char* bcp47;

Bcp47Entry(const char* i, const char* b) : icu(i), bcp47(b) {}
template<size_t new_len>
Bcp47Entry(const u8char (&i)[new_len], const u8char* b) : icu(i), len(new_len), bcp47(b) {}

inline bool operator==(const char* otherIcui) const {
return 0 == strcmp(icu, otherIcui);
inline bool operator==(const u8char* otherIcui) const {
return 0 == std::char_traits<u8char>::compare(icu, otherIcui, len);
}
};

// We've seen cases were uloc_toLanguageTag returns zh-CN. Add here any inconsistencies.
// Some AppxBundleManifests have zh-CN, zh-TW, zh-HK as languages.
static const Bcp47Entry bcp47List[] = {
Bcp47Entry(u8"zh-cn", u8"zh-Hans-CN"),
Bcp47Entry(u8"zh-hk", u8"zh-Hant-HK"),
Bcp47Entry(u8"zh-tw", u8"zh-Hant-TW"),
Bcp47Entry("zh-cn", "zh-Hans-CN"),
Bcp47Entry("zh-hk", "zh-Hant-HK"),
Bcp47Entry("zh-tw", "zh-Hant-TW"),
};

Bcp47Tag::Bcp47Tag(const std::string& fullTag, bool allowPseudoLocale)
Expand Down