Skip to content
Merged
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
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,16 @@ jobs:
run: haxe compile-cpp.hxml -D ${{ env.HXCPP_ARCH_FLAG }} -D no_http
- name: run
run: bin${{ inputs.sep }}cpp${{ inputs.sep }}TestMain-debug
build_tool:
runs-on: ${{ inputs.os }}
name: build tool tests
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup
uses: ./.github/workflows/setup
with:
haxe: ${{ inputs.haxe }}
- name: test c/cxx_standard attributes
working-directory: test/cxx_standard
run: haxelib run hxcpp Build.xml
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ hxcpp.n

.vscode

test/cxx_standard/main
test/cxx_standard/main.hash
test/cxx_standard/main.exe
test/cxx_standard/main.exe.hash

# Created by https://www.toptal.com/developers/gitignore/api/visualstudio
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio

Expand Down
6 changes: 4 additions & 2 deletions docs/build_xml/Defines.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ Defines affecting how the code is compiled. These can be on the command line wh
| *HXCPP_CHECK_POINTER* | Add null-pointer checks,even in release mode. |
| *HXCPP_PROFILER* | Add profiler support |
| *HXCPP_TELEMETRY* | Add telemetry support |
| *HXCPP_CPP11* | Use c++11 features and link libraries |
| *HXCPP_CPP17* | Use c++17 features and link libraries |
| *HXCPP_C_STANDARD* | Set default C standard |
| *HXCPP_CXX_STANDARD* | Set default C++ standard |
| *HXCPP_OBJC_STANDARD* | Set default Objective-C standard |
| *HXCPP_OBJCXX_STANDARD* | Set default Objective-C++ standard |
| *exe_link* | Generate executable file (rather than dynamic library on android) |
| *static_link* | Generate static library |
| *dll_link* | Generate dynamic library |
Expand Down
20 changes: 19 additions & 1 deletion docs/build_xml/Files.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ Files
------
The files node defines a group of files that all share the same attributes, including relative directory, default compiler flags and dependencies. The node can be used to define a set of header files on which other files can depend, or a set of source files to be compiled and included in a target.

```xml
<files id="foo" cxx_standard="14">
<file name="foo.cpp"/>
<file name="bar.c"/>
</files>
```

#### Attributes

+ `c_standard` = Default C standard for the file group
+ `cxx_standard` = Default C++ standard for the file group
+ `objc_standard` = Default Objective-C standard for the file group
+ `objcxx_standard` = Default Objective-C++ standard for the file group
#### Nodes
- *depend* - Declare that all files in the group depend on another file or another file group.
```xml
<depend name="filename" />
Expand Down Expand Up @@ -80,13 +94,17 @@ The files node defines a group of files that all share the same attributes, incl

- *file* - Add file to group, with optional attributes
```xml
<file name="filename" tags="tag,tag1" filterout="define" embedName="embed" >
<file name="filename" tags="tag,tag1" filterout="define" embedName="embed" cxx_standard="17">
<depend name="filename1" />
<depend name="filename2" />
</file>
```
+ name = name of file - may be absolute or relative to files.dir
+ tags = optional override of group tags. See [Tags.md](Tags.md).
+ `c_standard` = C standard for the file
+ `cxx_standard` = C++ standard for the file
+ `objc_standard` = Objective-C standard for the file
+ `objcxx_standard` = Objective-C++ standard for the file
+ filterout = allows files to be skipped at compile-time if the named define exists.
This is useful when the define is set sometime after the file list is parsed.
+ depend name = filename of additional dependency
Expand Down
6 changes: 6 additions & 0 deletions test/RunTests.hx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ class RunTests
command("cpp64"+sep+"Test",[]);
}

public static function cxx_standard() {
setDir("cxx_standard");
command("haxelib", ["run", "hxcpp", "Build.xml"]);
}


public static function setDir(name:String)
{
Expand Down Expand Up @@ -199,6 +204,7 @@ class RunTests
run("std64", std64);
run("native", native);
run("debugger", debugger);
run("cxx_standard", cxx_standard);

Sys.println("");

Expand Down
15 changes: 15 additions & 0 deletions test/cxx_standard/Build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<xml>
<files id="test" cxx_standard="17">
<compilerflag value="/Zc:__cplusplus" if="isMsvc" />
<file name="main.cpp" />
<file name="cxx14.cpp" cxx_standard="14" />
<file name="c11.c" c_standard="11" />
<file name="c17.c" c_standard="17" />
</files>

<set name="EXESUFFIX" value=".exe" if="windows" />

<target id="default" tool="linker" toolid="exe" output="main${EXESUFFIX}">
<files id="test"/>
</target>
</xml>
3 changes: 3 additions & 0 deletions test/cxx_standard/c11.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#if __STDC_VERSION__ < 201112L
#error "Not C11"
#endif
3 changes: 3 additions & 0 deletions test/cxx_standard/c17.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#if __STDC_VERSION__ < 201710L
#error "Not C17"
#endif
3 changes: 3 additions & 0 deletions test/cxx_standard/cxx14.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#if __cplusplus != 201402L
#error "Not C++14"
#endif
5 changes: 5 additions & 0 deletions test/cxx_standard/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#if __cplusplus < 201703L
#error "Not C++17"
#endif

int main() { return 0; }
4 changes: 0 additions & 4 deletions toolchain/android-toolchain-clang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
<set name="EXEPREFIX" value="llvm" />
</section>

<set name="HXCPP_CPP11" value="1" unless="HXCPP_NO_CPP11 || HXCPP_CPP17" />

<include name="toolchain/gcc-toolchain.xml"/>

<compiler id="android-gcc" exe="clang++">
Expand All @@ -63,8 +61,6 @@
<flag value="-DHXCPP_ANDROID_PLATFORM=${HXCPP_ANDROID_PLATFORM}" />

<!-- Options -->
<cppflag value="-std=c++11" if="HXCPP_CPP11" />
<cppflag value="-std=c++17" if="HXCPP_CPP17" />
<flag value="-flto" if="HXCPP_OPTIMIZE_LINK" unless="debug"/>
<flag value="-fvisibility=hidden"/>
<flag value="-ffunction-sections"/>
Expand Down
7 changes: 0 additions & 7 deletions toolchain/android-toolchain-gcc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
- you can also set the variable "android-19" directly
-->

<set name="HXCPP_CPP11" value="1" if="NDKV9+ || NDKV10+" unless="HXCPP_NO_CPP11" />


<!-- Set architecture -->
<section if="HXCPP_X86">
<set name="ARCH" value="-x86" />
Expand Down Expand Up @@ -96,8 +93,6 @@
<cppflag value="-frtti"/>
<flag value="-D_LINUX_STDDEF_H "/> <!-- Avoid compiler including 2 version of file -->
<flag value="-Wno-psabi" />
<cppflag value="-std=c++11" if="HXCPP_CPP11"/>
<flag value="-DHXCPP_CPP11" if="HXCPP_CPP11"/>

<section unless="HXCPP_X86 || HXCPP_X86_64">

Expand Down Expand Up @@ -168,7 +163,6 @@

<flag value="-frtti"/>
<flag value="-nostdlib"/>
<flag value="-std=c++11" if="HXCPP_CPP11"/>
<flag value="-Wl,-shared,-Bsymbolic"/>
<section if="HXCPP_OPTIMIZE_FOR_SIZE || HXCPP_GC_SECTIONS" unless="debug">
<flag value="-Wl,--gc-sections" />
Expand Down Expand Up @@ -218,7 +212,6 @@

<flag value="-frtti"/>
<flag value="-nostdlib"/>
<flag value="-std=c++11" if="HXCPP_CPP11"/>
<flag value="-Wl,--no-undefined" unless="dll_import" />
<flag value="-Wl,--unresolved-symbols=ignore-in-object-files" if="dll_import" />
<section unless="HXCPP_ANDROID_NO_16K_PAGES">
Expand Down
10 changes: 0 additions & 10 deletions toolchain/appletvos-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<include name="toolchain/gcc-toolchain.xml"/>
<!--<path name="${DEVELOPER_DIR}/Platforms/iPhoneOS.platform/Developer/usr/bin" />-->

<set name="FORCE_LIBGCC" value="1" if="HXCPP_IOS_STDCPP" unless="HXCPP_GCC" />
<set name="OBJGCC" value="-c11" if="HXCPP_CPP11" />
<set name="OBJGCC" value="-gcc" if="HXCPP_GCC" />
<set name="OBJDBG" value="-dbg" if="debug" />

Expand All @@ -24,10 +22,6 @@
<!-- <cppflag value="-fvisibility-inlines-hidden"/> -->
<pchflag value="-x" />
<pchflag value="c++-header" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<flag value="-g" if="HXCPP_DEBUG_LINK"/>
<flag value="-O2" unless="debug"/>
<flag value="-arch"/>
Expand Down Expand Up @@ -71,10 +65,6 @@
<linker id="dll" exe="g++" >
<exe name="xcrun --sdk appletvos${TVOS_VER} g++" if="HXCPP_GCC" />
<exe name="xcrun --sdk appletvos${TVOS_VER} clang++" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<flag value="-dynamiclib"/>
<flag value="-arch"/>
<flag value="arm64" if="HXCPP_ARM64" />
Expand Down
10 changes: 0 additions & 10 deletions toolchain/appletvsim-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<include name="toolchain/gcc-toolchain.xml"/>
<!--<path name="${DEVELOPER_DIR}/Platforms/iPhoneSimulator.platform/Developer/usr/bin" />-->

<set name="FORCE_LIBGCC" value="1" if="HXCPP_IOS_STDCPP" unless="HXCPP_GCC" />
<set name="OBJGCC" value="-c11" if="HXCPP_CPP11" />
<set name="OBJGCC" value="-gcc" if="HXCPP_GCC" />
<set name="OBJDBG" value="-dbg" if="debug" />

Expand All @@ -22,10 +20,6 @@
<!-- <cppflag value="-fvisibility-inlines-hidden"/> -->
<pchflag value="-x" />
<pchflag value="c++-header" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<flag value="-g" if="HXCPP_DEBUG_LINK"/>
<flag value="-O2" unless="debug"/>
<flag value="-fmessage-length=0"/>
Expand Down Expand Up @@ -78,10 +72,6 @@
<linker id="dll" exe="g++" >
<exe name="xcrun --sdk appletvsimulator${TVOS_VER} g++" if="HXCPP_GCC" />
<exe name="xcrun --sdk appletvsimulator${TVOS_VER} clang++" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<flag value="-dynamiclib"/>
<flag value="-arch"/>
<flag value="i386" unless="HXCPP_M64"/>
Expand Down
5 changes: 0 additions & 5 deletions toolchain/finish-setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
<set name="haxelink" value="dll" if="dll_import"/>
<set name="haxelink" value="dll" if="dll_link"/>

<set name="HXCPP_IOS_STDCPP" value="1" unless="HXCPP_CPP11 || HXCPP_CPP17" if="iphoneos"/>
<set name="HXCPP_IOS_STDCPP" value="1" unless="HXCPP_CPP11 || HXCPP_CPP17" if="iphonesim"/>
<set name="HXCPP_IOS_STDCPP" value="1" unless="HXCPP_CPP11" if="appletvos"/>
<set name="HXCPP_IOS_STDCPP" value="1" unless="HXCPP_CPP11" if="appletvsim"/>

<set name="DESTDIR" value="bin" />
<set name="DESTDIR" value="lib" if="static_link" unless="HXCPP_IOS_STDCPP"/>
<set name="NDLLDIR" value="ndll" />
Expand Down
17 changes: 0 additions & 17 deletions toolchain/iphoneos-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<echo value="Using iOS SDK ${IPHONE_VER}" if="VERBOSE"/>

<set name="HXCPP_CPP11" value="1" unless="HXCPP_NO_CPP11 || HXCPP_CPP17" />

<set name="ARCH" value ="-v7" if="HXCPP_ARMV7" />
<set name="ARCH" value ="-v7s" if="HXCPP_ARMV7S" />
Expand All @@ -14,9 +13,6 @@
<include name="toolchain/gcc-toolchain.xml"/>
<!--<path name="${DEVELOPER_DIR}/Platforms/iPhoneOS.platform/Developer/usr/bin" />-->

<set name="FORCE_LIBGCC" value="1" if="HXCPP_IOS_STDCPP" unless="HXCPP_GCC" />
<set name="OBJGCC" value="-c11" if="HXCPP_CPP11" />
<set name="OBJGCC" value="-c17" if="HXCPP_CPP17" />
<set name="OBJGCC" value="-gcc" if="HXCPP_GCC" />
<set name="OBJDBG" value="-dbg" if="debug" />

Expand All @@ -32,15 +28,6 @@
<pchflag value="-x" />
<pchflag value="c++-header" />

<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<cppflag value="-std=c++11" if="HXCPP_CPP11" />
<cppflag value="-std=c++17" if="HXCPP_CPP17" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<mmflag value="-std=c++11" if="HXCPP_CPP11" />
<mmflag value="-std=c++17" if="HXCPP_CPP17" />

<flag value="-g" if="HXCPP_DEBUG_LINK"/>
<flag value="-O2" unless="debug"/>
<flag value="-arch"/>
Expand Down Expand Up @@ -95,10 +82,6 @@
<exe name="xcrun --sdk iphoneos${IPHONE_VER} g++" if="HXCPP_GCC" />
<exe name="xcrun --sdk iphoneos${IPHONE_VER} clang++" />
<flag value="-Wl,-cache_path_lto,/tmp" if="HXCPP_OPTIMIZE_LINK_INCREMENTAL" unless="debug"/>
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<flag value="-dynamiclib"/>
<flag value="-arch"/>
<flag value="armv6" if="HXCPP_ARMV6" />
Expand Down
18 changes: 0 additions & 18 deletions toolchain/iphonesim-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

<echo value="Using iOS SDK ${IPHONE_VER}" if="VERBOSE"/>

<set name="HXCPP_CPP11" value="1" unless="HXCPP_NO_CPP11 || HXCPP_CPP17" />

<set name="ARCH" value ="-64" if="HXCPP_M64" />

<set name="HXCPP_USE_LIBTOOL" value="1" />
<set name="HXCPP_LIBTOOL" value="xcrun --sdk iphonesimulator${IPHONE_VER} libtool" />
<include name="toolchain/gcc-toolchain.xml"/>
<!--<path name="${DEVELOPER_DIR}/Platforms/iPhoneSimulator.platform/Developer/usr/bin" />-->

<set name="FORCE_LIBGCC" value="1" if="HXCPP_IOS_STDCPP" unless="HXCPP_GCC" />
<set name="OBJGCC" value="-c11" if="HXCPP_CPP11" />
<set name="OBJGCC" value="-c17" if="HXCPP_CPP17" />
<set name="OBJGCC" value="-gcc" if="HXCPP_GCC" />
<set name="OBJDBG" value="-dbg" if="debug" />

Expand All @@ -26,15 +21,6 @@
<pchflag value="-x" />
<pchflag value="c++-header" />

<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<cppflag value="-std=c++11" if="HXCPP_CPP11" />
<cppflag value="-std=c++17" if="HXCPP_CPP17" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<mmflag value="-std=c++11" if="HXCPP_CPP11" />
<mmflag value="-std=c++17" if="HXCPP_CPP17" />

<flag value="-g" if="HXCPP_DEBUG_LINK"/>
<flag value="-O2" unless="debug"/>
<flag value="-fmessage-length=0"/>
Expand Down Expand Up @@ -89,10 +75,6 @@
<linker id="dll" exe="g++" >
<exe name="xcrun --sdk iphonesimulator${IPHONE_VER} g++" if="HXCPP_GCC" />
<exe name="xcrun --sdk iphonesimulator${IPHONE_VER} clang++" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<flag value="-dynamiclib"/>
<flag value="-arch"/>
<flag value="i386" unless="HXCPP_M64"/>
Expand Down
4 changes: 0 additions & 4 deletions toolchain/linux-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
</section>
</section>

<set name="HXCPP_CPP11" value="1" unless="HXCPP_NO_CPP11 || HXCPP_CPP17" />

<include name="toolchain/gcc-toolchain.xml"/>
<set name="noM32" value="1" if="HXCPP_NO_M32" />
<set name="noM32" value="1" if="HXCPP_M64" />
Expand All @@ -40,8 +38,6 @@
<flag value="-c"/>
<flag value="-fvisibility=hidden"/>
<cppflag value="-frtti"/>
<cppflag value="-std=c++11" if="HXCPP_CPP11" />
<cppflag value="-std=c++17" if="HXCPP_CPP17"/>
<flag value="-g" if="debug"/>
<flag value="-O2" unless="debug"/>
<flag value="-fpic"/>
Expand Down
Loading