Browse Source

Misc linux cleanup

Couple things:
1) Fix build break- need to ifdef out a reference to Profiler thunk
2) Clean up CMakeLists:
   - Seperate out C++ flags from C flags
   - Switch use of CHAKRA_RUNTIME_SOURCE_DIR to using a relative path to
   get ninja to work

Add simple hello world test runner for Linux

Incorporate code review feedback
Hitesh Kanwathirtha 9 years ago
parent
commit
eb50a9ca59

+ 17 - 4
CMakeLists.txt

@@ -71,10 +71,11 @@ if(CLR_CMAKE_PLATFORM_UNIX)
 
     set(CMAKE_CXX_STANDARD 11)
 
-    add_compile_options(
-        -fms-extensions
-        -fdelayed-template-parsing
-        -msse4.1
+    set(c_warn_flags
+        -Wno-implicit-function-declaration
+    )
+
+    set(cxx_warn_flags
         -Wno-microsoft
         -Wno-unused-value
         -Wno-int-to-void-pointer-cast
@@ -96,6 +97,18 @@ if(CLR_CMAKE_PLATFORM_UNIX)
         -Wno-switch # switch values not handled
         -Wno-int-to-pointer-cast
     )
+
+    set(cxx_compile_flags
+        -fdelayed-template-parsing
+    )
+
+    add_compile_options(
+        -fms-extensions
+        -msse4.1
+        "$<$<COMPILE_LANGUAGE:C>:${c_warn_flags}>"
+        "$<$<COMPILE_LANGUAGE:CXX>:${cxx_warn_flags}>"
+        "$<$<COMPILE_LANGUAGE:CXX>:${cxx_compile_flags}>"
+    )
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
 if(CMAKE_BUILD_TYPE STREQUAL Debug)

+ 2 - 2
bin/ChakraCore/CMakeLists.txt

@@ -33,7 +33,7 @@ target_include_directories (
 #  icuuc: For the ICU (xplat-todo: Make this optional)
 #
 target_link_libraries(ChakraCore
-  -Wl,-undefined,error
+  -Wl,--no-undefined
   -Wl,--start-group
   -Wl,--whole-archive
   Chakra.Jsrt
@@ -70,4 +70,4 @@ target_link_libraries(ChakraCore
 add_custom_command(TARGET ChakraCore POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E copy_if_different 
   "${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCore.so"
-   ${CHAKRACORE_BINARY_DIR}/)
+   ${CHAKRACORE_BINARY_DIR}/)

+ 5 - 1
lib/Runtime/Base/FunctionBody.cpp

@@ -4848,7 +4848,11 @@ namespace Js
     void FunctionBody::SetEntryToDeferParseForDebugger()
     {
         ProxyEntryPointInfo* defaultEntryPointInfo = this->GetDefaultEntryPointInfo();
-        if (defaultEntryPointInfo->jsMethod != DefaultDeferredParsingThunk && defaultEntryPointInfo->jsMethod != ProfileDeferredParsingThunk)
+        if (defaultEntryPointInfo->jsMethod != DefaultDeferredParsingThunk
+#ifdef ENABLE_SCRIPT_PROFILING
+            && defaultEntryPointInfo->jsMethod != ProfileDeferredParsingThunk
+#endif
+            )
         {
 #ifdef ENABLE_SCRIPT_PROFILING
             // Just change the thunk, the cleanup will be done once the function gets called.

+ 2 - 0
lib/Runtime/Base/FunctionBody.h

@@ -2998,10 +2998,12 @@ namespace Js
             ULONG * line, LONG * col);
 #endif
 
+#ifdef ENABLE_SCRIPT_PROFILING
         HRESULT RegisterFunction(BOOL fChangeMode, BOOL fOnlyCurrent = FALSE);
         HRESULT ReportScriptCompiled();
         HRESULT ReportFunctionCompiled();
         void SetEntryToProfileMode();
+#endif
 
         void CheckAndRegisterFuncToDiag(ScriptContext *scriptContext);
         void SetEntryToDeferParseForDebugger();

+ 7 - 7
lib/Runtime/CMakeLists.txt

@@ -1,13 +1,13 @@
 project(CHAKRA_RUNTIME)
 
 include_directories(
-    $(CHAKRA_RUNTIME_SOURCE_DIR)
-    $(CHAKRA_RUNTIME_SOURCE_DIR)../Common
-    $(CHAKRA_RUNTIME_SOURCE_DIR)../Backend
-    $(CHAKRA_RUNTIME_SOURCE_DIR)../Parser
-    $(CHAKRA_RUNTIME_SOURCE_DIR)/ByteCode
-    $(CHAKRA_RUNTIME_SOURCE_DIR)/PlatformAgnostic
-    $(CHAKRA_RUNTIME_SOURCE_DIR)/Math
+    .
+    ../Common
+    ../Backend
+    ../Parser
+    ByteCode
+    PlatformAgnostic
+    Math
     )
 
 add_subdirectory (Base)

+ 12 - 0
test/Basics/hello.js

@@ -0,0 +1,12 @@
+//-------------------------------------------------------------------------------------------------------
+// Copyright (C) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+//-------------------------------------------------------------------------------------------------------
+
+function say(arg)
+{
+    WScript.Echo(arg);
+}
+
+say("hello world");
+say("PASS");

+ 27 - 0
test/runtests.sh

@@ -0,0 +1,27 @@
+#-------------------------------------------------------------------------------------------------------
+# Copyright (C) Microsoft. All rights reserved.
+# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+#-------------------------------------------------------------------------------------------------------
+#
+# Eventual test running harness on *nix for ChakraCore
+# Today, it's simply there to make sure hello.js doesn't regress
+#
+
+test_path=`dirname "$0"`
+ch_path="$test_path/../BuildLinux/ch"
+hello_path="$test_path/Basics/hello.js"
+
+if [ ! -f $ch_path ]; then
+    echo 'ch not found- exiting'
+    exit 1
+fi
+
+output=`$ch_path $hello_path 2>&1 | tail -n 1`
+
+if [ ! $output == "PASS" ]; then
+    echo "Hello world failed"
+    exit 1
+fi
+
+echo "Hello world passed"
+exit 0