Skip to content

Commit

Permalink
Merge pull request #10 from loki04/servo
Browse files Browse the repository at this point in the history
Adopt Servo project
  • Loading branch information
bgabor666 committed Mar 3, 2016
2 parents 9a44878 + 6accd65 commit e0c6dbf
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "src/CMSIS"]
path = src/CMSIS
url = https://github.com/ARM-software/CMSIS
[submodule "src/servo"]
path = src/servo
url = https://github.com/servo/servo.git
42 changes: 21 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,26 @@ set (SUM_RESULT ${CSiBE_BIN_DIR}/sum_results)
add_custom_target (size
COMMAND ${SUM_RESULT} ${CMAKE_BINARY_DIR}/all_results.csv ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS})

# PROJECTS
set (PROJECT_LIST)

# Add bzip2 project
list (APPEND SUBPROJECTS "bzip2-1.0.6")

# Add CMSIS project subprojects
# 'Generic' CMAKE_SYSTEM_NAME means 'an embedded system without OS' here.
if ((CMAKE_SYSTEM_NAME STREQUAL "Generic"))
set (CMSIS_BASE_DIR ${CSiBE_SRC_DIR}/CMSIS)
set (CMSIS_SUBPROJECTS CMSIS/BasicMathFunctions CMSIS/CommonTables CMSIS/ComplexMathFunctions
CMSIS/ControllerFunctions CMSIS/FastMathFunctions CMSIS/FilteringFunctions CMSIS/MatrixFunctions
CMSIS/StatisticsFunctions CMSIS/SupportFunctions CMSIS/TransformFunctions)
list(APPEND SUBPROJECTS ${CMSIS_SUBPROJECTS})
endif ()

# Add flex project except on embedded
if ((NOT CMAKE_SYSTEM_NAME MATCHES "Generic"))
list (APPEND SUBPROJECTS "flex-2.6.0")
if (NOT DEFINED ENV{CSiBE_SUBPROJECTS})
# Add bzip2 project
list (APPEND SUBPROJECTS "bzip2-1.0.6")

# Add CMSIS project subprojects
# 'Generic' CMAKE_SYSTEM_NAME means 'an embedded system without OS' here.
if ((CMAKE_SYSTEM_NAME STREQUAL "Generic"))
set (CMSIS_BASE_DIR ${CSiBE_SRC_DIR}/CMSIS)
set (CMSIS_SUBPROJECTS CMSIS/BasicMathFunctions CMSIS/CommonTables CMSIS/ComplexMathFunctions
CMSIS/ControllerFunctions CMSIS/FastMathFunctions CMSIS/FilteringFunctions CMSIS/MatrixFunctions
CMSIS/StatisticsFunctions CMSIS/SupportFunctions CMSIS/TransformFunctions)
list(APPEND SUBPROJECTS ${CMSIS_SUBPROJECTS})
endif ()

# Add flex project except on embedded
if ((NOT CMAKE_SYSTEM_NAME MATCHES "Generic"))
list (APPEND SUBPROJECTS "flex-2.6.0")
endif ()
else ()
set (SUBPROJECTS $ENV{CSiBE_SUBPROJECTS})
endif ()

# Setup the path and target names
Expand All @@ -49,10 +50,9 @@ foreach (ELEM ${SUBPROJECTS})
string(REGEX REPLACE ".*/" "" NAME ${ELEM})
add_subdirectory(${CSiBE_GEN_DIR}/${ELEM})
add_dependencies(size ${NAME}_size)
list(APPEND PROJECT_LIST ${NAME})
endforeach(ELEM)

if (NOT PROJECT_LIST)
if (NOT SUBPROJECTS)
message(FATAL_ERROR "No projects to build!")
endif ()

22 changes: 22 additions & 0 deletions gen/servo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
include(ExternalProject)

project (servo)

set (PROJECT_SOURCE_DIR ${CSiBE_SRC_DIR}/${PROJECT_NAME})
set (PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR})
set (PROJECT_GEN_DIR ${CSiBE_GEN_DIR}/${PROJECT_NAME})

set (SIZE_RESULT "${PROJECT_BINARY_DIR}/result.csv")

set (ENV{SERVO_CACHE_DIR} ${PROJECT_BINARY_DIR}/.servo)
set (ENV{CARGO_HOME} ${PROJECT_BINARY_DIR}/.cargo)
set (ENV{CARGO_TARGET_DIR} ${PROJECT_BINARY_DIR}/target)

# Uncomment to add additional compiler flags
# set (ENV{CSiBE_RUSTCFLAGS} "-C opt-level=0")

execute_process(COMMAND ${PROJECT_SOURCE_DIR}/mach bootstrap-rust)
execute_process(COMMAND ${PROJECT_GEN_DIR}/setup-csibe.py ${PROJECT_BINARY_DIR}/.servo)
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/mach bootstrap-cargo)
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/mach build -r)
29 changes: 29 additions & 0 deletions gen/servo/rustc-wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/python

import sys
import subprocess
import os

if __name__ == '__main__':
done = False
rsfile = False
addopts = os.getenv('CSiBE_RUSTCFLAGS','').split()

cmd = ['rustc-orig']

for arg in sys.argv[1:]:
if "--" == arg:
cmd.extend(addopts)
done = True
elif ".rs" in arg:
rsfile = True
cmd.append(arg)

if rsfile:
if not done:
cmd.extend(addopts)
else:
cmd = ['rustc-orig']
cmd.extend(sys.argv[1:])

sys.exit(subprocess.call(cmd))
30 changes: 30 additions & 0 deletions gen/servo/setup-csibe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python

import fnmatch
import os
import sys
import shutil

if __name__ == '__main__':
if len(sys.argv) <= 1:
sys.exit(1)

path = sys.argv[1]

match = None
for root, dirnames, filenames in os.walk(path):
for filename in fnmatch.filter(filenames, 'rustc'):
match = os.path.join(root, filename)
break

if not match:
sys.exit(1)

wrapper = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rustc-wrapper.py')

original = match + "-orig"
if os.path.isfile(original):
sys.exit(2)

os.rename(match, original)
shutil.copy2(wrapper, match)
1 change: 1 addition & 0 deletions src/servo
Submodule servo added at 9778e5

0 comments on commit e0c6dbf

Please sign in to comment.