Skip to content

Add jerry fdlibm library in build script #52

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion deps/jerry
Submodule jerry updated from a28d03 to 9d56dd
72 changes: 72 additions & 0 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ def build_libuv():
def libjerry_output_path():
return join_path([opt_build_libs(), 'libjerrycore.a'])

def libjerryfdlibm_output_path():
return join_path([opt_build_libs(), 'libjerryfdlibm.a'])

def check_build_libjerryfdlibm():
return (opt_target_arch() == 'arm' and opt_target_os() =='nuttx')

def build_libjerry():
# check libjerry submodule directory.
if not check_path(JERRY_ROOT):
Expand Down Expand Up @@ -361,6 +367,72 @@ def build_libjerry():
mkdir(opt_build_libs())
copy(build_cache_path, libjerry_output_path())

# fdlibm for nuttx
if check_build_libjerryfdlibm():
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we separate this "if" block as another function?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, does fdlib depends on jerry? if not, we don't need to call it "jerryfdlibm" just "fdlibm" is ok and not confusing.

Copy link
Contributor

Choose a reason for hiding this comment

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

On second thought, another build phase is unnecessary we can build "libjerry" and "fdlibm" at one time together by feeding both build target for make command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make -C /home/maxwell/harmony/iotjs/build/arm-nuttx/debug/deps/jerry debug.jerry-core debug.jerry-fdlibm.third_party.lib -j1
make: Entering directory `/home/maxwell/harmony/iotjs/build/arm-nuttx/debug/deps/jerry'
make: *** No rule to make target `debug.jerry-core debug.jerry-fdlibm.third_party.lib'.  Stop.

maybe another way?


build_cache_path = get_cache_path(build_cache_dir,
'libjerry-fdlibm',
git_hash)

# check if cache is available.
if not check_cached(build_cache_path):
# build jerry fdlibm

# make build directory.
mkdir(build_home)

# change current directory to build directory.
os.chdir(build_home)

# libjerry is using cmake.
# prepare cmake command line option.
jerry_cmake_opt = [JERRY_ROOT]

# set lto off.
jerry_cmake_opt.append('-DENABLE_LTO=OFF')

# tool chain file.
jerry_cmake_opt.append('-DCMAKE_TOOLCHAIN_FILE=' +
opt_cmake_toolchain_file())

# run cmake.
# FIXME: Running cmake once cause a problem because cmake does not
# know the system like "System is unknown to cmake". and the other
# settings are not applied intendly, running twice solves the
# problem.
check_run_cmd('cmake', jerry_cmake_opt)
check_run_cmd('cmake', jerry_cmake_opt)

# cmake will produce a Makefile.

# set build fdlibm target.
jerry_build_target = (opt_build_type() +
'.jerry-fdlibm.third_party.lib')
Copy link
Contributor

Choose a reason for hiding this comment

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

Except here, all routine in buding fdlibm is the same with libjerry.
Why don't we just build libjerry with this build target altogether? I think we don't need to do same thing twice.


# run make for fdlibm
check_run_cmd('make', ['-C',
build_home,
jerry_build_target,
opt_make_flags()])

# output: libjerry-fdlib.a
output = join_path([build_home,
'third-party/fdlibm/',
'lib' + jerry_build_target + '.a'])

# check if target is created.
if not check_path(output):
print 'Jerry fdlibm build failed - target not produced.'
return False

# copy output to cache
mkdir(build_cache_dir)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is wrong.
The cache is for libjerry. not for fdlib.

copy(output, build_cache_path)

# copy cache to libs directory
mkdir(opt_build_libs())
copy(build_cache_path, libjerryfdlibm_output_path())

return True


Expand Down